|
@@ -11,12 +11,17 @@ import static com.fdkankan.push.PushMessageConfig.IOS_SECRET_Z;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
+import cn.hutool.core.exceptions.ExceptionUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.fdkankan.common.constant.BuildStatus;
|
|
import com.fdkankan.common.constant.ConstantFilePath;
|
|
import com.fdkankan.common.constant.ConstantFilePath;
|
|
import com.fdkankan.common.constant.ConstantUrl;
|
|
import com.fdkankan.common.constant.ConstantUrl;
|
|
|
|
+import com.fdkankan.common.constant.ModelingBuildStatus;
|
|
|
|
+import com.fdkankan.common.constant.ServerCode;
|
|
import com.fdkankan.common.constant.UploadFilePath;
|
|
import com.fdkankan.common.constant.UploadFilePath;
|
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.util.ComputerUtil;
|
|
import com.fdkankan.common.util.ComputerUtil;
|
|
import com.fdkankan.common.util.CreateObjUtil;
|
|
import com.fdkankan.common.util.CreateObjUtil;
|
|
import com.fdkankan.common.util.FileUtil;
|
|
import com.fdkankan.common.util.FileUtil;
|
|
@@ -25,7 +30,11 @@ import com.fdkankan.common.util.SceneUtil;
|
|
import com.fdkankan.dingtalk.DingTalkSendUtils;
|
|
import com.fdkankan.dingtalk.DingTalkSendUtils;
|
|
import com.fdkankan.fyun.constant.StorageType;
|
|
import com.fdkankan.fyun.constant.StorageType;
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
|
|
+import com.fdkankan.modeling.bean.BuildSceneResultBean;
|
|
import com.fdkankan.modeling.constants.SysConstants;
|
|
import com.fdkankan.modeling.constants.SysConstants;
|
|
|
|
+import com.fdkankan.modeling.entity.BuildLog;
|
|
|
|
+import com.fdkankan.modeling.exception.BuildException;
|
|
|
|
+import com.fdkankan.modeling.service.IBuildLogService;
|
|
import com.fdkankan.mq.message.BuildSceneFailDTMqMessage;
|
|
import com.fdkankan.mq.message.BuildSceneFailDTMqMessage;
|
|
import com.fdkankan.mq.message.BuildSceneMqMessage;
|
|
import com.fdkankan.mq.message.BuildSceneMqMessage;
|
|
import com.fdkankan.mq.message.BuildSceneResultMqMessage;
|
|
import com.fdkankan.mq.message.BuildSceneResultMqMessage;
|
|
@@ -60,6 +69,7 @@ import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeoutException;
|
|
import java.util.concurrent.TimeoutException;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.apache.commons.lang3.time.StopWatch;
|
|
import org.apache.rocketmq.spring.annotation.MessageModel;
|
|
import org.apache.rocketmq.spring.annotation.MessageModel;
|
|
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
|
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
|
import org.apache.rocketmq.spring.core.RocketMQListener;
|
|
import org.apache.rocketmq.spring.core.RocketMQListener;
|
|
@@ -119,99 +129,83 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
@Autowired
|
|
@Autowired
|
|
private DingTalkSendUtils dingTalkSendUtils;
|
|
private DingTalkSendUtils dingTalkSendUtils;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBuildLogService buildLogService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- public synchronized void onMessage(String message) {
|
|
|
|
|
|
+ public void onMessage(String message) {
|
|
log.info("开始处理消息,消费者组:{},主题名:{}, 消息内容:{}", consumerGroup, topicName, message);
|
|
log.info("开始处理消息,消费者组:{},主题名:{}, 消息内容:{}", consumerGroup, topicName, message);
|
|
|
|
+ if (ObjectUtils.isEmpty(message)) {
|
|
|
|
+ SysConstants.SYSTEM_BUILDING = false;
|
|
|
|
+ log.error("消息体为空,退出构建,当前服务器id:{}", SysConstants.hostName);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
BuildSceneMqMessage buildSceneMqMessage = JSONObject.parseObject(message, BuildSceneMqMessage.class);
|
|
BuildSceneMqMessage buildSceneMqMessage = JSONObject.parseObject(message, BuildSceneMqMessage.class);
|
|
- if(StrUtil.isBlank(buildSceneMqMessage.getSceneNum())){
|
|
|
|
- log.error("消息结构错误,消费者组:{},主题名:{}, 消息内容:{}", consumerGroup, topicName, message);
|
|
|
|
|
|
+ if(Objects.isNull(buildSceneMqMessage) || StrUtil.isBlank(buildSceneMqMessage.getSceneNum())){
|
|
|
|
+ log.error("消息内容错误,消费者组:{},主题名:{}, 消息内容:{}", consumerGroup, topicName, message);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
process(buildSceneMqMessage);
|
|
process(buildSceneMqMessage);
|
|
|
|
+
|
|
|
|
+ log.info("处理消息结束,消费者组:{},主题名:{}, 消息内容:{}", consumerGroup, topicName, message);
|
|
}
|
|
}
|
|
|
|
|
|
public void process(BuildSceneMqMessage message) {
|
|
public void process(BuildSceneMqMessage message) {
|
|
- final ExecutorService exec = Executors.newFixedThreadPool(1);
|
|
|
|
- Callable<String> call = (Callable<String>) () -> {
|
|
|
|
- //开始执行耗时操作
|
|
|
|
- String key = RedisKey.SCENE_BUILDING + message.getSceneNum();
|
|
|
|
- try {
|
|
|
|
- // 获取缓存锁,防止重复消费
|
|
|
|
- Long building = redisUtil.incr(key, 1);
|
|
|
|
- if (building.compareTo(1L) != 0) {
|
|
|
|
- log.error("场景正在构建中,退出构建,当前服务器id:{},参数:{}", SysConstants.hostName, JSONObject.toJSONString(message));
|
|
|
|
- } else {
|
|
|
|
- redisUtil.expire(key, Duration.of(SysConstants.modelTimeOut, ChronoUnit.HOURS));
|
|
|
|
- }
|
|
|
|
- //休眠2秒等待数据入库
|
|
|
|
- Thread.sleep(2000L);
|
|
|
|
- try {
|
|
|
|
- FileUtils.writeFile("/opt/hosts/running.txt", DateUtil.formatDateTime(new Date()));
|
|
|
|
- String tomcatLog = "scenenum:" + message.getSceneNum() + "\ntime:" + DateUtil.formatDateTime(new Date()) +
|
|
|
|
- " action:create hostname:" + SysConstants.hostName;
|
|
|
|
- //打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
|
|
|
|
- FileWriter writer = new FileWriter("/mnt/elastic_log/tomcat" + "_" + message.getSceneNum() + ".log", true);
|
|
|
|
- writer.write(tomcatLog);
|
|
|
|
- writer.close();
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
|
|
|
|
- this.buildScene(message);
|
|
|
|
- redisUtil.del(key);
|
|
|
|
- try {
|
|
|
|
- FileUtils.deleteFile("/opt/hosts/running.txt");
|
|
|
|
- String tomcatLog = "scenenum:" + message.getSceneNum() + "\ntime:" + DateUtil.formatDateTime(new Date()) +
|
|
|
|
- " action:delete hostname:" + SysConstants.hostName;
|
|
|
|
- //打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
|
|
|
|
- FileWriter writer = new FileWriter("/mnt/elastic_log/tomcat" + "_" + message.getSceneNum() + "log", true);
|
|
|
|
- writer.write(tomcatLog);
|
|
|
|
- writer.close();
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("大场景计算失败",e);
|
|
|
|
- // TODO: 2022/1/25 测试阶段,先注释掉推送
|
|
|
|
-// this.sendDingTalkMq("计算失败", message);
|
|
|
|
- }finally {
|
|
|
|
- //释放锁
|
|
|
|
- redisUtil.del(key);
|
|
|
|
- }
|
|
|
|
- log.info("场景生成好了***");
|
|
|
|
- return "success";
|
|
|
|
- };
|
|
|
|
- Future<String> future = exec.submit(call);
|
|
|
|
|
|
+ SysConstants.SYSTEM_BUILDING = true;
|
|
|
|
+ if (SysConstants.SYSTEM_OFFING) {
|
|
|
|
+ SysConstants.SYSTEM_BUILDING = false;
|
|
|
|
+ log.error("服务实例:{} 正在关闭,退出构建!", SysConstants.hostName);
|
|
|
|
+ throw new BusinessException(ServerCode.SERVER_CLOSING);
|
|
|
|
+ }
|
|
|
|
+ //开始计时
|
|
|
|
+ StopWatch watch = new StopWatch();
|
|
|
|
+ watch.start();
|
|
|
|
+
|
|
|
|
+ BuildLog buildLog = new BuildLog();
|
|
|
|
+ BuildSceneResultBean buildSceneResult = new BuildSceneResultBean();
|
|
|
|
+
|
|
|
|
+ Future<BuildSceneResultBean> future = null;
|
|
try {
|
|
try {
|
|
- future.get(SysConstants.modelTimeOut, TimeUnit.HOURS); //任务处理超时时间设为 24个小时
|
|
|
|
|
|
+
|
|
|
|
+ //休眠2秒等待准备数据
|
|
|
|
+ Thread.sleep(2000L);
|
|
|
|
+
|
|
|
|
+ //计算前准备
|
|
|
|
+ preBuild(message, buildLog);
|
|
|
|
+
|
|
|
|
+ future = SysConstants.executorService.submit(()->{
|
|
|
|
+ return buildScene(message);
|
|
|
|
+ });
|
|
|
|
+ buildSceneResult = future.get(SysConstants.modelTimeOut, TimeUnit.SECONDS);
|
|
|
|
+
|
|
|
|
+ //结束计时
|
|
|
|
+ watch.stop();
|
|
|
|
+ buildLog.setDuration(watch.getTime(TimeUnit.SECONDS));
|
|
} catch (TimeoutException ex) {
|
|
} catch (TimeoutException ex) {
|
|
- ex.printStackTrace();
|
|
|
|
- StringWriter trace=new StringWriter();
|
|
|
|
- ex.printStackTrace(new PrintWriter(trace));
|
|
|
|
- log.error("超时了");
|
|
|
|
- log.error(trace.toString());
|
|
|
|
- FileUtils.deleteFile("/opt/hosts/running.txt");
|
|
|
|
- future.cancel(true);
|
|
|
|
- // TODO: 2022/1/25 测试阶段,先注释掉推送
|
|
|
|
-// this.sendDingTalkMq("计算超时", message);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- StringWriter trace=new StringWriter();
|
|
|
|
- e.printStackTrace(new PrintWriter(trace));
|
|
|
|
- log.error(trace.toString());
|
|
|
|
- FileUtils.deleteFile("/opt/hosts/running.txt");
|
|
|
|
- future.cancel(true);
|
|
|
|
- // TODO: 2022/1/25 测试阶段,先注释掉推送
|
|
|
|
-// this.sendDingTalkMq("计算失败", message);
|
|
|
|
|
|
+ log.error("服务实例:{} 构建异常:",SysConstants.hostName,ex);
|
|
|
|
+ buildSceneResult.setBuildStatus(ModelingBuildStatus.OVERTIME);
|
|
|
|
+ } catch (BuildException e){
|
|
|
|
+ buildSceneResult.setBuildStatus(e.getBuildStatus());
|
|
|
|
+ } catch(Exception e) {
|
|
|
|
+ log.error("服务实例:{} 构建异常:", SysConstants.hostName, e);
|
|
|
|
+ if (e.getCause() instanceof BuildException) {
|
|
|
|
+ buildSceneResult.setBuildStatus(((BuildException) e.getCause()).getBuildStatus());
|
|
|
|
+ } else {
|
|
|
|
+ buildSceneResult.setBuildStatus(ModelingBuildStatus.FAILED);
|
|
|
|
+ //未知异常,记录异常信息
|
|
|
|
+ buildLog.setReason(ExceptionUtil.stacktraceToString(e, 3000));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ //计算后处理
|
|
|
|
+ afterBuild(message, buildSceneResult, buildLog);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private void buildScene(BuildSceneMqMessage message){
|
|
|
|
- boolean buildSuccess = Boolean.FALSE;
|
|
|
|
|
|
+ private BuildSceneResultBean buildScene(BuildSceneMqMessage message){
|
|
|
|
+ ModelingBuildStatus buildStatus = ModelingBuildStatus.FAILED;
|
|
String projectNum = null;
|
|
String projectNum = null;
|
|
Long computeTime = null;//计算耗时
|
|
Long computeTime = null;//计算耗时
|
|
- JSONObject videosJson = null;
|
|
|
|
//如果mq生产者在消息体中执行了计算结果mq的主题名,就发到这个主题名,否则就发送到配置的主题名
|
|
//如果mq生产者在消息体中执行了计算结果mq的主题名,就发到这个主题名,否则就发送到配置的主题名
|
|
String resultTopicName = StrUtil.isNotBlank(message.getResultReceiverMqName()) ?
|
|
String resultTopicName = StrUtil.isNotBlank(message.getResultReceiverMqName()) ?
|
|
message.getResultReceiverMqName() : buildSceneResultTopic;
|
|
message.getResultReceiverMqName() : buildSceneResultTopic;
|
|
@@ -232,9 +226,6 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
String resolution = message.getResolution();
|
|
String resolution = message.getResolution();
|
|
//判断调用V2还是V3版本的算法
|
|
//判断调用V2还是V3版本的算法
|
|
String buildType = ObjectUtils.isEmpty(message.getBuildType()) ? "V2" : message.getBuildType();
|
|
String buildType = ObjectUtils.isEmpty(message.getBuildType()) ? "V2" : message.getBuildType();
|
|
- String webSite = message.getWebSite();
|
|
|
|
- Integer sceneStatus = message.getSceneStatus();
|
|
|
|
- String thumb = message.getThumb();
|
|
|
|
|
|
|
|
String dataPath = "data/data" + projectNum;//老版本文件路径
|
|
String dataPath = "data/data" + projectNum;//老版本文件路径
|
|
|
|
|
|
@@ -244,11 +235,6 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
Integer videoVersion = null;
|
|
Integer videoVersion = null;
|
|
|
|
|
|
try{
|
|
try{
|
|
- if(StringUtils.equals(message.getIsStandardization(),"1")){
|
|
|
|
- //表示标定算法
|
|
|
|
- ComputerUtil.computerCalibration(message.getPath());
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
|
|
Map<String, String> dataMap = ComputerUtil.getTypeString(cameraType, algorithm,
|
|
Map<String, String> dataMap = ComputerUtil.getTypeString(cameraType, algorithm,
|
|
resolution);
|
|
resolution);
|
|
@@ -277,17 +263,6 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
- //休眠1秒,否则可能获取不到场景资源
|
|
|
|
- Thread.sleep(1000);
|
|
|
|
-// if(sceneProId == null){
|
|
|
|
-// log.error("场景不存在,场景码:{}", projectNum);
|
|
|
|
-// // TODO: 2022/1/25 测试阶段,先注释掉推送
|
|
|
|
-//// this.sendDingTalkMq("场景不存在", message);
|
|
|
|
-// return;
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- long start = System.currentTimeMillis();
|
|
|
|
-
|
|
|
|
path = SceneUtil.getPath(path, cameraName, fileId, Integer.parseInt(cameraType), unicode);
|
|
path = SceneUtil.getPath(path, cameraName, fileId, Integer.parseInt(cameraType), unicode);
|
|
|
|
|
|
String dataFdagePath = path + File.separator + "capture" +File.separator+"data.fdage";
|
|
String dataFdagePath = path + File.separator + "capture" +File.separator+"data.fdage";
|
|
@@ -320,7 +295,6 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
//计算模型并返回需要上传oss的文件集合
|
|
//计算模型并返回需要上传oss的文件集合
|
|
map = ComputerUtil.computer(projectNum, path, buildType);
|
|
map = ComputerUtil.computer(projectNum, path, buildType);
|
|
//计算完成时间
|
|
//计算完成时间
|
|
- computeTime = (System.currentTimeMillis() - start) / 1000;
|
|
|
|
log.info("计算完成耗时:{}",computeTime);
|
|
log.info("计算完成耗时:{}",computeTime);
|
|
|
|
|
|
if(Integer.parseInt(cameraType) == 5 || Integer.parseInt(cameraType) == 6){
|
|
if(Integer.parseInt(cameraType) == 5 || Integer.parseInt(cameraType) == 6){
|
|
@@ -353,18 +327,66 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
}
|
|
}
|
|
|
|
|
|
CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
|
|
CreateObjUtil.deleteFile(path.replace(ConstantFilePath.BUILD_MODEL_PATH, "/") + "/capture");
|
|
- buildSuccess = Boolean.TRUE;
|
|
|
|
- } catch(Exception e){
|
|
|
|
- log.error("计算大场景失败"+projectNum, e);
|
|
|
|
- // TODO: 2022/1/25 测试阶段,先注释掉推送
|
|
|
|
-// this.sendDingTalkMq("计算失败", message);
|
|
|
|
- }finally {
|
|
|
|
- //发送计算结果到mq,再由消费者消费并操作数据库
|
|
|
|
- this.sendCallResult(buildSuccess, resultTopicName, cameraType, computeTime, fileId, payStatus,
|
|
|
|
- projectNum, videosJson, map, path, pushChannel, pushToken,prefix, videoVersion);
|
|
|
|
|
|
+ buildStatus = ModelingBuildStatus.SUCCESS;
|
|
|
|
+ }
|
|
|
|
+ finally {
|
|
//上传status.json console.log
|
|
//上传status.json console.log
|
|
- this.uploadStatusJsonAndConsoleLog(sceneStatus, webSite, projectNum, thumb, payStatus);
|
|
|
|
|
|
+// 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();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void afterBuild(BuildSceneMqMessage message, BuildSceneResultBean buildSceneResult, BuildLog buildLog){
|
|
|
|
+ try {
|
|
|
|
+ ModelingBuildStatus buildStatus = buildSceneResult.getBuildStatus();
|
|
|
|
+ String buildLogPath = String.format(UploadFilePath.BUILD_LOG_PATH, message.getSceneNum());
|
|
|
|
+ log.info("服务{} 计算结束:{},计算状态:{}", SysConstants.hostName, buildLog.getNum(),buildStatus.message());
|
|
|
|
+
|
|
|
|
+ if(!buildStatus.equals(ModelingBuildStatus.REPEAT)){
|
|
|
|
+ //释放锁
|
|
|
|
+ redisUtil.del(String.format(RedisKey.SCENE_BUILDING, message.getSceneNum()));
|
|
|
|
+ //如果是重复计算,没有走到计算逻辑,不需要上传日志文件
|
|
|
|
+ buildLog.setLogDetailPath(prefixAli+ buildLogPath + "console.log");
|
|
|
|
+ }
|
|
|
|
+ buildLog.setBuildStatus(buildStatus.code());
|
|
|
|
+ buildLog.setCameraType(Integer.parseInt(buildSceneResult.getCameraType()));
|
|
|
|
+ buildLogService.updateById(buildLog);
|
|
|
|
+
|
|
|
|
+ if(buildStatus.equals(ModelingBuildStatus.REPEAT)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //生成status.json文件
|
|
|
|
+ this.writeStatusJson(message.getSceneStatus(), message.getWebSite(),
|
|
|
|
+ message.getSceneNum(),message.getThumb(),message.getPayStatus());
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("计算后业务处理出错!", e);
|
|
|
|
+ }finally {
|
|
|
|
+ //发送计算结果mq
|
|
|
|
+ buildSceneResult.setDuration(buildLog.getDuration());
|
|
|
|
+ this.sendCallResult(message, buildSceneResult);
|
|
|
|
+
|
|
|
|
+ //计算完毕,将当前系统构建状态改为false
|
|
|
|
+ SysConstants.SYSTEM_BUILDING = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -387,6 +409,25 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void preBuild(BuildSceneMqMessage message, BuildLog buildLog) throws BuildException {
|
|
|
|
+
|
|
|
|
+ // 初始化日志参数
|
|
|
|
+ buildLog.setHostName(SysConstants.hostName);
|
|
|
|
+ buildLog.setTopicName(topicName);
|
|
|
|
+ buildLog.setNum(message.getSceneNum());
|
|
|
|
+ buildLog.setDataSource(message.getDataSource());
|
|
|
|
+ buildLogService.save(buildLog);
|
|
|
|
+
|
|
|
|
+ String key = RedisKey.SCENE_BUILDING + message.getSceneNum();
|
|
|
|
+ Long building = redisUtil.incr(key, 1);
|
|
|
|
+ if (building.compareTo(1L) != 0) {
|
|
|
|
+ log.error("场景正在构建中,退出构建,当前服务器id:{},参数:{}", SysConstants.hostName, JSONObject.toJSONString(message));
|
|
|
|
+ throw new BuildException(ModelingBuildStatus.REPEAT);
|
|
|
|
+ } else {
|
|
|
|
+ redisUtil.expire(key, Duration.of(SysConstants.modelTimeOut, ChronoUnit.HOURS));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void copyToEditDir(String num) throws IOException {
|
|
private void copyToEditDir(String num) throws IOException {
|
|
|
|
|
|
String editImagesPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
|
|
String editImagesPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
|
|
@@ -405,28 +446,43 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void sendCallResult(boolean buildSuccess, String resultTopicName, String cameraType, Long computeTime, String fileId,
|
|
|
|
- Integer payStatus, String projectNum, JSONObject videosJson,Map<String, String> uploadFiles,
|
|
|
|
- String path, Integer pushChannel, String pushToken, String prefix, Integer videoVersion){
|
|
|
|
- rocketMQProducer.sendOneWay(resultTopicName,
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 发送计算结果
|
|
|
|
+ * @param message
|
|
|
|
+ * @param buildSceneResult
|
|
|
|
+ */
|
|
|
|
+ private void sendCallResult(BuildSceneMqMessage message, BuildSceneResultBean buildSceneResult){
|
|
|
|
+ ModelingBuildStatus buildStatus = buildSceneResult.getBuildStatus();
|
|
|
|
+ //重复计算不需要发送mq做后置处理
|
|
|
|
+ if(buildStatus.equals(ModelingBuildStatus.REPEAT)){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ boolean buildSuccess = buildStatus.equals(ModelingBuildStatus.SUCCESS) ? true : false;
|
|
|
|
+ rocketMQProducer.sendOneWay(buildSceneResult.getResultTopicName(),
|
|
BuildSceneResultMqMessage.builder()
|
|
BuildSceneResultMqMessage.builder()
|
|
.buildSuccess(buildSuccess)
|
|
.buildSuccess(buildSuccess)
|
|
- .cameraType(cameraType)
|
|
|
|
- .computeTime(computeTime)
|
|
|
|
- .fileId(fileId)
|
|
|
|
- .payStatus(payStatus)
|
|
|
|
- .sceneCode(projectNum)
|
|
|
|
- .uploadFiles(uploadFiles)
|
|
|
|
- .path(path)
|
|
|
|
- .pushChannel(pushChannel)
|
|
|
|
- .pushToken(pushToken)
|
|
|
|
- .prefix(prefix)
|
|
|
|
- .videoVersion(videoVersion)
|
|
|
|
|
|
+ .cameraType(buildSceneResult.getCameraType())
|
|
|
|
+ .computeTime(buildSceneResult.getDuration())
|
|
|
|
+ .fileId(buildSceneResult.getFileId())
|
|
|
|
+ .payStatus(buildSceneResult.getPayStatus())
|
|
|
|
+ .sceneCode(message.getSceneNum())
|
|
|
|
+ .uploadFiles(buildSceneResult.getUploadMap())
|
|
|
|
+ .path(buildSceneResult.getPath())
|
|
|
|
+ .pushChannel(buildSceneResult.getPushChannel())
|
|
|
|
+ .pushToken(buildSceneResult.getPushToken())
|
|
|
|
+ .prefix(buildSceneResult.getPrefix())
|
|
|
|
+ .videoVersion(buildSceneResult.getVideoVersion())
|
|
.build());
|
|
.build());
|
|
|
|
+
|
|
|
|
+ //如果是计算失败,需要发送钉钉
|
|
|
|
+ if(!buildSuccess){
|
|
|
|
+ // TODO: 2022/1/25 测试阶段,先注释掉推送
|
|
|
|
+// this.sendDingTalkMq(buildStatus.message(), message);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- private void uploadStatusJsonAndConsoleLog(Integer sceneStatus, String webSite, String projectNum,
|
|
|
|
- String thumb, Integer payStatus){
|
|
|
|
|
|
+ private void writeStatusJson(Integer sceneStatus, String webSite,
|
|
|
|
+ String projectNum, String thumb, Integer payStatus){
|
|
try{
|
|
try{
|
|
JSONObject statusJson = new JSONObject();
|
|
JSONObject statusJson = new JSONObject();
|
|
//临时将-2改成1,app还没完全更新
|
|
//临时将-2改成1,app还没完全更新
|
|
@@ -444,7 +500,7 @@ public class BuildSceneListener implements RocketMQListener<String> {
|
|
FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"status.json", statusJson.toString());
|
|
FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"status.json", statusJson.toString());
|
|
|
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
- log.error("上传status.json/console.log失败", e);
|
|
|
|
|
|
+ log.error("生成status.json失败!", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|