Browse Source

自动恢复插入处理历史、告警持续时间

master
review512jwy@163.com 2 weeks ago
parent
commit
a6b4f05c85
  1. 21
      src/main/java/com/techsor/datacenter/sender/dao/DashboardAlertDao.java

21
src/main/java/com/techsor/datacenter/sender/dao/DashboardAlertDao.java

@ -258,13 +258,26 @@ public class DashboardAlertDao {
Long alertHistoryId = alertHistoryDTO.getId(); Long alertHistoryId = alertHistoryDTO.getId();
// 20260630需求,自动恢复的要插入一条到处理历史
long now = System.currentTimeMillis();
String insertHandleSql = "INSERT INTO alert_handle_history (" +
"alert_history_id, device_id, alert_status, status, handle_at, detail_title, detail_content" +
") VALUES (?, ?, 1, 4, ?, ?, ?)";
jdbcTemplate.update(insertHandleSql,
alertHistoryId,
entity.getDeviceId(),
now,
"自動復旧",
"自動復旧"
);
// 更新 alert_history // 更新 alert_history
String updateAlertHistorySql = "UPDATE alert_history SET handle_status = 4, alert_status = 1 WHERE id = ? and handle_status != 3 "; String updateAlertHistorySql = "UPDATE alert_history SET handle_status = 4, alert_status = 1, alarm_duration = ? - receive_ts WHERE id = ? and handle_status != 3 ";
jdbcTemplate.update(updateAlertHistorySql, alertHistoryId); jdbcTemplate.update(updateAlertHistorySql, now, alertHistoryId);
// 更新 alert_handle_history // 更新 alert_handle_history
// status值不能是完成status != 3 // status值不能是完成status != 3
String updateHandleHistorySql = "UPDATE alert_handle_history SET status = 4, alert_status = 1 WHERE alert_history_id = ? and status != 3"; // String updateHandleHistorySql = "UPDATE alert_handle_history SET status = 4, alert_status = 1 WHERE alert_history_id = ? and status != 3";
jdbcTemplate.update(updateHandleHistorySql, alertHistoryId); // jdbcTemplate.update(updateHandleHistorySql, alertHistoryId);
} }
} }

Loading…
Cancel
Save