lyhzzz 2 年之前
父节点
当前提交
9a7a384bb4

+ 3 - 4
src/main/java/com/fdkankan/ucenter/service/impl/ScenePlusServiceImpl.java

@@ -70,7 +70,7 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
     @Autowired
     private IScenePlusExtService scenePlusExtService;
     @Autowired
-    private SceneCommonService sceneCommonService;
+    public SceneCommonService sceneCommonService;
     @Autowired
     private ISceneEditInfoService sceneEditInfoService;
     @Autowired
@@ -252,7 +252,7 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
                 //copyDataSource
                 //cn.hutool.core.io.FileUtil.copyContent(new File(oldDataSource),new File(newDataSource),true);
 
-                this.copyOssAndNas(oldNum,newNum,sceneCommonService);
+                this.copyOssAndNas(oldNum,newNum);
 
                 //修改 oss status.json ,nas scene.json
                 String targetData = String.format(SceneResourcePath.DATA_VIEW_PATH,newNum);
@@ -284,7 +284,7 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
         return scenePlus.getId();
     }
 
-    private  void copyOssAndNas(String oldNum,String newNum,SceneCommonService sceneCommonService){
+    private  void copyOssAndNas(String oldNum,String newNum){
         // 拷贝场景编辑资源
         String oldEditPath = String.format(SceneResourcePath.EDIT_PATH_v4, oldNum);
         String newEditPath = String.format(SceneResourcePath.EDIT_PATH_v4, newNum);
@@ -304,7 +304,6 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
         String oldPath = SceneResourcePath.nasBasePath + oldNum;
         String newPath = SceneResourcePath.nasBasePath + newNum;
         if(new File(oldPath).exists()){
-            sceneCommonService.delLink(oldPath);
             FileUtil.copyContent(new File(oldPath), new File(newPath),true);
         }
         String oldPath_v4 = SceneResourcePath.nasBasePath_v4 + oldNum;

+ 30 - 6
src/main/java/com/fdkankan/ucenter/service/impl/SceneProServiceImpl.java

@@ -762,6 +762,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         this.save(scenePro);
 
         ExecutorService executor = ThreadUtil.newSingleExecutor();
+        try {
+
 
         CompletableFuture.runAsync(() -> {
 
@@ -798,7 +800,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
 
                 String sourceData = String.format(SceneResourcePath.dataPath, oldNum);
                 String targetData = String.format(SceneResourcePath.dataPath, scenePro.getNum());
-                this.copyOssAndNas(oldNum,scenePro.getNum(),sourceData,targetData,sceneCommonService);
+                this.copyOssAndNas(oldNum,scenePro.getNum(),sourceData,targetData);
                 //修改 oss status.json ,nas scene.json
                 sceneCommonService.updateOssJson(targetData,oldNum,newNum,"status.json");
                 sceneCommonService.updateOssJson(targetData,oldNum,newNum,"hot.json");
@@ -807,15 +809,15 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
 
                 String sourceImages = String.format(SceneResourcePath.imagesPath, oldNum);
                 String targetImages = String.format(SceneResourcePath.imagesPath, scenePro.getNum());
-                this.copyOssAndNas(oldNum,scenePro.getNum(),sourceImages,targetImages,sceneCommonService);
+                this.copyOssAndNas(oldNum,scenePro.getNum(),sourceImages,targetImages);
 
                 String sourceVideo = String.format(SceneResourcePath.videoPath, oldNum);
                 String targetVideo = String.format(SceneResourcePath.videoPath, scenePro.getNum());
-                this.copyOssAndNas(oldNum,scenePro.getNum(),sourceVideo,targetVideo,sceneCommonService);
+                this.copyOssAndNas(oldNum,scenePro.getNum(),sourceVideo,targetVideo);
 
                 String sourceVoice = String.format(SceneResourcePath.voicePath, oldNum);
                 String targetVoice = String.format(SceneResourcePath.voicePath, scenePro.getNum());
-                this.copyOssAndNas(oldNum,scenePro.getNum(),sourceVoice,targetVoice,sceneCommonService);
+                this.copyOssAndNas(oldNum,scenePro.getNum(),sourceVoice,targetVoice);
 
                 if(scenePro.getSceneSource() == 4){  //深时复制
                     String laserPath = laserService.copyDataSource(oldDataSource,scenePro.getDataSource());
@@ -837,15 +839,37 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         }, executor).whenComplete((reslut, e) -> {
             log.info("copy-success-");
         });
+        }catch ( Exception e){
+           log.error("copyError",e);
+        }
         return scenePro.getId();
     }
-    private void copyOssAndNas(String oldNum ,String newNum ,String sourcePath,String targetPath,SceneCommonService sceneCommonService){
+    private void copyOssAndNas(String oldNum ,String newNum ,String sourcePath,String targetPath){
         log.info("sceneCopy-ossSource-oldNum:{},newNum:{},sourcePath:{},targetPath:{}",oldNum,newNum,sourcePath,targetPath);
         fYunFileServiceInterface.copyFileInBucket(sourcePath,targetPath);
         File fileData = new File(SceneResourcePath.nasBasePath + sourcePath);
         if(fileData.exists()){
             if(targetPath.contains("images")){
-                sceneCommonService.delLink(SceneResourcePath.nasBasePath + sourcePath);
+                log.info("------------------------------------delLink");
+                String panPath = fileData.getPath() +"/panorama";
+                File file = new File(panPath);
+                log.info("delLink--filePath:{}",fileData.getPath());
+                log.info("delLink--filePath:{}",file.exists());
+                if(file.exists()){
+                    File[] files = file.listFiles();
+                    log.info("delLink--filePath:{}",files);
+                    log.info("delLink--filePath:{}",files.length);
+                    if(files == null || files.length == 0){
+                        return;
+                    }
+                    for (File file1 : files) {
+                        log.info("delLink--filePath:{}",file1.getPath());
+                        String linkPath =file1.getPath() + "/capture";
+                        if(new File(linkPath).exists()){
+                            FileUtil.del(file1);
+                        }
+                    }
+                }
             }
             cn.hutool.core.io.FileUtil.copyContent(fileData,new File(SceneResourcePath.nasBasePath + targetPath),true);
         }