Browse Source

fix: 物模型消息,设备重复在线,离线过滤处理

gaoyoulong 1 year ago
parent
commit
bdef7e045c

+ 5 - 0
iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/ThingServiceImpl.java

@@ -186,6 +186,11 @@ public class ThingServiceImpl implements IThingService {
 
     private void deviceStateChange(DeviceInfo device, DeviceStateChange action) {
         DeviceState state = action.getState();
+        if ( (device.getState().isOnline() && state == DeviceState.ONLINE) ||
+                (!device.getState().isOnline() && state == DeviceState.OFFLINE) ) {
+            return;
+        }
+
         if (state == DeviceState.ONLINE) {
             device.getState().setOnline(true);
             device.getState().setOnlineTime(System.currentTimeMillis());