Ver código fonte

Merge branch 'release-swsx' into test

# Conflicts:
#	src/main/java/com/fdkankan/contro/entity/ScenePlus.java
dengsixing 15 horas atrás
pai
commit
c43c4aa71e

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

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

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

@@ -33,7 +33,7 @@ public class BuildSxTestListener extends AbstrackBuildSceneListener {
             concurrency = "5"
     )
     public void buildScenePreHandler(Channel channel, Message message) throws Exception {
-        preHandle(channel,queueModelingPre,message,buildSceneService, "sxTest");
+        preHandle(channel,queueModelingPre,message,buildSceneService, "relocation");
     }
 
     /**
@@ -47,7 +47,7 @@ public class BuildSxTestListener extends AbstrackBuildSceneListener {
             concurrency = "2"
     )
     public void buildScenePostHandler(Channel channel, Message message) throws Exception {
-        postHandle(channel,queueModelingPost,message,buildSceneService, "sxTest");
+        postHandle(channel,queueModelingPost,message,buildSceneService, "relocation");
 
     }
 }

+ 176 - 30
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSxTestServiceImpl.java

@@ -8,12 +8,12 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.common.constant.*;
 import com.fdkankan.common.util.FileUtils;
-import com.fdkankan.contro.entity.ScenePlus;
-import com.fdkankan.contro.entity.ScenePlusExt;
+import com.fdkankan.contro.entity.*;
 import com.fdkankan.contro.mq.service.IBuildSceneService;
 import com.fdkankan.contro.service.*;
 import com.fdkankan.fyun.config.FYunFileConfig;
 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.enums.ModelTypeEnums;
@@ -23,6 +23,7 @@ import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
 import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
@@ -81,6 +82,8 @@ public class BuildSxTestServiceImpl implements IBuildSceneService {
     @Override
     public void buildScenePre(BuildSceneCallMessage message) throws Exception{
         String num = message.getSceneNum();
+        Map<String, Object> ext = message.getExt();
+        String qjkkNum = (String)ext.get("qjkkNum");
         try {
             //重新计算时需要删除文件夹,否知使用缓存
             if(new File(message.getPath() + File.separator + "results").exists()){
@@ -110,22 +113,41 @@ public class BuildSxTestServiceImpl implements IBuildSceneService {
             //下载资源到本地
 //            this.downLoadSource(message, message.getPath());
 
-            //TODO 等算法文档出来 下载文件
-
+            //下载深巡的pose文件夹,并重命名为extras
+            ScenePlus scenePlusByNum = scenePlusService.getScenePlusByNum(num);
+            Integer relocationMaxindex = scenePlusByNum.getRelocationMaxindex();
+            if(relocationMaxindex == null){
+                relocationMaxindex = -1;
+            }
+            String extrasPath = message.getPath() + "/extras/";
+            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/" + (relocationMaxindex++) + "." + FileUtil.extName(key));
+                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);
 
             JSONObject fdageData = commonService.getFdageData(message.getPath() + File.separator + "capture" + File.separator + "data.fdage");
-
-            //TODO 等算法文档出来 修改参数
-            buildService.writeDataJson(message, fdageData, null, null);
-
+            Map<String, String> dataMap = buildService.getTypeString(message.getCameraType(), message.getAlgorithm(), message.getResolution(), fdageData);
+            dataMap.put("splitType", "SPLIT_V31");
+            buildService.writeDataJson(message, fdageData, dataMap, null);
             log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
 
         }catch (Exception e){
             log.error("场景计算前置处理出错,num"+num, e);
-            buildSceneDTService.handBaseFail("场景计算资源准备异常!", message.getPath(), message.getSceneNum(), "计算控制服务器");
+            buildSceneDTService.handBaseFail("深巡场景重定向资源准备异常!", message.getPath(), message.getSceneNum(), "计算控制服务器");
             throw e;
         }
     }
@@ -158,79 +180,165 @@ public class BuildSxTestServiceImpl implements IBuildSceneService {
             fYunFileService.uploadFile(path + File.separator + "console.log", buildLogPath + "console.log");
             log.info("计算日志上传完成");
 
-            JSONObject fdageData = commonService.getFdageData(path + File.separator + "capture" +File.separator+"data.fdage");
-
             if (!message.getBuildSuccess()) {
                 log.error("建模失败,修改状态为失败状态");
                 scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
                         .set(ScenePlus::getSceneStatus, SceneStatus.FAILD.code())
                         .eq(ScenePlus::getNum, sceneCode));
 
-                //推送到全景看看
-                intermitSceneService.sendMq(sceneCode, fdageData, CommonSuccessStatus.FAIL.code());
+//                //计算失败通知激光系统修改状态
+//                fdkkLaserService.updateStatus(sceneCode, 1);
 
                 // 发送钉钉消息,计算失败
-                buildSceneDTService.handModelFail("计算失败", message.getPath(), sceneCode, message.getHostName());
+                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);
 
-            Integer cameraType = Integer.parseInt(message.getBuildContext().get("cameraType").toString());
-            Map<String, String> uploadFiles = getUploadFiles(scenePlus,path);
+            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");
+//            Integer videoVersion = fdageData.getInteger("videoVersion");
             //读取计算结果文件生成videosJson
-            JSONObject videosJson = commonService.getVideosJson(path, videoVersion, sceneCode, cameraType);
+//            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.getSceneSource(), space, videosJson.toJSONString(), message.getComputeTime(),false,scenePlusExt);
+//            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"))));
-
-            //删除计算目录
-            if(CollUtil.isEmpty(notDeleteNasNumList) || !notDeleteNasNumList.contains(sceneCode)){
-                CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/"));
-            }
+//            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, "/"));
+//            }
 
-            //如果相机容量不足,需要把场景的paystatus改为容量不足状态
-            scenePlus.setPayStatus(commonService.getPayStatus(scenePlus.getCameraId(), space, fdageData));
 
             this.uploadStatusJson(scenePlus, scenePlusExt);
 
             scenePlusService.updateById(scenePlus);
             scenePlusExtService.updateById(scenePlusExt);
 
-            //推送到全景看看
-            intermitSceneService.sendMq(sceneCode, fdageData, CommonSuccessStatus.SUCCESS.code());
+            //国际环境需要发邮件通知
+            if("eur".equals(env) &&
+                    !scenePlus.getSceneSource().equals(SceneSource.JG.code()) &&
+                    !scenePlus.getSceneSource().equals(SceneSource.SG.code())){
+                commonService.sendEmail(sceneCode, "relocation");
+            }
+
+            //发送到文保系统
+//            wbService.sendMq(sceneCode, CommonSuccessStatus.SUCCESS.code());
+
+            //四川日报打包消费
+//            this.sendMqToPackScene4Scrb(sceneCode);
 
             log.info("场景计算结果处理结束,场景码:{}", sceneCode);
 
         }catch (Exception e){
             log.error("场景计算结果处理出错,num"+sceneCode, e);
+
+            //计算失败通知激光系统修改状态
+//            fdkkLaserService.updateStatus(sceneCode, 1);
+
             buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
             throw e;
         }
     }
 
     private Map<String, String> getUploadFiles(ScenePlus scenePlus,String path) throws Exception {
+        if (ObjectUtils.isEmpty(scenePlus)) {
+            throw new Exception("未找到场景信息:" + path);
+        }
+
         String projectNum = scenePlus.getNum();
+
         String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, projectNum);
         String imagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, projectNum);
         String videoPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, projectNum);
@@ -253,10 +361,48 @@ public class BuildSxTestServiceImpl implements IBuildSceneService {
                 throw new Exception(filePath + "文件不存在");
             }
 
-            if(fileJson.getIntValue("clazz") == 1 || fileJson.getIntValue("clazz") == 22 || fileJson.getIntValue("clazz") == 3 || fileJson.getIntValue("clazz") == 5){
+            if ("vision2.txt".equals(fileName)) {
+                CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision2.txt", resultsPath + "vision2.modeldata");
+                map.put(resultsPath + "vision2.modeldata", imagesPath + "vision2.modeldata");
+                map.put(resultsPath + "vision2.txt", imagesPath + "vision2.txt");
+            }
+
+            if (fileJson.getIntValue("clazz") == 2) {
+                map.put(filePath, imagesPath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/" + fileName.replace("tex/", ""));
+            } else if (fileJson.getIntValue("clazz") == 3) {
+                map.put(filePath, imagesPath + "pan/high/" + fileName.replace("high/", ""));
+            } else if (fileJson.getIntValue("clazz") == 4) {
+                map.put(filePath, imagesPath + "pan/low/" + fileName.replace("low/", ""));
+            } else if (fileJson.getIntValue("clazz") == 5) {
                 map.put(filePath, imagesPath + fileName);
+            } else if (fileJson.getIntValue("clazz") == 7) {
+                map.put(filePath, imagesPath + fileName);
+            } else if (fileJson.getIntValue("clazz") == 10) {
+                String updown = FileUtils.readFile(filePath);
+                JSONObject updownJson = JSONObject.parseObject(updown);
+                String mappingOssPath = String.format("scene_edit_data/%s/data/", projectNum) + fileName.replace("updown", "mapping");
+                map.put(filePath, mappingOssPath);
+            } else {
+                if (fileJson.getIntValue("clazz") == 11 || fileJson.getIntValue("clazz") == 12) {
+                    map.put(filePath, videoPath + fileName.replace("videos/", ""));
+                    if (fileName.contains(".mp4")) {
+                        map.put(resultsPath + fileName.replace("mp4", "flv"), videoPath + fileName.replace("videos/", "").replace("mp4", "flv"));
+                    }
+                }
+
+                if (fileJson.getIntValue("clazz") == 16) {
+                    map.put(filePath, dataViewPath + fileName);
+                }
+
+                if (fileJson.getIntValue("clazz") == 18) {
+                    map.put(filePath, imagesPath + fileName);
+                }
             }
         }
+
+        CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision.txt", resultsPath + "vision.modeldata");
+        map.put(resultsPath + "vision.txt", imagesPath + "vision.txt");
+        map.put(resultsPath + "vision.modeldata", imagesPath + "vision.modeldata");
         return map;
     }
 

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

@@ -220,6 +220,13 @@ public class CommonServiceImpl implements ICommonService {
             fYunFileServiceInterface.uploadFileByCommand(localExtras, ossExtras);
         }
 
+        //上传post文件,用于深巡全景图重定位计算
+        String localPose = dataSource + "/result/pose";
+        String ossPose = ossResultPath + "pose";
+        if(FileUtil.exist(localExtras)){
+            fYunFileServiceInterface.uploadFileByCommand(localPose, ossPose);
+        }
+
         //开始上传
         fYunFileServiceInterface.uploadMulFiles(uploadMap);
     }

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

@@ -397,9 +397,9 @@ public class InnerServiceImpl implements IInnerService {
         ScenePlusExt scenePlusExtByPlusId = scenePlusExtService.getScenePlusExtByPlusId(sxScene.getId());
         BuildSceneCallMessage buildSceneCallMessage = new BuildSceneCallMessage();
         buildSceneCallMessage.setSceneNum(sxNum);
-        buildSceneCallMessage.setBizType("sxTest");
+        buildSceneCallMessage.setBizType("relocation");
         buildSceneCallMessage.setExt(params);
-        buildSceneCallMessage.setPath(scenePlusExtByPlusId.getDataSource());
+        buildSceneCallMessage.setPath(scenePlusExtByPlusId.getDataSource() + "_relocation");
         mqProducer.sendByWorkQueue("modeling-sx-pre", buildSceneCallMessage);
 
         sxScene.setSceneStatus(SceneStatus.wait.code());