Commit 47cdf891 by 罗志长

fix: 设备状态同步

parent 6ba86919
...@@ -1283,6 +1283,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -1283,6 +1283,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
return; return;
} }
RedisUtil.delete(key); RedisUtil.delete(key);
this.update(new UpdateWrapper<PlatDevice>().lambda()
.set(PlatDevice::getStatus, "online").eq(PlatDevice::getOriDeviceId, deviceId));
log.info("设备:{} 故障处理, 恢复正常", deviceId); log.info("设备:{} 故障处理, 恢复正常", deviceId);
} }
} }
......
...@@ -122,7 +122,7 @@ public class PushCallback implements MqttCallbackExtended { ...@@ -122,7 +122,7 @@ public class PushCallback implements MqttCallbackExtended {
return; return;
} }
handleFault(device); handleStatus(device);
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
checkAlarm(device); checkAlarm(device);
...@@ -213,8 +213,7 @@ public class PushCallback implements MqttCallbackExtended { ...@@ -213,8 +213,7 @@ public class PushCallback implements MqttCallbackExtended {
} }
String deviceId = device.getDeviceId(); String deviceId = device.getDeviceId();
String messageType = device.getMessageType(); String messageType = device.getMessageType();
//更新设备状态
platDeviceService.updateDeviceStatus(messageType, deviceId, "");
if (StringUtils.equalsAnyIgnoreCase(messageType, DeviceState.online.getValue())) { if (StringUtils.equalsAnyIgnoreCase(messageType, DeviceState.online.getValue())) {
return; return;
} }
...@@ -275,14 +274,17 @@ public class PushCallback implements MqttCallbackExtended { ...@@ -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())) { if (!REPORT_PROPERTY.equals(device.getMessageType())) {
return; return;
} }
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
platDeviceService.handleFault(device); // 处理设备故障
platDeviceService.handleFault(device);
// 更新设备状态
platDeviceService.updateDeviceStatus(device.getMessageType(), device.getDeviceId(), "");
}, taskExecutor); }, 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