瀏覽代碼

Merge branch 'feature-slimming-nas-20220130-dsx' into test

# Conflicts:
#	src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java
dsx 2 年之前
父節點
當前提交
ba5c8301fa

+ 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);
+}

+ 27 - 19
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -20,6 +20,7 @@ import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.contro.bean.SceneJsonBean;
 import com.fdkankan.contro.bean.SceneJsonBean;
 import com.fdkankan.contro.entity.*;
 import com.fdkankan.contro.entity.*;
 import com.fdkankan.contro.mq.service.IBuildSceneService;
 import com.fdkankan.contro.mq.service.IBuildSceneService;
+import com.fdkankan.contro.mq.service.ICommonService;
 import com.fdkankan.contro.service.*;
 import com.fdkankan.contro.service.*;
 import com.fdkankan.contro.vo.SceneEditControlsVO;
 import com.fdkankan.contro.vo.SceneEditControlsVO;
 import com.fdkankan.fyun.config.FYunFileConfig;
 import com.fdkankan.fyun.config.FYunFileConfig;
@@ -123,6 +124,8 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     private ICompanyService companyService;
     private ICompanyService companyService;
     @Autowired
     @Autowired
     private ISceneAsynOperLogService sceneAsynOperLogService;
     private ISceneAsynOperLogService sceneAsynOperLogService;
+    @Autowired
+    private ICommonService commonService;
 
 
     @Override
     @Override
     public void buildScenePre(BuildSceneCallMessage message) throws Exception{
     public void buildScenePre(BuildSceneCallMessage message) throws Exception{
@@ -289,7 +292,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             this.copyToEditDir(sceneCode);
             this.copyToEditDir(sceneCode);
 
 
             //计算完毕后,同步全景图到缓存目录
             //计算完毕后,同步全景图到缓存目录
-            this.cachePanorama(path, sceneCode);
+//            this.cachePanorama(path, sceneCode);
 
 
             //生成houseTypejson并上传
             //生成houseTypejson并上传
             boolean existHouseType = this.uploadHouseTypeJson(sceneCode, scenePlusExt.getDataSource());
             boolean existHouseType = this.uploadHouseTypeJson(sceneCode, scenePlusExt.getDataSource());
@@ -312,6 +315,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
                 fdkkLaserService.cloudPointBuild(sceneCode,path);
                 fdkkLaserService.cloudPointBuild(sceneCode,path);
             }
             }
 
 
+
             //写scene.json
             //写scene.json
             this.writeSceneJson(sceneCode, videosJson,sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus,scenePlusExt,company);
             this.writeSceneJson(sceneCode, videosJson,sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus,scenePlusExt,company);
 
 
@@ -329,7 +333,11 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             //更新场景主表
             //更新场景主表
             scenePlusService.updateById(scenePlus);
             scenePlusService.updateById(scenePlus);
 
 
-            CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
+            //上传计算结果文件
+            commonService.uploadBuildResultData(sceneCode, path, SceneVersionType.V4.code());
+
+            //删除计算目录
+            CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/"));
 
 
             log.info("场景计算结果处理结束,场景码:{}", sceneCode);
             log.info("场景计算结果处理结束,场景码:{}", sceneCode);
 
 
@@ -360,23 +368,23 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         });
         });
     }
     }
 
 
-    private void cachePanorama(String dataSource, String num){
-        String cachedImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
-        //将全景图缓存到缓存目录
-        List<String> imagesList = FileUtil.listFileNames(dataSource + "/caches/images");
-        //先清除旧的全景图
-        cn.hutool.core.io.FileUtil.del(cachedImagesPath);
-        String visionPath = dataSource + "/results/vision.txt";
-        List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
-        imagesList.stream().forEach(fileName -> {
-            if (panoramaImageList.contains(fileName)) {
-                String srcPath = dataSource + "/caches/images/" + fileName;
-                String targetPath = cachedImagesPath + fileName;
-                log.info("源文件:{}, 目标文件:{}", srcPath, targetPath);
-                cn.hutool.core.io.FileUtil.copy(srcPath, targetPath, true);
-            }
-        });
-    }
+//    private void cachePanorama(String dataSource, String num){
+//        String cachedImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
+//        //将全景图缓存到缓存目录
+//        List<String> imagesList = FileUtil.listFileNames(dataSource + "/caches/images");
+//        //先清除旧的全景图
+//        cn.hutool.core.io.FileUtil.del(cachedImagesPath);
+//        String visionPath = dataSource + "/results/vision.txt";
+//        List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
+//        imagesList.stream().forEach(fileName -> {
+//            if (panoramaImageList.contains(fileName)) {
+//                String srcPath = dataSource + "/caches/images/" + fileName;
+//                String targetPath = cachedImagesPath + fileName;
+//                log.info("源文件:{}, 目标文件:{}", srcPath, targetPath);
+//                cn.hutool.core.io.FileUtil.copy(srcPath, targetPath, true);
+//            }
+//        });
+//    }
 
 
     private Map<String, String> getUploadFiles(ScenePlus scenePlus,String path,Integer cameraType,JSONObject fdageData) throws Exception {
     private Map<String, String> getUploadFiles(ScenePlus scenePlus,String path,Integer cameraType,JSONObject fdageData) throws Exception {
         if (ObjectUtils.isEmpty(scenePlus)) {
         if (ObjectUtils.isEmpty(scenePlus)) {

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

@@ -0,0 +1,73 @@
+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 ossVisionPath = String.format(UploadFilePath.IMG_VIEW_PATH, num) + "vision.txt";
+                String visionPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "vision.txt";
+                fYunFileServiceInterface.downloadFile(ossVisionPath, visionPath);
+                List<String> panoramaImageList = SceneUtil.getPanoramaImageList(FileUtil.readUtf8String(visionPath));
+                imagesList.stream().forEach(fileName -> {
+                    if (panoramaImageList.contains(fileName)) {
+                        String srcPath = localCachesImagePath + fileName;
+                        String ossPath = ossCachesImagePath + fileName;
+                        uploadMap.put(srcPath, ossPath);
+                    }
+                });
+            }
+        }
+
+        //上传project.json
+        String localProjectJsonPath = dataSource + "/project.json";
+        String ossProjectJsonPath = ossResultPath + "project.json";
+        if(FileUtil.exist(localProjectJsonPath)){
+            uploadMap.put(localProjectJsonPath, ossProjectJsonPath);
+        }
+
+        //上传data.json
+        String localDataJsonPath = dataSource + "/data.json";
+        String ossDataJsonPath = ossResultPath + "data.json";
+        if(FileUtil.exist(localDataJsonPath)){
+            uploadMap.put(localDataJsonPath, ossDataJsonPath);
+        }
+
+        //开始上传
+        fYunFileServiceInterface.uploadMulFiles(uploadMap);
+    }
+}