|
@@ -0,0 +1,116 @@
|
|
|
+package com.fdkankan.job.job;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.common.constant.CommonOperStatus;
|
|
|
+import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
|
+import com.fdkankan.common.util.DateExtUtil;
|
|
|
+import com.fdkankan.dingtalk.DingTalkSendUtils;
|
|
|
+import com.fdkankan.job.entity.SceneBuildProcessLog;
|
|
|
+import com.fdkankan.job.entity.SceneCopyLog;
|
|
|
+import com.fdkankan.job.entity.ScenePlus;
|
|
|
+import com.fdkankan.job.entity.ScenePro;
|
|
|
+import com.fdkankan.job.service.ISceneBuildProcessLogService;
|
|
|
+import com.fdkankan.job.service.ISceneCopyLogService;
|
|
|
+import com.fdkankan.job.service.IScenePlusService;
|
|
|
+import com.fdkankan.job.service.ISceneProService;
|
|
|
+import com.fdkankan.model.constants.SceneBuildProcessType;
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 场景计算超时通知
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author dengsixing
|
|
|
+ * @since 2022/12/16
|
|
|
+ **/
|
|
|
+@RefreshScope
|
|
|
+@Component
|
|
|
+public class SceneCallTimeOutNoticeHandler {
|
|
|
+
|
|
|
+ @Value("${env}")
|
|
|
+ private String env;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IScenePlusService scenePlusService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneProService sceneProService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneBuildProcessLogService sceneBuildProcessLogService;
|
|
|
+ @Autowired
|
|
|
+ private DingTalkSendUtils dingTalkSendUtils;
|
|
|
+ @Autowired
|
|
|
+ private ISceneCopyLogService sceneCopyLogService;
|
|
|
+
|
|
|
+ public static final String DINGTALK_MSG_PATTERN =
|
|
|
+ "**日期**: %s\n\n" +
|
|
|
+ "**环境**: %s\n\n" +
|
|
|
+ "%s";
|
|
|
+
|
|
|
+ @XxlJob("SceneCallTimeOutNoticeHandler")
|
|
|
+ public void SceneCallTimeOutNoticeHandler() throws Exception {
|
|
|
+ XxlJobHelper.log("SceneCallTimeOutNoticeHandler start.....");
|
|
|
+
|
|
|
+ DateTime time = DateExtUtil.offsetDay(new Date(), -2);
|
|
|
+
|
|
|
+ List<ScenePlus> list = scenePlusService.list(new LambdaQueryWrapper<ScenePlus>().eq(ScenePlus::getSceneStatus, CommonSuccessStatus.WAITING.code()).lt(ScenePlus::getUpdateTime, time));
|
|
|
+
|
|
|
+ if(CollUtil.isNotEmpty(list)){
|
|
|
+ List<String> nums = list.stream().map(v -> v.getNum()).collect(Collectors.toList());
|
|
|
+ List<SceneCopyLog> copyList = sceneCopyLogService.list(new LambdaQueryWrapper<SceneCopyLog>().in(SceneCopyLog::getNewNum, nums));
|
|
|
+ if(CollUtil.isNotEmpty(copyList)){
|
|
|
+ Set<String> newNums = copyList.stream().map(v -> v.getNewNum()).collect(Collectors.toSet());
|
|
|
+ List<ScenePlus> copys = list.stream().filter(v -> newNums.contains(v.getNum())).collect(Collectors.toList());
|
|
|
+ if(CollUtil.isNotEmpty(copys)){
|
|
|
+ list.removeAll(copys);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String envName = "";
|
|
|
+ if(env.equals("gn")){
|
|
|
+ envName = "国内";
|
|
|
+ }
|
|
|
+ if(env.equals("eur")){
|
|
|
+ envName = "国际";
|
|
|
+ }
|
|
|
+ if(env.equals("jp")){
|
|
|
+ envName = "日本";
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder timeOutNums = new StringBuilder();
|
|
|
+ if(CollUtil.isNotEmpty(list)){
|
|
|
+ for (ScenePlus scenePlus : list) {
|
|
|
+ timeOutNums.append(scenePlus.getNum()).append("\n\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ String ddMsg = String.format(DINGTALK_MSG_PATTERN, DateUtil.today(), envName, timeOutNums);
|
|
|
+
|
|
|
+ dingTalkSendUtils.sendActioncardMsgToDingRobot(ddMsg, "场景计算超时通知");
|
|
|
+ XxlJobHelper.log("SceneCallTimeOutNoticeHandler end.....");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) throws SQLException {
|
|
|
+
|
|
|
+ System.out.println("ggg 123123");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|