|
@@ -2,6 +2,8 @@ package com.fdkankan.fusion.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.fusion.common.ResultCode;
|
|
|
+import com.fdkankan.fusion.common.enums.IdPreEnum;
|
|
|
+import com.fdkankan.fusion.common.util.IdUtils;
|
|
|
import com.fdkankan.fusion.common.util.UploadToOssUtil;
|
|
|
import com.fdkankan.fusion.entity.*;
|
|
|
import com.fdkankan.fusion.exception.BusinessException;
|
|
@@ -44,14 +46,24 @@ public class CopyCaseService {
|
|
|
ICaseVideoFolderService caseVideoFolderService;
|
|
|
@Autowired
|
|
|
ICaseVideoService caseVideoService;
|
|
|
-
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ ICaseViewService caseViewService;
|
|
|
+ @Autowired
|
|
|
+ IFusionGuideService fusionGuideService;
|
|
|
+ @Autowired
|
|
|
+ IFusionGuidePathService fusionGuidePathService;
|
|
|
+ @Autowired
|
|
|
+ IFusionNumService fusionNumService;
|
|
|
+ @Autowired
|
|
|
+ IFusionMeterService fusionMeterService;
|
|
|
+ @Autowired
|
|
|
+ ITmProjectService projectService;
|
|
|
+ @Autowired
|
|
|
+ ITmMessageService tmMessageService;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
UploadToOssUtil uploadToOssUtil;
|
|
|
- @Value("${upload.query-path}")
|
|
|
- private String queryPath;
|
|
|
|
|
|
|
|
|
public void copyCase(Integer oldCaseId){
|
|
@@ -66,6 +78,8 @@ public class CopyCaseService {
|
|
|
this.cpCaseSettingsResource(oldCaseId,newCaseId);
|
|
|
this.cpCaseTag(oldCaseId,newCaseId);
|
|
|
this.cpCaseVideo(oldCaseId,newCaseId);
|
|
|
+ this.cpCaseViewByCaseId(oldCaseId,newCaseId);
|
|
|
+ this.cpFusionGuide(oldCaseId,newCaseId);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -78,12 +92,38 @@ public class CopyCaseService {
|
|
|
if(caseEntity == null){
|
|
|
throw new BusinessException(ResultCode.CASE_NOT_EXIST);
|
|
|
}
|
|
|
+ String oldProjectId = caseEntity.getTmProjectId();
|
|
|
caseEntity.setCaseId(null);
|
|
|
caseEntity.setCaseTitle(caseEntity.getCaseTitle()+"(copy)");
|
|
|
+ String newProjectId = cpProject(oldProjectId);
|
|
|
+ caseEntity.setTmProjectId(newProjectId);
|
|
|
caseService.save(caseEntity);
|
|
|
return caseEntity.getCaseId();
|
|
|
}
|
|
|
|
|
|
+ private String cpProject(String oldProjectId) {
|
|
|
+ TmProject tmProject = projectService.getById(oldProjectId);
|
|
|
+ String newId = IdUtils.genId(IdPreEnum.PROJECT_PRE.getPre());
|
|
|
+ tmProject.setId(newId);
|
|
|
+ tmProject.setProjectSn(tmProject.getProjectSn() +"(copy)");
|
|
|
+ tmProject.setCaseNewName(projectService.setCaseNewName(tmProject));
|
|
|
+ projectService.save(tmProject);
|
|
|
+ cpMessage(oldProjectId,newId);
|
|
|
+ return newId;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void cpMessage(String oldProjectId, String newId) {
|
|
|
+ List<TmMessage> messages = tmMessageService.getByProjectId(oldProjectId);
|
|
|
+ if(messages == null || messages.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (TmMessage message : messages) {
|
|
|
+ message.setId(IdUtils.genId(IdPreEnum.MESSAGE_PRE.getPre()));
|
|
|
+ message.setProjectId(newId);
|
|
|
+ tmMessageService.save(message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 复制案件提取清单
|
|
|
*/
|
|
@@ -121,9 +161,13 @@ public class CopyCaseService {
|
|
|
return;
|
|
|
}
|
|
|
for (CaseFusion entity : listByCaseId) {
|
|
|
+ Integer oldFusionId = entity.getFusionId();
|
|
|
entity.setFusionId(null);
|
|
|
entity.setCaseId(newCaseId);
|
|
|
caseFusionService.save(entity);
|
|
|
+
|
|
|
+ cpCaseViewByFusionId(oldFusionId,entity.getFusionId(),newCaseId);
|
|
|
+ cpFusionNum(oldFusionId,entity.getFusionId());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -279,5 +323,103 @@ public class CopyCaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 复制案件视图提取
|
|
|
+ */
|
|
|
+ private void cpCaseViewByCaseId(Integer oldCaseId, Integer newCaseId) {
|
|
|
+ List<CaseView> listByCaseId = caseViewService.getByCaseId(oldCaseId);
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (CaseView entity : listByCaseId) {
|
|
|
+ if(entity.getFusionId() != null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ entity.setViewId(null);
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
+ caseViewService.save(entity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void cpCaseViewByFusionId(Integer oldFusionId, Integer newFusionId,Integer newCaseId) {
|
|
|
+ List<CaseView> listByCaseId = caseViewService.getByFusionId(oldFusionId);
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (CaseView entity : listByCaseId) {
|
|
|
+ entity.setViewId(null);
|
|
|
+ entity.setFusionId(newFusionId+"");
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
+ caseViewService.save(entity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复制案件导览
|
|
|
+ */
|
|
|
+ private void cpFusionGuide(Integer oldCaseId, Integer newCaseId) {
|
|
|
+ List<FusionGuide> listByCaseId = fusionGuideService.getAllList(oldCaseId);
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (FusionGuide entity : listByCaseId) {
|
|
|
+ Integer oldGuideId =entity.getFusionGuideId();
|
|
|
+
|
|
|
+ entity.setFusionGuideId(null);
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
+ fusionGuideService.save(entity);
|
|
|
+
|
|
|
+ Integer newGuideId = entity.getFusionGuideId();
|
|
|
+
|
|
|
+ List<FusionGuidePath> listByGuideId = fusionGuidePathService.getListByGuideId(oldGuideId);
|
|
|
+ if(listByGuideId == null || listByGuideId.isEmpty()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (FusionGuidePath byId : listByGuideId) {
|
|
|
+ byId.setGuidePathId(null);
|
|
|
+ byId.setGuideId(newGuideId);
|
|
|
+ fusionGuidePathService.save(byId);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复制案件编辑器ID
|
|
|
+ */
|
|
|
+ private void cpFusionNum(Integer oldFusionId, Integer newFusionId) {
|
|
|
+ List<FusionNum> listByCaseId = fusionNumService.getByFusionId(oldFusionId);
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (FusionNum entity : listByCaseId) {
|
|
|
+ Integer oldFusionNumId = entity.getFusionNumId();
|
|
|
+ entity.setFusionNumId(null);
|
|
|
+ entity.setFusionId(newFusionId);
|
|
|
+ fusionNumService.save(entity);
|
|
|
+
|
|
|
+ Integer newFusionNumId = entity.getFusionNumId();
|
|
|
|
|
|
+ cpFusionMeter(oldFusionNumId,newFusionNumId,newFusionId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复制案件测量数据
|
|
|
+ */
|
|
|
+ private void cpFusionMeter(Integer oldFusionNumId, Integer newFusionNumId,Integer newFusionId) {
|
|
|
+ List<FusionMeter> listByCaseId = fusionMeterService.getByFusionNumId(oldFusionNumId);
|
|
|
+ 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);
|
|
|
+ fusionMeterService.save(entity);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|