Explorar o código

Merge branch 'release-swsx' into test

# Conflicts:
#	src/main/java/com/fdkankan/contro/entity/ScenePlus.java
dengsixing hai 3 días
pai
achega
a0d8178c13

+ 0 - 5
src/main/java/com/fdkankan/contro/entity/ScenePlus.java

@@ -134,9 +134,4 @@ public class ScenePlus implements Serializable {
     @TableField("has_floorplan_ai")
     private Integer hasFloorplanAi;
 
-    @TableField("relocation_max_index")
-    private Integer relocationMaxindex;
-
-
-
 }

+ 109 - 0
src/main/java/com/fdkankan/contro/mq/listener/BuildSxRelocationListener.java

@@ -0,0 +1,109 @@
+package com.fdkankan.contro.mq.listener;
+
+import cn.hutool.core.exceptions.ExceptionUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.constant.CommonOperStatus;
+import com.fdkankan.contro.mq.service.impl.BuildSxRelocationServiceImpl;
+import com.fdkankan.contro.service.ICommonService;
+import com.fdkankan.contro.service.ISceneBuildProcessLogService;
+import com.fdkankan.model.constants.SceneBuildProcessType;
+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;
+import java.util.HashMap;
+
+@Slf4j
+@Component
+public class BuildSxRelocationListener {
+
+    @Value("${queue.modeling.sx-relocation-pre:sx-relocation-pre}")
+    private String queueModelingPre;
+    @Value("${queue.modeling.sx-relocation-post:sx-relocation-post}")
+    private String queueModelingPost;
+
+    @Autowired
+    private BuildSxRelocationServiceImpl buildSceneService;
+    @Autowired
+    private ISceneBuildProcessLogService sceneBuildProcessLogService;
+    @Autowired
+    private ICommonService commonService;
+
+    /**
+     * 场景计算前置资源准备处理
+     * @param channel
+     * @param message
+     * @throws Exception
+     */
+    @RabbitListener(
+            queuesToDeclare = @Queue("${queue.modeling.sx-relocation-pre:sx-relocation-pre}"),
+            concurrency = "5"
+    )
+    public void buildScenePreHandler(Channel channel, Message message) throws Exception {
+        String messageId = message.getMessageProperties().getMessageId();
+        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
+        HashMap<String, Object> map = JSON.parseObject(msg, HashMap.class);
+        String num = (String) map.get("num");
+        String path = (String) map.get("path");
+
+        BuildSceneCallMessage buildSceneMessage = new BuildSceneCallMessage();
+        buildSceneMessage.setSceneNum(num);
+        buildSceneMessage.setBizType("relocation");
+        buildSceneMessage.setPath(path);
+        buildSceneMessage.setCameraType("14");
+
+        log.info("开始准备重定位计算资源,队列名:{},id:{},消息体:{}", queueModelingPre, messageId, msg);
+        try {
+            //记录日志
+            sceneBuildProcessLogService.clearSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueModelingPre, "relocation");
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueModelingPre, CommonOperStatus.WAITING.code(), null, "relocation");
+            buildSceneService.buildScenePre(buildSceneMessage);
+            commonService.saveMqSendLog(num, buildSceneMessage, 0);
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueModelingPre, CommonOperStatus.SUCCESS.code(), null,"relocation");
+        }catch (Exception e){
+            log.error("重定位计算前置处理出错,num=" + num, e);
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueModelingPre, CommonOperStatus.FAILD.code(), ExceptionUtil.stacktraceToString(e, 3000), "relocation");
+        }
+        log.info("准备重定位计算资源完成,队列名:{},id:{},消息体:{}", queueModelingPre, messageId, msg);
+        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+    }
+
+    /**
+     * 场景计算后置结果处理
+     * @param channel
+     * @param message
+     * @throws Exception
+     */
+    @RabbitListener(
+            queuesToDeclare = @Queue("${queue.modeling.sx-relocation-post:sx-relocation-post}"),
+            concurrency = "5"
+    )
+    public void buildScenePostHandler(Channel channel, Message message) throws Exception {
+
+        String messageId = message.getMessageProperties().getMessageId();
+        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
+        log.info("场景重定位计算完成,开始处理计算结果,队列名:{},id:{},消息体:{}", queueModelingPost, messageId, msg);
+        BuildSceneResultMqMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneResultMqMessage.class);
+        String num = buildSceneMessage.getBuildContext().get("sceneNum").toString();
+        try {
+            sceneBuildProcessLogService.clearSceneBuildProcessLog(num, SceneBuildProcessType.POST.code(), queueModelingPost, "relocation");
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.POST.code(), queueModelingPost, CommonOperStatus.WAITING.code(), null, "relocation");
+            buildSceneService.buildScenePost(buildSceneMessage);
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.POST.code(), queueModelingPost, CommonOperStatus.SUCCESS.code(), null, "relocation");
+        }catch (Exception e){
+            log.error("场景重定位计算结果处理出错,num=" + num, e);
+            sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.POST.code(), queueModelingPost, CommonOperStatus.FAILD.code(), ExceptionUtil.stacktraceToString(e, 3000), "e57");
+        }
+        log.info("场景重定位计算结果处理完成,队列名:{},id:{},消息体:{}", queueModelingPost, messageId, msg);
+        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+    }
+}

+ 0 - 53
src/main/java/com/fdkankan/contro/mq/listener/BuildSxTestListener.java

@@ -1,53 +0,0 @@
-package com.fdkankan.contro.mq.listener;
-
-import com.fdkankan.contro.mq.service.impl.BuildSxTestServiceImpl;
-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;
-
-@Slf4j
-@Component
-public class BuildSxTestListener extends AbstrackBuildSceneListener {
-
-    @Value("${queue.modeling.sx.modeling-sx-pre:modeling-sx-pre}")
-    private String queueModelingPre;
-    @Value("${queue.modeling.sx.modeling-sx-post:modeling-sx-post}")
-    private String queueModelingPost;
-
-    @Autowired
-    private BuildSxTestServiceImpl buildSceneService;
-
-    /**
-     * 场景计算前置资源准备处理
-     * @param channel
-     * @param message
-     * @throws Exception
-     */
-    @RabbitListener(
-            queuesToDeclare = @Queue("${queue.modeling.sx.modeling-sx-pre:modeling-sx-pre}"),
-            concurrency = "5"
-    )
-    public void buildScenePreHandler(Channel channel, Message message) throws Exception {
-        preHandle(channel,queueModelingPre,message,buildSceneService, "relocation");
-    }
-
-    /**
-     * 场景计算后置结果处理
-     * @param channel
-     * @param message
-     * @throws Exception
-     */
-    @RabbitListener(
-            queuesToDeclare = @Queue("${queue.modeling.sx.modeling-sx-post:modeling-sx-post}"),
-            concurrency = "2"
-    )
-    public void buildScenePostHandler(Channel channel, Message message) throws Exception {
-        postHandle(channel,queueModelingPost,message,buildSceneService, "relocation");
-
-    }
-}

+ 16 - 156
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSxTestServiceImpl.java

@@ -1,7 +1,6 @@
 package com.fdkankan.contro.mq.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -46,7 +45,7 @@ import java.util.*;
 @Slf4j
 @Service
 @RefreshScope
-public class BuildSxTestServiceImpl implements IBuildSceneService {
+public class BuildSxRelocationServiceImpl implements IBuildSceneService {
 
     @Value("${queue.modeling.modeling-call}")
     private String queueModelingCall;
@@ -84,7 +83,6 @@ public class BuildSxTestServiceImpl implements IBuildSceneService {
         String num = message.getSceneNum();
         ScenePlus scenePlusByNum = scenePlusService.getScenePlusByNum(num);
         Map<String, Object> ext = message.getExt();
-        String qjkkNum = (String)ext.get("qjkkNum");
         try {
             //重新计算时需要删除文件夹,否知使用缓存
             if(new File(message.getPath() + File.separator + "results").exists()){
@@ -95,66 +93,22 @@ public class BuildSxTestServiceImpl implements IBuildSceneService {
                 FileUtils.deleteDirectory(message.getPath() + File.separator + "caches");
             }
 
-            //下载文件
-
-//            //删除点位校准数据
-//            if (Objects.nonNull(message.getExt())
-//                    && message.getExt().containsKey("deleteExtras")
-//                    && (Boolean) message.getExt().get("deleteExtras")) {
-//                String extras = String.format(UploadFilePath.scene_result_data_path, num).concat("extras");
-//                if(CollUtil.isNotEmpty(fYunFileService.listRemoteFiles(extras))){
-//                    fYunFileService.deleteFolder(extras);
-//                }
-//            }
-
-            //用户相机重新全量上传,需要解冻结
-//            sceneColdStorageService.unfreeze(num, "用户相机重新全量上传", message.getPath());
-
-            //根据相机类型,组装资源路径
-            //下载资源到本地
-//            this.downLoadSource(message, message.getPath());
-
-            //下载深巡的pose文件夹,并重命名为extras
-            Integer relocationMaxindex = scenePlusByNum.getRelocationMaxindex();
-            if(relocationMaxindex == null){
-                relocationMaxindex = -1;
-            }
-            String extrasPath = message.getPath() + "/extras/";
-            FileUtil.del(message.getPath());
-            fYunFileService.downloadFileByCommand(extrasPath, String.format(UploadFilePath.scene_result_data_path, num) + "pose/");
-            List<String> imgKeyList = fYunFileService.listRemoteFiles(String.format(UploadFilePath.IMG_VIEW_PATH, qjkkNum) + "panoramas/");
-            JSONObject query = new JSONObject();
-            JSONArray queryList = new JSONArray();
-            query.put("query", queryList);
-            for (String key : imgKeyList) {
-                String fileName = (++relocationMaxindex) + "." + FileUtil.extName(key);
-                fYunFileService.downloadFile(key, extrasPath + "images/query/" + fileName);
-                JSONObject fileNameObj = new JSONObject();
-                fileNameObj.put("filename", fileName);
-                queryList.add(fileNameObj);
-            }
-            //写query.json
-            FileUtil.writeUtf8String(query.toJSONString(), extrasPath + "query.json");
-            message.getExt().put("relocationMaxindex", relocationMaxindex);
-
-            //发送mq,就进行计算
             message.setResultReceiverMqName(queueModelingPost);
 
             ScenePlusExt scenePlusExtByPlusId = scenePlusExtService.getScenePlusExtByPlusId(scenePlusByNum.getId());
             String dataFdageKey = SceneUtil.getHomePath(scenePlusExtByPlusId.getDataSource()) + "data.fdage";
             JSONObject jsonObject = JSON.parseObject(fYunFileService.getFileContent(dataFdageKey));
-//            Map<String, String> dataMap = buildService.getTypeString(message.getCameraType(), message.getAlgorithm(), message.getResolution(),jsonObject);
-            Map<String, String> dataMap = new HashMap<>();
+            if (!ObjectUtils.isEmpty(modelType)) {
+                // 修改dataFdage文件
+                jsonObject.put("modelType", modelType);
+            }
+            Map<String, String> dataMap = buildService.getTypeString(message.getCameraType(), message.getAlgorithm(), message.getResolution(),jsonObject);
             dataMap.put("splitType", "SPLIT_V31");
-            dataMap.put("skyboxType", "SKYBOX_V6");
             buildService.writeDataJson(message, jsonObject, dataMap, null);
-            log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
-
         }catch (Exception e){
-            log.error("场景计算前置处理出错,num"+num, e);
             scenePlusByNum.setSceneStatus(SceneStatus.FAILD.code());
             scenePlusService.updateById(scenePlusByNum);
-            buildSceneDTService.handBaseFail("深巡场景重定资源准备异常!", message.getPath(), message.getSceneNum(), "计算控制服务器");
+            buildSceneDTService.handBaseFail("深巡场景重定位资源准备异常!", message.getPath(), message.getSceneNum(), "计算控制服务器");
             throw e;
         }
     }
@@ -179,6 +133,9 @@ public class BuildSxTestServiceImpl implements IBuildSceneService {
     public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
         String sceneCode = message.getBuildContext().get("sceneNum").toString();
         String path = message.getPath();
+        Map<String, Object> downParams = new HashMap<>();
+        downParams.put("sceneCode", sceneCode);
+        downParams.put("path", path);
         try {
             // 上传计算日志
             //如果是重复计算,没有走到计算逻辑,不需要上传日志文件
@@ -193,125 +150,32 @@ public class BuildSxTestServiceImpl implements IBuildSceneService {
                         .set(ScenePlus::getSceneStatus, SceneStatus.FAILD.code())
                         .eq(ScenePlus::getNum, sceneCode));
 
-//                //计算失败通知激光系统修改状态
-//                fdkkLaserService.updateStatus(sceneCode, 1);
-
                 // 发送钉钉消息,计算失败
                 buildSceneDTService.handModelFail("深巡场景重定向计算失败", message.getPath(), sceneCode, message.getHostName());
                 return;
             }
-//            JSONObject fdageData = commonService.getFdageData(path + File.separator + "capture" +File.separator+"data.fdage");
-
             ScenePlus scenePlus = scenePlusService.getScenePlusByNum(sceneCode);
-
             Map<String, String> uploadFiles = this.getUploadFiles(scenePlus,path);
 
             scenePlus.setPayStatus(PayStatus.PAY.code());
             scenePlus.setUpdateTime(new Date());
             scenePlus.setSceneStatus(SceneStatus.NO_DISPLAY.code());
 
-//            Integer videoVersion = fdageData.getInteger("videoVersion");
-            //读取计算结果文件生成videosJson
-//            JSONObject videosJson = commonService.getVideosJson(path, videoVersion, sceneCode, cameraType);
-
             ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
-//            boolean isObj = fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1;
-
-            //上传全景图俯视图
-//            this.uploadFloorCad(path, sceneCode, uploadFiles);
-
             log.info("开始上传场景计算结果数据,num:{}", sceneCode);
-            //由于3dtiles算法mesh文件发生变化,所以这里需要先清除一下oss的mesh目录,避免存在旧算法obj文件
-//            fYunFileService.deleteFolder(String.format(UploadFilePath.DATA_VIEW_PATH, sceneCode) + "mesh");
-//            fYunFileService.deleteFolder(String.format(UploadFilePath.IMG_VIEW_PATH,  sceneCode) + ModelKind.THREE_D_TILE.code());
             //上传文件
             fYunFileService.uploadMulFiles(uploadFiles);
 
-            //发送消息到点云系统处理
-            Map<String, String> aa = new HashMap<>();
-            aa.put("sceneCode", sceneCode);
-            aa.put("path", path);
-            mqProducer.sendByWorkQueue("laser-relocation-scene", aa);
-
-            //修改oss上dam的内容编码
-//            Map<String,String> damFileHeaders = new HashMap<>();
-//            damFileHeaders.put("Content-Encoding","gzip");
-//            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);
-
-            //计算完毕后,同步全景图到缓存目录
-//            this.cachePanorama(path, sceneCode);
-
-            //生成houseTypejson并上传
-//            boolean existHouseType = this.uploadHouseTypeJson(sceneCode, path);
-//            scenePlus.setHouseType(existHouseType ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code().intValue());
-
-            //生成floorpan.json
-//            commonService.uploadFloorplanJson(sceneCode, path);
-
-            //重置异步操作记录
-//            commonService.removeSceneAsynOperLog(sceneCode);
-
-            //清除用户编辑业务数据
-//            Set<String> bizs = new HashSet<>();
-//            bizs.add(UserEditDataType.BOX_MODEL.message());
-//            bizs.add(UserEditDataType.FLOORPLAN.message());
-//            bizs.add(UserEditDataType.FILTERS.message());
-//            commonService.initUserEditData(sceneCode, bizs, null);
-
-            //上传计算结果文件
-//            commonService.uploadBuildResultData(sceneCode, path, SceneVersionType.V4.code());
-
             //容量统计
             Long space = commonService.getSpace(sceneCode);
 
-            //ai识别
-//            aiService.detectScenePano(scenePlus, scenePlusExt, path);
-
-            //写入数据库
-//            this.updateDbPlus(scenePlus, scenePlusExt, space, videosJson.toJSONString(), message.getComputeTime(),isObj);
-
             Object[] editInfoArr = commonService.updateEditInfo(scenePlus);
-            SceneEditInfo sceneEditInfo = (SceneEditInfo)editInfoArr[0];
-            SceneEditInfoExt sceneEditInfoExt = (SceneEditInfoExt)editInfoArr[1];
-            SceneEditControls sceneEditControls = (SceneEditControls)editInfoArr[2];
 
             //如果相机容量不足,需要把场景的paystatus改为容量不足状态
             scenePlus.setPayStatus(commonService.getPayStatus(scenePlus.getCameraId(), space, new JSONObject()));
-            //统计原始资源大小
-//            scenePlusExt.setOrigSpace(FileUtil.size(new File(path.concat(File.separator).concat("capture"))));
-
-
-            log.info("生成scene.json上传oss并设置缓存,num:{}", sceneCode);
-//            CameraDetail cameraDetail = cameraDetailService.getByCameraId(scenePlus.getCameraId());
-//            Company company = !ObjectUtils.isEmpty(cameraDetail.getCompanyId()) ? companyService.getById(cameraDetail.getCompanyId()) : null;
-            //写scene.json
-//            commonService.writeSceneJson(sceneCode,sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus,scenePlusExt,company);
-
-//            String qrLogo = !ObjectUtils.isEmpty(company) && !ObjectUtils.isEmpty(company.getQrLogo()) ? company.getQrLogo() : null;
-//
-//            qrLogo = ObjectUtils.isEmpty(qrLogo) && !ObjectUtils.isEmpty(sceneEditInfoExt.getShareLogoImg()) ? fYunFileConfig.getHost().concat(sceneEditInfoExt.getShareLogoImg()) : null;
-//
-//            createQrCode(sceneCode, scenePlusExt, qrLogo);
-//
-//            //计算成功,通知APP
-//            Integer pushChannel = fdageData.getInteger("pushChannel");
-//            String pushToken = fdageData.getString("pushToken");
-//            this.pushMsgToApp(pushChannel,pushToken, cameraType, scenePlus.getTitle(), scenePlusExt.getWebSite());
-
-//            //删除计算目录
-//            if(CollUtil.isEmpty(notDeleteNasNumList) || !notDeleteNasNumList.contains(sceneCode)){
-//                CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/"));
-//            }
-
 
             this.uploadStatusJson(scenePlus, scenePlusExt);
 
-            Integer relocationMaxindex = Integer.valueOf(message.getExt().get("relocationMaxindex").toString());
-            scenePlus.setRelocationMaxindex(relocationMaxindex);
             scenePlusService.updateById(scenePlus);
             scenePlusExtService.updateById(scenePlusExt);
 
@@ -322,22 +186,18 @@ public class BuildSxTestServiceImpl implements IBuildSceneService {
                 commonService.sendEmail(sceneCode, "relocation");
             }
 
-            //发送到文保系统
-//            wbService.sendMq(sceneCode, CommonSuccessStatus.SUCCESS.code());
-
-            //四川日报打包消费
-//            this.sendMqToPackScene4Scrb(sceneCode);
-
+            //发送消息到点云系统处理
+            downParams.put("status", CommonSuccessStatus.SUCCESS.code());
             log.info("场景计算结果处理结束,场景码:{}", sceneCode);
 
         }catch (Exception e){
             log.error("场景计算结果处理出错,num"+sceneCode, e);
-
-            //计算失败通知激光系统修改状态
-//            fdkkLaserService.updateStatus(sceneCode, 1);
-
+            downParams.put("status", CommonSuccessStatus.FAIL.code());
             buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
             throw e;
+        } finally {
+            //发送消息到激光系统做处理
+            mqProducer.sendByWorkQueue("sx-relocation-done", downParams);
         }
     }