lyhzzz 2 months ago
parent
commit
5945ca9519
1 changed files with 21 additions and 12 deletions
  1. 21 12
      src/main/java/com/fdkankan/fusion/service/impl/CopyCaseService.java

+ 21 - 12
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;
@@ -329,10 +330,12 @@ public class CopyCaseService {
                 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(path)){
+                    for (Integer oldId : fusionNumIdMap.keySet()) {
+                        path = path.replaceAll("\"modelId\":\""+oldId+"\"","\"modelId\":\""+fusionNumIdMap.get(oldId)+"\"");
+                    }
+                    caseTagPoint.setPose(path);
                 }
-                caseTagPoint.setPose(path);
                 caseTagPointService.save(caseTagPoint);
             }
 
@@ -479,10 +482,12 @@ public class CopyCaseService {
             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(path)){
+                for (Integer oldId : fusionNumIdMap.keySet()) {
+                    path = path.replaceAll("\"fusionNumId\":\""+oldId+"\"","\"fusionNumId\":\""+fusionNumIdMap.get(oldId)+"\"");
+                }
+                entity.setPosition(path);
             }
-            entity.setPosition(path);
             fusionMeterService.save(entity);
         }
     }
@@ -498,10 +503,12 @@ public class CopyCaseService {
             casePath.setId(null);
             casePath.setCaseId(newCaseId);
             String path = casePath.getPath();
-            for (Integer oldId : fusionNumIdMap.keySet()) {
-                path = path.replaceAll("\"modelId\":\""+oldId+"\"","\"modelId\":\""+fusionNumIdMap.get(oldId)+"\"");
+            if(StringUtils.isNotBlank(path)){
+                for (Integer oldId : fusionNumIdMap.keySet()) {
+                    path = path.replaceAll("\"modelId\":\""+oldId+"\"","\"modelId\":\""+fusionNumIdMap.get(oldId)+"\"");
+                }
+                casePath.setPath(path);
             }
-            casePath.setPath(path);
 
             casePathService.save(casePath);
             pathIdMap.put(oldPathId,casePath.getId());
@@ -519,10 +526,12 @@ public class CopyCaseService {
             caseAnimation.setCaseId(newCaseId);
 
             String path = caseAnimation.getPaths();
-            for (Integer oldId : pathIdMap.keySet()) {
-                path = path.replaceAll("\"pathId\":\""+oldId+"\"","\"pathId\":\""+pathIdMap.get(oldId)+"\"");
+            if(StringUtils.isNotBlank(path)){
+                for (Integer oldId : pathIdMap.keySet()) {
+                    path = path.replaceAll("\"pathId\":\""+oldId+"\"","\"pathId\":\""+pathIdMap.get(oldId)+"\"");
+                }
+                caseAnimation.setPaths(path);
             }
-            caseAnimation.setPaths(path);
             caseAnimationService.save(caseAnimation);
         }
     }