Преглед на файлове

深光slam增加点位统计 增加统计原始数据大小

dsx преди 1 година
родител
ревизия
51047aaa03

+ 8 - 1
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -1,6 +1,7 @@
 package com.fdkankan.contro.controller;
 
 import cn.hutool.core.util.ZipUtil;
+import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.constant.ErrorCode;
@@ -210,7 +211,13 @@ public class SceneFileController{
 
     @PostMapping("/noticeBuild")
     public ResultData noticeBuild(String uuid) throws Exception {
-        return sceneFileBuildService.noticeBuild(uuid, false);
+        return sceneFileBuildService.noticeBuild(uuid);
+    }
+
+    @PostMapping("/noticeBuild_bd")
+    public ResultData noticeBuildBd(String uuid) throws Exception {
+        HttpUtil.post("http://localhost:8085/api/scene/file/noticeBuild", uuid);
+        return ResultData.ok();
     }
 
 

+ 14 - 0
src/main/java/com/fdkankan/contro/entity/OrigFileUploadBatch.java

@@ -47,6 +47,18 @@ public class OrigFileUploadBatch implements Serializable {
     private Integer status;
 
     /**
+     * 上传次数
+     */
+    @TableField("notice_times")
+    private Integer noticeTimes;
+
+    /**
+     * mq消息体
+     */
+    @TableField("mq_content")
+    private String mqContent;
+
+    /**
      * 创建时间
      */
     @TableField("create_time")
@@ -65,5 +77,7 @@ public class OrigFileUploadBatch implements Serializable {
     @TableLogic(value = "A", delval = "I")
     private String recStatus;
 
+    private Integer[] inStatus;
+
 
 }

+ 10 - 2
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneProgressServiceImpl.java

@@ -110,7 +110,7 @@ public class BuildSceneProgressServiceImpl implements IBuildSceneProgressService
                         params.put("progress", mainProgress);
                         params.put("status", commonSuccessStatus.code());
                         log.info("场景计算失败,发送进度请求,url:{}, param:{}", buildProgressUrl, JSON.toJSONString(params));
-                        HttpUtil.post(buildProgressUrl, JSON.toJSONString(params), 2000);
+                        this.sendNotice(params);
                         break;
                     case WAITING:
                         mainProgress += factor;
@@ -122,7 +122,7 @@ public class BuildSceneProgressServiceImpl implements IBuildSceneProgressService
                             params.put("progress", mainProgress);
                             params.put("status", commonSuccessStatus.code());
                             log.info("场景计算进行中,发送进度请求,url:{}, param:{}", buildProgressUrl, JSON.toJSONString(params));
-                            HttpUtil.post(buildProgressUrl, JSON.toJSONString(params), 2000);
+                            this.sendNotice(params);
                         }
                         break;
                 }
@@ -135,6 +135,14 @@ public class BuildSceneProgressServiceImpl implements IBuildSceneProgressService
 
     }
 
+    private void sendNotice(Map<String, Object> params){
+        try {
+            HttpUtil.post(buildProgressUrl, JSON.toJSONString(params), 2000);
+        }catch(Exception e){
+            log.error("发送进度通知请求失败, 通知载荷:{}", JSON.toJSONString(params), e);
+        }
+    }
+
     public static void main(String[] args) {
         File file = new File("D:\\test\\111.txt");
         WatchMonitor watchMonitor = WatchMonitor.create(file);

+ 11 - 7
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -72,9 +72,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     @Value("${queue.modeling.single.modeling-call}")
     private String singleModelingCall;
 
-    @Value("${queue.modeling.modeling-progress-notice}")
-    private String modelingProgressNotice;
-
     @Value("${model.type:#{null}}")
     private String modelType;
 
@@ -161,9 +158,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             //如果场景原始资源上传批次id不为空,则需要下载批次文件上传到oss目录
             this.downloadOrigFile(batchId, message.getPath());
 
-            //开始计算前发送mq消息,监听project.json文件的变化以更新进度条
-            mqProducer.sendByWorkQueue(modelingProgressNotice, message);
-
             //重新计算时需要删除文件夹,否知使用缓存
             if(new File(message.getPath() + File.separator + "results").exists()){
                 FileUtils.deleteDirectory(message.getPath() + File.separator + "results");
@@ -242,11 +236,14 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         if(StrUtil.isEmpty(batchId)){
             return;
         }
+
         List<OrigFileUpload> fileList = origFileUploadService.getByBatchId(batchId);
         if(CollUtil.isEmpty(fileList)){
             return;
         }
         String homePath = "/oss/4dkankan/" + SceneUtil.getHomePath(dataSource);
+
+
         for (OrigFileUpload origFileUpload : fileList) {
             int times = 0;
             String filePath = homePath.concat(origFileUpload.getFileName());
@@ -288,6 +285,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
         String sceneCode = message.getBuildContext().get("sceneNum").toString();
         String path = message.getPath();
+        String batchId = (String) message.getExt().get("batchId");
         try {
             // 上传计算日志
             //如果是重复计算,没有走到计算逻辑,不需要上传日志文件
@@ -415,6 +413,12 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
             scenePlusService.updateById(scenePlus);
 
+            OrigFileUploadBatch condition = new OrigFileUploadBatch();
+            condition.setBatchId(batchId);
+            OrigFileUploadBatch origFileUploadBatch = origFileUploadBatchService.getByCondition(condition);
+            origFileUploadBatch.setStatus(3);
+            origFileUploadBatchService.updateById(origFileUploadBatch);
+
             //国际环境需要发邮件通知
             if("eur".equals(env)){
                 commonService.sendEmail(sceneCode);
@@ -428,7 +432,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             params.put("title", scenePlus.getTitle());
             params.put("customUserId", ext.get("customUserId"));
             params.put("gps", ext.get("gps"));
-            params.put("totalTime", Integer.valueOf(redisUtil.get(String.format(RedisKey.SCENE_BUILD_EXPECT_TOTAL_TIME_NUM, sceneCode))));
+//            params.put("totalTime", Integer.valueOf(redisUtil.get(String.format(RedisKey.SCENE_BUILD_EXPECT_TOTAL_TIME_NUM, sceneCode))));
             params.put("progress", 100);
             params.put("status", CommonSuccessStatus.SUCCESS.code());
             HttpUtil.post(buildProgressUrl, JSON.toJSONString(params), 2000);

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

@@ -37,5 +37,5 @@ public interface ISceneFileBuildService extends IService<SceneFileBuild> {
 
     ResultData uploadFile(SendCallAlgorithmParam param) throws Exception;
 
-    ResultData noticeBuild(String params, boolean init) throws Exception;
+    ResultData noticeBuild(String params) throws Exception;
 }

+ 10 - 3
src/main/java/com/fdkankan/contro/service/impl/OrigFileUploadBatchServiceImpl.java

@@ -1,5 +1,7 @@
 package com.fdkankan.contro.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.common.constant.CommonSuccessStatus;
 import com.fdkankan.contro.entity.OrigFileUploadBatch;
@@ -24,13 +26,18 @@ public class OrigFileUploadBatchServiceImpl extends ServiceImpl<IOrigFileUploadB
     @Override
     public OrigFileUploadBatch getByCondition(OrigFileUploadBatch condition) {
         LambdaQueryWrapper<OrigFileUploadBatch> wrapper = new LambdaQueryWrapper();
-        wrapper.eq(OrigFileUploadBatch::getUuid, condition.getUuid());
+        if(StrUtil.isNotEmpty(condition.getUuid())){
+            wrapper.eq(OrigFileUploadBatch::getUuid, condition.getUuid());
+        }
         if(Objects.nonNull(condition.getStatus())){
             wrapper.eq(OrigFileUploadBatch::getStatus, condition.getStatus());
         }
-        if(Objects.nonNull(condition.getBatchId())){
+        if(StrUtil.isNotEmpty(condition.getBatchId())){
             wrapper.eq(OrigFileUploadBatch::getStatus, condition.getStatus());
         }
-        return this.getOne(new LambdaQueryWrapper<OrigFileUploadBatch>().eq(OrigFileUploadBatch::getUuid, uuid).in(OrigFileUploadBatch::getStatus, 0));
+        if(condition.getInStatus() != null && condition.getInStatus().length > 0){
+            wrapper.in(OrigFileUploadBatch::getStatus, condition.getInStatus());
+        }
+        return this.getOne(wrapper);
     }
 }

+ 30 - 24
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -1586,18 +1586,18 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
                 jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), rebuild,
                 jsonObject.getInteger("resolution"), firmwareVersion.toString(), sceneUrl, buildType, cameraDetail.getCooperationUser());
 
-        if (Objects.nonNull(scenePlusVO)) {
-            JSONObject statusJson = new JSONObject();
-            //临时将-2改成1,app还没完全更新
-            statusJson.put("status", scenePlusVO.getSceneStatus() == -2 ? 1 : scenePlusVO.getSceneStatus());
-            statusJson.put("webSite", scenePlusVO.getWebSite());
-            statusJson.put("sceneNum", scenePlusVO.getNum());
-            statusJson.put("thumb", scenePlusVO.getThumb());
-            statusJson.put("payStatus", 0);
-            statusJson.put("recStatus", 'A');
-            FileUtils.writeFile(localDataPath + "status.json", statusJson.toString());
-            fYunFileService.uploadFile(localDataPath + "status.json", dataViewPath + "status.json");
-        }
+//        if (Objects.nonNull(scenePlusVO)) {
+//            JSONObject statusJson = new JSONObject();
+//            //临时将-2改成1,app还没完全更新
+//            statusJson.put("status", scenePlusVO.getSceneStatus() == -2 ? 1 : scenePlusVO.getSceneStatus());
+//            statusJson.put("webSite", scenePlusVO.getWebSite());
+//            statusJson.put("sceneNum", scenePlusVO.getNum());
+//            statusJson.put("thumb", scenePlusVO.getThumb());
+//            statusJson.put("payStatus", 0);
+//            statusJson.put("recStatus", 'A');
+//            FileUtils.writeFile(localDataPath + "status.json", statusJson.toString());
+//            fYunFileService.uploadFile(localDataPath + "status.json", dataViewPath + "status.json");
+//        }
 
         BuildSceneCallMessage mqMessage = getBuildSceneMqMessage(sceneNum, cameraType, algorithm, jsonObject, buildType,
                 scenePlusVO.getDataSource());
@@ -1613,11 +1613,16 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         mqMessage.getExt().put("gps", jsonObject.getString("gps"));
 
         if(uploadType.equals("single")){//场景上传模式(single-细小文件上传, zip-压缩包上传)
-            //修改场景上传批次为进入计算
-            OrigFileUploadBatch origFileUploadBatch = origFileUploadBatchService.getWaitingBatchByUuid(unicode);
+            OrigFileUploadBatch condition = new OrigFileUploadBatch();
+            condition.setUuid(unicode);
+            condition.setStatus(0);
+            OrigFileUploadBatch origFileUploadBatch = origFileUploadBatchService.getByCondition(condition);
             origFileUploadBatch.setStatus(1);
-            origFileUploadBatchService.updateById(origFileUploadBatch);
+            origFileUploadBatch.setMqContent(JSON.toJSONString(mqMessage));
+            origFileUploadBatch.setNoticeTimes(origFileUploadBatch.getNoticeTimes() + 1);
             mqMessage.getExt().put("batchId", origFileUploadBatch.getBatchId());
+            mqMessage.getExt().put("noticeTimes", origFileUploadBatch.getNoticeTimes());
+            origFileUploadBatchService.updateById(origFileUploadBatch);
         }
         rabbitMqProducer.sendByWorkQueue(queueModelingPre, mqMessage);
 
@@ -2248,7 +2253,10 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         }
 
         //查询是否有等待通知计算的上传批次记录,如果有则加入,没有则新增
-        OrigFileUploadBatch origFileUploadBatch = origFileUploadBatchService.getByCondition(uuid);
+        OrigFileUploadBatch condition = new OrigFileUploadBatch();
+        condition.setUuid(uuid);
+        condition.setStatus(0);
+        OrigFileUploadBatch origFileUploadBatch = origFileUploadBatchService.getByCondition(condition);
         if(Objects.isNull(origFileUploadBatch)){
             origFileUploadBatch = new OrigFileUploadBatch();
             origFileUploadBatch.setUuid(uuid);
@@ -2280,7 +2288,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     }
 
     @Override
-    public ResultData noticeBuild(String uuid, boolean init) throws Exception {
+    public ResultData noticeBuild(String uuid) throws Exception {
         log.info("通知计算,uuid:{} " + uuid);
 
         String[] uuidArr = uuid.split("_");
@@ -2347,12 +2355,11 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             sceneNum = scenePlus.getNum();
         }else{
             sceneNum = scene3dNumService.generateSceneNum(cameraDetail.getType());
-            init = true;
         }
 
-        if(init){
+        //查询是否有已发送计算的批次,如果有,就不需要在发送了
 
-            JSONObject fdageData = JSONObject.parseObject(FileUtils.readFile(sendCallAlgorithmPath.concat(uuid).concat("/data.fdage")));
+        JSONObject fdageData = JSONObject.parseObject(FileUtils.readFile(sendCallAlgorithmPath.concat(uuid).concat("/data.fdage")));
 //        String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
 //        if(fdageData.containsKey("icon") && StringUtils.isNotEmpty(fdageData.getString("icon"))){
 //            String ossPath = ConstantFilePath.OSS_PREFIX + dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
@@ -2361,11 +2368,10 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 //            icon = fYunFileConfig.getHost() + imgViewPath + fdageData.getString("icon");
 //            log.info("上传icon成功....");
 //        }
-            buildScenePost(dataSource, fdageData, "V3", cameraType, sceneNum, camera, cameraDetail, rebuild, "", user, customUserId, "single");
+        buildScenePost(dataSource, fdageData, "V3", cameraType, sceneNum, camera, cameraDetail, rebuild, "", user, customUserId, "single");
 
-            scenePlus = scenePlusService.getScenePlusByNum(sceneNum);
-            fdkkLaserService.saveScene(scenePlus,fdageData,camera,user.getUserName(),rebuild == 1 ? true : false);
-        }
+        scenePlus = scenePlusService.getScenePlusByNum(sceneNum);
+        fdkkLaserService.saveScene(scenePlus,fdageData,camera,user.getUserName(),rebuild == 1 ? true : false);
 
         return ResultData.ok();
     }