瀏覽代碼

添加激光场景处理逻辑

tianboguang 2 年之前
父節點
當前提交
377b076661

+ 27 - 4
src/main/java/com/fdkankan/contro/listener/RabbitMqListener.java

@@ -1,10 +1,9 @@
-package com.fdkankan.contro.listener;
+package com.fdkankan.contro.mq.listener;
 
 import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.contro.constant.DingTalkConst;
 import com.fdkankan.contro.service.IBuildSceneDTService;
-import com.fdkankan.contro.service.IBuildScenePostService;
-import com.fdkankan.contro.service.IBuildScenePreService;
+import com.fdkankan.contro.mq.service.IBuildScenePostService;
+import com.fdkankan.contro.mq.service.IBuildScenePreService;
 import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
 import com.fdkankan.rabbitmq.bean.BuildSceneFailDTMqMessage;
 import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
@@ -34,6 +33,8 @@ public class RabbitMqListener {
     private String queueModelingPre;
     @Value("${queue.modeling.modeling-post}")
     private String queueModelingPost;
+    @Value("${queue.modeling.obj.modeling-post}")
+    private String queueObjModelingPost;
     @Value("${queue.modeling.modeling-dt}")
     private String queueModelingDt;
 
@@ -88,6 +89,28 @@ public class RabbitMqListener {
     }
 
     /**
+     * 场景计算后置结果处理
+     * @param channel
+     * @param message
+     * @throws Exception
+     */
+    @RabbitListener(
+            queuesToDeclare = @Queue("${queue.modeling.obj.modeling-post}"),
+            concurrency = "${maxThread.modeling.modeling-post}"
+    )
+    public void buildObjScenePostHandler(Channel channel, Message message) throws Exception {
+        Object correlation = message.getMessageProperties().getHeader("spring_returned_message_correlation");
+        String correlationId = (String) correlation;
+        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
+        log.info("场景计算结果处理开始,队列名:{},id:{},消息体:{}", queueObjModelingPost, correlationId, msg);
+        BuildSceneResultMqMessage resultMessage = JSONObject.parseObject(msg, BuildSceneResultMqMessage.class);
+        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+        Thread.sleep(2000L);
+        buildScenePostService.buildScenePost(resultMessage);
+
+    }
+
+    /**
      * 场景计算发送钉钉消息
      * @param channel
      * @param message

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

@@ -1,4 +1,4 @@
-package com.fdkankan.contro.service;
+package com.fdkankan.contro.mq.service;
 
 import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
 

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

@@ -1,4 +1,4 @@
-package com.fdkankan.contro.service;
+package com.fdkankan.contro.mq.service;
 
 import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
 

+ 91 - 0
src/main/java/com/fdkankan/contro/mq/service/impl/BuildObjScenePostServiceImpl.java

@@ -0,0 +1,91 @@
+package com.fdkankan.contro.mq.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.fdkankan.common.util.FileUtils;
+import com.fdkankan.contro.entity.*;
+import com.fdkankan.contro.mq.service.IBuildScenePostService;
+import com.fdkankan.contro.service.*;
+import com.fdkankan.fyun.config.FYunFileConfig;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.model.constants.ConstantFilePath;
+import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
+import com.fdkankan.redis.util.RedisUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/4/20
+ **/
+@Slf4j
+@Service
+public class BuildObjScenePostServiceImpl implements IBuildScenePostService {
+
+    @Value("${main.url}")
+    private String mainUrl;
+    @Value("${scene.pro.new.url}")
+    private String sceneProNewUrl;
+
+    @Value("${4dkk.laserService.host}")
+    private String laserHost;
+
+    @Autowired
+    private ISceneFileBuildService sceneFileBuildService;
+    @Autowired
+    private ICameraDetailService cameraDetailService;
+    @Autowired
+    private ISceneEditInfoService sceneEditInfoService;
+    @Autowired
+    private ISceneEditControlsService sceneEditControlsService;
+    @Autowired
+    private FYunFileServiceInterface fYunFileService;
+    @Autowired
+    private FYunFileConfig fYunFileConfig;
+
+    @Autowired
+    private RedisUtil redisUtil;
+    @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private IScenePlusExtService scenePlusExtService;
+    @Autowired
+    private ISceneEditInfoExtService sceneEditInfoExtService;
+
+    @Autowired
+    private IUserIncrementService userIncrementService;
+
+    @Autowired
+    private IFdkkLaserService fdkkLaserService;
+
+    @Override
+    public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
+        // 去除 OnlyExportMeshObj
+        String path = message.getPath();
+        String dataFdagePath = path + File.separator + "capture" + File.separator + "data.fdage";
+        log.info("dataFdagePath 文件路径 :{}", dataFdagePath);
+        String data = FileUtils.readFile(dataFdagePath);
+        //获取data.fdage的内容
+        JSONObject dataJson = new JSONObject();
+        if (data != null) {
+            dataJson = JSONObject.parseObject(data);
+        }
+        dataJson.remove("OnlyExportMeshObj");
+        FileUtils.writeFile(path + File.separator + "capture" + File.separator + "data.fdage", dataJson.toJSONString());
+        fYunFileService.uploadFile(path + File.separator + "capture" + File.separator + "data.fdage",
+                ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "") + "/data.fdage");
+
+        LambdaUpdateWrapper<ScenePlus> updateWrapper = new LambdaUpdateWrapper<ScenePlus>()
+                .set(ScenePlus::getSceneStatus, -2).eq(ScenePlus::getNum, message.getSceneCode());
+        scenePlusService.update(updateWrapper);
+    }
+}

+ 83 - 0
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneObjPreServiceImpl.java

@@ -0,0 +1,83 @@
+package com.fdkankan.contro.mq.service.impl;
+
+import com.fdkankan.common.util.FileUtils;
+import com.fdkankan.contro.mq.service.IBuildScenePreService;
+import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/3/1
+ **/
+@Slf4j
+@Service
+public class BuildSceneObjPreServiceImpl implements IBuildScenePreService {
+
+    @Value("${queue.modeling.modeling-call}")
+    private String queueModelingCall;
+
+    @Value("${queue.modeling.obj.modeling-post}")
+    private String queueObjModelingPost;
+
+    @Autowired
+    private RabbitMqProducer mqProducer;
+
+    @Override
+    public void buildScenePre(BuildSceneCallMessage message) {
+        boolean success = false;
+        try {
+            //根据相机类型,组装资源路径
+            String laserObjFilePath = message.getDataSource() + "_laser_obj";
+            log.info("开始生成OBJ文件,路径:{}", laserObjFilePath);
+
+            FileUtils.delAllFile(laserObjFilePath);
+
+
+            //下载资源到本地
+            this.downLoadSource(message, laserObjFilePath);
+
+            message.setDataSource(laserObjFilePath);
+
+            message.setResultReceiverMqName(queueObjModelingPost);
+
+            //发送mq,就进行计算
+            mqProducer.sendByWorkQueue(queueModelingCall, message);
+
+            success = true;
+
+            log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
+
+        }catch (Exception e){
+            log.error("场景计算前置处理出错", e);
+        }finally {
+            //如果前置处理失败,发送钉钉消息
+            if(!success){
+                String serverPath = message.getPath().substring(0,message.getPath().lastIndexOf("/")+1).concat(message.getPrefix());
+//            buildSceneDTService.handFail("场景计算前置处理出错", serverPath, message.getSceneNum(), BuildScenePreServiceImpl.hostName, null);
+            }
+
+        }
+    }
+
+    @Override
+    public void downLoadSource(BuildSceneCallMessage buildSceneMqMessage,String path) throws Exception{
+        FileUtils.copyFile(path + "/caches/reconstruction/final.bin", path + "/caches/reconstruction/final.bin", true);
+        FileUtils.copyFile(path + "/caches/reconstruction/chunk.json", path + "/caches/reconstruction/chunk.json", true);
+        FileUtils.copyDirectiory(path + "/caches/images", path + "/caches/images");
+
+        FileUtils.copyDirectiory(path + "/caches/depthmap_csc", path + "/caches/depthmap_csc");
+        FileUtils.copyDirectiory(path + "/caches/depthmap_vis", path + "/caches/depthmap_vis");
+        FileUtils.copyDirectiory(path + "/caches/depthmap", path + "/caches/depthmap");
+        FileUtils.copyFile(path + "/caches/panorama.json", path + "/caches/panorama.json", true);
+        FileUtils.copyFile(path + "/results/laserData/laser.ply", path + "/results/laserData/laser.ply", true);
+    }
+
+}

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

@@ -1,4 +1,4 @@
-package com.fdkankan.contro.service.impl;
+package com.fdkankan.contro.mq.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
@@ -15,6 +15,7 @@ import com.fdkankan.common.constant.*;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.contro.bean.*;
 import com.fdkankan.contro.entity.*;
+import com.fdkankan.contro.mq.service.IBuildScenePostService;
 import com.fdkankan.contro.service.*;
 import com.fdkankan.contro.vo.SceneEditControlsVO;
 import com.fdkankan.fyun.config.FYunFileConfig;
@@ -28,7 +29,6 @@ import com.fdkankan.model.utils.CreateHouseJsonUtil;
 import com.fdkankan.model.utils.CreateObjUtil;
 import com.fdkankan.push.config.PushMessageConfig;
 import com.fdkankan.push.utils.PushMsgUtil;
-import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
 import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;

+ 2 - 29
src/main/java/com/fdkankan/contro/service/impl/BuildScenePreServiceImpl.java

@@ -1,24 +1,18 @@
-package com.fdkankan.contro.service.impl;
+package com.fdkankan.contro.mq.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.util.FileUtils;
-import com.fdkankan.contro.service.IBuildScenePreService;
+import com.fdkankan.contro.mq.service.IBuildScenePreService;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.model.constants.ConstantFilePath;
-import com.fdkankan.model.utils.CreateObjUtil;
 import com.fdkankan.model.utils.SceneUtil;
 import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
-import com.fdkankan.redis.constant.RedisKey;
-import com.fdkankan.redis.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.io.File;
-import java.time.Duration;
-import java.time.temporal.ChronoUnit;
 import java.util.Date;
 
 /**
@@ -33,36 +27,15 @@ import java.util.Date;
 @Service
 public class BuildScenePreServiceImpl implements IBuildScenePreService {
 
-    @Value("${model.timeOut:48}")
-    private int modelTimeOut;
-    @Value("${environment:dev}")
-    private String environment;
     @Value("${queue.modeling.modeling-call}")
     private String queueModelingCall;
 
     @Autowired
-    RedisUtil redisUtil;
-    @Autowired
     private RabbitMqProducer mqProducer;
 
     @Autowired
     private FYunFileServiceInterface fYunFileService;
 
-    public static String hostName;
-
-
-    @Value("${hostName.filePath:/opt/hosts/hosts.txt}")
-    public void setHostName(String filePath){
-        try {
-            this.hostName = FileUtils.readFile(filePath);
-            log.error("从文件({})中获取服务器名称:{}", filePath,hostName);
-        } catch (Exception e) {
-            log.error("从文件中获取服务器名称失败,文件路径{}", filePath);
-            e.printStackTrace();
-        }
-    }
-
-
     @Override
     public void buildScenePre(BuildSceneCallMessage message) {
         boolean success = false;

+ 1 - 2
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -629,8 +629,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         ScenePlus scene = scenePlusService.getByFileId("/" + fileId + "/");
 
         int rebuild = 1;
-        log.info("是否是重算,rebuild:{}",rebuild);
-
         log.info("查询相机:" + snCode);
         Camera camera = cameraService.getByChildName(snCode);
 
@@ -661,6 +659,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             log.error("大场景序号为空:" + sceneNum);
             throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
         }
+        log.info("是否是重算,rebuild:{}",rebuild);
 
         String localDataPath = String.format(ConstantFilePath.DATABUFFER_FORMAT, sceneNum);
         String localImagesPath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, sceneNum);

+ 4 - 1
src/main/java/com/fdkankan/contro/service/impl/ScenePlusServiceImpl.java

@@ -77,7 +77,10 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
             log.info("该场景不属于八目相机无法重置容量,场景码为:" + num);
             return ResultData.error(ErrorCode.FAILURE_CODE_5057);
         }
-        cameraDetailService.updateCameraDetailByCameraIdAndSpace(scenePlus.getCameraId(), -scenePlusExt.getSpace());
+
+        if(!ObjectUtils.isEmpty(scenePlusExt.getSpace())){
+            cameraDetailService.updateCameraDetailByCameraIdAndSpace(scenePlus.getCameraId(), -scenePlusExt.getSpace());
+        }
 
         scenePlusExt.setSpace(Long.parseLong("0"));
         scenePlusExtService.updateById(scenePlusExt);