From 6b2817393ae1d7ea993072db1f0cf5aa43bfe9bb Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Sun, 5 Apr 2026 00:05:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=E7=94=B5=E8=AF=9D?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E7=BB=9F=E4=B8=80=E9=85=8D=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=BC=80=E5=90=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../intc/iot/config/AliyunIotProperties.java | 7 ++++++ .../intc/iot/handler/DeviceDataHandler.java | 23 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/config/AliyunIotProperties.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/config/AliyunIotProperties.java index f02adc6..18a3798 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/config/AliyunIotProperties.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/config/AliyunIotProperties.java @@ -101,6 +101,13 @@ public class AliyunIotProperties { */ private int saturabilityWarnHours = 8; + /** + * 是否启用报警电话通知 + * 全局开关,关闭后所有类型的报警都不会触发电话通知 + * 默认开启 + */ + private boolean callNoticeEnabled = true; + @Data public static class VmsMnsConfig { /** diff --git a/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java b/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java index b01c6d9..0987940 100644 --- a/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java +++ b/intc-modules/intc-iot/src/main/java/com/intc/iot/handler/DeviceDataHandler.java @@ -570,7 +570,7 @@ public class DeviceDataHandler { } // 仅对开启了电话通知开关的告警触发电话通知(MessageWarn 由通知方法内部插入) - if (!callWarnList.isEmpty()) { + if (!callWarnList.isEmpty() && aliyunIotProperties.isCallNoticeEnabled()) { triggerAlarmNotification(device, alarmMessage.toString(), sensorData, callWarnList); } } @@ -903,6 +903,11 @@ public class DeviceDataHandler { * @param deviceName 设备名称(serialNum) */ public void triggerOfflineAlarm(String deviceName) { + // 全局电话通知开关检查 + if (!aliyunIotProperties.isCallNoticeEnabled()) { + log.debug("[离线告警] 电话通知已全局关闭,跳过: {}", deviceName); + return; + } try { Device device = deviceMapper.selectOne( new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper() @@ -1026,6 +1031,11 @@ public class DeviceDataHandler { * @param deviceName 设备名称(serialNum) */ public void triggerSaturaHighAlarm(String deviceName) { + // 全局电话通知开关检查 + if (!aliyunIotProperties.isCallNoticeEnabled()) { + log.debug("[饱和度告警] 电话通知已全局关闭,跳过: {}", deviceName); + return; + } try { Device device = deviceMapper.selectOne( new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper() @@ -1151,6 +1161,11 @@ public class DeviceDataHandler { * @param params 事件参数 */ private void triggerDeviceErrorAlarm(String deviceName, JSONObject params) { + // 全局电话通知开关检查 + if (!aliyunIotProperties.isCallNoticeEnabled()) { + log.debug("[设备故障] 电话通知已全局关闭,跳过: {}", deviceName); + return; + } try { Device device = deviceMapper.selectOne( new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper() @@ -1500,8 +1515,10 @@ public class DeviceDataHandler { if (userId != null) { MessageWarn warn = createMessageWarn(deviceId, userId, pondName, title, WARN_TYPE_DISSOLVED_OXYGEN, message); messageWarnMapper.insert(warn); - // 创建电话通知记录 - createCallNotices(device, pondName, warn); + // 创建电话通知记录(全局开关控制) + if (aliyunIotProperties.isCallNoticeEnabled()) { + createCallNotices(device, pondName, warn); + } } }