|
@@ -108,6 +108,48 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
private final MercPlaceService mercPlaceService;
|
|
|
|
|
|
+ @PostMapping("groupByAdminName")
|
|
|
+ @ApiOperation("设备按管理员分组")
|
|
|
+ public R groupByAdminName(@RequestBody @Validated DeviceInfoDto.GroupByAdminNameDto dto) {
|
|
|
+ String noAdmin = "未分配管理员";
|
|
|
+ List<DeviceInfoDto.GroupByAdminName> deviceInfoList = baseMapper.groupByAdminName(dto);
|
|
|
+ deviceInfoList.forEach(i->{
|
|
|
+ SysDictRedis dictDeviceType = SysDictUtils.get(DictConsts.DEVICE_TYPE, String.valueOf(i.getDeviceType()));
|
|
|
+ i.setDeviceTypeName(dictDeviceType.getMsg());
|
|
|
+ if(!Emptys.check(i.getDeviceName())){
|
|
|
+ i.setDeviceName("");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //没有管理员的的设置默认值
|
|
|
+ deviceInfoList.stream().filter(s -> s.getAdminName() == null).forEach(s -> s.setAdminName(noAdmin));
|
|
|
+ //根据管理员名字分组
|
|
|
+ Map<String, List<DeviceInfoDto.GroupByAdminName>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfoDto.GroupByAdminName::getAdminName));
|
|
|
+ List<DeviceInfoDto.GroupByAdminNameVo> list = new ArrayList<>();
|
|
|
+ //不包含未分配管理员的
|
|
|
+ deviceMap.forEach(
|
|
|
+ (k,i)->{
|
|
|
+ DeviceInfoDto.GroupByAdminNameVo vo = new DeviceInfoDto.GroupByAdminNameVo();
|
|
|
+ if(!noAdmin.equals(k)){
|
|
|
+ vo.setAdminName(k)
|
|
|
+ .setDeviceNum(i.size())
|
|
|
+ .setDeviceInfos(i);
|
|
|
+ list.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ //包含分配管理员的
|
|
|
+ List<DeviceInfoDto.GroupByAdminName> noAdminNamesList = deviceMap.get(noAdmin);
|
|
|
+ if(Emptys.check(noAdminNamesList)){
|
|
|
+ DeviceInfoDto.GroupByAdminNameVo vo = new DeviceInfoDto.GroupByAdminNameVo();
|
|
|
+ vo.setAdminName(noAdmin)
|
|
|
+ .setDeviceNum(noAdminNamesList.size())
|
|
|
+ .setDeviceInfos(noAdminNamesList);
|
|
|
+ list.add(vo);
|
|
|
+ }
|
|
|
+ return R.ok(list);
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("eventList")
|
|
|
@ApiOperation("根据事件编码查询设备")
|
|
|
public R<PageBean<DeviceInfoDto.EventListVo>> eventList(@RequestBody @Validated DeviceInfoDto.EventList eventList) {
|
|
@@ -889,9 +931,9 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
//根据点位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();
|
|
|
- if(Emptys.check(mercPlaceList)){
|
|
|
+ if (Emptys.check(mercPlaceList)) {
|
|
|
//Map<Long, String> mercPlaceMap = mercPlaceList.stream().collect(Collectors.toMap(i -> i.getId(), i -> i.getAdminName()));
|
|
|
- Map<Long, String> mercPlaceMap = mercPlaceList.stream().collect(HashMap::new,(map,item) -> map.put(item.getId(),item.getAdminName()),HashMap::putAll);
|
|
|
+ Map<Long, String> mercPlaceMap = mercPlaceList.stream().collect(HashMap::new, (map, item) -> map.put(item.getId(), item.getAdminName()), HashMap::putAll);
|
|
|
deviceInfoList.forEach(i -> i.setAdminName(mercPlaceMap.get(i.getPlaceId())));
|
|
|
}
|
|
|
//没有管理员的的设置默认值
|
|
@@ -1011,7 +1053,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
dataList.add(vo);
|
|
|
}
|
|
|
DeviceInfoDto.MercHomeListVO orderTemp = null;
|
|
|
- for (int i=0; i<dataList.size(); i++){
|
|
|
+ for (int i = 0; i < dataList.size(); i++) {
|
|
|
if ("未分配管理员".equals(dataList.get(i).getAdminName())) {
|
|
|
orderTemp = dataList.get(i);
|
|
|
dataList.remove(i);
|