|
@@ -163,9 +163,8 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
|
watch.start();
|
|
|
|
|
|
BuildLog buildLog = new BuildLog();
|
|
|
- BuildSceneResultBean buildSceneResult = new BuildSceneResultBean();
|
|
|
-
|
|
|
- Future<BuildSceneResultBean> future = null;
|
|
|
+ final BuildSceneResultBean buildSceneResult = new BuildSceneResultBean();
|
|
|
+ Future<ModelingBuildStatus> future = null;
|
|
|
try {
|
|
|
|
|
|
//休眠2秒等待准备数据
|
|
@@ -175,9 +174,9 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
|
preBuild(message, buildLog);
|
|
|
|
|
|
future = SysConstants.executorService.submit(()->{
|
|
|
- return buildScene(message);
|
|
|
+ return buildScene(message, buildSceneResult);
|
|
|
});
|
|
|
- buildSceneResult = future.get(SysConstants.modelTimeOut, TimeUnit.SECONDS);
|
|
|
+ future.get(SysConstants.modelTimeOut, TimeUnit.HOURS);
|
|
|
|
|
|
//结束计时
|
|
|
watch.stop();
|
|
@@ -202,8 +201,7 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private BuildSceneResultBean buildScene(BuildSceneMqMessage message){
|
|
|
- ModelingBuildStatus buildStatus = ModelingBuildStatus.FAILED;
|
|
|
+ private ModelingBuildStatus buildScene(BuildSceneMqMessage message, BuildSceneResultBean buildSceneResult) throws Exception{
|
|
|
String projectNum = null;
|
|
|
Long computeTime = null;//计算耗时
|
|
|
//如果mq生产者在消息体中执行了计算结果mq的主题名,就发到这个主题名,否则就发送到配置的主题名
|
|
@@ -229,129 +227,134 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
|
|
|
|
String dataPath = "data/data" + projectNum;//老版本文件路径
|
|
|
|
|
|
- Map<String,String> map = new HashMap<>();
|
|
|
+ Map<String,String> map = null;
|
|
|
Integer pushChannel = null;
|
|
|
String pushToken = null;
|
|
|
Integer videoVersion = null;
|
|
|
|
|
|
- try{
|
|
|
-
|
|
|
- Map<String, String> dataMap = ComputerUtil.getTypeString(cameraType, algorithm,
|
|
|
- resolution);
|
|
|
- String splitType = dataMap.get("splitType");
|
|
|
- String skyboxType = dataMap.get("skyboxType");
|
|
|
- String dataDescribe = dataMap.get("dataDescribe");
|
|
|
+ buildSceneResult.setResultTopicName(resultTopicName);
|
|
|
+ buildSceneResult.setCameraType(cameraType);
|
|
|
+ buildSceneResult.setNum(projectNum);
|
|
|
|
|
|
- log.info("用的算法是:"+algorithm);
|
|
|
- log.info("用的相机是:"+ (Integer.parseInt(cameraType) < 4 ? "单球目" : "双球目(八目)"));
|
|
|
|
|
|
- //4表示硬件部研发的双球目相机,其余为旧版本相机
|
|
|
- if(Integer.parseInt(cameraType) < 3){
|
|
|
-
|
|
|
- String data = FileUtils.readFile(path + File.separator + "capture" +File.separator+"data.fdage");
|
|
|
- JSONObject dataJson = new JSONObject();
|
|
|
- if(data!=null){
|
|
|
- dataJson = JSONObject.parseObject(data);
|
|
|
- if(dataJson.containsKey("imgs")){
|
|
|
- splitType = "SPLIT_V4";
|
|
|
- }
|
|
|
- }
|
|
|
- //生成project.json和data.json供算法部使用
|
|
|
- ComputerUtil.createJson(path, splitType, skyboxType, dataDescribe, projectNum, path);
|
|
|
- //计算模型并返回需要上传oss的文件集合
|
|
|
- map = ComputerUtil.computer(projectNum, path, buildType);
|
|
|
+ Map<String, String> dataMap = ComputerUtil.getTypeString(cameraType, algorithm,
|
|
|
+ resolution);
|
|
|
+ String splitType = dataMap.get("splitType");
|
|
|
+ String skyboxType = dataMap.get("skyboxType");
|
|
|
+ String dataDescribe = dataMap.get("dataDescribe");
|
|
|
|
|
|
- } else {
|
|
|
+ log.info("用的算法是:"+algorithm);
|
|
|
+ log.info("用的相机是:"+ (Integer.parseInt(cameraType) < 4 ? "单球目" : "双球目(八目)"));
|
|
|
|
|
|
- path = SceneUtil.getPath(path, cameraName, fileId, Integer.parseInt(cameraType), unicode);
|
|
|
+ //4表示硬件部研发的双球目相机,其余为旧版本相机
|
|
|
+ if(Integer.parseInt(cameraType) < 3){
|
|
|
|
|
|
- String dataFdagePath = path + File.separator + "capture" +File.separator+"data.fdage";
|
|
|
- log.info("dataFdagePath 文件路径 :{}", dataFdagePath);
|
|
|
- String data = FileUtils.readFile(dataFdagePath);
|
|
|
- //获取data.fdage的内容
|
|
|
- JSONObject dataJson = new JSONObject();
|
|
|
- if(data!=null){
|
|
|
- dataJson = JSONObject.parseObject(data);
|
|
|
- }
|
|
|
- pushChannel = dataJson.getInteger("pushChannel");
|
|
|
- pushToken = dataJson.getString("pushToken");
|
|
|
-
|
|
|
- /*
|
|
|
- 1、判断是否计算过资源,若计算过删除缓存, 如果caches中存在_images文件或者目录,就删除掉,否则就删除除了images以外的所有文件和目录
|
|
|
- 2、删除上一次计算出来的result目录
|
|
|
- */
|
|
|
- this.deleteCachesAndResult(path);
|
|
|
-
|
|
|
- //v2版本使用4k算法
|
|
|
- if(dataJson.containsKey("videoVersion")
|
|
|
- && StringUtils.isNotEmpty(dataJson.getString("videoVersion"))
|
|
|
- && Integer.parseInt(dataJson.getString("videoVersion")) < 4){
|
|
|
- skyboxType = "SKYBOX_V6";
|
|
|
+ String data = FileUtils.readFile(path + File.separator + "capture" +File.separator+"data.fdage");
|
|
|
+ JSONObject dataJson = new JSONObject();
|
|
|
+ if(data!=null){
|
|
|
+ dataJson = JSONObject.parseObject(data);
|
|
|
+ if(dataJson.containsKey("imgs")){
|
|
|
+ splitType = "SPLIT_V4";
|
|
|
}
|
|
|
+ }
|
|
|
+ //生成project.json和data.json供算法部使用
|
|
|
+ ComputerUtil.createJson(path, splitType, skyboxType, dataDescribe, projectNum, path);
|
|
|
+ //计算模型并返回需要上传oss的文件集合
|
|
|
+ map = ComputerUtil.computer(projectNum, path, buildType);
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ path = SceneUtil.getPath(path, cameraName, fileId, Integer.parseInt(cameraType), unicode);
|
|
|
+
|
|
|
+ String dataFdagePath = path + File.separator + "capture" +File.separator+"data.fdage";
|
|
|
+ log.info("dataFdagePath 文件路径 :{}", dataFdagePath);
|
|
|
+ String data = FileUtils.readFile(dataFdagePath);
|
|
|
+ //获取data.fdage的内容
|
|
|
+ JSONObject dataJson = new JSONObject();
|
|
|
+ if(data!=null){
|
|
|
+ dataJson = JSONObject.parseObject(data);
|
|
|
+ }
|
|
|
+ pushChannel = dataJson.getInteger("pushChannel");
|
|
|
+ pushToken = dataJson.getString("pushToken");
|
|
|
+
|
|
|
+ /*
|
|
|
+ 1、判断是否计算过资源,若计算过删除缓存, 如果caches中存在_images文件或者目录,就删除掉,否则就删除除了images以外的所有文件和目录
|
|
|
+ 2、删除上一次计算出来的result目录
|
|
|
+ */
|
|
|
+ this.deleteCachesAndResult(path);
|
|
|
+
|
|
|
+ //v2版本使用4k算法
|
|
|
+ if(dataJson.containsKey("videoVersion")
|
|
|
+ && StringUtils.isNotEmpty(dataJson.getString("videoVersion"))
|
|
|
+ && Integer.parseInt(dataJson.getString("videoVersion")) < 4){
|
|
|
+ skyboxType = "SKYBOX_V6";
|
|
|
+ }
|
|
|
|
|
|
- //生成project.json和data.json并写到path目录下供算法部使用
|
|
|
- log.info("path:" + path);
|
|
|
- ComputerUtil.createJson(path, splitType, skyboxType, dataDescribe, projectNum, path);
|
|
|
- //计算模型并返回需要上传oss的文件集合
|
|
|
- map = ComputerUtil.computer(projectNum, path, buildType);
|
|
|
- //计算完成时间
|
|
|
- log.info("计算完成耗时:{}",computeTime);
|
|
|
+ //生成project.json和data.json并写到path目录下供算法部使用
|
|
|
+ log.info("path:" + path);
|
|
|
+ ComputerUtil.createJson(path, splitType, skyboxType, dataDescribe, projectNum, path);
|
|
|
+ //计算模型并返回需要上传oss的文件集合
|
|
|
+ map = ComputerUtil.computer(projectNum, path, buildType);
|
|
|
+ //计算完成时间
|
|
|
+ log.info("计算完成耗时:{}",computeTime);
|
|
|
|
|
|
- if(Integer.parseInt(cameraType) == 5 || Integer.parseInt(cameraType) == 6){
|
|
|
- map.put(path + File.separator + "capture/stitch_params.txt", dataPath + "/stitch_params.txt");
|
|
|
- }
|
|
|
- map.put(path + File.separator + "capture/Up.xml", dataPath + "/Up.xml");
|
|
|
- map.put(path + File.separator + "capture/Up2.xml", dataPath + "/Up2.xml");
|
|
|
+ if(Integer.parseInt(cameraType) == 5 || Integer.parseInt(cameraType) == 6){
|
|
|
+ map.put(path + File.separator + "capture/stitch_params.txt", dataPath + "/stitch_params.txt");
|
|
|
+ }
|
|
|
+ map.put(path + File.separator + "capture/Up.xml", dataPath + "/Up.xml");
|
|
|
+ map.put(path + File.separator + "capture/Up2.xml", dataPath + "/Up2.xml");
|
|
|
|
|
|
- //转台相机
|
|
|
- if(Integer.parseInt(cameraType) == 13){
|
|
|
- map.put(path + File.separator + "capture/Up.txt", dataPath + "/Up.txt");
|
|
|
- map.put(path + File.separator + "capture/Up2.txt", dataPath + "/Up2.txt");
|
|
|
- }
|
|
|
+ //转台相机
|
|
|
+ if(Integer.parseInt(cameraType) == 13){
|
|
|
+ map.put(path + File.separator + "capture/Up.txt", dataPath + "/Up.txt");
|
|
|
+ map.put(path + File.separator + "capture/Up2.txt", dataPath + "/Up2.txt");
|
|
|
+ }
|
|
|
|
|
|
- //计算已使用容量
|
|
|
- payStatus = 1;
|
|
|
+ //计算已使用容量
|
|
|
+ payStatus = 1;
|
|
|
|
|
|
- log.info("八目上完oss结束修改数据:"+projectNum);
|
|
|
+ log.info("八目上完oss结束修改数据:"+projectNum);
|
|
|
|
|
|
- //读取计算结果文件生成videosJson
|
|
|
+ //读取计算结果文件生成videosJson
|
|
|
// videosJson = this.getVideosJson(path, dataJson, projectNum, Integer.valueOf(cameraType));
|
|
|
- String videoVersionStr = dataJson.getString("videoVersion");
|
|
|
- videoVersion = StrUtil.isEmpty(videoVersionStr) ? null : Integer.parseInt(videoVersionStr);
|
|
|
+ String videoVersionStr = dataJson.getString("videoVersion");
|
|
|
+ videoVersion = StrUtil.isEmpty(videoVersionStr) ? null : Integer.parseInt(videoVersionStr);
|
|
|
|
|
|
- //更新scene.json里面的video数据
|
|
|
+ //更新scene.json里面的video数据
|
|
|
// this.updateVideosToSceneJson(projectNum, videosJson);
|
|
|
|
|
|
- //计算成功 激光转台相机 同步 请求
|
|
|
- this.jgSynch(message);
|
|
|
- }
|
|
|
-
|
|
|
- CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
|
|
|
- buildStatus = ModelingBuildStatus.SUCCESS;
|
|
|
- }
|
|
|
- finally {
|
|
|
- //上传status.json console.log
|
|
|
-// this.uploadStatusJsonAndConsoleLog(sceneStatus, webSite, projectNum, thumb, payStatus);
|
|
|
-
|
|
|
- //发送计算结果到mq,再由消费者消费并操作数据库
|
|
|
-// this.sendCallResult(buildSuccess, resultTopicName, cameraType, computeTime, fileId, payStatus,
|
|
|
-// projectNum, videosJson, map, path, pushChannel, pushToken,prefix, videoVersion);
|
|
|
-
|
|
|
- return BuildSceneResultBean.builder()
|
|
|
- .buildStatus(buildStatus)
|
|
|
- .resultTopicName(resultTopicName)
|
|
|
- .cameraType(cameraType)
|
|
|
- .fileId(fileId)
|
|
|
- .payStatus(payStatus)
|
|
|
- .num(projectNum)
|
|
|
- .uploadMap(map)
|
|
|
- .path(path)
|
|
|
- .pushChannel(pushChannel)
|
|
|
- .pushToken(pushToken)
|
|
|
- .prefix(prefix)
|
|
|
- .videoVersion(videoVersion)
|
|
|
- .build();
|
|
|
+ //计算成功 激光转台相机 同步 请求
|
|
|
+ this.jgSynch(message);
|
|
|
}
|
|
|
+
|
|
|
+ buildSceneResult.setBuildStatus(ModelingBuildStatus.SUCCESS);
|
|
|
+ buildSceneResult.setFileId(fileId);
|
|
|
+ buildSceneResult.setPayStatus(payStatus);
|
|
|
+ buildSceneResult.setUploadMap(map);
|
|
|
+ buildSceneResult.setPath(path);
|
|
|
+ buildSceneResult.setPushChannel(pushChannel);
|
|
|
+ buildSceneResult.setPushToken(pushToken);
|
|
|
+ buildSceneResult.setPrefix(prefix);
|
|
|
+ buildSceneResult.setVideoVersion(videoVersion);
|
|
|
+
|
|
|
+ CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
|
|
|
+
|
|
|
+ return ModelingBuildStatus.SUCCESS;
|
|
|
+
|
|
|
+// return BuildSceneResultBean.builder()
|
|
|
+// .buildStatus(ModelingBuildStatus.SUCCESS)
|
|
|
+// .resultTopicName(resultTopicName)
|
|
|
+// .cameraType(cameraType)
|
|
|
+// .fileId(fileId)
|
|
|
+// .payStatus(payStatus)
|
|
|
+// .num(projectNum)
|
|
|
+// .uploadMap(map)
|
|
|
+// .path(path)
|
|
|
+// .pushChannel(pushChannel)
|
|
|
+// .pushToken(pushToken)
|
|
|
+// .prefix(prefix)
|
|
|
+// .videoVersion(videoVersion)
|
|
|
+// .build();
|
|
|
}
|
|
|
|
|
|
private void afterBuild(BuildSceneMqMessage message, BuildSceneResultBean buildSceneResult, BuildLog buildLog){
|
|
@@ -477,7 +480,7 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
|
//如果是计算失败,需要发送钉钉
|
|
|
if(!buildSuccess){
|
|
|
// TODO: 2022/1/25 测试阶段,先注释掉推送
|
|
|
-// this.sendDingTalkMq(buildStatus.message(), message);
|
|
|
+ this.sendDingTalkMq(buildStatus.message(), message);
|
|
|
}
|
|
|
}
|
|
|
|