Commit 9fb8d9d1 authored by 黎博's avatar 黎博

优化编辑接口,新增发送策略

parent 065e3f4b
...@@ -130,6 +130,10 @@ public class SqlMonitorTaskController { ...@@ -130,6 +130,10 @@ public class SqlMonitorTaskController {
QuartzUtils.resumeScheduleJob(scheduler, sqlMonitorTask.getTaskName()); QuartzUtils.resumeScheduleJob(scheduler, sqlMonitorTask.getTaskName());
} }
} }
// 如果报警频率发生变更
if (!sqlMonitorTask.getTaskCron().equals(sqlMonitorTaskOld.getTaskCron())) {
QuartzUtils.updateSqlScheduleJob(scheduler, sqlMonitorTask);
}
return JsonResult.buildSuccessResult("监控修改成功!"); return JsonResult.buildSuccessResult("监控修改成功!");
} }
return JsonResult.buildErrorStateResult("监控修改失败", false); return JsonResult.buildErrorStateResult("监控修改失败", false);
...@@ -217,7 +221,7 @@ public class SqlMonitorTaskController { ...@@ -217,7 +221,7 @@ public class SqlMonitorTaskController {
} }
String markdownMsg = DingdingUtils.buildMarkdownMsg("监控报警", "**" + sqlMonitorTask.getTaskName() + "**\n\n" + dingText + "\n\n" + "[请" + sqlMonitorTask.getOwner() + "同学跟进,查看报警详情.]" + "(" + qaPlatformHost + "/monitor/addSqlMonitor?id=" + sqlMonitorTask.getId() + ")", true); String markdownMsg = DingdingUtils.buildMarkdownMsg("监控报警", "**" + sqlMonitorTask.getTaskName() + "**\n\n" + dingText + "\n\n" + "[请" + sqlMonitorTask.getOwner() + "同学跟进,查看报警详情.]" + "(" + qaPlatformHost + "/monitor/addSqlMonitor?id=" + sqlMonitorTask.getId() + ")", true);
boolean result = DingdingUtils.sendToDingding(markdownMsg, dingUrl); boolean result = DingdingUtils.sendToDingding(markdownMsg, dingUrl);
return JsonResult.buildSuccessResult(result ? "发送成功!" : "发送失败!", true); return result ? JsonResult.buildSuccessResult("发送成功!") : JsonResult.buildErrorStateResult("发送失败!", false);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return JsonResult.buildErrorStateResult("发送异常!", false); return JsonResult.buildErrorStateResult("发送异常!", false);
...@@ -233,6 +237,12 @@ public class SqlMonitorTaskController { ...@@ -233,6 +237,12 @@ public class SqlMonitorTaskController {
List<Map<String, String>> strategyList = new ArrayList<>(); List<Map<String, String>> strategyList = new ArrayList<>();
Map<String, String> dailyMap = new HashMap<>(); Map<String, String> dailyMap = new HashMap<>();
Map<String, String> hourlyMap = new HashMap<>(); Map<String, String> hourlyMap = new HashMap<>();
Map<String, String> oneMinMap = new HashMap<>();
Map<String, String> fiveMinMap = new HashMap<>();
oneMinMap.put("value", "0 0/1 * * * ?");
oneMinMap.put("label", "每1分钟执行一次");
fiveMinMap.put("value", "0 0/5 * * * ?");
fiveMinMap.put("label", "每5分钟执行一次");
hourlyMap.put("value", "0 0 * * * ?"); hourlyMap.put("value", "0 0 * * * ?");
hourlyMap.put("label", "每小时执行一次"); hourlyMap.put("label", "每小时执行一次");
dailyMap.put("value", "0 0 10 * * ?"); dailyMap.put("value", "0 0 10 * * ?");
...@@ -240,6 +250,8 @@ public class SqlMonitorTaskController { ...@@ -240,6 +250,8 @@ public class SqlMonitorTaskController {
Map<String, String> weeklyMap = new HashMap<>(); Map<String, String> weeklyMap = new HashMap<>();
weeklyMap.put("value", "0 0 10 ? * 2"); weeklyMap.put("value", "0 0 10 ? * 2");
weeklyMap.put("label", "每周一上午10点执行一次"); weeklyMap.put("label", "每周一上午10点执行一次");
strategyList.add(oneMinMap);
strategyList.add(fiveMinMap);
strategyList.add(hourlyMap); strategyList.add(hourlyMap);
strategyList.add(dailyMap); strategyList.add(dailyMap);
strategyList.add(weeklyMap); strategyList.add(weeklyMap);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment