|
@@ -1,7 +1,9 @@
|
|
|
package com.fdkankan.contro.mq.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.exceptions.ExceptionUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.fdkankan.common.constant.CommonOperStatus;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.contro.entity.ScenePlus;
|
|
|
import com.fdkankan.contro.entity.ScenePro;
|
|
@@ -12,6 +14,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;
|
|
@@ -77,10 +80,11 @@ public class BuildObjServiceImpl implements IBuildSceneService {
|
|
|
@Override
|
|
|
public void buildScenePre(BuildSceneCallMessage message) {
|
|
|
boolean success = false;
|
|
|
+ String num = message.getSceneNum();
|
|
|
try {
|
|
|
-
|
|
|
//记录日志
|
|
|
- sceneBuildProcessLogService.clearSceneBuildProcessLog(message.getSceneNum(), scenebuildt);
|
|
|
+ sceneBuildProcessLogService.clearSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueObjModelingPre);
|
|
|
+ sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueObjModelingPre, CommonOperStatus.WAITING.code(), null);
|
|
|
|
|
|
String path = message.getPath();
|
|
|
//根据相机类型,组装资源路径
|
|
@@ -120,12 +124,15 @@ public class BuildObjServiceImpl implements IBuildSceneService {
|
|
|
//发送mq,就进行计算
|
|
|
mqProducer.sendByWorkQueue(queueModelingCall, message);
|
|
|
|
|
|
+ sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueObjModelingPre, CommonOperStatus.SUCCESS.code(), null);
|
|
|
+
|
|
|
success = true;
|
|
|
|
|
|
log.info("场景计算资源准备结束,场景码:{}", message.getSceneNum());
|
|
|
|
|
|
}catch (Exception e){
|
|
|
log.error("场景计算前置处理出错", e);
|
|
|
+ sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueObjModelingPre, CommonOperStatus.FAILD.code(), ExceptionUtil.stacktraceToString(e, 3000));
|
|
|
}finally {
|
|
|
//如果前置处理失败,发送钉钉消息
|
|
|
if(!success){
|
|
@@ -153,74 +160,92 @@ 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 projectNum = message.getBuildContext().get("sceneNum").toString();
|
|
|
+ boolean success = false;
|
|
|
+ try {
|
|
|
+ //记录日志
|
|
|
+ sceneBuildProcessLogService.clearSceneBuildProcessLog(projectNum, SceneBuildProcessType.POST.code(), queueObjModelingPost);
|
|
|
+ sceneBuildProcessLogService.saveSceneBuildProcessLog(projectNum, SceneBuildProcessType.POST.code(), queueObjModelingPost, CommonOperStatus.WAITING.code(), null);
|
|
|
+
|
|
|
+ if (!message.getBuildSuccess()) {
|
|
|
+ log.error("生成OBJ场景计算失败!");
|
|
|
+ // 发送钉钉消息,计算失败
|
|
|
+ buildSceneDTService.handModelFail("生成OBJ场景计算失败!", message.getPath(), message.getBuildContext().get("sceneNum").toString(), message.getHostName());
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- 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 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);
|
|
|
+ }
|
|
|
|
|
|
- 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");
|
|
|
+ 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());
|
|
|
+ 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());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- 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");
|
|
|
+ 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");
|
|
|
|
|
|
- // 拷贝结果
|
|
|
- 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");
|
|
|
+ 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());
|
|
|
- }
|
|
|
+ for (File meshFile : meshFolder.listFiles()) {
|
|
|
+ fYunFileService.uploadFile(meshFile.getAbsolutePath(), String.format(UploadFilePath.DATA_VIEW_PATH, projectNum) + "mesh/" + meshFile.getName());
|
|
|
+ }
|
|
|
|
|
|
- fdkkLaserService.pushBuildStatusToLaserSystem(projectNum, laserObjFilePath + "/laserData/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);
|
|
|
- sceneProService.update(updateWrapper);
|
|
|
- sceneProEditService.update(new LambdaUpdateWrapper<SceneProEdit>().set(SceneProEdit::getMapVisi,0)
|
|
|
- .eq(SceneProEdit::getProId,scenePro.getId()));
|
|
|
- }
|
|
|
+ ScenePro scenePro = sceneProService.getByNum(projectNum);
|
|
|
+ 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
|
|
|
- fdkkV4Service.upgradeToV4(projectNum);
|
|
|
+ // 如果未升级V4,则升级V4
|
|
|
+ fdkkV4Service.upgradeToV4(projectNum);
|
|
|
+
|
|
|
+ sceneBuildProcessLogService.saveSceneBuildProcessLog(projectNum, SceneBuildProcessType.POST.code(), queueObjModelingPost, CommonOperStatus.SUCCESS.code(), null);
|
|
|
+
|
|
|
+ success = true;
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("场景计算结果处理出错,num=" + projectNum, e);
|
|
|
+ sceneBuildProcessLogService.saveSceneBuildProcessLog(projectNum, SceneBuildProcessType.POST.code(), queueObjModelingPost, CommonOperStatus.FAILD.code(), ExceptionUtil.stacktraceToString(e, 3000));
|
|
|
+ }finally {
|
|
|
+ if(!success){
|
|
|
+ buildSceneDTService.handBaseFail("生成OBJ场景计算结果处理异常", message.getPath(), projectNum, "计算控制服务器");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|