fix: 日志字符转义修复。

This commit is contained in:
tianyongbao
2026-04-12 20:49:44 +08:00
parent 2877fc9b7c
commit 45c55944a5

View File

@@ -1182,76 +1182,76 @@ public class DeviceDataHandler {
.last("LIMIT 1") .last("LIMIT 1")
); );
if (device == null) { if (device == null) {
log.debug("[\u8bbe\u5907\u6545\u969c] \u8bbe\u5907\u4e0d\u5b58\u5728\uff0c\u8df3\u8fc7: {}", deviceName); log.debug("[设备故障] 设备不存在,跳过: {}", deviceName);
return; return;
} }
Long deviceId = device.getId(); Long deviceId = device.getId();
Long userId = device.getUserId(); Long userId = device.getUserId();
if (userId == null) { if (userId == null) {
log.debug("[\u8bbe\u5907\u6545\u969c] \u8bbe\u5907\u672a\u7ed1\u5b9a\u7528\u6237\uff0c\u8df3\u8fc7: {}", deviceName); log.debug("[设备故障] 设备未绑定用户,跳过: {}", deviceName);
return; return;
} }
if (device.getPondId() == null) { 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; return;
} }
Pond pond = pondMapper.selectById(device.getPondId()); Pond pond = pondMapper.selectById(device.getPondId());
if (pond == null) { if (pond == null) {
log.debug("[\u8bbe\u5907\u6545\u969c] \u5858\u53e3\u4e0d\u5b58\u5728\uff0c\u8df3\u8fc7: {}", deviceName); log.debug("[设备故障] 塘口不存在,跳过: {}", deviceName);
return; return;
} }
String pondName = pond.getPondName(); String pondName = pond.getPondName();
String displayName = device.getDeviceName() != null ? device.getDeviceName() : deviceName; 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") int errorCode = params != null && params.containsKey("errorCode")
? params.getInt("errorCode", 0) : 0; ? params.getInt("errorCode", 0) : 0;
String errorDesc = DefineDeviceErrorCode.getErrorMessage(errorCode); String errorDesc = DefineDeviceErrorCode.getErrorMessage(errorCode);
if (StrUtil.isBlank(errorDesc)) { 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); 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); AquUser aquUser = aquUserMapper.selectById(userId);
if (aquUser == null) { if (aquUser == null) {
log.warn("[\u8bbe\u5907\u6545\u969c] \u7528\u6237\u4e0d\u5b58\u5728\uff0c\u8df3\u8fc7: {}", deviceName); log.warn("[设备故障] 用户不存在,跳过: {}", deviceName);
return; return;
} }
java.util.List<String> phoneList = parseWarnPhoneList(aquUser.getWarnPhoneJson()); java.util.List<String> phoneList = parseWarnPhoneList(aquUser.getWarnPhoneJson());
if (phoneList == null || phoneList.isEmpty()) { 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; 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; int maxBatchMinutesErr = CALL_NOTICE_RETRY_COUNT * CALL_NOTICE_MINUTE_INTERVAL * 2;
LocalDateTime activeBatchStartErr = LocalDateTime.now().minusMinutes(maxBatchMinutesErr); LocalDateTime activeBatchStartErr = LocalDateTime.now().minusMinutes(maxBatchMinutesErr);
long activeCountErr = warnCallNoticeMapper.countActiveByDeviceAndTitleAfter(deviceId, errorTitle, activeBatchStartErr); long activeCountErr = warnCallNoticeMapper.countActiveByDeviceAndTitleAfter(deviceId, errorTitle, activeBatchStartErr);
if (activeCountErr > 0) { 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; return;
} }
LocalDateTime suppressTimeErr = LocalDateTime.now().minusHours(aliyunIotProperties.getCallSuccessSuppressHours()); LocalDateTime suppressTimeErr = LocalDateTime.now().minusHours(aliyunIotProperties.getCallSuccessSuppressHours());
long recentCountErr = warnCallNoticeMapper.countSuccessByDeviceAndTitleAfter(deviceId, errorTitle, suppressTimeErr); long recentCountErr = warnCallNoticeMapper.countSuccessByDeviceAndTitleAfter(deviceId, errorTitle, suppressTimeErr);
if (recentCountErr > 0) { 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; return;
} }
// \u5199\u5165\u544a\u8b66\u6d88\u606f // 写入告警消息
MessageWarn warn = createMessageWarn(deviceId, userId, pondName, errorTitle, WARN_TYPE_DISSOLVED_OXYGEN, warnMsg); MessageWarn warn = createMessageWarn(deviceId, userId, pondName, errorTitle, WARN_TYPE_DISSOLVED_OXYGEN, warnMsg);
messageWarnMapper.insert(warn); messageWarnMapper.insert(warn);
// \u521b\u5efa\u7535\u8bdd\u901a\u77e5\u8bb0\u5f55 // 创建电话通知记录
LocalDateTime baseTime = LocalDateTime.now(); LocalDateTime baseTime = LocalDateTime.now();
int index = 0; int index = 0;
AquWarnCallNotice firstCallNotice = null; AquWarnCallNotice firstCallNotice = null;
@@ -1290,11 +1290,11 @@ public class DeviceDataHandler {
sendVoiceNotification(firstCallNotice, displayName, errorTitle); 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()); deviceName, pondName, phoneList.size());
} catch (Exception e) { } 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);
} }
} }