|
@@ -10,11 +10,11 @@ import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.model.utils.ComputerUtil;
|
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
|
-import com.fdkankan.model.utils.SceneUtil;
|
|
|
import com.fdkankan.modeling.bean.BuildSceneResultBean;
|
|
|
import com.fdkankan.modeling.constants.SysConstants;
|
|
|
import com.fdkankan.modeling.entity.BuildLog;
|
|
|
import com.fdkankan.modeling.exception.BuildException;
|
|
|
+import com.fdkankan.modeling.handler.LaserSceneObjGenerateHandler;
|
|
|
import com.fdkankan.modeling.service.IBuildLogService;
|
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
|
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
|
|
@@ -37,6 +37,7 @@ import org.springframework.util.ObjectUtils;
|
|
|
import java.io.File;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.Future;
|
|
@@ -75,6 +76,9 @@ public class RabbitMqListener {
|
|
|
@Autowired
|
|
|
private IBuildLogService buildLogService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LaserSceneObjGenerateHandler laserSceneObjGenerateHandler;
|
|
|
+
|
|
|
/**
|
|
|
* 场景计算
|
|
|
* @param channel
|
|
@@ -128,16 +132,19 @@ public class RabbitMqListener {
|
|
|
final BuildSceneResultBean buildSceneResult = new BuildSceneResultBean();
|
|
|
ModelingBuildStatus status = null;
|
|
|
try {
|
|
|
-
|
|
|
- //休眠2秒等待准备数据
|
|
|
- Thread.sleep(2000L);
|
|
|
-
|
|
|
+ Map<String,Object> buildContext = new HashMap<>();
|
|
|
//计算前准备
|
|
|
- preBuild(message, buildLog);
|
|
|
-
|
|
|
- Future<ModelingBuildStatus> future = SysConstants.executorService.submit(()-> buildScene(message, buildSceneResult));
|
|
|
+ preBuild(buildContext,message, buildLog);
|
|
|
+ Future<ModelingBuildStatus> future = SysConstants.executorService.submit(() -> {
|
|
|
+ try {
|
|
|
+ return buildScene(buildContext,message, buildSceneResult,buildLog);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("服务实例:{} 构建异常:", SysConstants.hostName, e);
|
|
|
+ e.printStackTrace();
|
|
|
+ return ModelingBuildStatus.FAILED;
|
|
|
+ }
|
|
|
+ });
|
|
|
status = future.get(SysConstants.modelTimeOut, TimeUnit.HOURS);
|
|
|
-
|
|
|
//结束计时
|
|
|
watch.stop();
|
|
|
buildLog.setDuration(watch.getTime(TimeUnit.SECONDS));
|
|
@@ -165,7 +172,7 @@ public class RabbitMqListener {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private ModelingBuildStatus buildScene(BuildSceneCallMessage message, BuildSceneResultBean buildSceneResult) throws Exception{
|
|
|
+ private ModelingBuildStatus buildScene(Map<String,Object> buildContext,BuildSceneCallMessage message, BuildSceneResultBean buildSceneResult,BuildLog logRecord) throws Exception{
|
|
|
Long computeTime = null;//计算耗时
|
|
|
String num = null;
|
|
|
//如果mq生产者在消息体中设置了结算结果mq队列名,就发到这个队列,否则就发送到默认队列
|
|
@@ -173,37 +180,25 @@ public class RabbitMqListener {
|
|
|
message.getResultReceiverMqName() : queueModelingPost;
|
|
|
//支付状态
|
|
|
int payStatus = 0;
|
|
|
- String unicode = message.getUnicode();
|
|
|
- String path = message.getPath();
|
|
|
+ String path = message.getDataSource();
|
|
|
String prefix = message.getPrefix();
|
|
|
num = message.getSceneNum();
|
|
|
//不同的相机不同的方法
|
|
|
String cameraType = message.getCameraType();
|
|
|
String algorithm = message.getAlgorithm();
|
|
|
String fileId = message.getFileId();
|
|
|
- String cameraName = message.getCameraName();
|
|
|
//0表示有4k图,1表示没有
|
|
|
String resolution = message.getResolution();
|
|
|
//判断调用V2还是V3版本的算法
|
|
|
String buildType = ObjectUtils.isEmpty(message.getBuildType()) ? "V2" : message.getBuildType();
|
|
|
|
|
|
- String dataPath = "data/data" + num;//老版本文件路径
|
|
|
-
|
|
|
Integer pushChannel = null;
|
|
|
String pushToken = null;
|
|
|
- Integer videoVersion = null;
|
|
|
|
|
|
buildSceneResult.setResultQueueName(resultQueueName);
|
|
|
buildSceneResult.setCameraType(cameraType);
|
|
|
buildSceneResult.setNum(num);
|
|
|
|
|
|
-
|
|
|
- Map<String, String> dataMap = ComputerUtil.getTypeString(cameraType, algorithm,
|
|
|
- resolution);
|
|
|
- String splitType = dataMap.get("splitType");
|
|
|
- String skyboxType = dataMap.get("skyboxType");
|
|
|
- String dataDescribe = dataMap.get("dataDescribe");
|
|
|
-
|
|
|
log.info("用的算法是:"+algorithm);
|
|
|
log.info("用的相机是:"+ (Integer.parseInt(cameraType) < 4 ? "单球目" : "双球目(八目)"));
|
|
|
|
|
@@ -211,6 +206,10 @@ public class RabbitMqListener {
|
|
|
if(Integer.parseInt(cameraType) < 3){
|
|
|
|
|
|
String data = FileUtils.readFile(path + File.separator + "capture" +File.separator+"data.fdage");
|
|
|
+ Map<String, String> dataMap = ComputerUtil.getTypeString(cameraType, algorithm, resolution,null);
|
|
|
+ String splitType = dataMap.get("splitType");
|
|
|
+ String skyboxType = dataMap.get("skyboxType");
|
|
|
+ String dataDescribe = dataMap.get("dataDescribe");
|
|
|
JSONObject dataJson = new JSONObject();
|
|
|
if(data!=null){
|
|
|
dataJson = JSONObject.parseObject(data);
|
|
@@ -224,9 +223,6 @@ public class RabbitMqListener {
|
|
|
ComputerUtil.computer(num, 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);
|
|
@@ -235,6 +231,27 @@ public class RabbitMqListener {
|
|
|
if(data!=null){
|
|
|
dataJson = JSONObject.parseObject(data);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ if (dataJson.containsKey("OnlyExportMeshObj")) {
|
|
|
+ logRecord.setBuildType(2);
|
|
|
+ Map<String, String> context = new HashMap<>();
|
|
|
+ context.put("path", message.getDataSource());
|
|
|
+ context.put("cameraType", cameraType);
|
|
|
+ context.put("algorithm", algorithm);
|
|
|
+ context.put("resolution", resolution);
|
|
|
+ context.put("projectNum", num);
|
|
|
+ context.put("buildType", buildType);
|
|
|
+ context.put("dataJson", data);
|
|
|
+ try {
|
|
|
+ laserSceneObjGenerateHandler.handle(context);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return ModelingBuildStatus.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
pushChannel = dataJson.getInteger("pushChannel");
|
|
|
pushToken = dataJson.getString("pushToken");
|
|
|
|
|
@@ -244,13 +261,17 @@ public class RabbitMqListener {
|
|
|
*/
|
|
|
this.deleteCachesAndResult(path);
|
|
|
|
|
|
+ Map<String, String> dataMap = ComputerUtil.getTypeString(cameraType, algorithm, resolution,dataJson);
|
|
|
+
|
|
|
+ String splitType = dataMap.get("splitType");
|
|
|
+ String skyboxType = dataMap.get("skyboxType");
|
|
|
+ String dataDescribe = dataMap.get("dataDescribe");
|
|
|
+
|
|
|
//v2版本使用4k算法
|
|
|
if (!ObjectUtils.isEmpty(dataJson.getInteger("videoVersion")) && dataJson.getIntValue("videoVersion") < 4) {
|
|
|
skyboxType = "SKYBOX_V6";
|
|
|
}
|
|
|
|
|
|
- //生成project.json和data.json并写到path目录下供算法部使用
|
|
|
- log.info("path:" + path);
|
|
|
ComputerUtil.createJson(path, splitType, skyboxType, dataDescribe, num, path);
|
|
|
//计算模型并返回需要上传oss的文件集合
|
|
|
ComputerUtil.computer(num, path, buildType);
|
|
@@ -303,7 +324,7 @@ public class RabbitMqListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void preBuild(BuildSceneCallMessage message, BuildLog buildLog) throws BuildException {
|
|
|
+ private void preBuild(Map<String,Object> buildContext,BuildSceneCallMessage message, BuildLog buildLog) throws BuildException {
|
|
|
|
|
|
// 初始化日志参数
|
|
|
buildLog.setHostName(SysConstants.hostName);
|
|
@@ -336,7 +357,7 @@ public class RabbitMqListener {
|
|
|
if(buildStatus.equals(ModelingBuildStatus.REPEAT)){
|
|
|
return;
|
|
|
}
|
|
|
- rabbitMqProducer.sendByWorkQueue(queueModelingPost,
|
|
|
+ rabbitMqProducer.sendByWorkQueue(ObjectUtils.isEmpty(message.getResultReceiverMqName()) ? queueModelingPost : message.getResultReceiverMqName(),
|
|
|
BuildSceneResultMqMessage.builder()
|
|
|
.buildSuccess(buildStatus.equals(ModelingBuildStatus.SUCCESS))
|
|
|
.cameraType(buildSceneResult.getCameraType())
|