增加装备专业统计功能,并修正装备状态统计注释
This commit is contained in:
parent
3c05b4776a
commit
210bf45c81
|
|
@ -196,14 +196,23 @@ public class DevInfoController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计装备
|
* 装备状态统计
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "装备统计")
|
@ApiOperation(value = "装备状态统计")
|
||||||
@GetMapping("/sumType")
|
@GetMapping("/sumType")
|
||||||
public AjaxResult sumType() {
|
public AjaxResult sumType() {
|
||||||
return success(devInfoService.sumType());
|
return success(devInfoService.sumType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装备专业统计
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "装备专业统计")
|
||||||
|
@GetMapping("/sumProfession")
|
||||||
|
public AjaxResult sumProfession() {
|
||||||
|
return success(devInfoService.sumProfession());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出设备信息列表
|
* 导出设备信息列表
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,8 @@ public interface DevInfoService {
|
||||||
|
|
||||||
Map<String, Integer> sumType();
|
Map<String, Integer> sumType();
|
||||||
|
|
||||||
|
Map<String, Integer> sumProfession();
|
||||||
|
|
||||||
List<DevInfoVo> selectDevInfoLists(DevInfoVo devInfo);
|
List<DevInfoVo> selectDevInfoLists(DevInfoVo devInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -679,7 +679,7 @@ public class DevInfoServiceImpl implements DevInfoService {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计装备
|
* 装备状态统计
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Integer> sumType() {
|
public Map<String, Integer> sumType() {
|
||||||
|
|
@ -687,15 +687,42 @@ public class DevInfoServiceImpl implements DevInfoService {
|
||||||
Map<String, Integer> sumTypeMap = new IdentityHashMap<>();
|
Map<String, Integer> sumTypeMap = new IdentityHashMap<>();
|
||||||
//获取所有的装备信息
|
//获取所有的装备信息
|
||||||
List<DevInfoVo> devInfoList = devInfoMapper.selectDevInfoList(devInfoVo);
|
List<DevInfoVo> devInfoList = devInfoMapper.selectDevInfoList(devInfoVo);
|
||||||
//获取每种状态列表
|
//获取每种状态列表(过滤掉状态为null的记录)
|
||||||
Map<Integer, List<DevInfo>> groupedByMaStatus = devInfoList.stream()
|
Map<Integer, List<DevInfo>> groupedByMaStatus = devInfoList.stream()
|
||||||
|
.filter(dev -> dev.getMaStatus() != null)
|
||||||
.collect(Collectors.groupingBy(DevInfo::getMaStatus));
|
.collect(Collectors.groupingBy(DevInfo::getMaStatus));
|
||||||
//获取所有的key
|
//获取所有的key
|
||||||
Set<Integer> keys = groupedByMaStatus.keySet();
|
Set<Integer> keys = groupedByMaStatus.keySet();
|
||||||
//根据key计算每种状态的数量
|
//根据key计算每种状态的数量
|
||||||
for (Integer key : keys) {
|
for (Integer key : keys) {
|
||||||
List<DevInfo> deviceList = groupedByMaStatus.get(key);
|
List<DevInfo> deviceList = groupedByMaStatus.get(key);
|
||||||
sumTypeMap.put(MaStatusEnum.getNameByCode(key), deviceList.size());
|
String statusName = MaStatusEnum.getNameByCode(key);
|
||||||
|
if (statusName != null) {
|
||||||
|
sumTypeMap.put(statusName, deviceList.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sumTypeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装备专业统计
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, Integer> sumProfession() {
|
||||||
|
DevInfoVo devInfoVo = new DevInfoVo();
|
||||||
|
Map<String, Integer> sumTypeMap = new IdentityHashMap<>();
|
||||||
|
//获取所有的装备信息
|
||||||
|
List<DevInfoVo> devInfoList = devInfoMapper.selectDevInfoList(devInfoVo);
|
||||||
|
// 获取每种专业的列表(过滤掉专业为null的记录)
|
||||||
|
Map<String, List<DevInfoVo>> groupedByProfession = devInfoList.stream()
|
||||||
|
.filter(dev -> dev.getProfession() != null)
|
||||||
|
.collect(Collectors.groupingBy(DevInfoVo::getProfession));
|
||||||
|
//获取所有的key
|
||||||
|
Set<String> professionKeys = groupedByProfession.keySet();
|
||||||
|
//根据key计算每种专业的数量
|
||||||
|
for (String professionKey : professionKeys) {
|
||||||
|
List<DevInfoVo> professionList = groupedByProfession.get(professionKey);
|
||||||
|
sumTypeMap.put(professionKey, professionList.size());
|
||||||
}
|
}
|
||||||
return sumTypeMap;
|
return sumTypeMap;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue