Ver código fonte

场景计算结果文件上传,上传全景图\球幕视频到缓存目录前,先清除旧的文件

dengsixing 3 anos atrás
pai
commit
3a2cf7fcff

+ 26 - 6
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/BuildScenePostServiceImpl.java

@@ -234,9 +234,6 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
             //拷贝部分文件到编辑目录,用于用户编辑
             this.copyToEditDir(sceneCode);
 
-            //计算成功,发短信
-            this.sendSms(pushChannel,pushToken, cameraType, scenePro.getSceneName(), scenePro.getWebSite());
-
 //            //上传日志文件
 //            buildScenePreService.uploadLogFile(sceneCode, sceneProExt.getDataSource());
 
@@ -244,6 +241,9 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
             this.writeSceneJson(sceneCode, videosJson,
                 sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus, scenePlusExt, arrearCap);
 
+            //计算成功,发短信
+            this.sendSms(pushChannel,pushToken, cameraType, scenePro.getSceneName(), scenePro.getWebSite());
+
             log.info("场景计算结果处理结束,场景码:{}", message.getSceneCode());
 
         }catch (Exception e){
@@ -367,23 +367,43 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
 
     private void uploadCaches(String num, Map<String,String> map, String path){
 
-        String sceneNumPAth = String.format("scene/%s", num);
+        String sceneNumPath = String.format("scene/%s", num);
 
+        List<String> ossImagesList = uploadToOssUtil.listKeys(String.format(UploadFilePath.IMG_CACHES_PATH, num));
+        if(CollUtil.isNotEmpty(ossImagesList)){
+            ossImagesList.parallelStream().forEach(key->{
+                try {
+                    uploadToOssUtil.delete(key);
+                } catch (IOException e) {
+                    log.error("删除全景图缓存失败,num:{},key:{}", num, key);
+                }
+            });
+        }
         List<String> imagesList = FileUtil.getFileList(path + "/caches/images");
         log.info("caches/images_path:{}", path + "/caches/images");
         if(CollUtil.isNotEmpty(imagesList)){
             log.info("上传的caches/images文件列表:{}", imagesList.toString());
             imagesList.stream().forEach(str -> {
                 if(str.endsWith(".jpg")){
-                    map.put(str, str.replace(path, sceneNumPAth));
+                    map.put(str, str.replace(path, sceneNumPath));
                 }
             });
         }
 
+        List<String> ossVideosList = uploadToOssUtil.listKeys(String.format(UploadFilePath.VIDEOS_CACHES_PATH, num));
+        if(CollUtil.isNotEmpty(ossVideosList)){
+            ossVideosList.parallelStream().forEach(key->{
+                try {
+                    uploadToOssUtil.delete(key);
+                } catch (IOException e) {
+                    log.error("删除球幕视频缓存失败,num:{},key:{}", num, key);
+                }
+            });
+        }
         List<String> videosList = FileUtil.getFileList(path + "/caches/videos");
         if(CollUtil.isNotEmpty(videosList)){
             log.info("上传的caches/videos文件列表:{}", videosList.toString());
-            videosList.stream().forEach(str -> map.put(str, str.replace(path, sceneNumPAth)));
+            videosList.stream().forEach(str -> map.put(str, str.replace(path, sceneNumPath)));
         }
     }