|
@@ -8,6 +8,7 @@ import cn.hutool.core.lang.Console;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.common.constant.ModelingBuildStatus;
|
|
|
import com.fdkankan.common.util.CmdUtils;
|
|
@@ -105,7 +106,6 @@ public class RabbitMqListener {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@RabbitListener(
|
|
|
- //queuesToDeclare = @Queue("${queue.modeling.modeling-call}"),
|
|
|
queuesToDeclare = @Queue("#{queueNameService.getQueueName()}"),
|
|
|
concurrency = "${maxThread.modeling.modeling-call}",
|
|
|
priority = "${mq.consumerPriority}"
|
|
@@ -176,8 +176,6 @@ public class RabbitMqListener {
|
|
|
StopWatch watch = new StopWatch();
|
|
|
watch.start();
|
|
|
|
|
|
- String num = message.getSceneNum();
|
|
|
-
|
|
|
//发送记录计算状态为计算中
|
|
|
this.sendCallBuildProcessLog(message, ModelingBuildStatus.CALCULATING);
|
|
|
|
|
@@ -239,67 +237,24 @@ public class RabbitMqListener {
|
|
|
String num = message.getSceneNum();
|
|
|
//不同的相机不同的方法
|
|
|
String cameraType = message.getCameraType();
|
|
|
- String algorithm = message.getAlgorithm();
|
|
|
- //0表示有4k图,1表示没有
|
|
|
- String resolution = message.getResolution();
|
|
|
//判断调用V2还是V3版本的算法
|
|
|
String buildType = ObjectUtils.isEmpty(message.getBuildType()) ? "V2" : message.getBuildType();
|
|
|
+ if(StrUtil.isEmpty(buildType)){
|
|
|
+ buildType = "V3";
|
|
|
+ }
|
|
|
|
|
|
buildSceneResult.setCameraType(cameraType);
|
|
|
buildSceneResult.setNum(num);
|
|
|
buildSceneResult.setPath(path);
|
|
|
|
|
|
- log.info("用的算法是:" + algorithm);
|
|
|
-
|
|
|
- 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);
|
|
|
- }
|
|
|
-
|
|
|
- if (dataJson.containsKey("OnlyExportMeshObj")) {
|
|
|
- logRecord.setBuildType(2);
|
|
|
- Map<String, String> context = new HashMap<>();
|
|
|
- context.put("path", path);
|
|
|
- context.put("cameraType", cameraType);
|
|
|
- context.put("algorithm", algorithm);
|
|
|
- context.put("resolution", resolution);
|
|
|
- context.put("projectNum", num);
|
|
|
- context.put("dataJson", data);
|
|
|
- try {
|
|
|
- laserSceneObjGenerateHandler.handle(context);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- // 检测计算结果文件是否有生成
|
|
|
- String resultsPath = path + File.separator + "results" + File.separator;
|
|
|
- if (!new File(resultsPath + "upload.json").exists()) {
|
|
|
- log.error("未检测到计算结果文件:upload.json");
|
|
|
- return ModelingBuildStatus.FAILED;
|
|
|
- }
|
|
|
-
|
|
|
- return ModelingBuildStatus.SUCCESS;
|
|
|
+ //调用算法
|
|
|
+ //todo 算法部调试用,完善后去掉
|
|
|
+ if(num.startsWith("SX-")){
|
|
|
+ this.computer(num, path);
|
|
|
+ }else{
|
|
|
+ ComputerUtil.computer(num, path, buildType);
|
|
|
}
|
|
|
|
|
|
- Map<String, String> dataMap = buildService.getTypeString(cameraType, algorithm, resolution,dataJson);
|
|
|
-
|
|
|
- String splitType = dataMap.get("splitType");
|
|
|
- String skyboxType = dataMap.get("skyboxType");
|
|
|
- if(Objects.nonNull(message.getExt().get("splitType"))){
|
|
|
- splitType = (String) message.getExt().get("splitType");
|
|
|
- }
|
|
|
- if(Objects.nonNull(message.getExt().get("skyboxType"))){
|
|
|
- skyboxType = (String) message.getExt().get("skyboxType");
|
|
|
- }
|
|
|
-
|
|
|
- ComputerUtil.createProjectAndDataFile(path,num, splitType, skyboxType,null,null);
|
|
|
- //计算模型并返回需要上传oss的文件集合
|
|
|
- ComputerUtil.computer(num, path, buildType);
|
|
|
-
|
|
|
// 检测计算结果文件是否有生成
|
|
|
String resultsPath = path + File.separator + "results" + File.separator;
|
|
|
if (!new File(resultsPath + "upload.json").exists()) {
|
|
@@ -316,6 +271,32 @@ public class RabbitMqListener {
|
|
|
return ModelingBuildStatus.SUCCESS;
|
|
|
}
|
|
|
|
|
|
+ public void computer(String projectNum, String path) throws Exception {
|
|
|
+ new HashMap();
|
|
|
+ path = path.replace("//", "/");
|
|
|
+ log.info("开始建模:" + projectNum);
|
|
|
+ String command = "sudo bash /home/ubuntu/bin_sx/Launcher.sh " + path;
|
|
|
+ CreateObjUtil.callshell(command);
|
|
|
+ log.info("计算完毕:" + command);
|
|
|
+ String uploadJsonPath = path + File.separator + "results" + File.separator + "upload.json";
|
|
|
+ String uploadData = FileUtils.readFile(uploadJsonPath);
|
|
|
+ log.info("upload.json 文件路径:{}, 内容:{}", uploadJsonPath, uploadData);
|
|
|
+ JSONObject uploadJson = null;
|
|
|
+ JSONArray array = null;
|
|
|
+ if (uploadData != null) {
|
|
|
+ uploadJson = JSONObject.parseObject(uploadData);
|
|
|
+ array = uploadJson.getJSONArray("upload");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (array == null) {
|
|
|
+ String instanceId = FileUtils.readFile("/opt/hosts/hosts.txt");
|
|
|
+ FileUtils.writeFile(path + File.separator + "javaErrorNow.log", instanceId + ":计算错误!");
|
|
|
+ Thread.sleep(10000L);
|
|
|
+ FileUtils.writeFile(path + File.separator + "javaError.log", instanceId + ":计算错误!");
|
|
|
+ throw new Exception("upload.json数据出错");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private ModelingBuildStatus buildScene4E57(BuildSceneCallMessage message, BuildSceneResultBean buildSceneResult) throws Exception{
|
|
|
//如果mq生产者在消息体中设置了结算结果mq队列名,就发到这个队列,否则就发送到默认队列
|
|
|
String path = message.getPath();
|
|
@@ -326,10 +307,6 @@ public class RabbitMqListener {
|
|
|
buildSceneResult.setNum(num);
|
|
|
buildSceneResult.setPath(path);
|
|
|
|
|
|
- String splitType = "SPLIT_V27";
|
|
|
- String skyboxType = "SKYBOX_V5";
|
|
|
-
|
|
|
- ComputerUtil.createProjectAndDataFile(path,num, splitType, skyboxType,null,null);
|
|
|
//计算模型并返回需要上传oss的文件集合
|
|
|
ComputerUtil.computer(num, path, "V3");
|
|
|
|