11.6 采集改错

dev
xiaohuo 8 months ago
parent d7ee5ad79f
commit e52a5cd73b
  1. 6
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java
  2. 5
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/job/GatherJob.java
  3. 3
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertLaunchServiceImpl.java
  4. 14
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java
  5. 15
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java
  6. 2
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/ScheduleRulesMapper.xml

@ -48,12 +48,8 @@ public class AlertMessageController extends BaseController
@ApiOperation("立即执行预警")
@Log(title = "【立即执行预警】", businessType = BusinessType.DELETE)
@PostMapping("/executeImmediate")
public AjaxResult executeImmediate(@RequestBody Map<String, List<Long>> paramMap) {
public AjaxResult executeImmediate() {
try {
List<Long> ruleIds = paramMap.get("ruleIds");
if (ruleIds == null || ruleIds.isEmpty()) {
return AjaxResult.error("请选择至少一条规则");
}
iAlertLaunchService.executeImmediateAlerts(); // 调用 Service 执行
return AjaxResult.success("立即预警任务已触发,存入成功,请查看");

@ -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);

@ -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));

@ -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();

@ -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;
}

@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectList" resultMap="ScheduleRulesResult">
SELECT *
FROM schedule_rules
WHERE status IN (0, 1)
WHERE status IN (0, 1,5)
</select>

Loading…
Cancel
Save