diff --git a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java index f6ca0cba..f0a2ba65 100644 --- a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java @@ -48,12 +48,8 @@ public class AlertMessageController extends BaseController @ApiOperation("立即执行预警") @Log(title = "【立即执行预警】", businessType = BusinessType.DELETE) @PostMapping("/executeImmediate") - public AjaxResult executeImmediate(@RequestBody Map> paramMap) { + public AjaxResult executeImmediate() { try { - List ruleIds = paramMap.get("ruleIds"); - if (ruleIds == null || ruleIds.isEmpty()) { - return AjaxResult.error("请选择至少一条规则"); - } iAlertLaunchService.executeImmediateAlerts(); // 调用 Service 执行 return AjaxResult.success("立即预警任务已触发,存入成功,请查看"); diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/job/GatherJob.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/job/GatherJob.java index fda98a32..5304d589 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/job/GatherJob.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/job/GatherJob.java @@ -40,8 +40,9 @@ public class GatherJob implements Job { try { if (rule == null) return; - // 1.状态为4时取消调度任务 - if (rule.getStatus() == 4) { + // 1.状态为5时取消调度任务 + if (rule.getStatus() == 5) { + rule.setStatus(4); Scheduler scheduler = context.getScheduler(); JobKey jobKey = context.getJobDetail().getKey(); // scheduler.deleteJob(jobKey); diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertLaunchServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertLaunchServiceImpl.java index ade8c281..9f8243de 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertLaunchServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertLaunchServiceImpl.java @@ -341,7 +341,8 @@ public class AlertLaunchServiceImpl implements IAlertLaunchService { " WHERE t3.equ_id = g1.equ_id " + " ) " + ") " + - "AND (g1." + col + " <> g2." + col + " OR g1." + col + " IS NULL OR g2." + col + " IS NULL)"; + "AND (g1." + col + " <> g2." + col + " OR g1." + col + " IS NULL OR g2." + col + " IS NULL)"+ + "AND b.status = '1'"; System.out.println(sql); System.out.println(jdbcTemplate.queryForList(sql)); diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java index 81fb8ca6..2434fd16 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java @@ -159,8 +159,10 @@ public class AlertRuleServiceImpl implements IAlertRuleService .append(" FROM equ_gather ") .append(" GROUP BY equ_id ") .append(") latest ON g.equ_id = latest.equ_id AND g.gather_time = latest.latest_time ") - .append("WHERE ") - .append(buildConditionsSql(conditions)); + .append("WHERE b.status = '1' "); // 先把固定条件放在前面 + if (!buildConditionsSql(conditions).isEmpty()) { + sql.append(" AND ").append(buildConditionsSql(conditions)); + } } else { // 其他表,需要连 equ_gather → equ_base → equ_type sql.append("src.*, g.equ_id, t.name AS equ_type,b.name AS equ_name,b.equ_number ") @@ -168,8 +170,12 @@ public class AlertRuleServiceImpl implements IAlertRuleService .append("JOIN equ_gather g ON src.equ_gather_id = g.id ") .append("JOIN equ_base b ON g.equ_id = b.id ") .append("JOIN equ_type t ON b.equ_type = t.id ") // ★ 新增关联 - .append("WHERE ") - .append(buildConditionsSql(conditions)); + .append("WHERE b.status = '1' "); // 先把固定条件放在前面 + + if (!buildConditionsSql(conditions).isEmpty()) { + sql.append(" AND ").append(buildConditionsSql(conditions)); + } + } return sql.toString(); diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java index 0f461f1e..8bc738dd 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java @@ -89,12 +89,13 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService { switch (rule.getStatus()) { case 1: // 正在执行 log.info("规则[{}]:正在执行上一个任务,等待上一个任务完成……", rule.getId()); - if (rule.getRuleType() == 2 || rule.getRuleType() == 1) { - rule.setStatus(2); - } else if (rule.getRuleType() == 0) { - log.info("改变状态为4"); - rule.setStatus(4); - } +// if (rule.getRuleType() == 2 || rule.getRuleType() == 1) { +//// rule.setStatus(2); +// } else +// if (rule.getRuleType() == 0) { + log.info("改变状态为5"); + rule.setStatus(5); +// } scheduleRulesMapper.updateScheduleRules(rule); return true; case 0: // 待执行 @@ -105,6 +106,8 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService { scheduleRulesMapper.updateScheduleRules(rule); iAlertSenderService.sendInternalMessage("采集整体任务取消成功","任务执行完此次,已取消后续任务","2"); return false; + case 5: + return true; default: return true; } diff --git a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/ScheduleRulesMapper.xml b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/ScheduleRulesMapper.xml index 3d1854d5..4533e85c 100644 --- a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/ScheduleRulesMapper.xml +++ b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/ScheduleRulesMapper.xml @@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"