能力使用部门排序

This commit is contained in:
wangliwen 2022-10-17 16:03:32 +08:00
parent b25309c134
commit abc082624d
2 changed files with 129 additions and 28 deletions

View File

@ -2024,34 +2024,130 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override @Override
public Object selectApplyDeptDetailTypeCountList(Map params) { public Object selectApplyDeptDetailTypeCountList(Map params) {
List<Map<String, Object>> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params); if (params.containsKey("deptId") && org.apache.commons.lang3.StringUtils.isNotEmpty(params.get("deptId").toString())) {
Map<String, List<Map<String, Object>>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString())); List<Map<String, Object>> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params);
ArrayList<Map> resultList = new ArrayList<>(); Map<String, List<Map<String, Object>>> typeCountListMap = typeCountListByApplyDept.stream().collect(Collectors.groupingBy(m -> m.get("deptName").toString()));
Map<String, Integer> countMap = new HashMap<>(); ArrayList<Map> resultList = new ArrayList<>();
typeCountListMap.forEach((k, v) -> { Map<String, Integer> countMap = new HashMap<>();
HashMap<Object, Object> map = new HashMap<>(); typeCountListMap.forEach((k, v) -> {
map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum()); HashMap<Object, Object> map = new HashMap<>();
map.put("name", k); map.put("count", v.stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
v.forEach(item -> { map.put("name", k);
map.put(item.get("type").toString(), item.get("count")); v.forEach(item -> {
if (countMap.containsKey(item.get("type"))) { map.put(item.get("type").toString(), item.get("count"));
countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type"))); if (countMap.containsKey(item.get("type"))) {
} else { countMap.replace(item.get("type").toString(), Integer.parseInt(item.get("count").toString()) + countMap.get(item.get("type")));
countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString())); } else {
} countMap.put(item.get("type").toString(), Integer.parseInt(item.get("count").toString()));
}
});
resultList.add(map);
}); });
resultList.add(map); Integer total = 0;
}); for (Integer count : countMap.values()) {
Integer total = 0; total += count;
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>> typeCountListByApplyDept = resourceDao.selectApplyDeptDetailTypeCountList(params);
List<HashMap<String, Object>> resultList = getDeptTemp1();
resultList.addAll(getDeptTemp2());
Map<String, Integer> countMap = new HashMap<>();
Map<String, List<Map<String, Object>>> typeCountListMap = // 市级部门
typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("2")).collect(Collectors.groupingBy(m -> m.get("dept_id").toString()));
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 = // 区级部门
typeCountListByApplyDept.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());
Map<String, List<Map<String, Object>>> typeCountListMap2 = // 会议室
typeCountListByApplyDept.stream().filter(index -> index.get("deptType").toString().equals("99")).collect(Collectors.groupingBy(m -> m.get("deptName").toString()));
resultList = resultList.stream().map(index -> {
if (typeCountListMap2.keySet().contains(index.get("name").toString())) { // 该部门存在上架信息
index.put("count", Integer.parseInt(index.get("count").toString()) + typeCountListMap2.get(index.get("name").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
typeCountListMap2.get(index.get("name").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()));
}
});
typeCountListMap2.remove(typeCountListMap2.get(index.get("deptName").toString()));// 去除
}
return index;
}).collect(Collectors.toList());
if (!typeCountListMap2.isEmpty()) { // 仍然有会议室信息
List<HashMap<String, Object>> temp = typeCountListMap2.keySet().stream().map(index_ -> {
HashMap<String, Object> map = new HashMap<>();
typeCountListMap2.get(index_).stream().forEach(count -> {
map.put(count.get("type").toString(), Integer.parseInt(count.get("type").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()));
}
});
map.put("name", index_);
map.put("dept_id", null);
map.put("yyzy", "0");
map.put("znsf", "0");
map.put("tcfw", "0");
map.put("kfzj", "0");
map.put("ywzj", "0");
map.put("jcss", "0");
map.put("zsk", "0");
map.put("sjzy", "0");
map.put("hys", "0");
return map;
}).collect(Collectors.toList()); // 会议室的
resultList.addAll(temp);
}
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;
} }
@Override @Override

View File

@ -1719,6 +1719,9 @@
SELECT SELECT
COUNT( taa.resource_id ) AS "count", COUNT( taa.resource_id ) AS "count",
sd.NAME AS "deptName", sd.NAME AS "deptName",
sd.id AS "dept_id",
sd.type AS "deptType",
sd.district AS "district",
( (
CASE CASE
tdr.type tdr.type
@ -1777,9 +1780,11 @@
UNION UNION
SELECT SELECT
COUNT( id ) AS 'count',
COUNT( id ) AS 'count' ,
dept AS 'deptName', dept AS 'deptName',
NULL AS "dept_id",
99 AS "deptType",
NULL AS "district",
'hys' AS 'type' 'hys' AS 'type'
FROM FROM
t_meetingroom_book tmb t_meetingroom_book tmb