|
@@ -1,8 +1,10 @@
|
|
|
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;
|
|
@@ -15,6 +17,7 @@ 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.SceneBuildProcessType;
|
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
|
|
@@ -48,6 +51,9 @@ public class BuildObjServiceImpl implements IBuildSceneService {
|
|
|
@Value("${queue.modeling.obj.modeling-post}")
|
|
|
private String queueObjModelingPost;
|
|
|
|
|
|
+ @Value("${queue.modeling.obj.modeling-pre}")
|
|
|
+ private String queueObjModelingPre;
|
|
|
+
|
|
|
@Value("${model.modelKind:3dtiles}")
|
|
|
private String modelKind;
|
|
|
|
|
@@ -76,9 +82,13 @@ public class BuildObjServiceImpl implements IBuildSceneService {
|
|
|
@Autowired
|
|
|
private IScenePlusService scenePlusService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISceneBuildProcessLogService sceneBuildProcessLogService;
|
|
|
+
|
|
|
@Override
|
|
|
- public void buildScenePre(BuildSceneCallMessage message) {
|
|
|
+ public void buildScenePre(BuildSceneCallMessage message) throws Exception{
|
|
|
boolean success = false;
|
|
|
+ String num = message.getSceneNum();
|
|
|
try {
|
|
|
String path = message.getPath();
|
|
|
//根据相机类型,组装资源路径
|
|
@@ -123,13 +133,13 @@ public class BuildObjServiceImpl implements IBuildSceneService {
|
|
|
log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
|
|
|
|
|
|
}catch (Exception e){
|
|
|
- log.error("场景计算前置处理出错", e);
|
|
|
+ log.error("生成OBJ场景资源准备异常,num=" + num, e);
|
|
|
+ throw e;
|
|
|
}finally {
|
|
|
//如果前置处理失败,发送钉钉消息
|
|
|
if(!success){
|
|
|
buildSceneDTService.handBaseFail("生成OBJ场景资源准备异常", message.getPath(), message.getSceneNum(), "计算控制服务器");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -152,92 +162,102 @@ public class BuildObjServiceImpl implements IBuildSceneService {
|
|
|
@Override
|
|
|
public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
|
|
|
|
|
|
- if (!message.getBuildSuccess()) {
|
|
|
- log.error("生成OBJ场景计算失败!");
|
|
|
- // 发送钉钉消息,计算失败
|
|
|
- buildSceneDTService.handModelFail("生成OBJ场景计算失败!", message.getPath(), message.getBuildContext().get("sceneNum").toString(), message.getHostName());
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
String path = message.getPath();
|
|
|
- String laserObjFilePath = path;
|
|
|
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);
|
|
|
+ boolean success = false;
|
|
|
+ try {
|
|
|
+ if (!message.getBuildSuccess()) {
|
|
|
+ log.error("生成OBJ场景计算失败!");
|
|
|
+ // 发送钉钉消息,计算失败
|
|
|
+ buildSceneDTService.handModelFail("生成OBJ场景计算失败!", message.getPath(), message.getBuildContext().get("sceneNum").toString(), message.getHostName());
|
|
|
+ return;
|
|
|
}
|
|
|
- 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目录异常");
|
|
|
+
|
|
|
+ String laserObjFilePath = path;
|
|
|
+ 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);
|
|
|
}
|
|
|
- //上传3dtiles文件
|
|
|
- fYunFileService.uploadFileByCommand(threedtilesPath, oss3dtilesPath);
|
|
|
- }
|
|
|
|
|
|
- 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(),
|
|
|
- ossImagePath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/"+textureFile.getName());
|
|
|
+ File texFile = new File(texPath);
|
|
|
+ if(texFile.exists()){
|
|
|
+ for (File textureFile : texFile.listFiles()) {
|
|
|
+ if(textureFile.getName().endsWith(".jpg")){
|
|
|
+ fYunFileService.uploadFile(textureFile.getAbsolutePath(),
|
|
|
+ ossImagePath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/"+textureFile.getName());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + "tex/texture1.jpg",
|
|
|
- ossImagePath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/texture1.jpg");
|
|
|
+ fYunFileService.uploadFile(laserObjFilePath + File.separator + "results" + File.separator + "tex/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);
|
|
|
|
|
|
- //上传mesh文件
|
|
|
- fYunFileService.uploadFileByCommand(laserObjFilePath + "/results/mesh", String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "mesh");
|
|
|
+ //上传mesh文件
|
|
|
+ fYunFileService.uploadFileByCommand(laserObjFilePath + "/results/mesh", String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "mesh");
|
|
|
|
|
|
- fdkkLaserService.pushBuildStatusToLaserSystem(projectNum, laserObjFilePath + "/laserData/mesh");
|
|
|
+ fdkkLaserService.pushBuildStatusToLaserSystem(projectNum, laserObjFilePath + "/laserData/mesh");
|
|
|
|
|
|
|
|
|
- if(!ObjectUtils.isEmpty(scenePro)){
|
|
|
- LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<ScenePro>()
|
|
|
- .set(ScenePro::getStatus, -2).eq(ScenePro::getNum, projectNum);
|
|
|
- sceneProService.update(updateWrapper);
|
|
|
- sceneProEditService.update(new LambdaUpdateWrapper<SceneProEdit>().set(SceneProEdit::getMapVisi,0)
|
|
|
- .eq(SceneProEdit::getProId,scenePro.getId()));
|
|
|
- }
|
|
|
+ if(!ObjectUtils.isEmpty(scenePro)){
|
|
|
+ LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<ScenePro>()
|
|
|
+ .set(ScenePro::getStatus, -2).eq(ScenePro::getNum, projectNum);
|
|
|
+ sceneProService.update(updateWrapper);
|
|
|
+ sceneProEditService.update(new LambdaUpdateWrapper<SceneProEdit>().set(SceneProEdit::getMapVisi,0)
|
|
|
+ .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
|
|
|
- if("v3".equals(version)){
|
|
|
- fdkkV4Service.upgradeToV4(projectNum);
|
|
|
+ // 如果未升级V4,则升级V4
|
|
|
+ if("v3".equals(version)){
|
|
|
+ fdkkV4Service.upgradeToV4(projectNum);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("生成OBJ场景计算结果处理异常,num=" + projectNum, e);
|
|
|
+ throw e;
|
|
|
+ }finally {
|
|
|
+ if(!success){
|
|
|
+ buildSceneDTService.handBaseFail("生成OBJ场景计算结果处理异常", message.getPath(), projectNum, "计算控制服务器");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|