Ver código fonte

设备条件筛选

谭斌 1 ano atrás
pai
commit
7ed3868795

+ 15 - 16
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -654,31 +654,32 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         } else {
             dto.setActiveState("1");
         }
-        List<DeviceInfoDto.MercHomeCountVO> list = this.baseMapper.merHomeCountList(dto);
-        if (CollUtil.isEmpty(list)) {
-            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 (deviceId != null) {
+            deviceIdList.add(deviceId);
+        }
         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);
-                }
+                List<Long> dbDeviceIdList = deviceStatusList.stream().map(DeviceStatus::getDeviceId).collect(Collectors.toList());
+                deviceIdList.addAll(dbDeviceIdList);
             }
         }
+        dto.setDeviceIdList(deviceIdList);
+
+        List<DeviceInfoDto.MercHomeCountVO> list = this.baseMapper.merHomeCountList(dto);
+        if (CollUtil.isEmpty(list)) {
+            return R.ok(Collections.emptyList());
+        }
+        List<DeviceInfoDto.MercHomeListVO> dataList = new ArrayList<>(list.size());
 
         LambdaQueryWrapper<DeviceInfo> lqw = new LambdaQueryWrapper<>();
         //非质检商户才需要激活
@@ -686,9 +687,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         lqw.eq(mercId != null, DeviceInfo::getMercId, mercId);
         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.in(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);
         //未分配线路的设置默认值

+ 15 - 2
device-api-service/src/main/resources/mapper/DeviceInfoMapper.xml

@@ -308,15 +308,28 @@
                 active_state = #{query.activeState}
             </if>
 
+            <if test="query.busyStatus != null  ">
+                busy_state = #{query.busyStatus}
+            </if>
+
+            <if test="query.deviceType != null  ">
+                device_type = #{deviceType}
+            </if>
+
             <if test="query.mercId != null">
                 and merc_id = #{query.mercId}
             </if>
             <if test="query.deviceName != null and query.deviceName != ''">
                 and device_name like concat('%', #{query.deviceName}, '%')
             </if>
-            <if test="query.deviceId != null">
-                and device_id = #{query.deviceId}
+            <if test="query.deviceIdList != null and query.deviceIdList.size>0 ">
+                and device_id in
+                <foreach collection="query.deviceIdList" index="index" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
             </if>
+
+
         </where>
         group by place_line_id
     </select>

+ 3 - 0
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -670,6 +670,9 @@ public class DeviceInfoDto {
         @ApiModelProperty("设备类型-字典类型:device_type")
         private Integer deviceType;
 
+        @ApiModelProperty(value = "设备ID", hidden = true)
+        private List<Long> deviceIdList;
+
     }