lyhzzz hace 4 semanas
padre
commit
e52f19be58
Se han modificado 1 ficheros con 28 adiciones y 18 borrados
  1. 28 18
      src/main/java/com/fdkankan/fusion/service/impl/CopyCaseService.java

+ 28 - 18
src/main/java/com/fdkankan/fusion/service/impl/CopyCaseService.java

@@ -9,6 +9,7 @@ import com.fdkankan.fusion.entity.*;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.service.*;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.math3.ode.ODEIntegrator;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -328,11 +329,14 @@ public class CopyCaseService {
                 caseTagPoint.setTagPointId(null);
                 caseTagPoint.setTagId(newTagId);
                 caseTagPoint.setFusionNumId(fusionNumIdMap.get(caseTagPoint.getFusionNumId()));
-                String path = caseTagPoint.getPose();
-                for (Integer oldId : fusionNumIdMap.keySet()) {
-                    path = path.replaceAll("\"modelId\":\""+oldId+"\"","\"modelId\":\""+fusionNumIdMap.get(oldId)+"\"");
+
+                if(StringUtils.isNotBlank(caseTagPoint.getPose())){
+                    String path = caseTagPoint.getPose();
+                    for (Integer oldId : fusionNumIdMap.keySet()) {
+                        path = path.replaceAll("\"modelId\":\""+oldId+"\"","\"modelId\":\""+fusionNumIdMap.get(oldId)+"\"");
+                    }
+                    caseTagPoint.setPose(path);
                 }
-                caseTagPoint.setPose(path);
                 caseTagPointService.save(caseTagPoint);
             }
 
@@ -478,11 +482,13 @@ public class CopyCaseService {
         for (FusionMeter entity : listByCaseId) {
             entity.setFusionMeterId(null);
             entity.setFusionId(newFusionId);
-            String path = entity.getPosition();
-            for (Integer oldId : fusionNumIdMap.keySet()) {
-                path = path.replaceAll("\"fusionNumId\":\""+oldId+"\"","\"fusionNumId\":\""+fusionNumIdMap.get(oldId)+"\"");
+            if(StringUtils.isNotBlank(entity.getPosition())){
+                String path = entity.getPosition();
+                for (Integer oldId : fusionNumIdMap.keySet()) {
+                    path = path.replaceAll("\"fusionNumId\":\""+oldId+"\"","\"fusionNumId\":\""+fusionNumIdMap.get(oldId)+"\"");
+                }
+                entity.setPosition(path);
             }
-            entity.setPosition(path);
             fusionMeterService.save(entity);
         }
     }
@@ -497,13 +503,15 @@ public class CopyCaseService {
             Integer oldPathId = casePath.getId();
             casePath.setId(null);
             casePath.setCaseId(newCaseId);
-            String path = casePath.getPath();
-            for (Integer oldId : fusionNumIdMap.keySet()) {
-                path = path.replaceAll("\"modelId\":\""+oldId+"\"","\"modelId\":\""+fusionNumIdMap.get(oldId)+"\"");
-            }
-            casePath.setPath(path);
+            if(StringUtils.isNotBlank(casePath.getPath())){
+                String path = casePath.getPath();
+                for (Integer oldId : fusionNumIdMap.keySet()) {
+                    path = path.replaceAll("\"modelId\":\""+oldId+"\"","\"modelId\":\""+fusionNumIdMap.get(oldId)+"\"");
+                }
+                casePath.setPath(path);
 
-            casePathService.save(casePath);
+                casePathService.save(casePath);
+            }
             pathIdMap.put(oldPathId,casePath.getId());
         }
         return pathIdMap;
@@ -518,11 +526,13 @@ public class CopyCaseService {
             caseAnimation.setId(null);
             caseAnimation.setCaseId(newCaseId);
 
-            String path = caseAnimation.getPaths();
-            for (Integer oldId : pathIdMap.keySet()) {
-                path = path.replaceAll("\"pathId\":\""+oldId+"\"","\"pathId\":\""+pathIdMap.get(oldId)+"\"");
+            if(StringUtils.isNotBlank(caseAnimation.getPaths())){
+                String path = caseAnimation.getPaths();
+                for (Integer oldId : pathIdMap.keySet()) {
+                    path = path.replaceAll("\"pathId\":\""+oldId+"\"","\"pathId\":\""+pathIdMap.get(oldId)+"\"");
+                }
+                caseAnimation.setPaths(path);
             }
-            caseAnimation.setPaths(path);
             caseAnimationService.save(caseAnimation);
         }
     }