|
@@ -1,5 +1,7 @@
|
|
|
package com.fdkankan.contro.mq.listener;
|
|
|
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.exceptions.ExceptionUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fdkankan.common.constant.CommonOperStatus;
|
|
@@ -7,7 +9,9 @@ import com.fdkankan.contro.constant.RedisConstants;
|
|
|
import com.fdkankan.contro.mq.service.IBuildSceneService;
|
|
|
import com.fdkankan.contro.service.ICommonService;
|
|
|
import com.fdkankan.contro.service.ISceneBuildProcessLogService;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.model.constants.SceneBuildProcessType;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneCallMessage;
|
|
|
import com.fdkankan.rabbitmq.bean.BuildSceneResultMqMessage;
|
|
|
import com.fdkankan.redis.util.RedisLockUtil;
|
|
@@ -17,8 +21,11 @@ import org.springframework.amqp.core.Message;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
@Slf4j
|
|
@@ -30,6 +37,8 @@ public class AbstrackBuildSceneListener implements IBuildSceneListener {
|
|
|
private ISceneBuildProcessLogService sceneBuildProcessLogService;
|
|
|
@Autowired
|
|
|
private ICommonService commonService;
|
|
|
+ @Resource
|
|
|
+ private FYunFileServiceInterface fileServiceInterface;
|
|
|
|
|
|
@Override
|
|
|
public void preHandle(Channel channel, String queueName, Message message, IBuildSceneService buildSceneService) throws IOException {
|
|
@@ -65,6 +74,10 @@ public class AbstrackBuildSceneListener implements IBuildSceneListener {
|
|
|
}catch (Exception e){
|
|
|
log.error("场景计算前置处理出错,num=" + num, e);
|
|
|
sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.PRE.code(), queueName, CommonOperStatus.FAILD.code(), ExceptionUtil.stacktraceToString(e, 3000));
|
|
|
+
|
|
|
+ String buildLogPath = String.format(UploadFilePath.BUILD_LOG_PATH, num);
|
|
|
+ String preLogPath = buildLogPath + "pre-error-" + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN) + ".log";
|
|
|
+ fileServiceInterface.uploadFile(ExceptionUtil.stacktraceToString(e).getBytes(StandardCharsets.UTF_8), preLogPath);
|
|
|
}
|
|
|
log.info("准备场景计算资源完成,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
|
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
@@ -96,6 +109,10 @@ public class AbstrackBuildSceneListener implements IBuildSceneListener {
|
|
|
}catch (Exception e){
|
|
|
log.error("场景计算结果处理出错,num=" + num, e);
|
|
|
sceneBuildProcessLogService.saveSceneBuildProcessLog(num, SceneBuildProcessType.POST.code(), queueName, CommonOperStatus.FAILD.code(), ExceptionUtil.stacktraceToString(e, 3000));
|
|
|
+
|
|
|
+ String buildLogPath = String.format(UploadFilePath.BUILD_LOG_PATH, num);
|
|
|
+ String preLogPath = buildLogPath + "post-error-" + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN) + ".log";
|
|
|
+ fileServiceInterface.uploadFile(ExceptionUtil.stacktraceToString(e).getBytes(StandardCharsets.UTF_8), preLogPath);
|
|
|
}
|
|
|
log.info("场景计算结果处理完成,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
|
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|