TRX 1 ano atrás
pai
commit
e199556691

+ 13 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DeviceSyncFromIotService.java

@@ -8,6 +8,7 @@ import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.service.school.DeviceInfoService;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.client.type.OnLineState;
+import com.zhongshu.card.server.core.dao.devices.DeviceInfoDao;
 import com.zhongshu.card.server.core.dao.org.OrganizationDao;
 import com.zhongshu.card.server.core.dao.org.OrganizationRelationDao;
 import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
@@ -50,6 +51,9 @@ public class DeviceSyncFromIotService {
     @Autowired
     CommonService commonService;
 
+    @Autowired
+    private DeviceInfoDao deviceInfoDao;
+
     /**
      * 物联网同步设备
      *
@@ -85,7 +89,15 @@ public class DeviceSyncFromIotService {
         HashMap<String, Object> map = new HashMap<>();
         map.put("lastOnlineTime", param.getLastOnlineTime());
         map.put("onLineState", CommonUtil.getEnumByName(OnLineState.class, param.getOnLineState()));
-        map.put("state", CommonUtil.getEnumByName(DataState.class, param.getState()));
+        log.info("-------------------------== {}", param.getState());
+        DataState state = CommonUtil.getEnumByName(DataState.class, param.getState());
+        if (state == null) {
+            DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(param.getDeviceId());
+            if (ObjectUtils.isNotEmpty(deviceInfo)) {
+                state = deviceInfo.getState();
+            }
+        }
+        map.put("state", state);
         map.put("lastOnlineTimeStr", DateUtils.paresTime(param.getLastOnlineTime(), DateUtils.FORMAT_LONG));
         commonService.updateData(where, map, DeviceInfo.class.getSimpleName());
         commonService.updateData(where, map, DeviceBind.class.getSimpleName());