Kaynağa Gözat

设备条件筛选

谭斌 1 yıl önce
ebeveyn
işleme
4e8e879c8d

+ 25 - 1
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -659,12 +659,36 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
             return R.ok(Collections.emptyList());
         }
         List<DeviceInfoDto.MercHomeListVO> dataList = new ArrayList<>(list.size());
+        Integer busyStatus = dto.getBusyStatus();
+        Integer onlineStatus = dto.getOnlineStatus();
+        Integer deviceType = dto.getDeviceType();
+        //条件查询 在线状态,运营状态,设备类型,
+        List<Long> deviceIdList = new ArrayList<>();
+        if (onlineStatus != null) {
+            List<DeviceStatus> deviceStatusList = deviceStatusService.list(Wrappers.<DeviceStatus>lambdaQuery()
+                    .eq(onlineStatus != null, DeviceStatus::getNetState, onlineStatus)
+            );
+            if (CollUtil.isNotEmpty(deviceStatusList)) {
+                deviceIdList = deviceStatusList.stream().map(DeviceStatus::getDeviceId).collect(Collectors.toList());
+                if (deviceId != null && !deviceIdList.contains(deviceId)) {
+                    deviceIdList.add(deviceId);
+                }
+            } else {
+                if (deviceId != null) {
+                    deviceIdList.add(deviceId);
+                }
+            }
+        }
 
         LambdaQueryWrapper<DeviceInfo> lqw = new LambdaQueryWrapper<>();
         //非质检商户才需要激活
         lqw.eq(!isQa, DeviceInfo::getActiveState, DeviceActiveStateEnum.TRUE.getCode());
         lqw.eq(mercId != null, DeviceInfo::getMercId, mercId);
-        lqw.eq(deviceId != null, DeviceInfo::getDeviceId, deviceId);
+        lqw.eq(busyStatus != null, DeviceInfo::getBusyState, busyStatus);
+        lqw.eq(deviceType != null, DeviceInfo::getDeviceType, deviceType);
+        lqw.eq(deviceId != null && CollUtil.isEmpty(deviceIdList), DeviceInfo::getDeviceId, deviceId);
+        lqw.in(deviceId != null && CollUtil.isNotEmpty(deviceIdList), DeviceInfo::getDeviceId, deviceIdList);
+        lqw.in(deviceId == null && CollUtil.isNotEmpty(deviceIdList), DeviceInfo::getDeviceId, deviceIdList);
         lqw.like(StrUtil.isNotEmpty(deviceName), DeviceInfo::getDeviceName, deviceName).orderByAsc(true, DeviceInfo::getDeviceName, DeviceInfo::getDeviceId);
         List<DeviceInfo> deviceInfoList = this.list(lqw);
         //未分配线路的设置默认值

+ 9 - 1
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -652,7 +652,6 @@ public class DeviceInfoDto {
         @ApiModelProperty(value = "商户id")
         private Long mercId;
 
-
         @ApiModelProperty(value = "设备名称")
         private String deviceName;
 
@@ -662,6 +661,15 @@ public class DeviceInfoDto {
         @ApiModelProperty("激活状态")
         private String activeState;
 
+        @ApiModelProperty("在线状态-字典类型:device_online_status(1-在线,2-离线)")
+        private Integer onlineStatus;
+
+        @ApiModelProperty("运营状态-字典类型:device_busy_status(1-运营中,2-已停运)")
+        private Integer busyStatus;
+
+        @ApiModelProperty("设备类型-字典类型:device_type")
+        private Integer deviceType;
+
     }