Pārlūkot izejas kodu

优化场景计算逻辑

tianboguang 2 gadi atpakaļ
vecāks
revīzija
817089b257

+ 37 - 0
src/main/java/com/fdkankan/contro/mq/listener/AbstrackBuildSceneListener.java

@@ -0,0 +1,37 @@
+package com.fdkankan.contro.mq.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.contro.mq.service.IBuildSceneService;
+import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
+import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
+import com.rabbitmq.client.Channel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+@Slf4j
+public class AbstrackBuildSceneListener implements IBuildSceneListener {
+    @Override
+    public void preHandle(Channel channel, String queueName, Message message, IBuildSceneService buildSceneService) throws IOException {
+        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:{},消息体:{}", msg, correlationId, msg);
+        BuildSceneCallMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneCallMessage.class);
+        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+        buildSceneService.buildScenePre(buildSceneMessage);
+    }
+
+    @Override
+    public void postHandle(Channel channel, String queueName, Message message, IBuildSceneService buildSceneService) 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:{},消息体:{}", queueName, correlationId, msg);
+        BuildSceneResultMqMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneResultMqMessage.class);
+        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+        buildSceneService.buildScenePost(buildSceneMessage);
+    }
+}

+ 71 - 0
src/main/java/com/fdkankan/contro/mq/listener/BuildObjListener.java

@@ -0,0 +1,71 @@
+package com.fdkankan.contro.mq.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.contro.mq.service.impl.BuildObjServiceImpl;
+import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
+import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
+import com.rabbitmq.client.Channel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.Queue;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.nio.charset.StandardCharsets;
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/4/19
+ **/
+@Slf4j
+@Component
+public class BuildObjListener extends AbstrackBuildSceneListener {
+
+
+    @Value("${queue.modeling.obj.modeling-pre}")
+    private String queueObjModelingPre;
+    @Value("${queue.modeling.obj.modeling-post}")
+    private String queueObjModelingPost;
+
+    @Autowired
+    private BuildObjServiceImpl buildObjService;
+
+
+    /**
+     * 场景计算前置资源准备处理
+     *
+     * @param channel
+     * @param message
+     * @throws Exception
+     */
+    @RabbitListener(
+            queuesToDeclare = @Queue("${queue.modeling.obj.modeling-pre}"),
+            concurrency = "${maxThread.modeling.modeling-pre}"
+    )
+    public void buildObjScenePreHandler(Channel channel, Message message) throws Exception {
+        preHandle(channel, queueObjModelingPre, message, buildObjService);
+    }
+
+
+    /**
+     * 场景计算后置结果处理
+     *
+     * @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 {
+        postHandle(channel, queueObjModelingPost, message, buildObjService);
+
+    }
+}

+ 58 - 0
src/main/java/com/fdkankan/contro/mq/listener/BuildSceneListener.java

@@ -0,0 +1,58 @@
+package com.fdkankan.contro.mq.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.contro.mq.service.impl.BuildSceneServiceImpl;
+import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
+import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
+import com.rabbitmq.client.Channel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.Queue;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.nio.charset.StandardCharsets;
+
+@Slf4j
+@Component
+public class BuildSceneListener extends AbstrackBuildSceneListener {
+
+    @Value("${queue.modeling.modeling-pre}")
+    private String queueModelingPre;
+    @Value("${queue.modeling.modeling-post}")
+    private String queueModelingPost;
+
+    @Autowired
+    private BuildSceneServiceImpl buildSceneService;
+
+    /**
+     * 场景计算前置资源准备处理
+     * @param channel
+     * @param message
+     * @throws Exception
+     */
+    @RabbitListener(
+            queuesToDeclare = @Queue("${queue.modeling.modeling-pre}"),
+            concurrency = "${maxThread.modeling.modeling-pre}"
+    )
+    public void buildScenePreHandler(Channel channel, Message message) throws Exception {
+        preHandle(channel,queueModelingPre,message,buildSceneService);
+    }
+
+    /**
+     * 场景计算后置结果处理
+     * @param channel
+     * @param message
+     * @throws Exception
+     */
+    @RabbitListener(
+            queuesToDeclare = @Queue("${queue.modeling.modeling-post}"),
+            concurrency = "${maxThread.modeling.modeling-post}"
+    )
+    public void buildScenePostHandler(Channel channel, Message message) throws Exception {
+        postHandle(channel,queueModelingPost,message,buildSceneService);
+
+    }
+}

+ 47 - 0
src/main/java/com/fdkankan/contro/mq/listener/DingTalkMessageListener.java

@@ -0,0 +1,47 @@
+package com.fdkankan.contro.mq.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.contro.service.IBuildSceneDTService;
+import com.fdkankan.rabbitmq.bean.BuildSceneFailDTMqMessage;
+import com.rabbitmq.client.Channel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.Queue;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.nio.charset.StandardCharsets;
+
+@Slf4j
+@Component
+public class DingTalkMessageListener {
+
+    @Value("${queue.modeling.modeling-dt}")
+    private String queueModelingDt;
+
+    @Autowired
+    private IBuildSceneDTService buildSceneDTService;
+
+    /**
+     * 场景计算发送钉钉消息
+     * @param channel
+     * @param message
+     * @throws Exception
+     */
+    @RabbitListener(
+            queuesToDeclare = @Queue("${queue.modeling.modeling-dt}"),
+            concurrency = "${maxThread.modeling.modeling-dt}"
+    )
+    public void buildSceneDTHandler(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:{},消息体:{}", queueModelingDt, correlationId, msg);
+        BuildSceneFailDTMqMessage dtMessage = JSONObject.parseObject(msg, BuildSceneFailDTMqMessage.class);
+//        buildSceneDTService.handFail(dtMessage.getReason(), dtMessage.getServerPath(),
+//            dtMessage.getNum(), dtMessage.getHostName(), DingTalkConst.contentExt);
+        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+    }
+}

+ 12 - 0
src/main/java/com/fdkankan/contro/mq/listener/IBuildSceneListener.java

@@ -0,0 +1,12 @@
+package com.fdkankan.contro.mq.listener;
+
+import com.fdkankan.contro.mq.service.IBuildSceneService;
+import com.rabbitmq.client.Channel;
+import org.springframework.amqp.core.Message;
+
+import java.io.IOException;
+
+public interface IBuildSceneListener {
+    void preHandle(Channel channel,String queueName, Message message, IBuildSceneService buildSceneService) throws IOException;
+    void postHandle(Channel channel,String queueName, Message message,IBuildSceneService buildSceneService) throws Exception;
+}

+ 0 - 170
src/main/java/com/fdkankan/contro/mq/listener/RabbitMqListener.java

@@ -1,170 +0,0 @@
-package com.fdkankan.contro.mq.listener;
-
-import com.alibaba.fastjson.JSONObject;
-import com.fdkankan.contro.mq.service.impl.BuildSceneObjPostServiceImpl;
-import com.fdkankan.contro.mq.service.impl.BuildSceneObjPreServiceImpl;
-import com.fdkankan.contro.mq.service.impl.BuildScenePostServiceImpl;
-import com.fdkankan.contro.mq.service.impl.BuildScenePreServiceImpl;
-import com.fdkankan.contro.service.IBuildSceneDTService;
-import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
-import com.fdkankan.rabbitmq.bean.BuildSceneFailDTMqMessage;
-import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
-import com.rabbitmq.client.Channel;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.nio.charset.StandardCharsets;
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/4/19
- **/
-@Slf4j
-@Component
-public class RabbitMqListener {
-    @Value("${queue.modeling.modeling-pre}")
-    private String queueModelingPre;
-    @Value("${queue.modeling.modeling-post}")
-    private String queueModelingPost;
-
-    @Value("${queue.modeling.obj.modeling-pre}")
-    private String queueObjModelingPre;
-    @Value("${queue.modeling.obj.modeling-post}")
-    private String queueObjModelingPost;
-
-    @Value("${queue.modeling.modeling-dt}")
-    private String queueModelingDt;
-
-    @Autowired
-    private BuildScenePreServiceImpl buildScenePreService;
-    @Autowired
-    private BuildScenePostServiceImpl buildScenePostService;
-
-    @Autowired
-    private BuildSceneObjPreServiceImpl buildSceneObjPreService;
-    @Autowired
-    private BuildSceneObjPostServiceImpl buildSceneObjPostService;
-
-    @Autowired
-    private IBuildSceneDTService buildSceneDTService;
-
-    /**
-     * 场景计算前置资源准备处理
-     * @param channel
-     * @param message
-     * @throws Exception
-     */
-    @RabbitListener(
-        queuesToDeclare = @Queue("${queue.modeling.modeling-pre}"),
-        concurrency = "${maxThread.modeling.modeling-pre}"
-    )
-    public void buildScenePreHandler(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:{},消息体:{}", queueModelingPre, correlationId, msg);
-        BuildSceneCallMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneCallMessage.class);
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-        Thread.sleep(2000L);
-        buildScenePreService.buildScenePre(buildSceneMessage);
-    }
-
-    /**
-     * 场景计算后置结果处理
-     * @param channel
-     * @param message
-     * @throws Exception
-     */
-    @RabbitListener(
-        queuesToDeclare = @Queue("${queue.modeling.modeling-post}"),
-        concurrency = "${maxThread.modeling.modeling-post}"
-    )
-    public void buildScenePostHandler(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:{},消息体:{}", queueModelingPost, 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
-     * @throws Exception
-     */
-    @RabbitListener(
-            queuesToDeclare = @Queue("${queue.modeling.obj.modeling-pre}"),
-            concurrency = "${maxThread.modeling.modeling-pre}"
-    )
-    public void buildObjScenePreHandler(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:{},消息体:{}", queueModelingPre, correlationId, msg);
-        BuildSceneCallMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneCallMessage.class);
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-        Thread.sleep(2000L);
-        buildSceneObjPreService.buildScenePre(buildSceneMessage);
-    }
-
-
-    /**
-     * 场景计算后置结果处理
-     * @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);
-        buildSceneObjPostService.buildScenePost(resultMessage);
-
-    }
-
-    /**
-     * 场景计算发送钉钉消息
-     * @param channel
-     * @param message
-     * @throws Exception
-     */
-    @RabbitListener(
-        queuesToDeclare = @Queue("${queue.modeling.modeling-dt}"),
-        concurrency = "${maxThread.modeling.modeling-dt}"
-    )
-    public void buildSceneDTHandler(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:{},消息体:{}", queueModelingDt, correlationId, msg);
-        BuildSceneFailDTMqMessage dtMessage = JSONObject.parseObject(msg, BuildSceneFailDTMqMessage.class);
-//        buildSceneDTService.handFail(dtMessage.getReason(), dtMessage.getServerPath(),
-//            dtMessage.getNum(), dtMessage.getHostName(), DingTalkConst.contentExt);
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-    }
-
-
-}

+ 0 - 17
src/main/java/com/fdkankan/contro/mq/service/IBuildScenePostService.java

@@ -1,17 +0,0 @@
-package com.fdkankan.contro.mq.service;
-
-import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/3/1
- **/
-public interface IBuildScenePostService {
-
-    void buildScenePost(BuildSceneResultMqMessage message) throws Exception;
-
-}

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

@@ -1,6 +1,7 @@
 package com.fdkankan.contro.mq.service;
 
 import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
+import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
 
 /**
  * <p>
@@ -10,9 +11,12 @@ import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
  * @author dengsixing
  * @since 2022/3/1
  **/
-public interface IBuildScenePreService {
+public interface IBuildSceneService {
 
     void buildScenePre(BuildSceneCallMessage message);
 
     void downLoadSource(BuildSceneCallMessage buildSceneMqMessage, String path) throws Exception;
+
+    void buildScenePost(BuildSceneResultMqMessage message) throws Exception;
+
 }

+ 85 - 2
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneObjPreServiceImpl.java

@@ -1,12 +1,20 @@
 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.mq.service.IBuildScenePreService;
+import com.fdkankan.contro.entity.ScenePro;
+import com.fdkankan.contro.mq.service.IBuildSceneService;
+import com.fdkankan.contro.service.IFdkkLaserService;
+import com.fdkankan.contro.service.ISceneProService;
+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.UploadFilePath;
 import com.fdkankan.model.utils.CreateObjUtil;
 import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
+import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import jodd.util.StringUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -27,7 +35,7 @@ import java.io.File;
  **/
 @Slf4j
 @Service
-public class BuildSceneObjPreServiceImpl implements IBuildScenePreService {
+public class BuildObjServiceImpl implements IBuildSceneService {
 
     @Value("${queue.modeling.modeling-call}")
     private String queueModelingCall;
@@ -41,6 +49,15 @@ public class BuildSceneObjPreServiceImpl implements IBuildScenePreService {
     @Autowired
     private FYunFileServiceInterface fYunFileService;
 
+    @Autowired
+    private ISceneProService sceneProService;
+
+    @Autowired
+    private IFdkkLaserService fdkkLaserService;
+
+    @Autowired
+    private FdkkV4Service fdkkV4Service;
+
     @Override
     public void buildScenePre(BuildSceneCallMessage message) {
         boolean success = false;
@@ -122,4 +139,70 @@ public class BuildSceneObjPreServiceImpl implements IBuildScenePreService {
         FileUtils.copyFile(path + "/results/laserData/laser.ply", path + "/results/laserData/laser.ply", true);
     }
 
+    @Override
+    public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
+        // 去除 OnlyExportMeshObj
+        String path = message.getPath();
+        String projectNum = message.getSceneCode();
+        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");
+
+
+        String laserObjFilePath = path + "_laser_obj";
+        CreateObjUtil.convertTxtToDam(laserObjFilePath + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
+        CreateObjUtil.convertDamToLzma(laserObjFilePath + File.separator + "results");
+        CreateObjUtil.convertTxtToDam(laserObjFilePath + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
+        File file = new File(laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma");
+        while (!file.exists()) {
+            Thread.sleep(60000);
+        }
+
+        fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", "images/images" + projectNum + "/" + ConstantFileName.modelUUID + "_50k.dam.lzma");
+        fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", "images/images" + projectNum + "/" + ConstantFileName.modelUUID + "_50k.dam");
+
+        String texPath = laserObjFilePath + File.separator + "results" + File.separator + "tex";
+
+        File texFile = new File(texPath);
+        if(texFile.exists()){
+            for (File textureFile : texFile.listFiles()) {
+                if(textureFile.getName().endsWith(".jpg")){
+                    fYunFileService.uploadFile(textureFile.getAbsolutePath(), "images/images" +
+                            projectNum + "/" + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/"+textureFile.getName());
+                }
+            }
+        }
+
+        fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + "tex/texture1.jpg", "images/images" +
+                projectNum + "/" + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/texture1.jpg");
+
+        // 拷贝结果
+        log.info("开始拷贝obj文件");
+        FileUtils.copyFolderAllFiles(laserObjFilePath + "/results/mesh", laserObjFilePath + "/laserData/mesh/", true);
+
+        File meshFolder = new File(laserObjFilePath + "/results/mesh");
+
+        for (File meshFile : meshFolder.listFiles()) {
+            fYunFileService.uploadFile(meshFile.getAbsolutePath(), String.format(UploadFilePath.DATA_VIEW_PATH,  projectNum) + "mesh/" + meshFile.getName());
+        }
+
+        fdkkLaserService.pushBuildStatusToLaserSystem(projectNum, laserObjFilePath + "/laserData/mesh");
+
+        LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<ScenePro>()
+                .set(ScenePro::getStatus, -2).eq(ScenePro::getNum, projectNum);
+        sceneProService.update(updateWrapper);
+
+        // 如果未升级V4,则升级V4
+        fdkkV4Service.upgradeToV4(projectNum);
+    }
+
 }

+ 0 - 112
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneObjPostServiceImpl.java

@@ -1,112 +0,0 @@
-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.ScenePro;
-import com.fdkankan.contro.mq.service.IBuildScenePostService;
-import com.fdkankan.contro.service.IFdkkLaserService;
-import com.fdkankan.contro.service.ISceneProService;
-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.UploadFilePath;
-import com.fdkankan.model.utils.CreateObjUtil;
-import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.io.File;
-
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/4/20
- **/
-@Slf4j
-@Service
-public class BuildSceneObjPostServiceImpl implements IBuildScenePostService {
-    @Autowired
-    private FYunFileServiceInterface fYunFileService;
-
-    @Autowired
-    private ISceneProService sceneProService;
-
-    @Autowired
-    private IFdkkLaserService fdkkLaserService;
-
-    @Autowired
-    private FdkkV4Service fdkkV4Service;
-
-    @Override
-    public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
-        // 去除 OnlyExportMeshObj
-        String path = message.getPath();
-        String projectNum = message.getSceneCode();
-        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");
-
-
-        String laserObjFilePath = path + "_laser_obj";
-        CreateObjUtil.convertTxtToDam(laserObjFilePath + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
-        CreateObjUtil.convertDamToLzma(laserObjFilePath + File.separator + "results");
-        CreateObjUtil.convertTxtToDam(laserObjFilePath + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
-        File file = new File(laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma");
-        while (!file.exists()) {
-            Thread.sleep(60000);
-        }
-
-        fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", "images/images" + projectNum + "/" + ConstantFileName.modelUUID + "_50k.dam.lzma");
-        fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", "images/images" + projectNum + "/" + ConstantFileName.modelUUID + "_50k.dam");
-
-        String texPath = laserObjFilePath + File.separator + "results" + File.separator + "tex";
-
-        File texFile = new File(texPath);
-        if(texFile.exists()){
-            for (File textureFile : texFile.listFiles()) {
-                if(textureFile.getName().endsWith(".jpg")){
-                    fYunFileService.uploadFile(textureFile.getAbsolutePath(), "images/images" +
-                            projectNum + "/" + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/"+textureFile.getName());
-                }
-            }
-        }
-
-        fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + "tex/texture1.jpg", "images/images" +
-                projectNum + "/" + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/texture1.jpg");
-
-        // 拷贝结果
-        log.info("开始拷贝obj文件");
-        FileUtils.copyFolderAllFiles(laserObjFilePath + "/results/mesh", laserObjFilePath + "/laserData/mesh/", true);
-
-        File meshFolder = new File(laserObjFilePath + "/results/mesh");
-
-        for (File meshFile : meshFolder.listFiles()) {
-            fYunFileService.uploadFile(meshFile.getAbsolutePath(), String.format(UploadFilePath.DATA_VIEW_PATH,  projectNum) + "mesh/" + meshFile.getName());
-        }
-
-        fdkkLaserService.pushBuildStatusToLaserSystem(projectNum, laserObjFilePath + "/laserData/mesh");
-
-        LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<ScenePro>()
-                .set(ScenePro::getStatus, -2).eq(ScenePro::getNum, projectNum);
-        sceneProService.update(updateWrapper);
-
-        // 如果未升级V4,则升级V4
-        fdkkV4Service.upgradeToV4(projectNum);
-    }
-}

+ 0 - 117
src/main/java/com/fdkankan/contro/mq/service/impl/BuildScenePreServiceImpl.java

@@ -1,117 +0,0 @@
-package com.fdkankan.contro.mq.service.impl;
-
-import com.fdkankan.common.util.FileUtils;
-import com.fdkankan.contro.mq.service.IBuildScenePreService;
-import com.fdkankan.fyun.face.FYunFileServiceInterface;
-import com.fdkankan.model.constants.ConstantFilePath;
-import com.fdkankan.model.utils.SceneUtil;
-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;
-
-import java.io.File;
-import java.util.Date;
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/3/1
- **/
-@Slf4j
-@Service
-public class BuildScenePreServiceImpl implements IBuildScenePreService {
-
-    @Value("${queue.modeling.modeling-call}")
-    private String queueModelingCall;
-
-    @Autowired
-    private RabbitMqProducer mqProducer;
-
-    @Autowired
-    private FYunFileServiceInterface fYunFileService;
-
-    @Override
-    public void buildScenePre(BuildSceneCallMessage message) {
-        boolean success = false;
-        try {
-            //根据相机类型,组装资源路径
-            String path = SceneUtil.getPath(message.getPath(), message.getCameraName(),
-                message.getFileId(), Integer.parseInt(message.getCameraType()), message.getUnicode());
-
-            //下载资源到本地
-            this.downLoadSource(message, path);
-
-            //发送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{
-        String cameraName = buildSceneMqMessage.getCameraName();
-        String fileId = buildSceneMqMessage.getFileId();
-        String unicode = buildSceneMqMessage.getUnicode();
-        int cameraType = Integer.parseInt(buildSceneMqMessage.getCameraType());
-        String prefix = buildSceneMqMessage.getPrefix();
-        String imgsName = buildSceneMqMessage.getImgsName();
-        if(cameraType < 3){
-            for(int i = 0;i<5;++i){
-                try{
-                    FileUtils.downLoadFromUrl(prefix+imgsName+"?m="+new Date().getTime(), imgsName,
-                        path + File.separator + "capture");
-                    FileUtils.decompress(path + File.separator + "capture" +File.separator+imgsName,
-                        path + File.separator + "capture") ;
-                    break;
-                }catch(Exception e){
-                    log.error(String.format("第%d次下载并解压资源失败", i+1),  e);
-                    if(i<4)
-                    {
-                        FileUtils.deleteFile(path + File.separator + "capture" +File.separator+imgsName);
-                        FileUtils.delFolder(path + File.separator + "capture" +File.separator+"images");
-                    }
-                    Thread.sleep(10000);
-                }
-            }
-            FileUtils.deleteFile(path + File.separator + "capture" +File.separator+"zip.Zip");
-        }else{
-            String ossPath = ConstantFilePath.OSS_PREFIX + cameraName.replace("4DKKPRO_", "")
-                .replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator
-                + unicode + File.separator;
-            if(cameraType == 5 || cameraType == 6){
-                path = ConstantFilePath.BUILD_MODEL_PATH + unicode;
-                //下载zip包
-                FileUtils.downLoadFromUrl(prefix + "/" + imgsName + "?m=" + System.currentTimeMillis(), imgsName, path + File.separator + "capture");
-                //解压
-                FileUtils.decompress(path + File.separator + "capture" + File.separator + imgsName,
-                    path + File.separator + "capture") ;
-                //删除压缩包
-                FileUtils.delFile(path + File.separator + "capture" + File.separator + imgsName);
-            }else if(cameraType == 14) {
-                fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
-            } else{
-                fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
-            }
-        }
-    }
-
-}

+ 94 - 4
src/main/java/com/fdkankan/contro/mq/service/impl/BuildScenePostServiceImpl.java

@@ -15,7 +15,7 @@ import com.fdkankan.common.constant.*;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.contro.bean.SceneJsonBean;
 import com.fdkankan.contro.entity.*;
-import com.fdkankan.contro.mq.service.IBuildScenePostService;
+import com.fdkankan.contro.mq.service.IBuildSceneService;
 import com.fdkankan.contro.service.*;
 import com.fdkankan.contro.service.impl.FdkkV4Service;
 import com.fdkankan.contro.vo.SceneEditControlsVO;
@@ -28,9 +28,12 @@ import com.fdkankan.model.constants.ConstantFilePath;
 import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.model.utils.CreateHouseJsonUtil;
 import com.fdkankan.model.utils.CreateObjUtil;
+import com.fdkankan.model.utils.SceneUtil;
 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.rabbitmq.util.RabbitMqProducer;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -57,13 +60,22 @@ import java.util.stream.Collectors;
  **/
 @Slf4j
 @Service
-public class BuildScenePostServiceImpl implements IBuildScenePostService {
+public class BuildSceneServiceImpl implements IBuildSceneService {
 
     @Value("${main.url}")
     private String mainUrl;
     @Value("${scene.pro.new.url}")
     private String sceneProNewUrl;
 
+    @Value("${queue.modeling.modeling-call}")
+    private String queueModelingCall;
+
+    @Autowired
+    private RabbitMqProducer mqProducer;
+
+    @Autowired
+    private FYunFileServiceInterface fYunFileService;
+
     @Autowired
     private ISceneFileBuildService sceneFileBuildService;
     @Autowired
@@ -72,8 +84,7 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
     private ISceneEditInfoService sceneEditInfoService;
     @Autowired
     private ISceneEditControlsService sceneEditControlsService;
-    @Autowired
-    private FYunFileServiceInterface fYunFileService;
+
     @Autowired
     private FYunFileConfig fYunFileConfig;
 
@@ -96,6 +107,85 @@ public class BuildScenePostServiceImpl implements IBuildScenePostService {
     private FdkkV4Service fdkkV4Service;
 
     @Override
+    public void buildScenePre(BuildSceneCallMessage message) {
+        boolean success = false;
+        try {
+            //根据相机类型,组装资源路径
+            String path = SceneUtil.getPath(message.getPath(), message.getCameraName(),
+                    message.getFileId(), Integer.parseInt(message.getCameraType()), message.getUnicode());
+
+            //下载资源到本地
+            this.downLoadSource(message, path);
+
+            //发送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{
+        String cameraName = buildSceneMqMessage.getCameraName();
+        String fileId = buildSceneMqMessage.getFileId();
+        String unicode = buildSceneMqMessage.getUnicode();
+        int cameraType = Integer.parseInt(buildSceneMqMessage.getCameraType());
+        String prefix = buildSceneMqMessage.getPrefix();
+        String imgsName = buildSceneMqMessage.getImgsName();
+        if(cameraType < 3){
+            for(int i = 0;i<5;++i){
+                try{
+                    FileUtils.downLoadFromUrl(prefix+imgsName+"?m="+new Date().getTime(), imgsName,
+                            path + File.separator + "capture");
+                    FileUtils.decompress(path + File.separator + "capture" +File.separator+imgsName,
+                            path + File.separator + "capture") ;
+                    break;
+                }catch(Exception e){
+                    log.error(String.format("第%d次下载并解压资源失败", i+1),  e);
+                    if(i<4)
+                    {
+                        FileUtils.deleteFile(path + File.separator + "capture" +File.separator+imgsName);
+                        FileUtils.delFolder(path + File.separator + "capture" +File.separator+"images");
+                    }
+                    Thread.sleep(10000);
+                }
+            }
+            FileUtils.deleteFile(path + File.separator + "capture" +File.separator+"zip.Zip");
+        }else{
+            String ossPath = ConstantFilePath.OSS_PREFIX + cameraName.replace("4DKKPRO_", "")
+                    .replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator
+                    + unicode + File.separator;
+            if(cameraType == 5 || cameraType == 6){
+                path = ConstantFilePath.BUILD_MODEL_PATH + unicode;
+                //下载zip包
+                FileUtils.downLoadFromUrl(prefix + "/" + imgsName + "?m=" + System.currentTimeMillis(), imgsName, path + File.separator + "capture");
+                //解压
+                FileUtils.decompress(path + File.separator + "capture" + File.separator + imgsName,
+                        path + File.separator + "capture") ;
+                //删除压缩包
+                FileUtils.delFile(path + File.separator + "capture" + File.separator + imgsName);
+            }else if(cameraType == 14) {
+                fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
+            } else{
+                fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
+            }
+        }
+    }
+
+
+    @Override
     public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
         Integer cameraType = Integer.parseInt(message.getCameraType());
         String sceneCode = message.getSceneCode();