|
@@ -1,11 +1,16 @@
|
|
|
package com.fdkankan.jp.xspace.listener;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.thread.ThreadUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
|
import com.fdkankan.dingtalk.DingTalkSendUtils;
|
|
|
+import com.fdkankan.fyun.config.FYunFileConfig;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.jp.xspace.common.constant.NasPathConstant;
|
|
|
+import com.fdkankan.jp.xspace.common.constant.OSSPathConstant;
|
|
|
import com.fdkankan.jp.xspace.common.exception.PackException;
|
|
|
import com.fdkankan.jp.xspace.common.rabbitmq.RabbitmqConstant;
|
|
|
import com.fdkankan.jp.xspace.common.rabbitmq.dto.SceneXspaceMqDTO;
|
|
@@ -63,6 +68,10 @@ public class RabbitMqListener {
|
|
|
private IUnityService unityService;
|
|
|
@Autowired
|
|
|
private ISceneXspaceService sceneXspaceService;
|
|
|
+ @Resource
|
|
|
+ private FYunFileServiceInterface fYunFileService;
|
|
|
+ @Resource
|
|
|
+ private FYunFileConfig fYunFileConfig;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -79,6 +88,7 @@ public class RabbitMqListener {
|
|
|
String msg = new String(message.getBody(), StandardCharsets.UTF_8);
|
|
|
log.info("开始消费消息,id:{},content:{}", messageId, msg);
|
|
|
SceneXspace bean = JSON.parseObject(msg, SceneXspace.class);
|
|
|
+ String workPath = NasPathConstant.UNITY_WORK_PATH + bean.getNum() + "/" + bean.getSerial() + "/";
|
|
|
String errorReason = null;
|
|
|
|
|
|
Future submit = executorService.submit(()-> unityService.packXspace(bean));
|
|
@@ -108,14 +118,27 @@ public class RabbitMqListener {
|
|
|
try {
|
|
|
if(bean.getStatus() == CommonSuccessStatus.FAIL.code()){
|
|
|
User user = userService.getById(bean.getUserId());
|
|
|
- String workPath = NasPathConstant.UNITY_WORK_PATH + bean.getNum() + "/" + bean.getSerial() + "/";
|
|
|
+ String errorLogPath = workPath + "error.log";
|
|
|
+ String errorLogKey = String.format(OSSPathConstant.XSPACE_SCENE_FORMAT, bean.getNum(), bean.getSerial()) + "log/error.log";
|
|
|
+ String logUrl = fYunFileConfig.getHost() + errorLogKey;
|
|
|
+ String extContent = null;
|
|
|
+ if(FileUtil.exist(errorLogPath)){
|
|
|
+ fYunFileService.uploadFile(errorLogPath, errorLogKey);
|
|
|
+ extContent = "**error-log**: " + logUrl + "\n\n";
|
|
|
+ }
|
|
|
String content = String.format(DINGTALK_MSG_PATTERN, profile, errorReason, bean.getNum(), user.getUserName(), workPath);
|
|
|
+ if(StrUtil.isNotEmpty(extContent)){
|
|
|
+ content = content + extContent;
|
|
|
+ }
|
|
|
dingTalkSendUtils.sendActioncardMsgToDingRobot(content, "场景同步失败");
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.error("发送钉钉失败", e);
|
|
|
}
|
|
|
|
|
|
+ //删除本地资源
|
|
|
+ FileUtil.del(workPath);
|
|
|
+
|
|
|
log.info("结束消费消息,id:{}", messageId);
|
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
}
|