Explorar o código

fix 数据迁移bug

lvxianyun %!s(int64=2) %!d(string=hai) anos
pai
achega
1296fe8f7c

+ 2 - 1
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/constant/MiGrationRelCode.java

@@ -66,7 +66,8 @@ public enum MiGrationRelCode {
 	Pe2Bd("Pe2Bd"),
 	Pe2Fl("Pe2Fl"),
 	Pe2Sh("Pe2Sh"),
-	Pe2Sp("Pe2Sp");
+	Pe2Sp("Pe2Sp"),
+	Sp2Si("Sp2Si");
 
 	private String code;
 	public String getCode(){

+ 0 - 29
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/constant/MigrationObjType.java

@@ -1,29 +0,0 @@
-package com.persagy.proxy.migration.constant;
-
-/**
- * @author lvxianyun
- * @title: MigrationObjType
- * @projectName adm-middleware
- * @description: 
- * @date 2021/12/9 21:04
- */
-public enum MigrationObjType {
-
-     project("project") ,building("building") , floor("floor") ,component("component") , equipment("equipment") , shaft("shaft") , system("system") ,  /*ispace ,*/ space("space") ;
-
-     private String code;
-
-     public String getCode() {
-          return code;
-     }
-
-     MigrationObjType(String code) {
-          this.code = code;
-     }
-
-     @Override
-     public String toString() {
-          return this.code;
-     }
-
-}

+ 1 - 2
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/controller/DataMigrationController.java

@@ -20,7 +20,6 @@ import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.common.entity.DmpResult;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.migration.constant.MigrationConstant;
-import com.persagy.proxy.migration.constant.MigrationObjType;
 import com.persagy.proxy.migration.handler.DataMigrationHandler;
 import com.persagy.proxy.migration.model.DataMigrationExcel;
 import com.persagy.proxy.migration.model.MigrationInfo;
@@ -245,7 +244,7 @@ public class DataMigrationController {
         queryCriteria.setOnlyCount(true);
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();
         criteria.put("valid", 1);
-        criteria.put("objType", MigrationObjType.project.getCode());
+        criteria.put("objType", "project");
         queryCriteria.setCriteria(criteria);
 
         String requestBody = JsonHelper.toJsonStr(queryCriteria);

+ 17 - 0
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/service/Impl/MigrationAbstractServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.http.HttpException;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONUtil;
 import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.basic.utils.JsonNodeUtils;
@@ -13,6 +14,8 @@ import com.persagy.dmp.common.constant.ResponseCode;
 import com.persagy.dmp.common.model.entity.AuditableEntity;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.JsonHelper;
+import com.persagy.dmp.define.client.DigitalDefineFacade;
+import com.persagy.dmp.define.entity.ObjectTypeDefine;
 import com.persagy.dmp.migrate.client.DigitalMigrateLogFacade;
 import com.persagy.dmp.rwd.migrate.entity.SyncData;
 import com.persagy.proxy.common.entity.DmpResult;
@@ -468,4 +471,18 @@ public class MigrationAbstractServiceImpl<T> implements IMigrationAbstractServic
         }
         return targetsMap;
     }
+
+
+    public List<String> getObjTypes(InstanceUrlParam context){
+        QueryCriteria queryCriteria = new QueryCriteria();
+        ObjectNode criteria = JsonNodeFactory.instance.objectNode();
+        criteria.put("valid", 1);
+        queryCriteria.setCriteria(criteria);
+        List<ObjectTypeDefine> types = DigitalDefineFacade.queryObjectType(context.getGroupCode(),context.getProjectId(),context.getUserId(),context.getUserId(),queryCriteria);
+        if(CollUtil.isEmpty(types)){
+            return null;
+        }
+        Map<String,List<ObjectTypeDefine>> objType = types.stream().collect(Collectors.groupingBy(ObjectTypeDefine::getObjType));
+        return objType.keySet().stream().collect(Collectors.toList());
+    }
 }

+ 13 - 16
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/service/Impl/ObjectDigitalMigration.java

@@ -8,16 +8,12 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.basic.utils.JsonNodeUtils;
 import com.persagy.dmp.common.constant.ResponseCode;
-import com.persagy.dmp.common.model.entity.AuditableEntity;
-import com.persagy.dmp.common.model.entity.BaseEntity;
-import com.persagy.dmp.define.entity.ObjectTypeDefine;
 import com.persagy.dmp.digital.client.DigitalObjectFacade;
 import com.persagy.dmp.digital.entity.ObjectDigital;
 import com.persagy.dmp.rwd.migrate.entity.SyncData;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import com.persagy.proxy.migration.constant.MigrationConstant;
-import com.persagy.proxy.migration.constant.MigrationObjType;
 import com.persagy.proxy.migration.constant.MigrationTable;
 import com.persagy.proxy.migration.constant.MigrationType;
 import com.persagy.proxy.migration.model.DataMigrationExcel;
@@ -25,7 +21,6 @@ import com.persagy.proxy.migration.model.DataMigrationResponse;
 import com.persagy.proxy.migration.model.MigrationInfo;
 import com.persagy.proxy.migration.service.IDataMigration;
 import com.persagy.proxy.migration.service.IDataMigrationProcess;
-import com.persagy.proxy.migration.service.Impl.MigrationAbstractServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
@@ -55,14 +50,14 @@ public class ObjectDigitalMigration extends MigrationAbstractServiceImpl<ObjectD
         log.info("######################### dt_object 数据迁移内容获取开始 #########################");
         long start = System.currentTimeMillis();
         List<DataMigrationExcel> dataMigrationExcels = new ArrayList<>();
+        List<String> objTypes = getObjTypes(context);
+        for(String objType : objTypes){
+            log.info("######################### dt_object "+objType+"数据迁移内容获取开始 #########################");
 
-        for(MigrationObjType objType : MigrationObjType.values()){
-            log.info("######################### dt_object "+objType.getCode()+"数据迁移内容获取开始 #########################");
-
-            QueryCriteria queryCriteria = getQueryCriteria(objType.getCode());
+            QueryCriteria queryCriteria = getQueryCriteria(objType);
             dataMigrationExcels.addAll(startMigrateForExcel(context,migrationInfo,queryCriteria));
 
-            log.info("######################### dt_object "+objType.getCode()+"数据迁移内容获取结束 #########################");
+            log.info("######################### dt_object "+objType+"数据迁移内容获取结束 #########################");
         }
 
         long end = System.currentTimeMillis();
@@ -80,13 +75,14 @@ public class ObjectDigitalMigration extends MigrationAbstractServiceImpl<ObjectD
     public AdmResponse migrateForLog(InstanceUrlParam context, MigrationInfo migrationInfo) {
         log.info("######################### dt_object 同步开始 #########################");
         long start = System.currentTimeMillis();
-        for(MigrationObjType objType : MigrationObjType.values()){
-            log.info("######################### dt_object "+objType.getCode()+"同步开始 #########################");
+        List<String> objTypes = getObjTypes(context);
+        for(String objType : objTypes){
+            log.info("######################### dt_object "+objType+"同步开始 #########################");
 
-            QueryCriteria queryCriteria = getQueryCriteria(objType.getCode());
+            QueryCriteria queryCriteria = getQueryCriteria(objType);
             startMigrateForLog(context,migrationInfo,queryCriteria);
 
-            log.info("######################### dt_object "+objType.getCode()+"同步结束 #########################");
+            log.info("######################### dt_object "+objType+"同步结束 #########################");
         }
         long end = System.currentTimeMillis();
         log.info("######################### dt_object 数据迁移已结束 时间:"+(end-start)+" #########################");
@@ -104,8 +100,9 @@ public class ObjectDigitalMigration extends MigrationAbstractServiceImpl<ObjectD
         StringBuffer sqls = new StringBuffer(" \n -- 数据迁移  dt_object ------ \n");
         //获取已经采集的数据
         String sqls_temp = "";
-        for(MigrationObjType objType : MigrationObjType.values()){
-            QueryCriteria queryCriteria = getQueryCriteria(objType.getCode());
+        List<String> objTypes = getObjTypes(context);
+        for(String objType : objTypes){
+            QueryCriteria queryCriteria = getQueryCriteria(objType);
             List<ObjectNode> admData = getAdmData(context,queryCriteria);
             if(CollUtil.isEmpty(admData)){
                 continue;