Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-10-17 13:57:42 +08:00
commit 5a8e5643da
1 changed files with 72 additions and 55 deletions

View File

@ -2056,67 +2056,84 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public Object selectDeptDetailTypeCountList(Map params) {
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()));
List<HashMap<String, Object>> resultList = getDeptTemp1();
resultList.addAll(getDeptTemp2());
Map<String, Integer> countMap = new HashMap<>();
resultList = resultList.stream().map(index -> {
if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息
index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> {
index.put(count.get("type").toString(), count.get("count"));
if (countMap.containsKey(count.get("type"))) {
countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type")));
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(count.get("type").toString(), Integer.parseInt(count.get("count").toString()));
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;
}
return index;
}).collect(Collectors.toList());
Map<String, List<Map<String, Object>>> typeCountListMap1 = // 区级部门
typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("3")).collect(Collectors.groupingBy(m -> m.get("district").toString()));
resultList = resultList.stream().map(index -> {
if (typeCountListMap1.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息
index.put("count", typeCountListMap1.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
typeCountListMap1.get(index.get("dept_id").toString()).stream().forEach(count -> {
index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString()));
if (countMap.containsKey(count.get("type"))) {
countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type")));
} else {
countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()));
}
});
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()));
List<HashMap<String, Object>> resultList = getDeptTemp1();
resultList.addAll(getDeptTemp2());
Map<String, Integer> countMap = new HashMap<>();
resultList = resultList.stream().map(index -> {
if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息
index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> {
index.put(count.get("type").toString(), count.get("count"));
if (countMap.containsKey(count.get("type"))) {
countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type")));
} else {
countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()));
}
});
}
return index;
}).collect(Collectors.toList());
Map<String, List<Map<String, Object>>> typeCountListMap1 = // 区级部门
typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("3")).collect(Collectors.groupingBy(m -> m.get("district").toString()));
resultList = resultList.stream().map(index -> {
if (typeCountListMap1.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息
index.put("count", typeCountListMap1.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
typeCountListMap1.get(index.get("dept_id").toString()).stream().forEach(count -> {
index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString()));
if (countMap.containsKey(count.get("type"))) {
countMap.replace(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + countMap.get(count.get("type")));
} else {
countMap.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()));
}
});
}
return index;
}).collect(Collectors.toList());
Integer total = 0;
for (Integer count : countMap.values()) {
total += count;
}
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;
countMap.put("count", total);
HashMap<String, Object> count = new HashMap<>();
count.put("name", "总计");
count.putAll(countMap);
resultList.add(count);
return resultList;
}
countMap.put("count", total);
HashMap<String, Object> count = new HashMap<>();
count.put("name", "总计");
count.putAll(countMap);
resultList.add(count);
return resultList;
}
/**