From 90da58d73e79d3040beda76d54ca89008fcc2799 Mon Sep 17 00:00:00 2001 From: George Date: Tue, 3 Mar 2026 20:49:53 +0800 Subject: [PATCH] =?UTF-8?q?20260303:=E4=BF=AE=E5=A4=8Dbug=EF=BC=8C1.?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=AE=A1=E7=90=86-=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=85=AC=E5=91=8A-=E6=96=87=E6=A1=A3=EF=BC=9B2.=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=85=AC=E4=BC=97=E5=8F=B7=E9=80=9A=E7=9F=A5=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=86=85=E5=AE=B9=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/notify/AlertPushParams.java | 4 ++++ .../iot/data/ruleEngine/SceneContext.java | 9 ++++++--- .../service/impl/NotifySendServiceImpl.java | 3 +++ yack-web/src/components/FileUpload/index.vue | 13 ++++++++++-- yack-web/src/views/system/notice/index.vue | 20 +++++++++++++------ 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/fastbee-common/src/main/java/com/fastbee/common/core/notify/AlertPushParams.java b/fastbee-common/src/main/java/com/fastbee/common/core/notify/AlertPushParams.java index d1b133b3..7deffcb6 100644 --- a/fastbee-common/src/main/java/com/fastbee/common/core/notify/AlertPushParams.java +++ b/fastbee-common/src/main/java/com/fastbee/common/core/notify/AlertPushParams.java @@ -37,6 +37,10 @@ public class AlertPushParams { * 告警发生地点 */ private String address; + /** + * 告警内容 + */ + private String alertContent; /** * 告警名称 */ diff --git a/fastbee-iot-data/src/main/java/com/fastbee/iot/data/ruleEngine/SceneContext.java b/fastbee-iot-data/src/main/java/com/fastbee/iot/data/ruleEngine/SceneContext.java index f8c0da8b..9f2d2170 100644 --- a/fastbee-iot-data/src/main/java/com/fastbee/iot/data/ruleEngine/SceneContext.java +++ b/fastbee-iot-data/src/main/java/com/fastbee/iot/data/ruleEngine/SceneContext.java @@ -112,14 +112,14 @@ public class SceneContext { // 执行动作 } else if (scriptTemplate.getPurpose() == 3) { scene_logger.info("[{}]=====+>符合触发条件!", requestId); - if (scriptTemplate.getCheckdelay() != 0) { + if (scriptTemplate.getCheckdelay() != 0 || scriptTemplate.getDelay() != 0) { // 告警恢复规则 设备上线触发 不加载 if (scriptTemplate.getSource() != 5 && type != 5) { loadDelayTrigger(scriptTemplate); } } else { // 执行动作,延迟执行,线程休眠 delay x 1000毫秒 - Thread.sleep(scriptTemplate.getDelay() * 1000L); + // Thread.sleep(scriptTemplate.getDelay() * 1000L); if (scriptTemplate.getSource() == 4) { // 存在相同未处理告警只记录 不触发告警通知和动作 if (checkDeviceAlerting(scriptTemplate.getSceneId(), requestId, this.deviceNum)) { @@ -360,6 +360,7 @@ public class SceneContext { String key = "CHECK_" + scriptTemplate.getSceneId() + deviceNum; // 默认上线执行告警恢复 在延迟匹配周期内不告警 ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); + int delayTime = scriptTemplate.getCheckdelay() > 0 ? scriptTemplate.getCheckdelay() : scriptTemplate.getDelay(); executor.schedule(() -> { // 设备未上线,则执行告警任务 if (scriptTemplate.getSource() == 4) { @@ -369,7 +370,7 @@ public class SceneContext { // 下发指令 this.send(scriptTemplate); } - }, scriptTemplate.getCheckdelay(), TimeUnit.SECONDS); + }, delayTime, TimeUnit.SECONDS); scene_logger.info("[{}]=====+>延时执行告警任务:{}", requestId, key); ruleService.addCheckTask(key, executor); } @@ -512,6 +513,8 @@ public class SceneContext { } alertPushParams.setAddress(address); alertPushParams.setAlertTime(DateUtils.parseDateToStr(DateUtils.YY_MM_DD_HH_MM_SS, new Date())); + // 告警内容 格式:id:value + alertPushParams.setAlertContent(sceneThingsModelItem.getId() + ":" + sceneThingsModelItem.getValue()); return alertPushParams; } diff --git a/fastbee-notify/fastbee-notify-core/src/main/java/com/fastbee/notify/core/service/impl/NotifySendServiceImpl.java b/fastbee-notify/fastbee-notify-core/src/main/java/com/fastbee/notify/core/service/impl/NotifySendServiceImpl.java index b76ed087..cff0300b 100644 --- a/fastbee-notify/fastbee-notify-core/src/main/java/com/fastbee/notify/core/service/impl/NotifySendServiceImpl.java +++ b/fastbee-notify/fastbee-notify-core/src/main/java/com/fastbee/notify/core/service/impl/NotifySendServiceImpl.java @@ -164,6 +164,9 @@ public class NotifySendServiceImpl implements NotifySendService { map.put(variables.get(i), alertPushParams.getSerialNumber()); } else if (i == 2) { map.put(variables.get(i), alertPushParams.getAddress()); + } else if (i == 3) { + // 报警内容 + map.put(variables.get(i), alertPushParams.getAlertContent()); } else { map.put(variables.get(i), alertPushParams.getAlertName()); } diff --git a/yack-web/src/components/FileUpload/index.vue b/yack-web/src/components/FileUpload/index.vue index aa12f236..6908cf52 100644 --- a/yack-web/src/components/FileUpload/index.vue +++ b/yack-web/src/components/FileUpload/index.vue @@ -34,6 +34,15 @@