|
@@ -96,20 +96,32 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
@Override
|
|
|
@ApiOperation("设备在线数查询")
|
|
|
- public R<DeviceInfoDto.NetStateCountVo> netStateCount(DeviceInfoDto.NetStateCountDto dto) {
|
|
|
- List<DeviceInfoDto.NetStateCount> netStateCountList = baseMapper.netStateCount(dto.getMercId());
|
|
|
- Integer count = 0;
|
|
|
- DeviceInfoDto.NetStateCountVo vo = new DeviceInfoDto.NetStateCountVo();
|
|
|
- for (DeviceInfoDto.NetStateCount i : netStateCountList) {
|
|
|
- count += i.getCount();
|
|
|
- if ("1".equals(i.getNetState())) {
|
|
|
- vo.setOnLineCount(i.getCount());
|
|
|
- } else if ("2".equals(i.getNetState())) {
|
|
|
- vo.setOffLineCount(i.getCount());
|
|
|
+ public R<Map<Long, DeviceInfoDto.NetStateCountVo>> netStateCount(DeviceInfoDto.NetStateCountDto dto) {
|
|
|
+ List<DeviceInfoDto.NetStateCount> netStateCountList = baseMapper.netStateCount(dto.getMercIdList());
|
|
|
+ List<Long> netStateCountMercList = netStateCountList.stream().map(DeviceInfoDto.NetStateCount::getMercId).distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, DeviceInfoDto.NetStateCountVo> voMap = new HashMap<>();
|
|
|
+ List<Long> mercIdList = Emptys.check(dto.getMercIdList())?dto.getMercIdList():netStateCountMercList;
|
|
|
+ if(!Emptys.check(mercIdList)){
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ for (Long mercId : mercIdList) {
|
|
|
+ Integer count = 0;
|
|
|
+ Integer offline = 0;
|
|
|
+ DeviceInfoDto.NetStateCountVo vo = new DeviceInfoDto.NetStateCountVo().setMercId(mercId);
|
|
|
+ for (DeviceInfoDto.NetStateCount i : netStateCountList) {
|
|
|
+ if (Objects.equals(i.getMercId(), mercId)) {
|
|
|
+ count += i.getCount();
|
|
|
+ if ("1".equals(i.getNetState())) {
|
|
|
+ vo.setOnLineCount(i.getCount());
|
|
|
+ } else {
|
|
|
+ offline += i.getCount();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ vo.setCount(count).setOffLineCount(offline);
|
|
|
+ voMap.put(mercId, vo);
|
|
|
}
|
|
|
- vo.setCount(count);
|
|
|
- return R.ok(vo);
|
|
|
+ return R.ok(voMap);
|
|
|
}
|
|
|
|
|
|
@Override
|