fix(加班申请、工作报告、我的绩效): 修复一系列bug、对不合理的地方进行调整。

This commit is contained in:
dk
2026-06-22 22:58:03 +08:00
parent b4f6eab64c
commit 856668ec25
12 changed files with 365 additions and 64 deletions

View File

@@ -18,7 +18,11 @@ import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@@ -90,4 +94,24 @@ public class DeptController {
return success(BeanUtils.toBean(dept, DeptRespVO.class));
}
@GetMapping("/list-self-and-children")
@Operation(summary = "获取部门自身及全部子部门")
@Parameter(name = "id", description = "部门编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:dept:query')")
public CommonResult<List<DeptSimpleRespVO>> getDeptSelfAndChildren(@RequestParam("id") Long id) {
DeptDO self = deptService.getDept(id);
if (self == null) {
return success(List.of());
}
List<DeptDO> combined = new ArrayList<>();
combined.add(self);
combined.addAll(deptService.getChildDeptList(id));
Map<Long, DeptDO> distinctMap = new LinkedHashMap<>();
combined.forEach(dept -> distinctMap.putIfAbsent(dept.getId(), dept));
List<DeptDO> result = new ArrayList<>(distinctMap.values());
result.sort(Comparator.comparing(DeptDO::getSort, Comparator.nullsLast(Integer::compareTo))
.thenComparing(DeptDO::getId, Comparator.nullsLast(Long::compareTo)));
return success(BeanUtils.toBean(result, DeptSimpleRespVO.class));
}
}

View File

@@ -15,6 +15,7 @@ import com.njcn.rdms.module.system.dal.dataobject.dept.DeptDO;
import com.njcn.rdms.module.system.dal.dataobject.user.AdminUserDO;
import com.njcn.rdms.module.system.dal.dataobject.user.UserManagementRelationDO;
import com.njcn.rdms.module.system.service.dept.DeptService;
import com.njcn.rdms.module.system.service.user.AdminUserService;
import com.njcn.rdms.module.system.service.user.UserManagementRelationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -27,9 +28,13 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.Comparator;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.njcn.rdms.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
@@ -58,6 +63,9 @@ public class UserManagementRelationController {
@Resource
private UserManagementRelationService userManagementRelationService;
@Resource
private AdminUserService adminUserService;
/**
* 创建用户管理链路
*
@@ -192,6 +200,47 @@ public class UserManagementRelationController {
return success(UserConvert.INSTANCE.convertSimpleList(users, deptMap));
}
/**
* 获取某用户当前生效的直属下级列表。
*
* 口径:只返回直接下级,不递归孙级;仅返回当前生效的管理链路。
*/
@GetMapping("/direct-subordinates")
@Operation(summary = "获取某用户当前生效的直属下级列表")
@Parameter(name = "userId", description = "用户ID", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:user-management-relation:query')")
public CommonResult<List<UserSimpleRespVO>> getDirectSubordinates(@RequestParam("userId") Long userId) {
List<UserManagementRelationDO> relations = userManagementRelationService.getRelationListByManagerUserId(userId);
if (relations.isEmpty()) {
return success(Collections.emptyList());
}
LocalDateTime now = LocalDateTime.now();
Set<Long> subordinateIds = new LinkedHashSet<>();
relations.stream()
.filter(relation -> relation.getSubordinateUserId() != null)
.filter(relation -> relation.getEffectiveFrom() == null || !relation.getEffectiveFrom().isAfter(now))
.filter(relation -> relation.getEffectiveUntil() == null || relation.getEffectiveUntil().isAfter(now))
.map(UserManagementRelationDO::getSubordinateUserId)
.forEach(subordinateIds::add);
if (subordinateIds.isEmpty()) {
return success(Collections.emptyList());
}
List<AdminUserDO> users = adminUserService.getUserList(subordinateIds).stream()
.filter(adminUserService::isUserAvailable)
.sorted(Comparator.comparing(AdminUserDO::getSort, Comparator.nullsLast(Integer::compareTo))
.thenComparing(AdminUserDO::getId, Comparator.nullsLast(Long::compareTo)))
.toList();
if (users.isEmpty()) {
return success(Collections.emptyList());
}
Map<Long, DeptDO> deptMap = deptService.getDeptMap(convertList(users, AdminUserDO::getDeptId));
List<UserSimpleRespVO> result = UserConvert.INSTANCE.convertSimpleList(users, deptMap).stream()
.sorted(Comparator.comparing(UserSimpleRespVO::getSort, Comparator.nullsLast(Integer::compareTo))
.thenComparing(UserSimpleRespVO::getId, Comparator.nullsLast(Long::compareTo)))
.toList();
return success(result);
}
/**
* 获取用户管理链路树形结构
*