fix:设备电话通知和告警,以及设备历史数据,增加设备有效期判断。
This commit is contained in:
@@ -412,6 +412,12 @@ public class DeviceDataHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
// 设备已过期,不触发告警
|
||||
if (device.getDeadTime() != null && device.getDeadTime().before(new java.util.Date())) {
|
||||
log.debug("[告警] 设备已过期,跳过告警检查: {}", deviceName);
|
||||
return;
|
||||
}
|
||||
|
||||
Long deviceId = device.getId();
|
||||
Long userId = device.getUserId();
|
||||
|
||||
@@ -1183,6 +1189,8 @@ public class DeviceDataHandler {
|
||||
Device device = deviceMapper.selectOne(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<Device>()
|
||||
.eq(Device::getSerialNum, deviceName)
|
||||
.select(Device::getId, Device::getSerialNum, Device::getDeviceName,
|
||||
Device::getPondId, Device::getUserId, Device::getDeadTime)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
if (device == null) {
|
||||
@@ -1190,6 +1198,12 @@ public class DeviceDataHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
// 设备已过期,不触发故障告警
|
||||
if (device.getDeadTime() != null && device.getDeadTime().before(new java.util.Date())) {
|
||||
log.debug("[设备故障] 设备已过期,跳过故障告警: {}", deviceName);
|
||||
return;
|
||||
}
|
||||
|
||||
Long deviceId = device.getId();
|
||||
Long userId = device.getUserId();
|
||||
if (userId == null) {
|
||||
@@ -1326,12 +1340,20 @@ public class DeviceDataHandler {
|
||||
Device device = deviceMapper.selectOne(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<Device>()
|
||||
.eq(Device::getSerialNum, deviceName)
|
||||
.select(Device::getId, Device::getSerialNum, Device::getDeviceName, Device::getWarnCode,
|
||||
Device::getPondId, Device::getUserId, Device::getDeadTime)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
if (device == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 设备已过期,不处理故障码
|
||||
if (device.getDeadTime() != null && device.getDeadTime().before(new java.util.Date())) {
|
||||
log.debug("[故障码] 设备已过期,跳过处理: {}", deviceName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (errorCode == 0) {
|
||||
// 清除所有故障码
|
||||
clearErrorCodeRecords(device);
|
||||
@@ -1795,17 +1817,23 @@ public class DeviceDataHandler {
|
||||
}
|
||||
int sensorErrorCode = rawCode;
|
||||
|
||||
// 查询设备,需要 id / warnCode / isOxygenUsed / pondId
|
||||
// 查询设备,需要 id / warnCode / isOxygenUsed / pondId / deadTime
|
||||
Device device = deviceMapper.selectOne(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<Device>()
|
||||
.eq(Device::getSerialNum, deviceName)
|
||||
.select(Device::getId, Device::getWarnCode, Device::getIsOxygenUsed, Device::getPondId)
|
||||
.select(Device::getId, Device::getWarnCode, Device::getIsOxygenUsed, Device::getPondId, Device::getDeadTime)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
if (device == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 设备已过期,不处理探头错误码
|
||||
if (device.getDeadTime() != null && device.getDeadTime().before(new java.util.Date())) {
|
||||
log.debug("[探头错误码] 设备已过期,跳过处理: {}", deviceName);
|
||||
return;
|
||||
}
|
||||
|
||||
int currentCode = device.getWarnCode() != null ? device.getWarnCode() : 0;
|
||||
int newCode = currentCode;
|
||||
|
||||
@@ -2269,18 +2297,25 @@ public class DeviceDataHandler {
|
||||
*/
|
||||
private void handleLinkedCtrl(String deviceName, double dissolvedOxygen) {
|
||||
try {
|
||||
// 查询当前设备(需要 id、iotId、pondId)
|
||||
// 查询当前设备(需要 id、iotId、pondId、deadTime)
|
||||
Device currentDevice = deviceMapper.selectOne(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<Device>()
|
||||
.eq(Device::getSerialNum, deviceName)
|
||||
.select(Device::getId, Device::getIotId, Device::getSerialNum, Device::getDeviceName,
|
||||
Device::getPondId, Device::getValueDissolvedOxygen, Device::getUserId)
|
||||
Device::getPondId, Device::getValueDissolvedOxygen, Device::getUserId,
|
||||
Device::getDeadTime)
|
||||
.last("LIMIT 1")
|
||||
);
|
||||
if (currentDevice == null || currentDevice.getId() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 设备已过期,不执行联动控制
|
||||
if (currentDevice.getDeadTime() != null && currentDevice.getDeadTime().before(new java.util.Date())) {
|
||||
log.debug("[联动控制] 设备已过期,跳过处理: {}", deviceName);
|
||||
return;
|
||||
}
|
||||
|
||||
// 先更新当前设备的实时溶解氧(确保后续取最低值时已包含本次上报值)
|
||||
// 注意:updateDeviceRealTimeData 在 handleLinkedCtrl 调用前已执行,此处直接使用传入值
|
||||
|
||||
|
||||
Reference in New Issue
Block a user