TRX 1 год назад
Родитель
Сommit
0f3f5e2c9c

+ 12 - 0
OneCardIotClient/src/main/java/com/zhongshu/iot/client/model/mqtt/DeviceInfoSearchParam.java

@@ -30,6 +30,15 @@ public class DeviceInfoSearchParam extends SuperSearchParam {
     @Schema(description = "设备类型:消费机 闸机")
     private List<DeviceType> deviceTypes = new ArrayList<>();
 
+    public void addDeviceTypes(DeviceType devicesType) {
+        if (deviceTypes == null) {
+            deviceTypes = new ArrayList<>();
+        }
+        if (!deviceTypes.contains(devicesType)) {
+            deviceTypes.add(devicesType);
+        }
+    }
+
     @Schema(description = "筛选不属于的设备类型")
     private List<DeviceType> ninDeviceTypes = new ArrayList<DeviceType>();
 
@@ -50,4 +59,7 @@ public class DeviceInfoSearchParam extends SuperSearchParam {
 
     private Long endLastOnlineTime;
 
+    private DeviceType deviceType;
+
+
 }

+ 4 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/DeviceInfoService.java

@@ -177,6 +177,9 @@ public class DeviceInfoService {
         if (!CommonUtil.longIsEmpty(param.getEndLastOnlineTime())) {
             param.setEndLastOnlineTime(DateUtils.getDayEndTime(param.getEndLastOnlineTime()));
         }
+        if (param.getDeviceType() != null) {
+            param.addDeviceTypes(param.getDeviceType());
+        }
         Page<DeviceInfo> page = deviceInfoDao.page(pageable, param);
         return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
     }
@@ -287,7 +290,7 @@ public class DeviceInfoService {
     private void updateDeviceOnLineStateByState(DeviceInfo deviceInfo) {
         if (deviceInfo != null) {
             if (deviceInfo.getState() == DeviceState.Enable) {
-
+                deviceInfo.setOnLineState(OnLineState.OffLine);
             } else if (deviceInfo.getState() == DeviceState.Disable) {
                 deviceInfo.setOnLineState(OnLineState.Disable);
             } else if (deviceInfo.getState() == DeviceState.Cancel) {