From 6bb02480dd00126e85c697ea294b6fdf77599d68 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Sun, 12 Apr 2026 20:49:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A5=E5=BF=97=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E8=BD=AC=E4=B9=89=E4=BF=AE=E5=A4=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../intc/iot/handler/DeviceDataHandler.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) 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 2c802a8..1476edc 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 @@ -1182,76 +1182,76 @@ public class DeviceDataHandler { .last("LIMIT 1") ); if (device == null) { - log.debug("[\u8bbe\u5907\u6545\u969c] \u8bbe\u5907\u4e0d\u5b58\u5728\uff0c\u8df3\u8fc7: {}", deviceName); + log.debug("[设备故障] 设备不存在,跳过: {}", deviceName); return; } Long deviceId = device.getId(); Long userId = device.getUserId(); if (userId == null) { - log.debug("[\u8bbe\u5907\u6545\u969c] \u8bbe\u5907\u672a\u7ed1\u5b9a\u7528\u6237\uff0c\u8df3\u8fc7: {}", deviceName); + log.debug("[设备故障] 设备未绑定用户,跳过: {}", deviceName); return; } if (device.getPondId() == null) { - log.debug("[\u8bbe\u5907\u6545\u969c] \u8bbe\u5907\u672a\u7ed1\u5b9a\u5858\u53e3\uff0c\u8df3\u8fc7: {}", deviceName); + log.debug("[设备故障] 设备未绑定塘口,跳过: {}", deviceName); return; } Pond pond = pondMapper.selectById(device.getPondId()); if (pond == null) { - log.debug("[\u8bbe\u5907\u6545\u969c] \u5858\u53e3\u4e0d\u5b58\u5728\uff0c\u8df3\u8fc7: {}", deviceName); + log.debug("[设备故障] 塘口不存在,跳过: {}", deviceName); return; } String pondName = pond.getPondName(); String displayName = device.getDeviceName() != null ? device.getDeviceName() : deviceName; - // \u89e3\u6790\u4e8b\u4ef6\u53c2\u6570\u83b7\u53d6\u6545\u969c\u7801 + // 解析事件参数获取故障码 int errorCode = params != null && params.containsKey("errorCode") ? params.getInt("errorCode", 0) : 0; String errorDesc = DefineDeviceErrorCode.getErrorMessage(errorCode); if (StrUtil.isBlank(errorDesc)) { - errorDesc = "\u8bbe\u5907\u6545\u969c(code=" + errorCode + ")"; + errorDesc = "设备故障(code=" + errorCode + ")"; } - String warnMsg = String.format("%s\u5858\u53e3\u4e2d%s(%s)\u53d1\u751f\u6545\u969c\uff1a%s", + String warnMsg = String.format("%s塘口中%s(%s)发生故障:%s", pondName, displayName, deviceName, errorDesc); - log.error("[\u8bbe\u5907\u6545\u969c] \u8bbe\u5907: {}, \u6545\u969c\u4fe1\u606f: {}", deviceName, warnMsg); + log.error("[设备故障] 设备: {}, 故障信息: {}", deviceName, warnMsg); - // \u83b7\u53d6\u544a\u8b66\u624b\u673a\u53f7 + // 获取告警手机号 AquUser aquUser = aquUserMapper.selectById(userId); if (aquUser == null) { - log.warn("[\u8bbe\u5907\u6545\u969c] \u7528\u6237\u4e0d\u5b58\u5728\uff0c\u8df3\u8fc7: {}", deviceName); + log.warn("[设备故障] 用户不存在,跳过: {}", deviceName); return; } java.util.List phoneList = parseWarnPhoneList(aquUser.getWarnPhoneJson()); if (phoneList == null || phoneList.isEmpty()) { - log.warn("[\u8bbe\u5907\u6545\u969c] \u7528\u6237\u672a\u914d\u7f6e\u544a\u8b66\u624b\u673a\u53f7\uff0c\u8df3\u8fc7: {}", deviceName); + log.warn("[设备故障] 用户未配置告警手机号,跳过: {}", deviceName); return; } - // \u53cc\u91cd\u6291\u5236 - String errorTitle = "\u63a7\u5236\u5668\u6545\u969c"; + // 双重抑制 + String errorTitle = "控制器故障"; int maxBatchMinutesErr = CALL_NOTICE_RETRY_COUNT * CALL_NOTICE_MINUTE_INTERVAL * 2; LocalDateTime activeBatchStartErr = LocalDateTime.now().minusMinutes(maxBatchMinutesErr); long activeCountErr = warnCallNoticeMapper.countActiveByDeviceAndTitleAfter(deviceId, errorTitle, activeBatchStartErr); if (activeCountErr > 0) { - log.debug("[\u8bbe\u5907\u6545\u969c] \u5f53\u524d\u6709\u6d3b\u8dc3\u901a\u77e5\u6279\u6b21\u5728\u8fdb\u884c\uff0c\u8df3\u8fc7: {}", deviceName); + log.debug("[设备故障] 当前有活跃通知批次在进行,跳过: {}", deviceName); return; } LocalDateTime suppressTimeErr = LocalDateTime.now().minusHours(aliyunIotProperties.getCallSuccessSuppressHours()); long recentCountErr = warnCallNoticeMapper.countSuccessByDeviceAndTitleAfter(deviceId, errorTitle, suppressTimeErr); if (recentCountErr > 0) { - log.debug("[\u8bbe\u5907\u6545\u969c] {}h\u5185\u5df2\u6709\u56de\u6267\u6210\u529f\u7684\u901a\u77e5\uff0c\u8df3\u8fc7: {}", aliyunIotProperties.getCallSuccessSuppressHours(), deviceName); + log.debug("[设备故障] {}h内已有回执成功的通知,跳过: {}", aliyunIotProperties.getCallSuccessSuppressHours(), deviceName); return; } - // \u5199\u5165\u544a\u8b66\u6d88\u606f + // 写入告警消息 MessageWarn warn = createMessageWarn(deviceId, userId, pondName, errorTitle, WARN_TYPE_DISSOLVED_OXYGEN, warnMsg); messageWarnMapper.insert(warn); - // \u521b\u5efa\u7535\u8bdd\u901a\u77e5\u8bb0\u5f55 + // 创建电话通知记录 LocalDateTime baseTime = LocalDateTime.now(); int index = 0; AquWarnCallNotice firstCallNotice = null; @@ -1290,11 +1290,11 @@ public class DeviceDataHandler { sendVoiceNotification(firstCallNotice, displayName, errorTitle); } - log.info("[\u8bbe\u5907\u6545\u969c] \u5df2\u89e6\u53d1\u901a\u77e5 - \u8bbe\u5907\uff1a{}, \u5858\u53e3\uff1a{}, \u624b\u673a\u53f7\u6570\uff1a{}", + log.info("[设备故障] 已触发通知 - 设备:{}, 塘口:{}, 手机号数:{}", deviceName, pondName, phoneList.size()); } catch (Exception e) { - log.error("[\u8bbe\u5907\u6545\u969c] \u89e6\u53d1\u6545\u969c\u544a\u8b66\u5931\u8d25: {}", e.getMessage(), e); + log.error("[设备故障] 触发故障告警失败: {}", e.getMessage(), e); } }