Sfoglia il codice sorgente

场景计算完后 上传必要文件到oss并删除计算目录

dsx 2 anni fa
parent
commit
20721e054f

+ 12 - 0
src/main/java/com/fdkankan/contro/mq/service/ICommonService.java

@@ -0,0 +1,12 @@
+package com.fdkankan.contro.mq.service;
+
+public interface ICommonService {
+
+    /**
+     * 上传计算结果文件
+     * @param num
+     * @param dataSource
+     * @param version
+     */
+    public void uploadBuildResultData(String num, String dataSource, String version);
+}

+ 7 - 2
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -19,6 +19,7 @@ import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.contro.bean.SceneJsonBean;
 import com.fdkankan.contro.entity.*;
 import com.fdkankan.contro.mq.service.IBuildSceneService;
+import com.fdkankan.contro.mq.service.ICommonService;
 import com.fdkankan.contro.service.*;
 import com.fdkankan.contro.vo.SceneEditControlsVO;
 import com.fdkankan.fyun.config.FYunFileConfig;
@@ -118,6 +119,8 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     private ICompanyService companyService;
     @Autowired
     private ISceneAsynOperLogService sceneAsynOperLogService;
+    @Autowired
+    private ICommonService commonService;
 
     @Override
     public void buildScenePre(BuildSceneCallMessage message) {
@@ -322,9 +325,11 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             String pushToken = fdageData.getString("pushToken");
             this.pushMsgToApp(pushChannel,pushToken, cameraType, scenePlus.getTitle(), scenePlusExt.getWebSite());
 
+            //上传计算结果文件
+            commonService.uploadBuildResultData(sceneCode, path, SceneVersionType.V4.code());
 
-
-            CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
+            //删除计算目录
+            CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/"));
 
             log.info("场景计算结果处理结束,场景码:{}", sceneCode);
 

+ 64 - 0
src/main/java/com/fdkankan/contro/mq/service/impl/CommonServiceImpl.java

@@ -0,0 +1,64 @@
+package com.fdkankan.contro.mq.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.io.FileUtil;
+import com.fdkankan.common.util.FileUtils;
+import com.fdkankan.contro.mq.service.ICommonService;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.model.constants.ConstantFilePath;
+import com.fdkankan.model.constants.UploadFilePath;
+import com.fdkankan.model.utils.SceneUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class CommonServiceImpl implements ICommonService {
+
+    @Autowired
+    private FYunFileServiceInterface fYunFileServiceInterface;
+
+
+    @Override
+    public void uploadBuildResultData(String num, String dataSource, String version) {
+
+        Map<String, String> uploadMap = new HashMap<>();
+
+        String ossResultPath = String.format(UploadFilePath.scene_result_data_path, num);
+
+        //上传caches/images
+        String localCachesImagePath = dataSource + "/caches/images/";
+        String ossCachesImagePath = ossResultPath + "caches/images/";
+        //先清除旧的全景图
+        fYunFileServiceInterface.deleteFolder(ossCachesImagePath);
+        if(FileUtil.exist(localCachesImagePath)){
+            List<String> imagesList = FileUtil.listFileNames(localCachesImagePath);
+            if(CollUtil.isNotEmpty(imagesList)){
+                String visionPath = dataSource + "/results/vision.txt";
+                List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
+                imagesList.stream().forEach(fileName -> {
+                    if (panoramaImageList.contains(fileName)) {
+                        String srcPath = localCachesImagePath + fileName;
+                        String ossPath = ossCachesImagePath + fileName;
+                        uploadMap.put(localCachesImagePath, ossCachesImagePath);
+                    }
+                });
+            }
+        }
+
+        //上传project.json
+        String localProjectJsonPath = dataSource + "/project.json";
+        String ossProjectJsonPath = ossResultPath + "project.json";
+        if(FileUtil.exist(localProjectJsonPath)){
+            uploadMap.put(localProjectJsonPath, ossProjectJsonPath);
+        }
+
+        //开始上传
+        fYunFileServiceInterface.uploadMulFiles(uploadMap);
+    }
+}