fix:太阳能网控,离线报警优化配置。
This commit is contained in:
@@ -89,6 +89,13 @@ public class AliyunIotProperties {
|
||||
*/
|
||||
private int offlineWarnDelayMinutes = 6;
|
||||
|
||||
/**
|
||||
* 太阳能网控离线告警延迟触发时间(分钟)
|
||||
* 太阳能网控工作1分钟、休眠10分钟属于正常行为,需要更长的延迟才能判定为真正离线
|
||||
* 默认 30 分钟
|
||||
*/
|
||||
private int solarOfflineWarnDelayMinutes = 30;
|
||||
|
||||
/**
|
||||
* 夜间溶解氧饱和度告警阈值(%),超过此值时开始计时
|
||||
* 对应 C# DeviceSaturabilityWarnValue = 200
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user