fix:太阳能网控,离线报警优化配置。

This commit is contained in:
tianyongbao
2026-04-26 07:24:50 +08:00
parent b3dcaaf209
commit e5babe0469
3 changed files with 27 additions and 1 deletions

View File

@@ -888,8 +888,25 @@ public class DeviceDataHandler {
log.debug("[离线告警] 已有等待标记,跳过重复写入: {}", deviceName);
return;
}
String offlineTime = LocalDateTime.now().format(DATETIME_FORMATTER);
// 查询设备类型太阳能网控type=3使用独立的延迟时长
int offlineDelayMinutes = aliyunIotProperties.getOfflineWarnDelayMinutes();
try {
Device deviceForType = deviceMapper.selectOne(
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<Device>()
.eq(Device::getSerialNum, deviceName)
.select(Device::getDeviceType)
.last("LIMIT 1")
);
if (deviceForType != null && Integer.valueOf(3).equals(deviceForType.getDeviceType())) {
offlineDelayMinutes = aliyunIotProperties.getSolarOfflineWarnDelayMinutes();
log.debug("[离线告警] 太阳能网控设备,使用延迟 {} 分钟: {}", offlineDelayMinutes, deviceName);
}
} catch (Exception e) {
log.warn("[离线告警] 查询设备类型失败,使用默认延迟: {}", e.getMessage());
}
String offlineTime = LocalDateTime.now().format(DATETIME_FORMATTER);
int ttlMinutes = offlineDelayMinutes * OFFLINE_WAIT_TTL_MULTIPLIER;
RedisUtils.setCacheObject(redisKey, offlineTime, Duration.ofMinutes(ttlMinutes));
log.info("[离线告警] 设备离线,已记录等待标记,将在 {} 分钟后触发告警: {}", offlineDelayMinutes, deviceName);