Browse Source

分组排序

hechunping 1 year ago
parent
commit
c935aacc70

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

@@ -779,13 +779,13 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         Long deviceId = dto.getDeviceId();
         List<Long> searchPlaceIdList = new ArrayList<>();
         //根据管理员名字查询点位ID列表
-        if (Emptys.check(dto.getAdminName())){
+        if (Emptys.check(dto.getAdminName())) {
             MercPlaceDto.ListDto placeDto = new MercPlaceDto.ListDto();
             placeDto.setMercId(mercId).setAdminName(dto.getAdminName());
             List<MercPlaceDto.Vo> searchPlaceList = mercPlaceService.list(placeDto).getData();
             if (Emptys.check(searchPlaceList)) {
                 searchPlaceIdList = searchPlaceList.stream().map(MercPlaceDto.Vo::getId).distinct().collect(Collectors.toList());
-            }else {
+            } else {
                 return R.ok();
             }
         }
@@ -802,7 +802,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
             LambdaQueryWrapper<DeviceInfo> deviceLqw = Wrappers.<DeviceInfo>lambdaQuery()
                     .eq(DeviceInfo::getMercId, mercId)
                     .in(Emptys.check(searchPlaceIdList), DeviceInfo::getPlaceId, searchPlaceIdList);
-            if(Emptys.check(searchKey)){
+            if (Emptys.check(searchKey)) {
                 deviceLqw.and(wrapper -> wrapper
                         .eq(Emptys.check(searchKey), DeviceInfo::getDeviceId, searchKey)
                         .or()
@@ -885,14 +885,12 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         lqw.eq(deviceType != null, DeviceInfo::getDeviceType, deviceType);
         lqw.in(CollUtil.isNotEmpty(deviceIdList), DeviceInfo::getDeviceId, deviceIdList);
         lqw.like(StrUtil.isNotEmpty(deviceName), DeviceInfo::getDeviceName, deviceName).orderByAsc(true, DeviceInfo::getDeviceName, DeviceInfo::getDeviceId);
-        List<DeviceInfoDto.Vo> deviceInfoList = copy(DeviceInfoDto.Vo.class,this.list(lqw));
+        List<DeviceInfoDto.Vo> deviceInfoList = copy(DeviceInfoDto.Vo.class, this.list(lqw));
         //根据点位ID查询管理员名字
         List<Long> placeIdList = deviceInfoList.stream().map(DeviceInfoDto.Vo::getPlaceId).distinct().filter(Objects::nonNull).collect(Collectors.toList());
         List<MercPlaceDto.Vo> mercPlaceList = mercPlaceService.list(new MercPlaceDto.ListDto().setIds(placeIdList)).getData();
         Map<Long, String> mercPlaceMap = mercPlaceList.stream().collect(Collectors.toMap(i -> i.getId(), i -> i.getAdminName()));
-        deviceInfoList.forEach(i->{
-            i.setAdminName(mercPlaceMap.get(i.getPlaceId()));
-        });
+        deviceInfoList.forEach(i -> i.setAdminName(mercPlaceMap.get(i.getPlaceId())));
 
         //没有管理员的的设置默认值
         deviceInfoList.stream().filter(s -> s.getAdminName() == null).forEach(s -> s.setAdminName("未分配管理员"));
@@ -901,6 +899,8 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
 
         //根据管理员名字分组
         Map<String, List<DeviceInfoDto.Vo>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfoDto.Vo::getAdminName));
+
+
         DateTime date = DateTime.now();
         DateTime start = DateUtil.beginOfDay(date);
         DateTime end = DateUtil.endOfDay(date);
@@ -1008,7 +1008,15 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
 
             dataList.add(vo);
         }
-
+        DeviceInfoDto.MercHomeListVO orderTemp = null;
+        for (int i=0; i<dataList.size(); i++){
+            if ("未分配管理员".equals(dataList.get(i).getAdminName())) {
+                orderTemp = dataList.get(i);
+                dataList.remove(i);
+                dataList.add(orderTemp);
+                break;
+            }
+        }
         return R.ok(dataList);
     }