feat: 接单部门分析显示所有接单部门(包括没有任务的)
This commit is contained in:
parent
5c1d938183
commit
3f8a3446f8
@ -2092,9 +2092,15 @@ public class AnalyticsService {
|
||||
Map<Long, Long> deptParentIds = departments.stream()
|
||||
.collect(Collectors.toMap(d -> d.getId(), d -> d.getParentId() != null ? d.getParentId() : 0L, (a, b) -> a));
|
||||
|
||||
// 🔥 获取每个部门的人数(包含部门负责人)
|
||||
// 🔥 获取所有接单类型的部门(包括没有任务的)
|
||||
List<Department> receivingDepts = departments.stream()
|
||||
.filter(d -> "receiving".equals(d.getDeptType()) && d.getStatus() != null && d.getStatus() == 1)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 🔥 获取每个接单部门的人数(包含部门负责人)
|
||||
Map<Long, Integer> deptMemberCounts = new HashMap<>();
|
||||
for (Long deptId : tasksByDept.keySet()) {
|
||||
for (Department dept : receivingDepts) {
|
||||
Long deptId = dept.getId();
|
||||
// 查询该部门及其子部门的所有用户数量
|
||||
List<Long> deptAndChildIds = getDeptAndChildIds(deptId);
|
||||
Long memberCount = userMapper.selectCount(new LambdaQueryWrapper<User>()
|
||||
@ -2106,9 +2112,10 @@ public class AnalyticsService {
|
||||
deptMemberCounts.put(deptId, memberCount.intValue() + leaderCount);
|
||||
}
|
||||
|
||||
for (Map.Entry<Long, List<Task>> entry : tasksByDept.entrySet()) {
|
||||
Long deptId = entry.getKey();
|
||||
List<Task> deptTasks = entry.getValue();
|
||||
// 🔥 遍历所有接单部门(包括没有任务的)
|
||||
for (Department dept : receivingDepts) {
|
||||
Long deptId = dept.getId();
|
||||
List<Task> deptTasks = tasksByDept.getOrDefault(deptId, Collections.emptyList());
|
||||
|
||||
DimensionAnalysisVO.ReceivingDeptAnalysis analysis = new DimensionAnalysisVO.ReceivingDeptAnalysis();
|
||||
analysis.setDeptId(deptId);
|
||||
@ -2194,7 +2201,7 @@ public class AnalyticsService {
|
||||
result.add(analysis);
|
||||
}
|
||||
|
||||
// 按任务数量降序排序
|
||||
// 按任务数量降序排序(有任务的排前面)
|
||||
result.sort((a, b) -> Integer.compare(b.getTotalTasks(), a.getTotalTasks()));
|
||||
|
||||
return result;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user