Commit 47cdf891 by 罗志长

fix: 设备状态同步

parent 6ba86919
......@@ -1283,6 +1283,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
return;
}
RedisUtil.delete(key);
this.update(new UpdateWrapper<PlatDevice>().lambda()
.set(PlatDevice::getStatus, "online").eq(PlatDevice::getOriDeviceId, deviceId));
log.info("设备:{} 故障处理, 恢复正常", deviceId);
}
}
......
......@@ -122,7 +122,7 @@ public class PushCallback implements MqttCallbackExtended {
return;
}
handleFault(device);
handleStatus(device);
CompletableFuture.runAsync(() -> {
checkAlarm(device);
......@@ -213,8 +213,7 @@ public class PushCallback implements MqttCallbackExtended {
}
String deviceId = device.getDeviceId();
String messageType = device.getMessageType();
//更新设备状态
platDeviceService.updateDeviceStatus(messageType, deviceId, "");
if (StringUtils.equalsAnyIgnoreCase(messageType, DeviceState.online.getValue())) {
return;
}
......@@ -275,14 +274,17 @@ public class PushCallback implements MqttCallbackExtended {
}
/**
* 处理设备故障
* 处理设备状态
*/
public void handleFault(DeviceInfo device) {
public void handleStatus(DeviceInfo device) {
if (!REPORT_PROPERTY.equals(device.getMessageType())) {
return;
}
CompletableFuture.runAsync(() -> {
// 处理设备故障
platDeviceService.handleFault(device);
// 更新设备状态
platDeviceService.updateDeviceStatus(device.getMessageType(), device.getDeviceId(), "");
}, taskExecutor);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment