fix: 接单部门分析显示完整部门层级名称(父部门-子部门)避免同名混淆

This commit is contained in:
Your Name 2026-01-17 10:16:40 +08:00
parent 456282ce98
commit 5c1d938183

View File

@ -2089,6 +2089,8 @@ public class AnalyticsService {
List<Department> departments = departmentMapper.selectList(null);
Map<Long, String> deptNames = departments.stream()
.collect(Collectors.toMap(d -> d.getId(), d -> d.getDeptName(), (a, b) -> a));
Map<Long, Long> deptParentIds = departments.stream()
.collect(Collectors.toMap(d -> d.getId(), d -> d.getParentId() != null ? d.getParentId() : 0L, (a, b) -> a));
// 🔥 获取每个部门的人数(包含部门负责人)
Map<Long, Integer> deptMemberCounts = new HashMap<>();
@ -2110,7 +2112,17 @@ public class AnalyticsService {
DimensionAnalysisVO.ReceivingDeptAnalysis analysis = new DimensionAnalysisVO.ReceivingDeptAnalysis();
analysis.setDeptId(deptId);
analysis.setDeptName(deptNames.getOrDefault(deptId, "未知部门"));
// 🔥 如果是子部门且有同名部门,显示为"父部门-子部门"格式
String deptName = deptNames.getOrDefault(deptId, "未知部门");
Long parentId = deptParentIds.getOrDefault(deptId, 0L);
if (parentId != null && parentId > 0) {
String parentName = deptNames.get(parentId);
if (parentName != null && !parentName.isEmpty()) {
deptName = parentName + "-" + deptName;
}
}
analysis.setDeptName(deptName);
analysis.setTotalTasks(deptTasks.size());
// 🔥 设置部门人数