|
@@ -1,6 +1,7 @@
|
|
|
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;
|
|
@@ -32,6 +33,7 @@ import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -77,10 +79,15 @@ public class BuildSxRelocationServiceImpl implements IBuildSceneService {
|
|
|
private IntermitSceneService intermitSceneService;
|
|
|
@Autowired
|
|
|
private IBuildService buildService;
|
|
|
+ @Autowired
|
|
|
+ private IRelocationBatchDetailService relocationBatchDetailService;
|
|
|
+ @Autowired
|
|
|
+ private IRelocationBatchService relocationBatchService;
|
|
|
|
|
|
@Override
|
|
|
public void buildScenePre(BuildSceneCallMessage message) throws Exception{
|
|
|
String num = message.getSceneNum();
|
|
|
+ Long batchId = (Long) message.getExt().get("batchId");
|
|
|
ScenePlus scenePlusByNum = scenePlusService.getScenePlusByNum(num);
|
|
|
try {
|
|
|
//重新计算时需要删除文件夹,否知使用缓存
|
|
@@ -92,8 +99,7 @@ public class BuildSxRelocationServiceImpl implements IBuildSceneService {
|
|
|
FileUtils.deleteDirectory(message.getPath() + File.separator + "caches");
|
|
|
}
|
|
|
|
|
|
- String extrasPath = message.getPath() + File.separator + "extras";
|
|
|
- fYunFileService.downloadFileByCommand(extrasPath, String.format(UploadFilePath.scene_result_data_path, num) + "pose/");
|
|
|
+ this.downLoadSource(message, message.getPath());
|
|
|
|
|
|
message.setResultReceiverMqName(queueModelingPost);
|
|
|
|
|
@@ -110,30 +116,43 @@ public class BuildSxRelocationServiceImpl implements IBuildSceneService {
|
|
|
}catch (Exception e){
|
|
|
scenePlusByNum.setSceneStatus(SceneStatus.FAILD.code());
|
|
|
scenePlusService.updateById(scenePlusByNum);
|
|
|
+ //修改重定位记录为退出计算
|
|
|
+ relocationBatchService.update(new LambdaUpdateWrapper<RelocationBatch>().eq(RelocationBatch::getId, batchId).set(RelocationBatch::getStatus, 2));
|
|
|
buildSceneDTService.handBaseFail("深巡场景重定位资源准备异常!", message.getPath(), message.getSceneNum(), "计算控制服务器");
|
|
|
throw e;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private String getOssPath(String path) {
|
|
|
- String ossPath = ConstantFilePath.OSS_PREFIX
|
|
|
- + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
|
|
|
- .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
|
|
|
- if (!ossPath.endsWith("/")) {
|
|
|
- ossPath = ossPath.concat("/");
|
|
|
- }
|
|
|
- return ossPath;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void downLoadSource(BuildSceneCallMessage buildSceneMqMessage,String path){
|
|
|
- String ossPath = getOssPath(path);
|
|
|
- fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
|
|
|
+ String num = buildSceneMqMessage.getSceneNum();
|
|
|
+ Long batchId = (Long)buildSceneMqMessage.getExt().get("batchId");
|
|
|
+ //下载深巡缓存数据
|
|
|
+ String extrasPath = path + File.separator + "extras";
|
|
|
+ fYunFileService.downloadFileByCommand(extrasPath, String.format(UploadFilePath.scene_result_data_path, num) + "pose/");
|
|
|
+ String imagesPath = extrasPath + File.separator + "images";
|
|
|
+ //下载图片
|
|
|
+ String queryPath = imagesPath + File.separator + "query";
|
|
|
+ List<RelocationBatchDetail> detailList = relocationBatchDetailService.listByBatchId(batchId);
|
|
|
+ detailList.stream().forEach(v->{
|
|
|
+ fYunFileService.downloadFile(v.getBucket(), v.getImgKey(), queryPath + File.separator + v.getFileName());
|
|
|
+ });
|
|
|
+ //生成query.json
|
|
|
+ List<String> imgNameList = FileUtil.listFileNames(queryPath);
|
|
|
+ List<JSONObject> filenames = imgNameList.stream().map(v -> {
|
|
|
+ JSONObject a = new JSONObject();
|
|
|
+ a.put("filename", v);
|
|
|
+ return a;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ JSONObject query = new JSONObject();
|
|
|
+ query.put("query", filenames);
|
|
|
+ FileUtil.writeUtf8String(query.toJSONString(), extrasPath + File.separator + "query.json");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void buildScenePost(BuildSceneResultMqMessage message) throws Exception {
|
|
|
String sceneCode = message.getBuildContext().get("sceneNum").toString();
|
|
|
+ Long batchId = (Long) message.getExt().get("batchId");
|
|
|
String path = message.getPath();
|
|
|
Map<String, Object> downParams = new HashMap<>();
|
|
|
downParams.put("sceneCode", sceneCode);
|
|
@@ -147,7 +166,7 @@ public class BuildSxRelocationServiceImpl implements IBuildSceneService {
|
|
|
log.info("计算日志上传完成");
|
|
|
|
|
|
if (!message.getBuildSuccess()) {
|
|
|
- log.error("建模失败,修改状态为失败状态");
|
|
|
+ log.error("重定位计算报错,修改状态为失败状态");
|
|
|
scenePlusService.update(new LambdaUpdateWrapper<ScenePlus>()
|
|
|
.set(ScenePlus::getSceneStatus, SceneStatus.FAILD.code())
|
|
|
.eq(ScenePlus::getNum, sceneCode));
|
|
@@ -190,16 +209,18 @@ public class BuildSxRelocationServiceImpl implements IBuildSceneService {
|
|
|
|
|
|
//发送消息到点云系统处理
|
|
|
downParams.put("status", CommonSuccessStatus.SUCCESS.code());
|
|
|
- log.info("场景计算结果处理结束,场景码:{}", sceneCode);
|
|
|
+ log.info("场景重定位计算结果处理结束,场景码:{}", sceneCode);
|
|
|
|
|
|
}catch (Exception e){
|
|
|
- log.error("场景计算结果处理出错,num"+sceneCode, e);
|
|
|
+ log.error("场景重定位计算结果处理出错,num"+sceneCode, e);
|
|
|
downParams.put("status", CommonSuccessStatus.FAIL.code());
|
|
|
- buildSceneDTService.handBaseFail("场景计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
|
|
|
+ buildSceneDTService.handBaseFail("场景重定位计算结果处理出错!", message.getPath(), sceneCode, "计算控制服务器");
|
|
|
throw e;
|
|
|
} finally {
|
|
|
//发送消息到激光系统做处理
|
|
|
mqProducer.sendByWorkQueue("sx-relocation-done", downParams);
|
|
|
+ //修改重定位记录为退出计算
|
|
|
+ relocationBatchService.update(new LambdaUpdateWrapper<RelocationBatch>().eq(RelocationBatch::getId, batchId).set(RelocationBatch::getStatus, 2));
|
|
|
}
|
|
|
}
|
|
|
|