feat(工作报告团队视角): 工作报告现在可以查看团队视角了(查看下属)。
fix(工作报告定时生成): 修复工作报告定时生成带来的一些问题。
This commit is contained in:
@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.njcn.rdms.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@@ -56,4 +57,9 @@ public class UserManagementRelationApiImpl implements UserManagementRelationApi
|
||||
return success(BeanUtils.toBean(list, UserManagementRelationRespDTO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Set<Long>> getAllSubordinateUserIds(Long managerUserId) {
|
||||
return success(userManagementRelationService.getAllSubordinateUserIds(managerUserId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.njcn.rdms.framework.common.pojo.CommonResult;
|
||||
import com.njcn.rdms.framework.common.util.object.BeanUtils;
|
||||
import com.njcn.rdms.framework.excel.core.util.ExcelUtils;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.user.UserSimpleRespVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.MySubordinateTreeRespVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.UserManagementRelationQueryReqVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.UserManagementRelationRespVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.UserManagementRelationSaveReqVO;
|
||||
@@ -211,6 +212,13 @@ public class UserManagementRelationController {
|
||||
return success(userManagementRelationService.getRelationTree(reqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/my-subordinate-tree")
|
||||
@Operation(summary = "获取当前用户下属树")
|
||||
@PreAuthorize("@ss.hasPermission('project:work-report:team-dashboard')")
|
||||
public CommonResult<MySubordinateTreeRespVO> getMySubordinateTree() {
|
||||
return success(userManagementRelationService.getMySubordinateTree(null));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出用户管理链路 Excel
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 我的下属树 Response VO")
|
||||
@Data
|
||||
public class MySubordinateTreeRespVO {
|
||||
|
||||
@Schema(description = "用户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2042074259501088770")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "戴坤")
|
||||
private String userNickname;
|
||||
|
||||
@Schema(description = "是否为根节点", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
private Boolean isRoot;
|
||||
|
||||
@Schema(description = "下属总人数(递归)", requiredMode = Schema.RequiredMode.REQUIRED, example = "18")
|
||||
private Integer subordinateCount;
|
||||
|
||||
@Schema(description = "子节点")
|
||||
private List<MySubordinateTreeRespVO> children;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.njcn.rdms.module.system.service.user;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.njcn.rdms.framework.common.util.collection.CollectionUtils;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.MySubordinateTreeRespVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.UserManagementRelationQueryReqVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.UserManagementRelationSaveReqVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.UserManagementRelationTreeRespVO;
|
||||
@@ -12,6 +13,7 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户管理链路 Service 接口
|
||||
@@ -108,6 +110,14 @@ public interface UserManagementRelationService {
|
||||
*/
|
||||
List<UserManagementRelationTreeRespVO> getRelationTree(UserManagementRelationQueryReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获取当前用户为根节点的下属树。
|
||||
*
|
||||
* @param rootUserId 根用户 ID;为空时默认当前登录用户
|
||||
* @return 下属树
|
||||
*/
|
||||
MySubordinateTreeRespVO getMySubordinateTree(Long rootUserId);
|
||||
|
||||
/**
|
||||
* 获取还未绑定直属上级的候选下级用户列表
|
||||
*
|
||||
@@ -115,6 +125,14 @@ public interface UserManagementRelationService {
|
||||
*/
|
||||
List<AdminUserDO> getCandidateSubordinateUsers();
|
||||
|
||||
/**
|
||||
* 获取管理者全部直接/间接下属 ID(不含本人)。
|
||||
*
|
||||
* @param managerUserId 管理者用户 ID
|
||||
* @return 全部下属用户 ID
|
||||
*/
|
||||
Set<Long> getAllSubordinateUserIds(Long managerUserId);
|
||||
|
||||
/**
|
||||
* 获得用户管理链路 Map
|
||||
*
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.njcn.rdms.framework.common.enums.CommonStatusEnum;
|
||||
import com.njcn.rdms.framework.common.exception.ServiceException;
|
||||
import com.njcn.rdms.framework.common.util.object.BeanUtils;
|
||||
import com.njcn.rdms.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.njcn.rdms.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.MySubordinateTreeRespVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.UserManagementRelationQueryReqVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.UserManagementRelationSaveReqVO;
|
||||
import com.njcn.rdms.module.system.controller.admin.user.vo.userManagementRelation.UserManagementRelationTreeRespVO;
|
||||
@@ -349,6 +351,44 @@ public class UserManagementRelationServiceImpl implements UserManagementRelation
|
||||
return buildFullTree(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MySubordinateTreeRespVO getMySubordinateTree(Long rootUserId) {
|
||||
Long resolvedRootUserId = rootUserId != null ? rootUserId : SecurityFrameworkUtils.getLoginUserId();
|
||||
if (resolvedRootUserId == null) {
|
||||
return null;
|
||||
}
|
||||
TreeBuildContext context = buildTreeContext(new UserManagementRelationQueryReqVO());
|
||||
if (context == null) {
|
||||
AdminUserDO self = adminUserService.getUser(resolvedRootUserId);
|
||||
if (!adminUserService.isUserAvailable(self)) {
|
||||
return null;
|
||||
}
|
||||
MySubordinateTreeRespVO root = new MySubordinateTreeRespVO();
|
||||
root.setUserId(self.getId());
|
||||
root.setUserNickname(self.getNickname());
|
||||
root.setIsRoot(Boolean.TRUE);
|
||||
root.setSubordinateCount(0);
|
||||
root.setChildren(Collections.emptyList());
|
||||
return root;
|
||||
}
|
||||
return buildMySubordinateTreeNode(resolvedRootUserId, true, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> getAllSubordinateUserIds(Long managerUserId) {
|
||||
if (managerUserId == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
TreeBuildContext context = buildTreeContext(new UserManagementRelationQueryReqVO());
|
||||
if (context == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
Set<Long> result = new LinkedHashSet<>();
|
||||
collectSubordinateIds(managerUserId, context, result);
|
||||
result.remove(managerUserId);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过某个用户的id,判断管理链路表中是否有该用户的记录
|
||||
* 判断原则:
|
||||
@@ -636,6 +676,57 @@ public class UserManagementRelationServiceImpl implements UserManagementRelation
|
||||
return node;
|
||||
}
|
||||
|
||||
private MySubordinateTreeRespVO buildMySubordinateTreeNode(Long userId, boolean root, TreeBuildContext context) {
|
||||
AdminUserDO user = context.getUserMap().get(userId);
|
||||
if (!adminUserService.isUserAvailable(user)) {
|
||||
return null;
|
||||
}
|
||||
List<MySubordinateTreeRespVO> children = new ArrayList<>();
|
||||
for (Long subordinateId : context.getManagerToSubordinatesMap().getOrDefault(userId, Collections.emptyList())) {
|
||||
if (Objects.equals(subordinateId, userId)) {
|
||||
continue;
|
||||
}
|
||||
MySubordinateTreeRespVO child = buildMySubordinateTreeNode(subordinateId, false, context);
|
||||
if (child != null) {
|
||||
children.add(child);
|
||||
}
|
||||
}
|
||||
MySubordinateTreeRespVO node = new MySubordinateTreeRespVO();
|
||||
node.setUserId(user.getId());
|
||||
node.setUserNickname(user.getNickname());
|
||||
node.setIsRoot(root);
|
||||
node.setChildren(children);
|
||||
node.setSubordinateCount(sumSubordinateCount(children));
|
||||
return node;
|
||||
}
|
||||
|
||||
private int sumSubordinateCount(List<MySubordinateTreeRespVO> children) {
|
||||
int total = 0;
|
||||
for (MySubordinateTreeRespVO child : children) {
|
||||
if (child == null) {
|
||||
continue;
|
||||
}
|
||||
total += 1;
|
||||
total += child.getSubordinateCount() == null ? 0 : child.getSubordinateCount();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
private void collectSubordinateIds(Long managerUserId, TreeBuildContext context, Set<Long> result) {
|
||||
for (Long subordinateId : context.getManagerToSubordinatesMap().getOrDefault(managerUserId, Collections.emptyList())) {
|
||||
if (Objects.equals(subordinateId, managerUserId)) {
|
||||
continue;
|
||||
}
|
||||
AdminUserDO subordinate = context.getUserMap().get(subordinateId);
|
||||
if (!adminUserService.isUserAvailable(subordinate)) {
|
||||
continue;
|
||||
}
|
||||
if (result.add(subordinateId)) {
|
||||
collectSubordinateIds(subordinateId, context, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一时间有效性过滤条件:
|
||||
* <p>
|
||||
|
||||
Reference in New Issue
Block a user