lyhzzz hai 4 semanas
pai
achega
f7f03c4d8d

+ 0 - 1
src/main/java/com/fdkankan/fusion/service/ICaseOverviewService.java

@@ -2,7 +2,6 @@ package com.fdkankan.fusion.service;
 
 import com.fdkankan.fusion.entity.CaseOverview;
 import com.baomidou.mybatisplus.extension.service.IService;
-import scala.Int;
 
 import java.util.List;
 

+ 32 - 39
src/main/java/com/fdkankan/fusion/service/impl/CopyCaseService.java

@@ -103,8 +103,6 @@ public class CopyCaseService {
         HashMap<Integer, Integer> pathIdMap = this.cpPath(oldCaseId,newCaseId,fusionNumIdMap);
         this.cpAnimation(oldCaseId,newCaseId,pathIdMap);
 
-        this.cpOverview(oldCaseId,newCaseId);
-        this.cpTabluation(oldCaseId,newCaseId);
     }
 
 
@@ -181,9 +179,16 @@ public class CopyCaseService {
             return;
         }
         for (CaseFiles entity : listByCaseId) {
-            if(entity.getOverviewId() != null || entity.getTabulationId() != null){
-                continue;
+            if(entity.getOverviewId() != null ){
+                HashMap<String,Integer> map = this.cpOverview(newCaseId,entity.getOverviewId());
+                entity.setOverviewId(map.get("overviewId"));
+                entity.setTabulationId(map.get("tabulationId"));
+            }
+            if(entity.getOverviewId() == null && entity.getTabulationId() != null ){
+                Integer newId = this.cpTabluation(newCaseId,entity.getTabulationId());
+                entity.setTabulationId(newId);
             }
+
             entity.setFilesId(null);
             entity.setCaseId(newCaseId);
             caseFilesService.save(entity);
@@ -547,45 +552,33 @@ public class CopyCaseService {
             caseAnimationService.save(caseAnimation);
         }
     }
-    private void cpOverview(Integer oldCaseId, Integer newCaseId){
-        List<CaseOverview> byCaseId = caseOverviewService.getByCaseId(oldCaseId);
-        for (CaseOverview caseOverview : byCaseId) {
-            Integer oldOverId = caseOverview.getId();
-            caseOverview.setId(null);
-            caseOverview.setCaseId(newCaseId);
-            caseOverviewService.save(caseOverview);
-
-            CaseFiles caseFiles = caseFilesService.getByOverviewId(oldOverId);
-            caseFiles.setFilesId(null);
-            caseFiles.setOverviewId(caseOverview.getId());
-            caseFiles.setCaseId(newCaseId);
-            if(caseOverview.getCaseTabulation() != null){
-                List<CaseTabulation> byOverId = caseTabulationService.getByOverId(oldOverId);
-                for (CaseTabulation caseTabulation : byOverId) {
-                    caseTabulation.setId(null);
-                    caseTabulation.setOverviewId(caseOverview.getId());
-                    caseTabulation.setCaseId(newCaseId);
-                    caseTabulationService.save(caseTabulation);
-                    caseFiles.setTabulationId(caseTabulation.getId());
-                }
-            }
-            caseFilesService.save(caseFiles);
-        }
-    }
-
-    private void cpTabluation(Integer oldCaseId, Integer newCaseId){
-        List<CaseTabulation> byCaseId = caseTabulationService.getByCaseId(oldCaseId);
-        for (CaseTabulation caseTabulation : byCaseId) {
-            Integer oldId = caseTabulation.getId();
+    private HashMap<String,Integer> cpOverview(Integer newCaseId, Integer oldId){
+        HashMap<String,Integer> map = new HashMap<>();
+        CaseOverview caseOverview = caseOverviewService.getById(oldId);
+        Integer oldOverId = caseOverview.getId();
+        caseOverview.setId(null);
+        caseOverview.setCaseId(newCaseId);
+        caseOverviewService.save(caseOverview);
+        map.put("overviewId",caseOverview.getId());
+
+        List<CaseTabulation> byOverId = caseTabulationService.getByOverId(oldOverId);
+        for (CaseTabulation caseTabulation : byOverId) {
             caseTabulation.setId(null);
+            caseTabulation.setOverviewId(caseOverview.getId());
             caseTabulation.setCaseId(newCaseId);
             caseTabulationService.save(caseTabulation);
+            map.put("tabulationId",caseTabulation.getId());
 
-            CaseFiles caseFiles = caseFilesService.getByTabulation(oldId);
-            caseFiles.setFilesId(null);
-            caseFiles.setTabulationId(caseTabulation.getId());
-            caseFiles.setCaseId(newCaseId);
-            caseFilesService.save(caseFiles);
         }
+        return map;
+
+    }
+
+    private Integer cpTabluation( Integer newCaseId,Integer oldId){
+        CaseTabulation caseTabulation = caseTabulationService.getById(oldId);
+        caseTabulation.setId(null);
+        caseTabulation.setCaseId(newCaseId);
+        caseTabulationService.save(caseTabulation);
+        return caseTabulation.getId();
     }
 }