From e52a5cd73b3accf64b4f4f9353c9e70708263a4c Mon Sep 17 00:00:00 2001 From: xiaohuo <14141624+dsgfhrh@user.noreply.gitee.com> Date: Thu, 6 Nov 2025 17:01:34 +0800 Subject: [PATCH 1/7] =?UTF-8?q?11.6=20=E9=87=87=E9=9B=86=E6=94=B9=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AlertMessageController.java | 6 +----- .../main/java/com/alops/system/job/GatherJob.java | 5 +++-- .../service/impl/AlertLaunchServiceImpl.java | 3 ++- .../system/service/impl/AlertRuleServiceImpl.java | 14 ++++++++++---- .../service/impl/ScheduleRulesServiceImpl.java | 15 +++++++++------ .../mapper/system/ScheduleRulesMapper.xml | 2 +- 6 files changed, 26 insertions(+), 19 deletions(-) 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" From ba849694f15fe0ed10b2155a494f7e404435df63 Mon Sep 17 00:00:00 2001 From: xiaohuo <14141624+dsgfhrh@user.noreply.gitee.com> Date: Thu, 6 Nov 2025 21:01:48 +0800 Subject: [PATCH 2/7] =?UTF-8?q?11.6=E6=B7=BB=E5=8A=A0=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E4=B8=AD=E6=96=AD=E9=92=A9=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/mapper/ScheduleRulesMapper.java | 6 ++ .../service/impl/ScheduleShutdownHook.java | 57 +++++++++++++++++++ .../mapper/system/ScheduleRulesMapper.xml | 7 +++ 3 files changed, 70 insertions(+) create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleShutdownHook.java diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/ScheduleRulesMapper.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/ScheduleRulesMapper.java index a2df65b0..5baf8948 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/ScheduleRulesMapper.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/ScheduleRulesMapper.java @@ -16,6 +16,12 @@ public interface ScheduleRulesMapper { + /** + * 将 status 为 1 或 5 的记录更新为 3 + * @return 更新的记录数 + */ + int updateStatusFrom1And5To3(); + public List selectList(); public List selectListOne(); diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleShutdownHook.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleShutdownHook.java new file mode 100644 index 00000000..a150e71c --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleShutdownHook.java @@ -0,0 +1,57 @@ +package com.alops.system.service.impl; + +import com.alops.system.mapper.ScheduleRulesMapper; +import com.alops.system.service.IAlertSenderService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +@Component +public class ScheduleShutdownHook { + private static final Logger log = LoggerFactory.getLogger(ScheduleShutdownHook.class); + + @Autowired + private ScheduleRulesMapper scheduleRulesMapper; + + @Autowired + private IAlertSenderService iAlertSenderService; + + private static ScheduleShutdownHook instance; + + @PostConstruct + public void init() { + instance = this; + registerShutdownHook(); + } + + private void registerShutdownHook() { + Runtime.getRuntime().addShutdownHook(new Thread(() -> { + log.info("检测到应用关闭,开始更新任务状态..."); + updateInterruptedStatus(); + })); + } + + private void updateInterruptedStatus() { + try { + // 将所有状态为1(执行中)、5(等待中)的任务更新为3(执行失败) + int affectedRows = scheduleRulesMapper.updateStatusFrom1And5To3(); + log.info("成功更新 {} 个任务状态为中断", affectedRows); + + // 发送站内信 + if (affectedRows > 0) { + iAlertSenderService.sendInternalMessage( + "系统中断", + "采集任务被外部中断,已更新" + affectedRows + "个任务状态", + "2" + ); + } + + } catch (Exception e) { + log.error("中断处理失败: {}", e.getMessage(), e); + // 备用方案:直接输出到控制台 + System.err.println("中断处理失败: " + e.getMessage()); + } + } +} 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 4533e85c..7598fa92 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 @@ -42,6 +42,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select id, rule_name, rule_type, frequency, gather_time, start_time, end_time, status,created_at ,created_by from schedule_rules + + UPDATE schedule_rules + SET status = 3 + WHERE status IN (1, 5) + + + SELECT * From 9039f8db87a3c57c79f5b1ab25d27ab494829d0c Mon Sep 17 00:00:00 2001 From: Wangxin Date: Thu, 6 Nov 2025 21:37:33 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E3=80=90web=E3=80=91=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=AB=99=E5=86=85=E4=BF=A1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alops-ui/src/api/message/index.js | 15 +++ .../alops-ui/src/views/message/index.vue | 95 +++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 ALOps_sys_fe/alops-ui/src/api/message/index.js create mode 100644 ALOps_sys_fe/alops-ui/src/views/message/index.vue diff --git a/ALOps_sys_fe/alops-ui/src/api/message/index.js b/ALOps_sys_fe/alops-ui/src/api/message/index.js new file mode 100644 index 00000000..0fcd0dab --- /dev/null +++ b/ALOps_sys_fe/alops-ui/src/api/message/index.js @@ -0,0 +1,15 @@ +import request from '@/utils/request' +import { parseStrEmpty } from "@/utils/ruoyi"; + +// 查询预警消息列表 +export function messageList(query) { + return request({ + url: '/message/list', + method: 'get', + params: query + }) +} + + + + diff --git a/ALOps_sys_fe/alops-ui/src/views/message/index.vue b/ALOps_sys_fe/alops-ui/src/views/message/index.vue new file mode 100644 index 00000000..5d2c7238 --- /dev/null +++ b/ALOps_sys_fe/alops-ui/src/views/message/index.vue @@ -0,0 +1,95 @@ + + + From f1d706c75909bbc55dca2d29f891c60da97d8eda Mon Sep 17 00:00:00 2001 From: Wangxin Date: Thu, 6 Nov 2025 21:49:13 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E3=80=90web=E3=80=91=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=A9=BA=E7=8A=B6=E6=80=81=E5=88=A4=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inMonitoring/devicesState/history.vue | 8 ++++---- .../inMonitoring/devicesState/interface.vue | 18 +++++++++--------- .../inMonitoring/devicesState/routing.vue | 6 +++--- .../views/inMonitoring/devicesState/vlan.vue | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/history.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/history.vue index 91e92cb0..f3687bd7 100644 --- a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/history.vue +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/history.vue @@ -10,17 +10,17 @@ > @@ -39,7 +39,7 @@ diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/interface.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/interface.vue index 50cd32bb..cb7d24dc 100644 --- a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/interface.vue +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/interface.vue @@ -10,12 +10,12 @@ > @@ -25,37 +25,37 @@ diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/routing.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/routing.vue index 4e1af7dd..70c5191c 100644 --- a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/routing.vue +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/routing.vue @@ -10,17 +10,17 @@ > diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/vlan.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/vlan.vue index d9dcc453..29de0312 100644 --- a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/vlan.vue +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/vlan.vue @@ -10,17 +10,17 @@ > From ddc716eabd782942f72911eb44b0367091c61c0f Mon Sep 17 00:00:00 2001 From: Wangxin Date: Thu, 6 Nov 2025 21:58:50 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E3=80=90web=E3=80=91=20=E7=AB=99=E5=86=85?= =?UTF-8?q?=E4=BF=A1=E5=BC=B9=E7=AA=97=E6=94=B9=E4=B8=80=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ALOps_sys_fe/alops-ui/src/views/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ALOps_sys_fe/alops-ui/src/views/index.vue b/ALOps_sys_fe/alops-ui/src/views/index.vue index 07ff5052..ce9628df 100644 --- a/ALOps_sys_fe/alops-ui/src/views/index.vue +++ b/ALOps_sys_fe/alops-ui/src/views/index.vue @@ -375,7 +375,7 @@ export default { // 定期更新设备状态数据(每分钟更新一次) setInterval(() => { this.refreshDeviceStatus(); - }, 60000); + }, 600000); }, beforeDestroy() { // 移除事件监听 From 50d5e5e02225efa29806cb334b05cd755377fdf8 Mon Sep 17 00:00:00 2001 From: Wangxin Date: Thu, 6 Nov 2025 22:20:33 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E3=80=90web=E3=80=91=20=E6=B7=BB=E5=8A=A0v?= =?UTF-8?q?eneer=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inMonitoring/devicesState/detail.vue | 8 +- .../inMonitoring/devicesState/veneer.vue | 93 +++++++++++++++++++ .../views/inMonitoring/devicesState/vlan.vue | 2 +- 3 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/veneer.vue diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/detail.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/detail.vue index 3a374f1d..a47e6aba 100644 --- a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/detail.vue +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/detail.vue @@ -227,6 +227,9 @@
+
+ +
@@ -245,10 +248,12 @@ import Interface from './interface.vue' import Vlan from './vlan.vue' import Routing from './routing.vue' import LineChart from './LineChart.vue' +import Veneer from './veneer.vue' + export default { name: "cardItem", - components: { History, Interface, Vlan, Routing, LineChart }, + components: { History, Interface, Vlan, Routing, LineChart, Veneer}, data() { return { DateValue: [dayjs().subtract(1, 'month').format('YYYY-MM-DD HH:mm:ss'),dayjs().format('YYYY-MM-DD HH:mm:ss')], @@ -258,6 +263,7 @@ export default { { name: '接口信息' }, { name: 'VLAN信息' }, { name: '路由表信息' }, + { name: 'venner信息' }, ], tabIndex: 0, dsId:null, diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/veneer.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/veneer.vue new file mode 100644 index 00000000..fb17a395 --- /dev/null +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/veneer.vue @@ -0,0 +1,93 @@ + + + \ No newline at end of file diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/vlan.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/vlan.vue index 29de0312..051946d0 100644 --- a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/vlan.vue +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/vlan.vue @@ -52,7 +52,7 @@ export default { // 查询参数 queryParams: { pageNum: 1, - pageSize: 10, + pageSize: 1000, name: undefined }, }