fix: 修复部门负责人查看待审核子任务组的逻辑
1. 使用leader_id查找用户负责的所有部门,而不是user.dept_id 2. 合并所有负责部门的待审核子任务组 3. 支持一个用户是多个部门负责人的场景
This commit is contained in:
parent
4ceacdf327
commit
62fd513df7
@ -299,15 +299,33 @@ public class TaskItemController {
|
||||
return Result.success(groups);
|
||||
}
|
||||
|
||||
// 如果没有提供部门ID,从用户信息中获取
|
||||
if (deptId == null) {
|
||||
if (user == null || user.getDeptId() == null) {
|
||||
return Result.success(new java.util.ArrayList<>());
|
||||
}
|
||||
deptId = user.getDeptId();
|
||||
// 查找用户作为负责人的所有部门
|
||||
List<com.designhub.entity.Department> leadingDepts = departmentMapper.selectList(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<com.designhub.entity.Department>()
|
||||
.eq(com.designhub.entity.Department::getLeaderId, userId)
|
||||
.eq(com.designhub.entity.Department::getStatus, 1)
|
||||
);
|
||||
|
||||
if (leadingDepts.isEmpty()) {
|
||||
// 不是任何部门的负责人,返回空列表
|
||||
return Result.success(new java.util.ArrayList<>());
|
||||
}
|
||||
|
||||
List<Map<String, Object>> groups = taskItemService.getPendingApprovalGroups(deptId);
|
||||
return Result.success(groups);
|
||||
// 合并所有负责部门的待审核子任务组
|
||||
List<Map<String, Object>> allGroups = new java.util.ArrayList<>();
|
||||
java.util.Set<String> addedKeys = new java.util.HashSet<>();
|
||||
|
||||
for (com.designhub.entity.Department dept : leadingDepts) {
|
||||
List<Map<String, Object>> groups = taskItemService.getPendingApprovalGroups(dept.getId());
|
||||
for (Map<String, Object> group : groups) {
|
||||
String key = group.get("taskId") + "-" + group.get("groupNo");
|
||||
if (!addedKeys.contains(key)) {
|
||||
addedKeys.add(key);
|
||||
allGroups.add(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Result.success(allGroups);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user