This commit is contained in:
wangliwen 2022-10-17 13:56:19 +08:00
parent dd08d7b139
commit ad54ba9ac1
1 changed files with 72 additions and 55 deletions

View File

@ -2056,6 +2056,36 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public Object selectDeptDetailTypeCountList(Map params) {
if (params.containsKey("deptId") && params.get("deptId") != null) {
List<Map<String, Object>> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params);
Map<String, List<Map<String, Object>>> typeCountListMap = typeCountListByDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString()));
ArrayList<Map> resultList = new ArrayList<>();
Map<String, Integer> countMap = new HashMap<>();
typeCountListMap.forEach((k, v) -> {
HashMap<Object, Object> map = new HashMap<>();
map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
map.put("name", k);
v.forEach(item -> {
map.put(item.get("type").toString(), item.get("count"));
if (countMap.containsKey(item.get("type"))) {
countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type")));
} else {
countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString()));
}
});
resultList.add(map);
});
Integer total = 0;
for (Integer count : countMap.values()) {
total += count;
}
countMap.put("count", total);
HashMap<String, Object> count = new HashMap<>();
count.put("name", "总计");
count.putAll(countMap);
resultList.add(count);
return resultList;
} else { // 全部部门
List<Map<String, Object>> typeCountListByDept = resourceDao.selectDeptDetailTypeCountList(params);
Map<String, List<Map<String, Object>>> typeCountListMap = // 市级部门
typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString()));
@ -2092,21 +2122,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
return index;
}).collect(Collectors.toList());
// typeCountListMap.forEach((k, v) -> {
// HashMap<String, Object> map = new HashMap<>();
// map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
// map.put("name", k);
// v.forEach(item -> {
// map.put(item.get("type").toString(), item.get("count"));
// if (countMap.containsKey(item.get("type"))) {
// countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type")));
// } else {
// countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString()));
// }
// });
// resultList.add(map);
// });
Integer total = 0;
for (Integer count : countMap.values()) {
total += count;
@ -2119,6 +2134,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
return resultList;
}
}
/**
* @return 返回市级部门的初级构造
*/