lyhzzz 3 mesiacov pred
rodič
commit
b1f651a87b

+ 23 - 10
src/main/java/com/fdkankan/fusion/service/impl/CopyCaseService.java

@@ -90,11 +90,12 @@ public class CopyCaseService {
         this.cpFusionGuide(oldCaseId,newCaseId);
         this.cpCaseScript(oldCaseId,newCaseId);
         this.cpImgTag(oldCaseId,newCaseId);
-        HashMap<Integer, Integer> fusionNumIdMap = this.cpCaseFusion(oldCaseId, newCaseId);
 
+        HashMap<Integer, Integer> fusionNumIdMap = this.cpCaseFusion(oldCaseId, newCaseId);
         this.cpCaseTag(oldCaseId,newCaseId,fusionNumIdMap);
-        this.cpPath(oldCaseId,newCaseId,fusionNumIdMap);
-        this.cpAnimation(oldCaseId,newCaseId);
+
+        HashMap<Integer, Integer> pathIdMap = this.cpPath(oldCaseId,newCaseId,fusionNumIdMap);
+        this.cpAnimation(oldCaseId,newCaseId,pathIdMap);
     }
 
 
@@ -195,7 +196,7 @@ public class CopyCaseService {
             cpCaseViewByFusionId(oldFusionId,entity.getFusionId(),newCaseId);
             cpFusionNum(oldFusionId,entity.getFusionId(),fusionNumIdMap);
 
-            cpFusionMeter(oldFusionId,entity.getFusionId());
+            cpFusionMeter(oldFusionId,entity.getFusionId(),fusionNumIdMap);
 
         }
         return fusionNumIdMap;
@@ -464,17 +465,19 @@ public class CopyCaseService {
     /**
      * 复制案件测量数据
      */
-    private void cpFusionMeter(Integer oldFusionId,Integer newFusionId) {
+    private void cpFusionMeter(Integer oldFusionId,Integer newFusionId,HashMap<Integer,Integer> fusionNumIdMap) {
         List<FusionMeter> listByCaseId = fusionMeterService.getListByFusionId(oldFusionId,null);
         if(listByCaseId == null || listByCaseId.isEmpty()){
             return;
         }
         for (FusionMeter entity : listByCaseId) {
-            //String oldPosition = entity.getPosition();
             entity.setFusionMeterId(null);
             entity.setFusionId(newFusionId);
-            //String newPosition = oldPosition.replaceAll("\"fusionNumId\":\""+oldFusionNumId+"\"","\"fusionNumId\":\""+newFusionNumId+"\"");
-            //entity.setPosition(newPosition);
+            String path = entity.getPosition();
+            for (Integer oldId : fusionNumIdMap.keySet()) {
+                path = path.replaceAll("\"fusionNumId\":\""+oldId+"\"","\"fusionNumId\":\""+fusionNumIdMap.get(oldId)+"\"");
+            }
+            entity.setPosition(path);
             fusionMeterService.save(entity);
         }
     }
@@ -482,9 +485,11 @@ public class CopyCaseService {
     /**
      * 复制路线
      */
-    private void cpPath(Integer oldCaseId,Integer newCaseId,HashMap<Integer, Integer> fusionNumIdMap){
+    private HashMap<Integer, Integer> cpPath(Integer oldCaseId,Integer newCaseId,HashMap<Integer, Integer> fusionNumIdMap){
+        HashMap<Integer, Integer> pathIdMap = new HashMap<>();
         List<CasePath> casePaths = casePathService.getByCaseId(oldCaseId);
         for (CasePath casePath : casePaths) {
+            Integer oldPathId = casePath.getId();
             casePath.setId(null);
             casePath.setCaseId(newCaseId);
             String path = casePath.getPath();
@@ -494,17 +499,25 @@ public class CopyCaseService {
             casePath.setPath(path);
 
             casePathService.save(casePath);
+            pathIdMap.put(oldPathId,casePath.getId());
         }
+        return pathIdMap;
     }
 
     /**
      * 复制动画数据
      */
-    private void cpAnimation(Integer oldCaseId,Integer newCaseId){
+    private void cpAnimation(Integer oldCaseId,Integer newCaseId,HashMap<Integer, Integer> pathIdMap){
         List<CaseAnimation> list = caseAnimationService.getListByCaseId(oldCaseId);
         for (CaseAnimation caseAnimation : list) {
             caseAnimation.setId(null);
             caseAnimation.setCaseId(newCaseId);
+
+            String path = caseAnimation.getPaths();
+            for (Integer oldId : pathIdMap.keySet()) {
+                path = path.replaceAll("\"pathId\":\""+oldId+"\"","\"pathId\":\""+pathIdMap.get(oldId)+"\"");
+            }
+            caseAnimation.setPaths(path);
             caseAnimationService.save(caseAnimation);
         }
     }