Kaynağa Gözat

obj计算,下载capture

dsx 2 yıl önce
ebeveyn
işleme
3b3ec07e09

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

@@ -26,4 +26,6 @@ public interface ICommonService {
     public void uploadFloorplanJson(String num, String dataSource) throws Exception;
 
     public void sendEmail(String num);
+
+    String getOssOrignPath(String path);
 }

+ 19 - 37
src/main/java/com/fdkankan/contro/mq/service/impl/BuildObjServiceImpl.java

@@ -1,7 +1,7 @@
 package com.fdkankan.contro.mq.service.impl;
 
-import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -19,7 +19,6 @@ import com.fdkankan.contro.service.impl.FdkkV4Service;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.model.constants.ConstantFileName;
 import com.fdkankan.model.constants.ConstantFilePath;
-import com.fdkankan.model.constants.SceneBuildProcessType;
 import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.model.utils.CreateObjUtil;
 import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
@@ -34,6 +33,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
 import java.io.File;
+import java.util.Calendar;
 import java.util.List;
 import java.util.Objects;
 
@@ -106,9 +106,9 @@ public class BuildObjServiceImpl implements IBuildSceneService {
     public void buildScenePre(BuildSceneCallMessage message) throws Exception{
         boolean success = false;
         String num = message.getSceneNum();
+        String path = message.getPath();
+        String laserObjFilePath = path + "_laser_obj";
         try {
-            String path = message.getPath();
-            String laserObjFilePath = path + "_laser_obj";
             //根据相机类型,组装资源路径
             log.info("开始准备生成OBJ场景资源,路径:{}", laserObjFilePath);
 
@@ -122,9 +122,13 @@ public class BuildObjServiceImpl implements IBuildSceneService {
                 log.error("data.fdage文件不存在");
                 return ;
             }
+            //下载资源到本地
+            this.downLoadSource(message, laserObjFilePath);
+
             if (!jsonObject.containsKey("exportMeshObj") || jsonObject.getIntValue("exportMeshObj") != 1) {
                 // 写入data.fdage 防止重算
                 jsonObject.put("exportMeshObj", 1);
+                FileUtil.writeUtf8String(jsonObject.toJSONString(), laserObjFilePath + File.separator + "capture" + File.separator + "data.fdage");
                 fYunFileService.uploadFile(laserObjFilePath + File.separator + "capture" + File.separator + "data.fdage",
                         ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "") + "/data.fdage");
             }
@@ -138,9 +142,6 @@ public class BuildObjServiceImpl implements IBuildSceneService {
             message.setPath(laserObjFilePath);
             message.setResultReceiverMqName(queueObjModelingPost);
 
-            //下载资源到本地
-            this.downLoadSource(message, laserObjFilePath);
-
             //发送mq,就进行计算
             mqProducer.sendByWorkQueue(queueModelingCall, message);
 
@@ -152,41 +153,21 @@ public class BuildObjServiceImpl implements IBuildSceneService {
             log.error("生成OBJ场景资源准备异常,num=" + num, e);
             buildSceneDTService.handBaseFail("生成OBJ场景资源准备异常", message.getPath(), message.getSceneNum(), "计算控制服务器");
             throw e;
+        }finally {
+            fdkkLaserService.pushBuildStatusToLaserSystem(num, laserObjFilePath + "/laserData/mesh", success ? CommonOperStatus.SUCCESS.code() : CommonOperStatus.FAILD.code());
         }
     }
 
     @Override
     public void downLoadSource(BuildSceneCallMessage message,String path) throws Exception{
 
-        ScenePro scenePro = sceneProService.getByNum(message.getSceneNum());
-        String version = "V4";
-        if(Objects.nonNull(scenePro) && scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue()){
-            version = "V3";
-        }
+        //下载原始资源文件
+        String ossPath = commonService.getOssOrignPath(message.getPath());
+        fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
 
-        if(SceneVersionType.V4.code().equals(version)){
-            String ossResultPath = String.format(UploadFilePath.scene_result_data_path, message.getSceneNum());
-            fYunFileService.downloadFile(ossResultPath + "caches/reconstruction/final.bin", path + "/caches/reconstruction/final.bin");
-            fYunFileService.downloadFile(ossResultPath + "caches/reconstruction/chunk.json", path + "/caches/reconstruction/chunk.json");
-            fYunFileService.downloadFile(ossResultPath + "caches/floor_group_fix.json", path + "/caches/floor_group_fix.json");
-            fYunFileService.downloadFileByCommand(path + "/caches/images/", ossResultPath + "caches/images/");
-            fYunFileService.downloadFileByCommand( path + "/caches/depthmap_csc/" , ossResultPath + "caches/depthmap_csc/");
-            fYunFileService.downloadFileByCommand( path + "/caches/depthmap_vis/", ossResultPath + "caches/depthmap_vis/");
-            fYunFileService.downloadFileByCommand( path + "/caches/depthmap/", ossResultPath + "caches/depthmap/");
-            fYunFileService.downloadFile(ossResultPath + "caches/panorama.json", path + "/caches/panorama.json");
-            fYunFileService.downloadFile(ossResultPath + "results/laserData/laser.ply", path + "/results/laserData/laser.ply");
-        }else{
-            String prevoisPath = message.getBuildContext().get("previousPath").toString();
-            FileUtils.copyFile(prevoisPath + "/caches/reconstruction/final.bin", path + "/caches/reconstruction/final.bin", true);
-            FileUtils.copyFile(prevoisPath + "/caches/reconstruction/chunk.json", path + "/caches/reconstruction/chunk.json", true);
-            FileUtils.copyFile(prevoisPath + "/caches/floor_group_fix.json", path + "/caches/floor_group_fix.json", true);
-            FileUtils.copyDirectiory(prevoisPath + "/caches/images", path + "/caches/images");
-            FileUtils.copyDirectiory(prevoisPath + "/caches/depthmap_csc", path + "/caches/depthmap_csc");
-            FileUtils.copyDirectiory(prevoisPath + "/caches/depthmap_vis", path + "/caches/depthmap_vis");
-            FileUtils.copyDirectiory(prevoisPath + "/caches/depthmap", path + "/caches/depthmap");
-            FileUtils.copyFile(prevoisPath + "/caches/panorama.json", path + "/caches/panorama.json", true);
-            FileUtils.copyFile(prevoisPath + "/results/laserData/laser.ply", path + "/results/laserData/laser.ply", true);
-        }
+        //下载caches/image,算法会执行快一些
+        String ossResultPath = String.format(UploadFilePath.scene_result_data_path, message.getSceneNum());
+        fYunFileService.downloadFileByCommand(path + "/caches/images/", ossResultPath + "caches/images/");
     }
 
     @Override
@@ -275,15 +256,16 @@ public class BuildObjServiceImpl implements IBuildSceneService {
             }
 
             ScenePlus scenePlus = scenePlusService.getScenePlusByNum(projectNum);
-            if(!ObjectUtils.isEmpty(scenePlus)){
+            if(Objects.nonNull(scenePlus)){
                 LambdaUpdateWrapper<ScenePlus> plusUpdateWrapper = new LambdaUpdateWrapper<ScenePlus>()
                         .set(ScenePlus::getSceneStatus, -2).eq(ScenePlus::getNum, projectNum);
                 scenePlusService.update(plusUpdateWrapper);
+                ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
+                scenePlusExt.setAlgorithmTime(Calendar.getInstance().getTime());
 
                 if(this.modelKind.equals(ModelKind.THREE_D_TILE.code())
                         && CollUtil.isNotEmpty(sdTilesSceneSourceList)
                         && sdTilesSceneSourceList.contains(SceneSource.JG.code())){
-                    ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
                     scenePlusExt.setModelKind(ModelKind.THREE_D_TILE.code());
                     scenePlusExtService.updateById(scenePlusExt);
 

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

@@ -12,6 +12,7 @@ import com.fdkankan.contro.factory.UserEditData.UserEditDataHandlerFactory;
 import com.fdkankan.contro.mq.service.ICommonService;
 import com.fdkankan.contro.service.*;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.model.constants.ConstantFilePath;
 import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.model.utils.FloorPlanUserUtil;
 import com.fdkankan.sms.SendMailAcceUtils;
@@ -225,4 +226,14 @@ public class CommonServiceImpl implements ICommonService {
             log.error("发送邮件失败,num:" + num, e);
         }
     }
+
+    public String getOssOrignPath(String path) {
+        String ossPath = ConstantFilePath.OSS_PREFIX
+                + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
+                .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
+        if (!ossPath.endsWith("/")) {
+            ossPath = ossPath.concat("/");
+        }
+        return ossPath;
+    }
 }