浏览代码

Merge branch 'release' into feature-managev2.1.2-20230128-dsx

# Conflicts:
#	src/main/java/com/fdkankan/contro/mq/service/impl/BuildObjServiceImpl.java
dsx 2 年之前
父节点
当前提交
e566501753

+ 5 - 0
src/main/java/com/fdkankan/contro/bean/SceneJsonBean.java

@@ -118,6 +118,11 @@ public class SceneJsonBean {
     private String sceneKind;
 
     /**
+     * dam,3dtiles
+     */
+    private String modelKind;
+
+    /**
      * 空间视频数据
      */
     private String boxVideos;

+ 6 - 0
src/main/java/com/fdkankan/contro/entity/ScenePlusExt.java

@@ -125,6 +125,12 @@ public class ScenePlusExt implements Serializable {
     private String sceneKind;
 
     /**
+     * 算法模型类型(dam,3dtiles)
+     */
+    @TableField("model_kind")
+    private String modelKind;
+
+    /**
      * 计算耗时
      */
     @TableField("compute_time")

+ 59 - 31
src/main/java/com/fdkankan/contro/mq/service/impl/BuildObjServiceImpl.java

@@ -1,9 +1,12 @@
 package com.fdkankan.contro.mq.service.impl;
 
 import cn.hutool.core.exceptions.ExceptionUtil;
+import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.common.constant.CommonOperStatus;
+import com.fdkankan.common.constant.CommonStatus;
+import com.fdkankan.common.constant.ModelKind;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.contro.entity.ScenePlus;
 import com.fdkankan.contro.entity.ScenePro;
@@ -27,6 +30,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
 import java.io.File;
+import java.util.List;
+import java.util.Objects;
 
 /**
  * <p>
@@ -49,6 +54,9 @@ public class BuildObjServiceImpl implements IBuildSceneService {
     @Value("${queue.modeling.obj.modeling-pre}")
     private String queueObjModelingPre;
 
+    @Value("${model.modelKind:3dtiles}")
+    private String modelKind;
+
     @Autowired
     private RabbitMqProducer mqProducer;
 
@@ -141,6 +149,7 @@ public class BuildObjServiceImpl implements IBuildSceneService {
         String prevoisPath = message.getBuildContext().get("previousPath").toString();
         FileUtils.copyFile(prevoisPath + "/caches/reconstruction/final.bin", path + "/caches/reconstruction/final.bin", true);
         FileUtils.copyFile(prevoisPath + "/caches/reconstruction/chunk.json", path + "/caches/reconstruction/chunk.json", true);
+        FileUtils.copyFile(prevoisPath + "/caches/floor_group_fix.json", path + "/caches/floor_group_fix.json", true);
         FileUtils.copyDirectiory(prevoisPath + "/caches/images", path + "/caches/images");
 
         FileUtils.copyDirectiory(prevoisPath + "/caches/depthmap_csc", path + "/caches/depthmap_csc");
@@ -164,47 +173,67 @@ public class BuildObjServiceImpl implements IBuildSceneService {
                 return;
             }
 
+            String path = message.getPath();
             String laserObjFilePath = path;
-            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);
+            String projectNum = message.getBuildContext().get("sceneNum").toString();
+            ScenePro scenePro = sceneProService.getByNum(projectNum);
+            String version = "v4";
+            String ossImagePath = String.format(UploadFilePath.IMG_VIEW_PATH,  projectNum);
+            //如果是微服务上线之前的存量场景且未生成过obj(未升级过),需要上传到v3的目录,在函数最后调用升级接口进行文件拷贝
+            if(Objects.nonNull(scenePro) && scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue()){
+                ossImagePath = String.format(ConstantFilePath.IMAGE_PATH_FORMAT, projectNum);
+                version = "v3";
+            }
+            //上传obj
+            String resultsPath = path + File.separator + "results" + File.separator;
+            if(this.modelKind.equals(ModelKind.DAM.code())){
+                CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
+                CreateObjUtil.convertDamToLzma(path + File.separator + "results/");
+                CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
+                File file = new File(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma");
+                while (!file.exists()) {
+                    Thread.sleep(60000);
+                }
+                fYunFileService.uploadFile(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", ossImagePath + ConstantFileName.modelUUID + "_50k.dam.lzma");
+                fYunFileService.uploadFile(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", ossImagePath + ConstantFileName.modelUUID + "_50k.dam");
+            }
+            if(this.modelKind.equals(ModelKind.THREE_D_TILE.code())){
+                String threedtilesPath = resultsPath + ModelKind.THREE_D_TILE.code();
+                String oss3dtilesPath = ossImagePath + ModelKind.THREE_D_TILE.code();
+                List<String> list = FileUtils.list(new File(threedtilesPath));
+                if(CollUtil.isEmpty(list)){
+                    log.error("3dtiles目录异常,3dtiles地址:{}", new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
+                    throw new Exception("3dtiles目录异常");
+                }
+                //上传3dtiles文件
+                fYunFileService.uploadFileByCommand(threedtilesPath, oss3dtilesPath);
             }
 
-            fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", String.format(UploadFilePath.IMG_VIEW_PATH,  projectNum) + ConstantFileName.modelUUID + "_50k.dam.lzma");
-            fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", String.format(UploadFilePath.IMG_VIEW_PATH,  projectNum) + ConstantFileName.modelUUID + "_50k.dam");
-
-            String texPath = laserObjFilePath + File.separator + "results" + File.separator + "tex";
+                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(),
-                                String.format(UploadFilePath.IMG_VIEW_PATH,  projectNum) + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/"+textureFile.getName());
+                            ossImagePath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/"+textureFile.getName());
                     }
                 }
             }
 
             fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + "tex/texture1.jpg",
-                    String.format(UploadFilePath.IMG_VIEW_PATH,  projectNum) + "/" + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/texture1.jpg");
+                    ossImagePath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/texture1.jpg");
 
-            // 拷贝结果
-            log.info("开始拷贝obj文件");
-            FileUtils.copyFolderAllFiles(laserObjFilePath + "/results/mesh", laserObjFilePath + "/laserData/mesh/", true);
+                // 拷贝结果
+                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());
-            }
+            //上传mesh文件
+            fYunFileService.uploadFileByCommand(laserObjFilePath + "/results/mesh", String.format(UploadFilePath.DATA_VIEW_PATH,  projectNum) + "mesh");
 
             fdkkLaserService.pushBuildStatusToLaserSystem(projectNum, laserObjFilePath + "/laserData/mesh");
 
 
-            ScenePro scenePro = sceneProService.getByNum(projectNum);
             if(!ObjectUtils.isEmpty(scenePro)){
                 LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<ScenePro>()
                         .set(ScenePro::getStatus, -2).eq(ScenePro::getNum, projectNum);
@@ -213,18 +242,17 @@ public class BuildObjServiceImpl implements IBuildSceneService {
                         .eq(SceneProEdit::getProId,scenePro.getId()));
             }
 
-            ScenePlus scenePlus = scenePlusService.getScenePlusByNum(projectNum);
-            if(!ObjectUtils.isEmpty(scenePlus)){
-                LambdaUpdateWrapper<ScenePlus> plusUpdateWrapper = new LambdaUpdateWrapper<ScenePlus>()
-                        .set(ScenePlus::getSceneStatus, -2).eq(ScenePlus::getNum, projectNum);
-                scenePlusService.update(plusUpdateWrapper);
-            }
+                ScenePlus scenePlus = scenePlusService.getScenePlusByNum(projectNum);
+                if(!ObjectUtils.isEmpty(scenePlus)){
+                    LambdaUpdateWrapper<ScenePlus> plusUpdateWrapper = new LambdaUpdateWrapper<ScenePlus>()
+                            .set(ScenePlus::getSceneStatus, -2).eq(ScenePlus::getNum, projectNum);
+                    scenePlusService.update(plusUpdateWrapper);
+                }
 
             // 如果未升级V4,则升级V4
-            fdkkV4Service.upgradeToV4(projectNum);
-
-            success = true;
-
+            if("v3".equals(version)){
+                fdkkV4Service.upgradeToV4(projectNum);
+            }
         }catch (Exception e){
             log.error("生成OBJ场景计算结果处理异常,num=" + projectNum, e);
             throw e;

+ 33 - 12
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -81,6 +81,9 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     @Value("${model.type:#{null}}")
     private String modelType;
 
+    @Value("${model.modelKind:3dtiles}")
+    private String modelKind;
+
     @Autowired
     private RabbitMqProducer mqProducer;
 
@@ -249,7 +252,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             scenePlus.setSceneStatus(SceneStatus.NO_DISPLAY.code());
             scenePlusService.updateById(scenePlus);
 
-
             Integer videoVersion = fdageData.getInteger("videoVersion");
             //读取计算结果文件生成videosJson
             JSONObject videosJson = this.getVideosJson(path, videoVersion, sceneCode, cameraType);
@@ -267,16 +269,18 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             //上传全景图俯视图
             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.uploadMulFiles(uploadFiles);
 
             Map<String,String> damFileHeaders = new HashMap<>();
             damFileHeaders.put("Content-Encoding","gzip");
-
-            if (!fYunFileService.getFyunType().equals(FYunTypeEnum.LOCAL.code())) {
-                // dam 文件设置请求头
-                uploadFiles.entrySet().stream().filter(entry -> FileNameUtil.extName(entry.getKey()).equals("dam"))
+            if (!ObjectUtils.isEmpty(cameraType) && !cameraType.equals(14)) {
+                if (!fYunFileService.getFyunType().equals(FYunTypeEnum.LOCAL.code())) {
+                    // dam 文件设置请求头
+                    uploadFiles.entrySet().stream().filter(entry -> FileNameUtil.extName(entry.getKey()).equals("dam"))
                         .forEach(entry -> {
                             if (!new File(entry.getKey()).exists()) {
                                 log.error("文件不存在,不予gzip压缩,文件路径:{}", entry.getKey());
@@ -288,6 +292,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
                             FileUtil.rename(new File(entry.getKey() + ".gzip"), entry.getKey(), true);
                             fYunFileService.uploadFile(entry.getKey(), entry.getValue(), damFileHeaders);
                         });
+                }
             }
 
             //拷贝部分文件到编辑目录,用于用户编辑
@@ -303,9 +308,6 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             //重置异步操作记录
             this.removeSceneAsynOperLog(sceneCode);
 
-            //写scene.json
-
-
             log.info("生成scene.json上传oss并设置缓存,num:{}", sceneCode);
             CameraDetail cameraDetail = cameraDetailService.getByCameraId(scenePlus.getCameraId());
             Company company = !ObjectUtils.isEmpty(cameraDetail.getCompanyId()) ? companyService.getById(cameraDetail.getCompanyId()) : null;
@@ -318,6 +320,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
                 sceneEditControls.setShowMap(0);
             }
 
+            //写scene.json
             this.writeSceneJson(sceneCode, videosJson,sceneEditInfo, sceneEditInfoExt, sceneEditControls, scenePlus,scenePlusExt,company);
 
             String qrLogo = !ObjectUtils.isEmpty(company) && !ObjectUtils.isEmpty(company.getQrLogo()) ? company.getQrLogo() : null;
@@ -448,9 +451,8 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             }
         }
 
-
-        if ((fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1)
-                || (!ObjectUtils.isEmpty(cameraType) && (!cameraType.equals(14)))) {
+        //exportMeshObj这个是字段由app写入的
+        if (!ObjectUtils.isEmpty(cameraType) && cameraType != 14) {
             CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
             CreateObjUtil.convertDamToLzma(path + File.separator + "results/");
             CreateObjUtil.convertTxtToDam(path + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
@@ -458,6 +460,20 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             map.put(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", imagesPath + ConstantFileName.modelUUID + "_50k.dam");
         }
 
+        if(this.modelKind.equals(ModelKind.THREE_D_TILE.code())
+                && (!ObjectUtils.isEmpty(cameraType) && cameraType == 14 )//是激光场景
+                && (fdageData.containsKey("exportMeshObj") && fdageData.getIntValue("exportMeshObj") == 1)//选择生成obj
+        ){
+            List<String> list = FileUtils.list(new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
+            if(CollUtil.isEmpty(list)){
+                log.error("3dtiles目录异常,3dtiles地址:{}", new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
+                throw new Exception("3dtiles目录异常");
+            }
+            list.stream().forEach(str->{
+                map.put(str, str.replace(path + File.separator + "results" + File.separator, imagesPath));
+            });
+        }
+
         CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision.txt", resultsPath + "vision.modeldata");
         map.put(resultsPath + "vision.txt", imagesPath + "vision.txt");
         map.put(resultsPath + "vision.modeldata", imagesPath + "vision.modeldata");
@@ -523,6 +539,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         sceneJson.setImgVersion(sceneEditInfo.getImgVersion());
         sceneJson.setSceneFrom(scenePlusExt.getSceneFrom());
         sceneJson.setSceneKind(scenePlusExt.getSceneKind());
+        sceneJson.setModelKind(scenePlusExt.getModelKind());
         sceneJson.setVideos(JSON.toJSONString(videosJson));
         sceneJson.setPayStatus(scenePlus.getPayStatus());
 
@@ -593,6 +610,8 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +".png";
         String outPathEn = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +"_en.png";
         QrConfig qrConfig = QrConfig.create();
+        qrConfig.setWidth(512);
+        qrConfig.setHeight(512);
         if(!ObjectUtils.isEmpty(localLogoPath)){
             qrConfig.setImg(localLogoPath);
         }
@@ -826,6 +845,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
 
         String sceneKind = scenePlusExt.getSceneScheme() == 3 ? SceneKind.FACE.code():SceneKind.TILES.code();
         scenePlusExt.setSceneKind(sceneKind);
+//        scenePlusExt.setModelKind(modelKind);
 
         scenePlusExtService.updateById(scenePlusExt);
     }
@@ -867,6 +887,7 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
             sceneEditInfo.setVersion(sceneEditInfo.getVersion() + 1);
             sceneEditInfo.setImgVersion(sceneEditInfo.getImgVersion() + 1);
+            sceneEditInfo.setIsUploadObj(CommonStatus.NO.code());
             sceneEditInfoService.updateById(sceneEditInfo);
         }
         if(sceneEditControls == null){

+ 48 - 6
src/main/java/com/fdkankan/contro/mq/service/impl/BuildV3SceneServiceImpl.java

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.common.constant.CommonOperStatus;
 import com.fdkankan.common.constant.ExpiredStatus;
+import com.fdkankan.common.constant.ModelKind;
 import com.fdkankan.common.constant.PayStatus;
 import com.fdkankan.common.constant.SceneStatus;
 import com.fdkankan.common.util.FileUtils;
@@ -72,6 +73,9 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
     @Value("${model.type:#{null}}")
     private String modelSceneKind;
 
+    @Value("${model.modelKind:3dtiles}")
+    private String modelKind;
+
     @Autowired
     private RabbitMqProducer mqProducer;
 
@@ -111,6 +115,12 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
         boolean success = false;
         String num = message.getSceneNum();
         try {
+
+            //重新计算时需要删除文件夹,否知使用缓存
+            if(new File(message.getPath() + File.separator + "results").exists()){
+                FileUtils.deleteDirectory(message.getPath() + File.separator + "results");
+            }
+
             //根据相机类型,组装资源路径
             //下载资源到本地
             this.downLoadSource(message, message.getPath());
@@ -237,17 +247,23 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
             Map<String,String> damFileHeaders = new HashMap<>();
             damFileHeaders.put("Content-Encoding","gzip");
 
-            if (!fYunFileService.getFyunType().equals(FYunTypeEnum.LOCAL.code())) {
-                // dam 文件设置请求头
-                uploadFiles.entrySet().stream().filter(entry -> FileNameUtil.extName(entry.getKey()).equals("dam"))
+            if(modelKind.equals(ModelKind.DAM.code())) {
+                if (!fYunFileService.getFyunType().equals(FYunTypeEnum.LOCAL.code())) {
+                    // dam 文件设置请求头
+                    uploadFiles.entrySet().stream()
+                        .filter(entry -> FileNameUtil.extName(entry.getKey()).equals("dam"))
                         .filter(entry -> new File(entry.getKey()).exists())
                         .forEach(entry -> {
                             // gzip压缩
-                            FileUtil.writeBytes(ZipUtil.gzip(new File(entry.getKey())), entry.getKey() + ".gzip");
+                            FileUtil.writeBytes(ZipUtil.gzip(new File(entry.getKey())),
+                                entry.getKey() + ".gzip");
                             // 重命名
-                            FileUtil.rename(new File(entry.getKey() + ".gzip"), entry.getKey(), true);
-                            fYunFileService.uploadFile(entry.getKey(), entry.getValue(), damFileHeaders);
+                            FileUtil
+                                .rename(new File(entry.getKey() + ".gzip"), entry.getKey(), true);
+                            fYunFileService
+                                .uploadFile(entry.getKey(), entry.getValue(), damFileHeaders);
                         });
+                }
             }
 
             //生成houseTypejson并上传
@@ -360,6 +376,32 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
             map.put(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", imagesPath + ConstantFileName.modelUUID + "_50k.dam.lzma");
             map.put(path + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", imagesPath + ConstantFileName.modelUUID + "_50k.dam");
         }
+        // TODO: 2023/1/12 3dtiles临时上激光场景
+        //这里适配旧算法和新算法,生成obj|上传3dtiles
+//        if (!ObjectUtils.isEmpty(cameraType) && (!cameraType.equals(14))){
+//            if(this.modelKind.equals(ModelKind.DAM.code())){
+//                CreateObjUtil.convertTxtToDam(resultsPath + "tex" + File.separator + "modeldata.txt", resultsPath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
+//                CreateObjUtil.convertDamToLzma(resultsPath + File.separator + "results/");
+//                CreateObjUtil.convertTxtToDam(resultsPath + File.separator + "results" + File.separator + "tex" + File.separator + "modeldata.txt", resultsPath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam");
+//                File file = new File(resultsPath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma");
+//                while (!file.exists()) {
+//                    Thread.sleep(60000);
+//                }
+//                fYunFileService.uploadFile(resultsPath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam.lzma", imagesPath + ConstantFileName.modelUUID + "_50k.dam.lzma");
+//                fYunFileService.uploadFile(resultsPath + File.separator + "results" + File.separator + ConstantFileName.modelUUID + "_50k.dam", imagesPath + ConstantFileName.modelUUID + "_50k.dam");
+//            }
+//            if(this.modelKind.equals(ModelKind.THREE_D_TILE.code())){
+//                String threedtilesPath = resultsPath + ModelKind.THREE_D_TILE.code();
+//                String oss3dtilesPath = imagesPath + ModelKind.THREE_D_TILE.code();
+//                List<String> list = FileUtils.list(new File(threedtilesPath));
+//                if(CollUtil.isEmpty(list)){
+//                    log.error("3dtiles目录异常,3dtiles地址:{}", new File(path + File.separator + "results" + File.separator + ModelKind.THREE_D_TILE.code()));
+//                    throw new Exception("3dtiles目录异常");
+//                }
+//                //上传3dtiles文件
+//                fYunFileService.uploadFileByCommand(threedtilesPath, oss3dtilesPath);
+//            }
+//        }
 
         CreateObjUtil.convertTxtToVisionmodeldata(resultsPath + "vision.txt", resultsPath + "vision.modeldata");
         map.put(resultsPath + "vision.txt", imagesPath + "vision.txt");

+ 0 - 5
src/main/java/com/fdkankan/contro/service/impl/FdkkV4Service.java

@@ -38,11 +38,6 @@ public class FdkkV4Service {
     public void upgradeToV4(String num){
         // 如果场景在旧表中存在,则需要升级,否则不需要升级
         ScenePro scenePro = sceneProService.getByNum(num);
-        if(ObjectUtils.isEmpty(scenePro)){
-            log.error("scene_pro 表中不存在该记录,退出升级!");
-            return;
-        }
-
         String url = mainUrl + String.format(UPGRADE_TO_V4,num);
         log.info("v3场景升级v4,url:{}",url);
         ResponseEntity<Result> responseEntity = restTemplate.getForEntity(url, Result.class);

+ 68 - 25
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.qrcode.QrCodeUtil;
 import cn.hutool.extra.qrcode.QrConfig;
 import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -85,6 +86,9 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     @Value("${v3.controlUrl:#{null}}")
     private String v3controlUrl;
 
+    @Value("${model.modelKind:3dtiles}")
+    private String modelKind;
+
     @Value("${build.notSupport.beforeTime:202203}")
     private String jgNotSupportBuildTime;
 
@@ -92,6 +96,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     private RedisUtil redisUtil;
 
 
+
     @Autowired
     private IScenePlusExtService scenePlusExtService;
 
@@ -513,6 +518,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +".png";
         String outPathEn = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+ num +"_en.png";
         QrConfig qrConfig = QrConfig.create();
+        qrConfig.setWidth(512);
+        qrConfig.setHeight(512);
         if(!org.apache.commons.lang3.ObjectUtils.isEmpty(localLogoPath)){
             qrConfig.setImg(localLogoPath);
         }
@@ -581,12 +588,14 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             }
         }
 
-        ResultData ok = callV3(preParams, fdageJson,"api/scene/file/uploadSuccessBuild");
-        if (ok != null) return ok;
-
         // 判断是否是V3的场景
         ScenePro scenePro = sceneProService.getOne(
-                new LambdaQueryWrapper<ScenePro>().like(ScenePro::getDataSource, fileId));
+            new LambdaQueryWrapper<ScenePro>().like(ScenePro::getDataSource, fileId));
+
+        boolean callV3 = callV3(scenePro, preParams, fdageJson, "api/scene/file/uploadSuccessBuild");
+        if(callV3) return ResultData.ok();
+
+
         if (ObjectUtils.isEmpty(scenePro) || (!ObjectUtils.isEmpty(scenePro.getIsUpgrade()) && scenePro.getIsUpgrade() == 1)) {
             buildScene(fileId, prefixBuffer.toString(),fdageJson,buildType,cameraType);
         }else{
@@ -595,7 +604,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         return ResultData.ok();
     }
 
-    private ResultData callV3(String preParams, JSONObject fdageJson,String api) {
+    private boolean callV3(ScenePro scenePro, String preParams, JSONObject fdageJson,String api) throws Exception {
         String cameraName = fdageJson.getJSONObject("cam").getString("uuid");
 
         Camera camera = cameraService.getByChildName(cameraName);
@@ -609,7 +618,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             log.error("该相机详情不存在:" + cameraName);
             throw new BusinessException(CameraConstant.FAILURE_6003);
         }
-        // 判断是否是正顺的场景,如果是正顺的场景,则发送到原来的系统进行计算
+        // 判断是否是正顺|火调|普通v3的场景,如果是正顺|火调|普通v3的场景,则发送到原来的系统进行计算
         if (!ObjectUtils.isEmpty(cameraDetail.getCompanyId())) {
             Company company = companyService.getById(cameraDetail.getCompanyId());
             if(ObjectUtils.isEmpty(company)){
@@ -617,18 +626,25 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
                 throw new BusinessException(CameraConstant.FAILURE_6003);
             }
             if (!ObjectUtils.isEmpty(company.getSceneVersion()) && company.getSceneVersion().equals("V3")) {
-                callV3Service(preParams,api);
-                return ResultData.ok();
+                callV3Service(preParams, api);
+                return Boolean.TRUE;
             }
         }
-        return null;
+        // TODO: 2023/1/12 3dtiles临时上激光场景
+//        else if (Objects.nonNull(scenePro) &&
+//            scenePro.getSceneSource() != SceneSource.JG.code() &&
+//            scenePro.getIsUpgrade() == CommonStatus.NO.code().intValue()){
+//            callV3Service(preParams,api);
+//            return Boolean.TRUE;
+//        }
+        return Boolean.FALSE;
     }
 
-    public void callV3Service(String params,String api){
+    public void callV3Service(String params,String api) throws Exception {
         log.info("params:{}", params);
         if(ObjectUtils.isEmpty(v3controlUrl)){
             log.error("未配置V3服务器!");
-            return;
+            throw new Exception("未配置V3服务器!");
         }
         HttpHeaders headers = new HttpHeaders();
         headers.setContentType(MediaType.MULTIPART_FORM_DATA);
@@ -636,9 +652,9 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         paramMap.add("params",params);
         HttpEntity<Object> formEntity = new HttpEntity<>(paramMap,headers);
         ResponseEntity<Result> responseEntity = restTemplate.postForEntity(v3controlUrl+api, formEntity, Result.class);
-        if (responseEntity.getStatusCode() != HttpStatus.OK || responseEntity.getBody().getCode() != HttpStatus.OK.value()) {
-            log.error("正顺场景请求V3服务器失败!");
-            return;
+        if (responseEntity.getStatusCode().value() != HttpStatus.OK.value() || responseEntity.getBody().getCode() != ServerCode.SUCCESS.code()) {
+            log.error("正顺场景请求V3服务器失败, params:{}, result:{}",params, JSON.toJSONString(responseEntity));
+            throw new BusinessException(ErrorCode.SYSTEM_BUSY);
         }
         log.info("正顺场景请求V3服务器成功!");
     }
@@ -699,19 +715,18 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             cameraType = 14L;
         }
 
-        ResultData ok = callV3(preParams, fdageJson,"api/scene/file/turntableUploadSuccess");
-        if (ok != null) return ok;
-
-
-        ScenePlusVO scenePlusVO = null;
-
         // 判断是否是V3的场景
         ScenePro scenePro = sceneProService.getOne(
-                new LambdaQueryWrapper<ScenePro>().like(ScenePro::getDataSource, fileId));
+            new LambdaQueryWrapper<ScenePro>().like(ScenePro::getDataSource, fileId));
+
+        boolean callV3 = callV3(scenePro, preParams, fdageJson, "api/scene/file/turntableUploadSuccess");
+        if (callV3) return ResultData.ok();
 
         //激光场景校验是否能够计算
         this.checkJgCanBuild(scenePro);
 
+        ScenePlusVO scenePlusVO = null;
+
         if (ObjectUtils.isEmpty(scenePro) || (!ObjectUtils.isEmpty(scenePro.getIsUpgrade()) && scenePro.getIsUpgrade() == 1)) {
             scenePlusVO = buildScene(fileId, prefixBuffer.toString(), fdageJson, buildType, cameraType);
         } else {
@@ -774,6 +789,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         if(cameraType.longValue() == 14 ){
             scenePlus.setSceneSource(4);
             scenePlusExt.setSceneScheme(10);
+            scenePlusExt.setModelKind(modelKind);
         }
 
         if (pic != null && pic.length() > 5) {
@@ -1066,12 +1082,23 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 
         ScenePro scenePro = sceneProService.getByNum(num);
 
+        // TODO: 2023/1/12 3dtiles临时上激光场景
+//        if(Objects.nonNull(scenePro) && (Objects.isNull(scenePro.getIsUpgrade())
+//            || scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue())){
+//            if(scenePro.getSceneSource() == SceneSource.JG.code().intValue()){
+//                return rebuildV3Scene(scenePro,num,force);
+//            }else{
+//                return rebuildV3SceneToMini(scenePro);
+//            }
+//        }
+
+
         //激光场景校验是否能够计算
         this.checkJgCanBuild(scenePro);
 
         //如果是v3场景,不允许重算,需要升级v4后再调此接口进行重算
         if(Objects.nonNull(scenePro) && (Objects.isNull(scenePro.getIsUpgrade())
-            || scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue())){
+                || scenePro.getIsUpgrade() != CommonStatus.YES.code().intValue())){
             return rebuildV3Scene(scenePro,num,force);
         }
 
@@ -1139,11 +1166,19 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         if(deleteExtras){
             message.getExt().put("deleteExtras",deleteExtras);
         }
+        if (force) {
+            message.setRebuild("1");
+        }
         rabbitMqProducer.sendByWorkQueue(queueModelingPre, message);
         scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
             .set(ScenePlus::getSceneStatus, SceneStatus.wait.code())
             .eq(ScenePlus::getNum, num));
 
+        if(cameraType == 14){
+            scenePlusExt.setModelKind(this.modelKind);
+        }
+        scenePlusExtService.updateById(scenePlusExt);
+
         return ResultData.ok();
     }
 
@@ -1191,9 +1226,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         String buildType = scenePro.getBuildType();
         Integer sceneScheme = scenePro.getSceneScheme();
 
-        //重新计算时需要删除文件夹,否知使用缓存
-        FileUtils.delAllFile(path + File.separator + "results");
-
         String dataFdageOssPath = ConstantFilePath.OSS_PREFIX+ path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
                 .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "") + "/data.fdage";
 
@@ -1606,4 +1638,15 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         return scene;
     }
 
+    private ResultData rebuildV3SceneToMini(ScenePro scenePro){
+        log.info("v3场景重算,请求v3服务器,url:{}",v3controlUrl+"api/scene/rebuildScene?num=" + scenePro.getNum());
+        ResponseEntity<Result> responseEntity = restTemplate.getForEntity(v3controlUrl+"api/scene/rebuildScene?num=" + scenePro.getNum(), Result.class);
+        if (responseEntity.getStatusCode().value() != HttpStatus.OK.value() || responseEntity.getBody().getCode() != ServerCode.SUCCESS.code()) {
+            log.error("请求V3服务器重算场景失败, num:{}, result:{}",scenePro.getNum(), JSON.toJSONString(responseEntity));
+            throw new BusinessException(ErrorCode.SYSTEM_BUSY);
+        }
+        log.info("v3场景重算,请求v3服务器,url:{}, result",v3controlUrl+"api/scene/rebuildScene?num=" + scenePro.getNum(), JSON.toJSONString(responseEntity));
+        return ResultData.ok();
+    }
+
 }