Kaynağa Gözat

修改了settings.xml 用于适配云效
增加了项目、日志的同步功能

verguenza 5 yıl önce
ebeveyn
işleme
88cbc828d2

+ 113 - 38
settings.xml

@@ -1,45 +1,120 @@
 <?xml version="1.0" encoding="UTF-8"?>
-
 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
-  <pluginGroups>
-  </pluginGroups>
-
-  <proxies>
-  </proxies>
-
-  <servers>
-
-    <server>
-        <id>rdc-releases</id>
-        <username>7IxD1n</username>
-        <password>R2zIxECSB5</password>
-    </server>
+    <mirrors>
+        <mirror>
+            <id>mirror</id>
+            <mirrorOf>!rdc-releases,!rdc-snapshots</mirrorOf>
+            <name>mirror</name>
+            <url>https://maven.aliyun.com/nexus/content/groups/public</url>
+        </mirror>
 
-    <server>
-        <id>rdc-snapshots</id>
-        <username>7IxD1n</username>
-        <password>R2zIxECSB5</password>
-    </server>
-  </servers>
+    </mirrors>
+    <servers>
+        <server>
+            <id>rdc-releases</id>
+            <username>7IxD1n</username>
+            <password>R2zIxECSB5</password>
+        </server>
+        <server>
+            <id>rdc-snapshots</id>
+            <username>7IxD1n</username>
+            <password>R2zIxECSB5</password>
+        </server>
+    </servers>
+    <profiles>
+        <profile>
+            <id>nexus</id>
+            <repositories>
+                <repository>
+                    <id>central</id>
+                    <url>https://maven.aliyun.com/nexus/content/groups/public</url>
+                    <releases>
+                        <enabled>true</enabled>
+                    </releases>
+                    <snapshots>
+                        <enabled>false</enabled>
+                    </snapshots>
+                </repository>
+                <repository>
+                    <id>snapshots</id>
+                    <url>https://maven.aliyun.com/nexus/content/groups/public</url>
+                    <releases>
+                        <enabled>false</enabled>
+                    </releases>
+                    <snapshots>
+                        <enabled>true</enabled>
+                    </snapshots>
+                </repository>
+                <repository>
+                    <id>rdc-releases</id>
+                    <url>https://repo.rdc.aliyun.com/repository/109287-release-nNDwQE/</url>
+                    <releases>
+                        <enabled>true</enabled>
+                    </releases>
+                    <snapshots>
+                        <enabled>false</enabled>
+                    </snapshots>
+                </repository>
+                <repository>
+                    <id>rdc-snapshots</id>
+                    <url>https://repo.rdc.aliyun.com/repository/109287-snapshot-ZkSC5j/</url>
+                    <releases>
+                        <enabled>false</enabled>
+                    </releases>
+                    <snapshots>
+                        <enabled>true</enabled>
+                    </snapshots>
+                </repository>
+            </repositories>
+            <pluginRepositories>
+                <pluginRepository>
+                    <id>central</id>
+                    <url>https://maven.aliyun.com/nexus/content/groups/public</url>
+                    <releases>
+                        <enabled>true</enabled>
+                    </releases>
+                    <snapshots>
+                        <enabled>false</enabled>
+                    </snapshots>
+                </pluginRepository>
+                <pluginRepository>
+                    <id>snapshots</id>
+                    <url>https://maven.aliyun.com/nexus/content/groups/public</url>
+                    <releases>
+                        <enabled>false</enabled>
+                    </releases>
+                    <snapshots>
+                        <enabled>true</enabled>
+                    </snapshots>
+                </pluginRepository>
+                <pluginRepository>
+                    <id>rdc-releases</id>
+                    <url>https://repo.rdc.aliyun.com/repository/109287-release-nNDwQE/</url>
+                    <releases>
+                        <enabled>true</enabled>
+                    </releases>
+                    <snapshots>
+                        <enabled>false</enabled>
+                    </snapshots>
+                </pluginRepository>
+                <pluginRepository>
+                    <id>rdc-snapshots</id>
+                    <url>https://repo.rdc.aliyun.com/repository/109287-snapshot-ZkSC5j/</url>
+                    <releases>
+                        <enabled>false</enabled>
+                    </releases>
+                    <snapshots>
+                        <enabled>true</enabled>
+                    </snapshots>
+                </pluginRepository>
+            </pluginRepositories>
+        </profile>
 
-  <mirrors>
-  </mirrors>
-  <profiles>
-      <profile>
-          <id>rdc-private-repo</id>
-          <repositories>
-              <repository>
-                  <id>rdc-releases</id>
-                  <url>https://repo.rdc.aliyun.com/repository/109287-release-nNDwQE/</url>
-              </repository>
-              <repository>
-                  <id>rdc-snapshots</id>
-                  <url>https://repo.rdc.aliyun.com/repository/109287-snapshot-ZkSC5j/</url>
-              </repository>
-          </repositories>
-      </profile>
-  </profiles>
+    </profiles>
 
-</settings>
+    <activeProfiles>
+        <activeProfile>nexus</activeProfile>
+    </activeProfiles>
+</settings>

+ 14 - 0
src/main/java/com/galaxis/manatee/dao/ChuanyunLogDao.java

@@ -0,0 +1,14 @@
+package com.galaxis.manatee.dao;
+
+import com.galaxis.capsule.util.GalaxisRepository;
+import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunLogDO;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author zcj
+ * @version 0.1
+ * @date 2020/5/22 11:30 下午
+ */
+@Repository
+public interface ChuanyunLogDao extends GalaxisRepository<ChuanyunLogDO,String> {
+}

+ 6 - 0
src/main/java/com/galaxis/manatee/dao/ChuanyunUserDao.java

@@ -11,4 +11,10 @@ import org.springframework.stereotype.Repository;
  */
 @Repository
 public interface ChuanyunUserDao extends GalaxisRepository<ChuanyunUserDO,String> {
+    /**
+     * 根据名字获取人员对象
+     * @param name  名字
+     * @return  对象
+     */
+    ChuanyunUserDO findByName(String name);
 }

+ 15 - 0
src/main/java/com/galaxis/manatee/dao/ProjectSwitchDao.java

@@ -0,0 +1,15 @@
+package com.galaxis.manatee.dao;
+
+import com.galaxis.capsule.util.GalaxisRepository;
+import com.galaxis.manatee.entity.chuanyun.data.object.ProjectSwitch;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 用来处理各个业务项目到集团项目数据转化时候的临时对象
+ * @author zcj
+ * @version 0.1
+ * @date 2020/5/18 2:26 下午
+ */
+@Repository
+public interface ProjectSwitchDao extends GalaxisRepository<ProjectSwitch,String> {
+}

+ 5 - 0
src/main/java/com/galaxis/manatee/entity/chuanyun/data/object/ChuanyunDayLog.java

@@ -43,6 +43,11 @@ public class ChuanyunDayLog extends BasicSubDO{
     @JsonProperty("project")
     private String projectId;
     /**
+     * 项目Id字符串
+     */
+    @JsonProperty("projectId")
+    private String projectIdString;
+    /**
      * 工厂地址ID
      */
     @JsonProperty("factoryLocation")

+ 4 - 0
src/main/java/com/galaxis/manatee/entity/chuanyun/data/object/ChuanyunLogDO.java

@@ -40,6 +40,10 @@ public class ChuanyunLogDO extends BasicDO{
     @JsonProperty("userCompany")
     private String userCompanyId;
     /**
+     * 按天或按周
+     */
+    private String dayOrWeek;
+    /**
      * 用户
      */
     @JsonProperty("user")

+ 19 - 0
src/main/java/com/galaxis/manatee/entity/chuanyun/data/object/ProjectSwitch.java

@@ -0,0 +1,19 @@
+package com.galaxis.manatee.entity.chuanyun.data.object;
+
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+/**
+ * @author zcj
+ * @version 0.1
+ * @date 2020/5/18 2:25 下午
+ */
+@Entity
+@Data
+public class ProjectSwitch {
+    @Id
+    private String source;
+    private String target;
+}

+ 67 - 0
src/main/java/com/galaxis/manatee/task/ChuanyunHumanResourceScheduledTask.java

@@ -0,0 +1,67 @@
+package com.galaxis.manatee.task;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.galaxis.manatee.dao.ChuanyunLogDao;
+import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunLogDO;
+import com.galaxis.manatee.entity.chuanyun.dto.Filter;
+import com.galaxis.manatee.manager.ChuanYunManager;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author zcj
+ * @version 0.1
+ * @date 2020/5/22 11:33 下午
+ */
+@Slf4j
+@Service
+public class ChuanyunHumanResourceScheduledTask {
+
+    private final Integer pageSize=100;
+    private final ChuanYunManager chuanYunManager;
+    private final ChuanyunLogDao chuanyunLogDao;
+
+    public ChuanyunHumanResourceScheduledTask(ChuanYunManager chuanYunManager, ChuanyunLogDao chuanyunLogDao) {
+        this.chuanYunManager = chuanYunManager;
+        this.chuanyunLogDao = chuanyunLogDao;
+    }
+
+//    @Scheduled(cron = "0 0 3 * * *")
+    @Scheduled(fixedDelay = 1000000000L)
+    private void updateLog(){
+        var objectMapper=new ObjectMapper();
+        var start=0;
+        var totalCount=0L;
+        var flag=true;
+        while (flag){
+            try {
+                //从氚云查询数据
+                var filter= Filter.instance(start,start+pageSize,true);
+                var chuanyunFindAllResponse=chuanYunManager.findAll(ChuanyunLogDO.SCHEMA_CODE,filter);
+                if(chuanyunFindAllResponse.getReturnData()==null){
+                    flag=false;
+                    continue;
+                }
+                if(chuanyunFindAllResponse.getReturnData().getTotalCount()>=start+pageSize){
+                    start+=pageSize;
+                }else{
+                    flag=false;
+                }
+                //转化为POJO
+                List<ChuanyunLogDO> result=objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>(){});
+                //获取项目总数
+                totalCount=chuanyunFindAllResponse.getReturnData().getTotalCount();
+                //保存
+                chuanyunLogDao.saveAll(result);
+            }catch (Exception e){
+                log.error(e.getMessage());
+                e.printStackTrace();
+            }
+        }
+        log.info("日志信息保存"+totalCount);
+    }
+}

+ 231 - 7
src/main/java/com/galaxis/manatee/task/TestService.java

@@ -1,17 +1,22 @@
 package com.galaxis.manatee.task;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunDayLog;
-import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunLogDO;
+import com.galaxis.manatee.dao.ChuanyunUserDao;
+import com.galaxis.manatee.dao.ProjectSwitchDao;
+import com.galaxis.manatee.entity.chuanyun.data.object.*;
 import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunSaveDTO;
 import com.galaxis.manatee.entity.chuanyun.dto.Filter;
 import com.galaxis.manatee.manager.ChuanYunManager;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
@@ -24,12 +29,173 @@ import java.util.List;
  */
 @Slf4j
 @Service
-public class TestService {
+public class FixService {
 
     private final ChuanYunManager chuanYunManager;
+    private final ChuanyunUserDao chuanyunUserDao;
+    private final ProjectSwitchDao projectSwitchDao;
 
-    public TestService(ChuanYunManager chuanYunManager) {
+    public FixService(ChuanYunManager chuanYunManager, ChuanyunUserDao chuanyunUserDao, ProjectSwitchDao projectSwitchDao) {
         this.chuanYunManager = chuanYunManager;
+        this.chuanyunUserDao = chuanyunUserDao;
+        this.projectSwitchDao = projectSwitchDao;
+    }
+
+    /**
+     * 修复修改obejctId的问题,日志和报销
+     */
+//    @Scheduled(fixedDelay = 999999999L)
+    private void fixProject(){
+
+        projectSwitchDao.findAll().forEach(projectSwitch -> {
+
+            var originProjectId=projectSwitch.getSource();
+            var targetProjectId=projectSwitch.getTarget();
+
+            //第一步简历老项目新项目对应关系
+            //获取项目
+            var objectMapper=new ObjectMapper();
+            var pageSize=20;
+            var start=0;
+            var totalCount=0L;
+            var flag=true;
+            //++++++++++++++++++修复报销
+            List<String> matchersString=new ArrayList<>();
+//        matchersString.add("Status_2,1");
+            matchersString.add("F0000093_2,"+originProjectId);
+            while (flag){
+                try {
+                    //从氚云查询数据
+                    var filter= Filter.instance(start,start+pageSize,true,Filter.AND,matchersString);
+                    var chuanyunFindAllResponse=chuanYunManager.findAll(ChuanyunReimbursementDO.SCHEMA_CODE,filter);
+                    if(chuanyunFindAllResponse.getReturnData()==null){
+                        flag=false;
+                        continue;
+                    }
+                    if(chuanyunFindAllResponse.getReturnData().getTotalCount()>=start+pageSize){
+                        start+=pageSize;
+                    }else{
+                        flag=false;
+                    }
+                    //转化为POJO
+                    List<ChuanyunReimbursementDO> result=objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>(){});
+                    result.forEach(chuanyunReimbursementDO -> {
+                        ReimbursementDTO reimbursementDTO=new ReimbursementDTO();
+                        reimbursementDTO.setProject(targetProjectId);
+                        log.info(chuanyunReimbursementDO+"");
+                        //保存
+                        try {
+                            String bizObjectString=objectMapper.writeValueAsString(reimbursementDTO);
+                            ChuanyunSaveDTO chuanyunSaveDTO=chuanYunManager.update(ChuanyunReimbursementDO.SCHEMA_CODE,chuanyunReimbursementDO.getObjectId(),bizObjectString);
+                            log.info(chuanyunSaveDTO+"");
+                        } catch (JsonProcessingException e) {
+                            e.printStackTrace();
+                        }
+                    });
+                    //获取项目总数
+                    totalCount=chuanyunFindAllResponse.getReturnData().getTotalCount();
+                }catch (Exception e){
+                    log.error(e.getMessage());
+                    e.printStackTrace();
+                }
+            }
+            //++++++++++++++++++修复日志
+            //获取idList
+            List<String> idList=new ArrayList<>();
+            start=0;
+            flag=true;
+            matchersString=new ArrayList<>();
+//            matchersString.add("project_2,"+originProjectId);
+            matchersString.add("projectId_2,"+originProjectId);
+            while (flag){
+                try{
+                    //从氚云查询数据
+                    var filter= Filter.instance(start,start+pageSize,true,Filter.AND,matchersString);
+                    var chuanyunFindAllResponse=chuanYunManager.findAll("D001789DayLog",filter);
+                    if(chuanyunFindAllResponse.getReturnData()==null){
+                        flag=false;
+                        continue;
+                    }
+                    if(chuanyunFindAllResponse.getReturnData().getTotalCount()>=start+pageSize){
+                        start+=pageSize;
+                    }else{
+                        flag=false;
+                    }
+                    //转化为POJO
+                    List<IdName> result=objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>(){});
+                    result.forEach(idName ->{
+                        try {
+                            idList.add(idName.getParentObjectId());
+                        }catch (Exception e){
+                            log.error(e.getMessage());
+                        }
+                    });
+                }catch (Exception e){
+                    e.printStackTrace();
+                }
+            }
+            for(String parentId:idList){
+                matchersString=new ArrayList<>();
+                matchersString.add("ObjectId_2,"+parentId);
+                flag=true;
+                start=0;
+                totalCount=0L;
+                while (flag){
+                    try {
+                        //从氚云查询数据
+                        var filter= Filter.instance(start,start+pageSize,true,Filter.AND,matchersString);
+                        var chuanyunFindAllResponse=chuanYunManager.findAll(ChuanyunLogDO.SCHEMA_CODE,filter);
+                        if(chuanyunFindAllResponse.getReturnData()==null){
+                            flag=false;
+                            continue;
+                        }
+                        if(chuanyunFindAllResponse.getReturnData().getTotalCount()>=start+pageSize){
+                            start+=pageSize;
+                        }else{
+                            flag=false;
+                        }
+                        //转化为POJO
+                        List<ChuanyunLogDO> result=objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>(){});
+                        result.forEach(chuanyunLogDO -> {
+                            String logDateString=chuanyunLogDO.getLogDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                            LogDTO logDTO=new LogDTO();
+                            logDTO.setTitle(logDateString);
+                            ChuanyunUserDO chuanyunUserDO=chuanyunUserDao.findByName(chuanyunLogDO.getUserId());
+                            logDTO.setUser(chuanyunUserDO.getObjectId());
+                            logDTO.setLogDate(logDateString);
+                            logDTO.setDayOrWeek(chuanyunLogDO.getDayOrWeek());
+
+                            List<ChuanyunDayLog> chuanyunDayLogList=new ArrayList<>();
+                            chuanyunLogDO.getDayLogList().forEach(chuanyunDayLog -> {
+                                ChuanyunDayLog newChuanyunDayLog=new ChuanyunDayLog();
+                                BeanUtils.copyProperties(chuanyunDayLog,newChuanyunDayLog);
+                                if(StringUtils.isEmpty(chuanyunDayLog.getProjectId())||
+                                        chuanyunDayLog.getProjectId().equals(originProjectId)||
+                                        chuanyunDayLog.getProjectIdString().equals(originProjectId)){
+                                    newChuanyunDayLog.setProjectId(targetProjectId);
+                                }
+                                newChuanyunDayLog.setProjectIdString(newChuanyunDayLog.getProjectId());
+                                chuanyunDayLogList.add(newChuanyunDayLog);
+                            });
+                            logDTO.setDayLogList(chuanyunDayLogList);
+                            try {
+                                ChuanyunSaveDTO chuanyunSaveDTO=chuanYunManager.update(ChuanyunLogDO.SCHEMA_CODE,chuanyunLogDO.getObjectId(),objectMapper.writeValueAsString(logDTO));
+                                log.info(chuanyunSaveDTO+"");
+                            } catch (JsonProcessingException e) {
+                                e.printStackTrace();
+                            }
+                        });
+                        //获取项目总数
+                    }catch (Exception e){
+                        log.error(e.getMessage());
+                        e.printStackTrace();
+                    }
+                }
+            }
+
+            log.info("修复id问题"+projectSwitch.getSource()+"###"+projectSwitch.getTarget());
+        });
+        log.info("修复id问题结束");
     }
 
     /**
@@ -201,13 +367,31 @@ public class TestService {
 }
 
 @Data
+class ReimbursementDTO{
+    @JsonProperty("F0000093")
+    private String project;
+}
+
+/**
+ * 日志更新信息
+ */
+@Data
 class LogDTO{
+    /**
+     * 标题
+     */
     private String title;
-
+    /**
+     * 用户
+     */
     private String user;
-
+    /**
+     * 日志日期
+     */
     private String logDate;
-
+    /**
+     * 每周填写或者每天填写
+     */
     private String dayOrWeek;
 
     /**
@@ -216,3 +400,43 @@ class LogDTO{
     @JsonProperty("D001789DayLog")
     private List<ChuanyunDayLog> dayLogList;
 }
+
+/**
+ * 更新的数据
+ */
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+class ProjectId{
+
+    @JsonProperty("D001789DayLog")
+    private List<DayLog> dayLog;
+}
+
+/**
+ * 查询的数据
+ */
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+class IdName{
+    @JsonProperty("Name")
+    private String name;
+
+    @JsonProperty("ObjectId")
+    private String objectId;
+
+    @JsonProperty("D001789DayLog")
+    private List<DayLog> dayLog;
+
+    @JsonProperty("ParentObjectId")
+    private String parentObjectId;
+}
+
+/**
+ * 每日明细项目
+ */
+class DayLog{
+    /**
+     * 项目
+     */
+    private String project;
+}