|
@@ -0,0 +1,283 @@
|
|
|
|
+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.util.UploadToOssUtil;
|
|
|
|
+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.math3.ode.ODEIntegrator;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+@Slf4j
|
|
|
|
+public class CopyCaseService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseService caseService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseNumService caseNumService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseExtractDetailService caseExtractDetailService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseFilesService caseFilesService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseFusionService caseFusionService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseImgService caseImgService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseInquestService caseInquestService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseSettingsService caseSettingsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseSettingsResourceService caseSettingsResourceService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseTagService caseTagService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseTagPointService caseTagPointService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseVideoFolderService caseVideoFolderService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICaseVideoService caseVideoService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ UploadToOssUtil uploadToOssUtil;
|
|
|
|
+ @Value("${upload.query-path}")
|
|
|
|
+ private String queryPath;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public void copyCase(Integer oldCaseId){
|
|
|
|
+ Integer newCaseId = this.cpCaseEntity(oldCaseId);
|
|
|
|
+ this.cpCaseExtractDetail(oldCaseId,newCaseId);
|
|
|
|
+ this.cpCaseFile(oldCaseId,newCaseId);
|
|
|
|
+ this.cpCaseFusion(oldCaseId,newCaseId);
|
|
|
|
+ this.cpCaseImg(oldCaseId,newCaseId);
|
|
|
|
+ this.cpCaseInquest(oldCaseId,newCaseId);
|
|
|
|
+ this.cpCaseNum(oldCaseId,newCaseId);
|
|
|
|
+ this.cpCaseSettings(oldCaseId,newCaseId);
|
|
|
|
+ this.cpCaseSettingsResource(oldCaseId,newCaseId);
|
|
|
|
+ this.cpCaseTag(oldCaseId,newCaseId);
|
|
|
|
+ this.cpCaseVideo(oldCaseId,newCaseId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 复制案件信息
|
|
|
|
+ */
|
|
|
|
+ private Integer cpCaseEntity(Integer caseId) {
|
|
|
|
+ CaseEntity caseEntity = caseService.getById(caseId);
|
|
|
|
+ if(caseEntity == null){
|
|
|
|
+ throw new BusinessException(ResultCode.CASE_NOT_EXIST);
|
|
|
|
+ }
|
|
|
|
+ caseEntity.setCaseId(null);
|
|
|
|
+ caseEntity.setCaseTitle(caseEntity.getCaseTitle()+"(copy)");
|
|
|
|
+ caseService.save(caseEntity);
|
|
|
|
+ return caseEntity.getCaseId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 复制案件提取清单
|
|
|
|
+ */
|
|
|
|
+ private void cpCaseExtractDetail(Integer oldCaseId,Integer newCaseId){
|
|
|
|
+ CaseExtractDetail caseExtractDetail = caseExtractDetailService.getByCaseId(oldCaseId);
|
|
|
|
+ if(caseExtractDetail== null){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ caseExtractDetail.setId(null);
|
|
|
|
+ caseExtractDetail.setCaseId(newCaseId);
|
|
|
|
+ caseExtractDetailService.save(caseExtractDetail);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 复制案件方位图等
|
|
|
|
+ */
|
|
|
|
+ private void cpCaseFile(Integer oldCaseId, Integer newCaseId) {
|
|
|
|
+ List<CaseFiles> listByCaseId = caseFilesService.getByCaseId(oldCaseId);
|
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (CaseFiles entity : listByCaseId) {
|
|
|
|
+ entity.setFilesId(null);
|
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
|
+ caseFilesService.save(entity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 复制案件编辑器关联关系
|
|
|
|
+ */
|
|
|
|
+ private void cpCaseFusion(Integer oldCaseId, Integer newCaseId) {
|
|
|
|
+ List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(oldCaseId);
|
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (CaseFusion entity : listByCaseId) {
|
|
|
|
+ entity.setFusionId(null);
|
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
|
+ caseFusionService.save(entity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 复制案件照片制卷
|
|
|
|
+ */
|
|
|
|
+ private void cpCaseImg(Integer oldCaseId, Integer newCaseId) {
|
|
|
|
+ List<CaseImg> listByCaseId = caseImgService.getByCaseId(oldCaseId);
|
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (CaseImg entity : listByCaseId) {
|
|
|
|
+ entity.setId(null);
|
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
|
+ caseImgService.save(entity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 复制案件勘验笔录
|
|
|
|
+ */
|
|
|
|
+ private void cpCaseInquest(Integer oldCaseId, Integer newCaseId) {
|
|
|
|
+ CaseInquest entity = caseInquestService.getByCaseId(oldCaseId);
|
|
|
|
+ if(entity == null ){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ entity.setId(null);
|
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
|
+ caseInquestService.save(entity);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 复制案件场景关系
|
|
|
|
+ */
|
|
|
|
+ private void cpCaseNum(Integer oldCaseId, Integer newCaseId) {
|
|
|
|
+ List<CaseNumEntity> listByCaseId = caseNumService.getByCaseId(oldCaseId);
|
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (CaseNumEntity entity : listByCaseId) {
|
|
|
|
+ entity.setId(null);
|
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
|
+ caseNumService.save(entity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 复制案件系统设置
|
|
|
|
+ */
|
|
|
|
+ private void cpCaseSettings(Integer oldCaseId, Integer newCaseId) {
|
|
|
|
+ List<CaseSettings> listByCaseId = caseSettingsService.getByCaseId(oldCaseId);
|
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (CaseSettings entity : listByCaseId) {
|
|
|
|
+ entity.setSettingsId(null);
|
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
|
+ caseSettingsService.save(entity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 复制案件系统设置资源
|
|
|
|
+ */
|
|
|
|
+ private void cpCaseSettingsResource(Integer oldCaseId, Integer newCaseId) {
|
|
|
|
+ List<CaseSettingsResource> listByCaseId = caseSettingsResourceService.getByCaseId(oldCaseId);
|
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (CaseSettingsResource entity : listByCaseId) {
|
|
|
|
+ entity.setId(null);
|
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
|
+ caseSettingsResourceService.save(entity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 复制案件标注
|
|
|
|
+ */
|
|
|
|
+ private void cpCaseTag(Integer oldCaseId, Integer newCaseId) {
|
|
|
|
+ List<CaseTag> listByCaseId = caseTagService.getListByCaseId(oldCaseId);
|
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (CaseTag entity : listByCaseId) {
|
|
|
|
+ Integer oldTagId =entity.getTagId();
|
|
|
|
+
|
|
|
|
+ entity.setTagId(null);
|
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
|
+ caseTagService.save(entity);
|
|
|
|
+
|
|
|
|
+ Integer newTagId = entity.getTagId();
|
|
|
|
+
|
|
|
|
+ List<CaseTagPoint> caseTagPointList = caseTagPointService.getByTagId(oldTagId);
|
|
|
|
+ if(caseTagPointList == null || caseTagPointList.isEmpty()){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ for (CaseTagPoint caseTagPoint : caseTagPointList) {
|
|
|
|
+ caseTagPoint.setTagPointId(null);
|
|
|
|
+ caseTagPoint.setTagId(newTagId);
|
|
|
|
+ caseTagPointService.save(caseTagPoint);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 复制案件录制视频
|
|
|
|
+ */
|
|
|
|
+ private void cpCaseVideo(Integer oldCaseId, Integer newCaseId) {
|
|
|
|
+ List<CaseVideoFolder> listByCaseId = caseVideoFolderService.getAllList(oldCaseId);
|
|
|
|
+ if(listByCaseId == null || listByCaseId.isEmpty()){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ for (CaseVideoFolder entity : listByCaseId) {
|
|
|
|
+ Integer oldFolderId =entity.getVideoFolderId();
|
|
|
|
+
|
|
|
|
+ entity.setVideoFolderId(null);
|
|
|
|
+ entity.setCaseId(newCaseId);
|
|
|
|
+ caseVideoFolderService.save(entity);
|
|
|
|
+
|
|
|
|
+ Integer newFolderId = entity.getVideoFolderId();
|
|
|
|
+
|
|
|
|
+ String newVideoFolderCover= entity.getVideoFolderCover().replace(oldFolderId+"",newFolderId+"");
|
|
|
|
+ String newVideoMergeUrl = entity.getVideoMergeUrl().replace(oldFolderId+"",newFolderId+"");
|
|
|
|
+
|
|
|
|
+ String oldVideoFolderCoverOssPath = uploadToOssUtil.getOssPath(entity.getVideoFolderCover());
|
|
|
|
+ String newVideoFolderCoverOssPath = uploadToOssUtil.getOssPath(newVideoFolderCover);
|
|
|
|
+ uploadToOssUtil.copyFile(oldVideoFolderCoverOssPath,newVideoFolderCoverOssPath);
|
|
|
|
+ if(uploadToOssUtil.existKey(newVideoFolderCoverOssPath)){
|
|
|
|
+ entity.setVideoFolderCover(newVideoFolderCover);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String oldVideoMergeUrlOssPath = uploadToOssUtil.getOssPath(entity.getVideoMergeUrl());
|
|
|
|
+ String newVideoMergeUrlOssPath = uploadToOssUtil.getOssPath(newVideoMergeUrl);
|
|
|
|
+ uploadToOssUtil.copyFile(oldVideoMergeUrlOssPath,newVideoMergeUrlOssPath);
|
|
|
|
+ if(uploadToOssUtil.existKey(newVideoMergeUrlOssPath)){
|
|
|
|
+ entity.setVideoMergeUrl(newVideoMergeUrl);
|
|
|
|
+ }
|
|
|
|
+ caseVideoFolderService.updateById(entity);
|
|
|
|
+
|
|
|
|
+ List<CaseVideo> caseVideos = caseVideoService.getAllList(oldFolderId);
|
|
|
|
+ if(caseVideos == null || caseVideos.isEmpty()){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ for (CaseVideo caseVideo : caseVideos) {
|
|
|
|
+ caseVideo.setVideoId(null);
|
|
|
|
+ caseVideo.setFolderId(newFolderId);
|
|
|
|
+ caseVideo.setVideoPath(caseVideo.getVideoPath().replace(oldFolderId+"",newFolderId+""));
|
|
|
|
+ caseVideoService.save(caseVideo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|