浏览代码

v4.10.0 场景容量统计加上caches内容

dsx 2 年之前
父节点
当前提交
073f17b075

+ 18 - 30
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -207,7 +207,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
     }
 
-
     @Override
     public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
         String sceneCode = message.getBuildContext().get("sceneNum").toString();
@@ -237,12 +236,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             Integer cameraType = Integer.parseInt(message.getBuildContext().get("cameraType").toString());
             Map<String, String> uploadFiles = getUploadFiles(scenePlus,path,cameraType,fdageData);
 
-            //计算场景消耗磁盘空间
-            long space = this.calUseSpace(uploadFiles);
-
-
             scenePlus.setPayStatus(PayStatus.PAY.code());
-
             scenePlus.setUpdateTime(new Date());
             scenePlus.setSceneStatus(SceneStatus.NO_DISPLAY.code());
 
@@ -252,8 +246,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
             ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
             boolean isObj = fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1;
-            //写入数据库
-            this.updateDbPlus(scenePlus.getSceneSource(), space, videosJson.toJSONString(), message.getComputeTime(),isObj,scenePlusExt);
 
             //上传全景图俯视图
             this.uploadFloorCad(path, sceneCode, uploadFiles);
@@ -264,21 +256,11 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             //上传文件
             fYunFileService.uploadMulFiles(uploadFiles);
 
+            //修改oss上dam的内容编码
             Map<String,String> damFileHeaders = new HashMap<>();
             damFileHeaders.put("Content-Encoding","gzip");
-            // dam 文件设置请求头
-            uploadFiles.entrySet().stream().filter(entry -> FileNameUtil.extName(entry.getKey()).equals("dam"))
-                .forEach(entry -> {
-                    if (!new File(entry.getKey()).exists()) {
-                        log.error("文件不存在,不予gzip压缩,文件路径:{}", entry.getKey());
-                        return;
-                    }
-                    // gzip压缩
-                    FileUtil.writeBytes(ZipUtil.gzip(new File(entry.getKey())), entry.getKey() + ".gzip");
-                    // 重命名
-                    FileUtil.rename(new File(entry.getKey() + ".gzip"), entry.getKey(), true);
-                    fYunFileService.uploadFile(entry.getKey(), entry.getValue(), damFileHeaders);
-                });
+            String damPath = path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam";
+            fYunFileService.uploadFile(damPath,  String.format(UploadFilePath.IMG_VIEW_PATH, sceneCode) + ConstantFileName.modelUUID + "_50k.dam", damFileHeaders);
 
             //拷贝部分文件到编辑目录,用于用户编辑
             this.copyToEditDir(sceneCode);
@@ -287,11 +269,11 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 //            this.cachePanorama(path, sceneCode);
 
             //生成houseTypejson并上传
-            boolean existHouseType = this.uploadHouseTypeJson(sceneCode, scenePlusExt.getDataSource());
+            boolean existHouseType = this.uploadHouseTypeJson(sceneCode, path);
             scenePlus.setHouseType(existHouseType ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code().intValue());
 
             //生成floorpan.json
-            commonService.uploadFloorplanJson(sceneCode, scenePlusExt.getDataSource());
+            commonService.uploadFloorplanJson(sceneCode, path);
 
             //重置异步操作记录
             this.removeSceneAsynOperLog(sceneCode);
@@ -302,8 +284,15 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             bizs.add(UserEditDataType.FLOORPLAN.message());
             commonService.initUserEditData(sceneCode, bizs, null);
 
+            //计算场景消耗磁盘空间
+            long space = this.calUseSpace(uploadFiles);
+
             //上传计算结果文件
-            commonService.uploadBuildResultData(sceneCode, path, SceneVersionType.V4.code());
+            Long cacheSize = commonService.uploadBuildResultData(sceneCode, path, SceneVersionType.V4.code());
+            space += cacheSize;
+
+            //写入数据库
+            this.updateDbPlus(scenePlus.getSceneSource(), space, videosJson.toJSONString(), message.getComputeTime(),isObj,scenePlusExt);
 
             Object[] editInfoArr = this.updateEditInfo(scenePlus);
             SceneEditInfo sceneEditInfo = (SceneEditInfo)editInfoArr[0];
@@ -312,7 +301,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
             if (cameraType == 14) {
                 //计算成功  激光转台相机 同步 请求
-                fdkkLaserService.syncBuildResult(scenePlus.getNum(), scenePlusExt.getDataSource(),scenePlus.getCreateTime(), Calendar.getInstance().getTime());
+                fdkkLaserService.syncBuildResult(scenePlus.getNum(), path, scenePlus.getCreateTime(), Calendar.getInstance().getTime());
                 sceneEditControlsService.update(new LambdaUpdateWrapper<SceneEditControls>().set(SceneEditControls::getShowMap,0)
                         .eq(SceneEditControls::getEditInfoId,sceneEditInfo.getId()));
                 sceneEditControls.setShowMap(0);
@@ -488,11 +477,10 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
         if(genModel){
             if (!gen3dTiles) {
-                CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
-                CreateObjUtil.convertDamToLzma(path + File.separator + "results/");
-                CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
-                map.put(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", imagesPath + ConstantFileName.modelUUID + "_50k.dam.lzma");
-                map.put(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", imagesPath + ConstantFileName.modelUUID + "_50k.dam");
+                String damPath = path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam";
+                CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", damPath);
+                FileUtil.writeBytes(ZipUtil.gzip(new File(damPath)), damPath);
+                map.put(damPath, imagesPath + ConstantFileName.modelUUID + "_50k.dam");
             }else{
                 List<String> list = FileUtils.list(new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
                 if(CollUtil.isEmpty(list)){

+ 1 - 1
src/main/java/com/fdkankan/contro/service/ICommonService.java

@@ -14,7 +14,7 @@ public interface ICommonService {
      * @param dataSource
      * @param version
      */
-    public void uploadBuildResultData(String num, String dataSource, String version);
+    public Long uploadBuildResultData(String num, String dataSource, String version);
 
     /**
      * 删除用户编辑数据业务方法

+ 13 - 2
src/main/java/com/fdkankan/contro/service/impl/CommonServiceImpl.java

@@ -69,9 +69,10 @@ public class CommonServiceImpl implements ICommonService {
     @Autowired
     private ICameraService cameraService;
 
-
     @Override
-    public void uploadBuildResultData(String num, String dataSource, String version) {
+    public Long uploadBuildResultData(String num, String dataSource, String version) {
+
+        Long cacheSize = 0L;
 
         Map<String, String> uploadMap = new HashMap<>();
 
@@ -85,6 +86,7 @@ public class CommonServiceImpl implements ICommonService {
         String ossCachesImagePath = ossResultPath + "caches/images/";
         //先清除旧的全景图
         if(FileUtil.exist(localCachesImagePath)){
+            cacheSize += FileUtil.size(new File(localCachesImagePath));
             fYunFileServiceInterface.uploadFileByCommand(localCachesImagePath, ossCachesImagePath);
         }
 
@@ -123,21 +125,25 @@ public class CommonServiceImpl implements ICommonService {
         String localReconstruction = dataSource + "/caches/reconstruction/";
         String ossReconstruction = ossResultPath + "caches/reconstruction/";
         if(FileUtil.exist(localReconstruction)){
+            cacheSize += FileUtil.size(new File(localReconstruction));
             fYunFileServiceInterface.uploadFileByCommand(localReconstruction, ossReconstruction);
         }
         String localDepthmap = dataSource + "/caches/depthmap/";
         String ossDepthmap = ossResultPath + "caches/depthmap/";
         if(FileUtil.exist(localDepthmap)){
+            cacheSize += FileUtil.size(new File(localDepthmap));
             fYunFileServiceInterface.uploadFileByCommand(localDepthmap, ossDepthmap);
         }
         String localDepthmapAsc = dataSource + "/caches/depthmap_csc/";
         String ossDepthmapAsc = ossResultPath + "caches/depthmap_csc/";
         if(FileUtil.exist(localDepthmapAsc)){
+            cacheSize += FileUtil.size(new File(localDepthmapAsc));
             fYunFileServiceInterface.uploadFileByCommand(localDepthmapAsc, ossDepthmapAsc);
         }
         String localPanoramaJson =  dataSource + "/caches/panorama.json";
         String ossPanoramaJson =  ossResultPath + "caches/panorama.json";
         if(FileUtil.exist(localPanoramaJson)){
+            cacheSize += FileUtil.size(new File(localPanoramaJson));
             fYunFileServiceInterface.uploadFile(localPanoramaJson, ossPanoramaJson);
         }
 //        String localLaserPly = dataSource + "/results/laserData/laser.ply";
@@ -148,23 +154,28 @@ public class CommonServiceImpl implements ICommonService {
         String localFloorGroupFixJson = dataSource + "/caches/floor_group_fix.json";
         String ossFloorGroupFixJson = ossResultPath + "caches/floor_group_fix.json";
         if(FileUtil.exist(localFloorGroupFixJson)){
+            cacheSize += FileUtil.size(new File(localFloorGroupFixJson));
             fYunFileServiceInterface.uploadFile(localFloorGroupFixJson, ossFloorGroupFixJson);
         }
 
         String localDepthmapVis = dataSource + "/caches/depthmap_vis";
         String ossDepthmapVis = ossResultPath + "caches/depthmap_vis";
         if(FileUtil.exist(localDepthmapVis)){
+            cacheSize += FileUtil.size(new File(localDepthmapVis));
             fYunFileServiceInterface.uploadFileByCommand(localDepthmapVis, ossDepthmapVis);
         }
 
         String localIntensity = dataSource + "/caches/intensity";
         String ossIntensity = ossResultPath + "caches/intensity";
         if(FileUtil.exist(localIntensity)){
+            cacheSize += FileUtil.size(new File(localIntensity));
             fYunFileServiceInterface.uploadFileByCommand(localIntensity, ossIntensity);
         }
 
         //开始上传
         fYunFileServiceInterface.uploadMulFiles(uploadMap);
+
+        return cacheSize;
     }
 
     @Override