feat(REQ-3488): 添加NodeUserProfile定义及解析。重构NodeUserService.list方法的代码,将listReq的resolve抽成一个方法,提升page主方法的可读性。
This commit is contained in:
parent
69dae02844
commit
0ea671f661
@ -33,7 +33,9 @@ public class NodeProfile {
|
|||||||
* 平台班组所属团队/单位 id
|
* 平台班组所属团队/单位 id
|
||||||
*/
|
*/
|
||||||
private Long ouId;
|
private Long ouId;
|
||||||
//
|
|
||||||
|
// org_project_team 字段
|
||||||
|
private Long projectTeamId;
|
||||||
/**
|
/**
|
||||||
* 总包ID
|
* 总包ID
|
||||||
*/
|
*/
|
||||||
@ -110,11 +112,11 @@ public class NodeProfile {
|
|||||||
// 新冗余字段
|
// 新冗余字段
|
||||||
private Long belongProjectTeamNodeId;
|
private Long belongProjectTeamNodeId;
|
||||||
|
|
||||||
|
// org_project_group 字段
|
||||||
/**
|
/**
|
||||||
* 主键id
|
* 主键id
|
||||||
*/
|
*/
|
||||||
private Long id;
|
private Long projectGroupId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小组类型 0-直属小组 1-合作小组
|
* 小组类型 0-直属小组 1-合作小组
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import lombok.experimental.SuperBuilder;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ -186,4 +187,33 @@ public class NodeUserDTO implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private List<NodeUserBriefDTO> subordinateUsers;
|
private List<NodeUserBriefDTO> subordinateUsers;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析profile
|
||||||
|
* 调用方需要根据nodeType来解析profile,自行使用正确的对象来接收<br>。
|
||||||
|
* 解析对象需要 {@link #getNode()}.nodType信息,请确认{@link ListNodeUserReq.Needs#getNode()} = true,否则仅会返回json的profile。<br>
|
||||||
|
* <pre>
|
||||||
|
* NodeUserProfile.ProjectWorkerProfile projectTeamProfile = projectTeamNodeUser.resolveProfile(); // nodeType = 4
|
||||||
|
* NodeUserProfile.PlatTeamProfile platTeamProfile = platTeamNodeUser.resolveProfile(); // nodeType = 2
|
||||||
|
* JSONObject normalProfile = normalNodeUser.resolveProfile(); // nodeType = 1
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @see NodeUserProfile#resolveProfileClass(Integer)
|
||||||
|
*/
|
||||||
|
public <T> T resolveProfile() {
|
||||||
|
if (profile == null || profile.isEmpty()) {
|
||||||
|
return (T) profile;
|
||||||
|
}
|
||||||
|
if (node == null || node.getNodeType() == null) {
|
||||||
|
// 没有聚合node信息的情况,直接返回JSONObject的profile
|
||||||
|
return (T) profile;
|
||||||
|
}
|
||||||
|
Class<?> clazz = NodeUserProfile.resolveProfileClass(node.getNodeType());
|
||||||
|
if (clazz == null) {
|
||||||
|
return (T) profile;
|
||||||
|
}
|
||||||
|
return (T) Optional.ofNullable(profile).map(p -> JSONObject.parseObject(p.toString(), clazz)).orElse(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,108 @@
|
|||||||
|
package cn.axzo.orgmanax.dto.nodeuser.dto;
|
||||||
|
|
||||||
|
import cn.axzo.orgmanax.dto.node.enums.NodeTypeEnum;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门人员Profile定义
|
||||||
|
*/
|
||||||
|
public class NodeUserProfile {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目工人Profile,为了方便直观看到对应关系,字段和 org_project_team 保持一致
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
@Data
|
||||||
|
public static class ProjectWorkerProfile {
|
||||||
|
// org_project_worker 字段
|
||||||
|
/**
|
||||||
|
* 项目班组节点id。
|
||||||
|
*/
|
||||||
|
private Long projectWorkerId;
|
||||||
|
/**
|
||||||
|
* 状态:0、未激活 1、已激活 3已退场
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 工种类别
|
||||||
|
*/
|
||||||
|
private String professionCategoryName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否删除 0:未删除 其他:已删除
|
||||||
|
*/
|
||||||
|
private Long isDelete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后一次进工地的时间,进场打卡更新
|
||||||
|
* 进场打卡更新,
|
||||||
|
*/
|
||||||
|
private Date lastCheckInTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后一次出工地的时间,出场打卡更新
|
||||||
|
*/
|
||||||
|
private Date lastCheckOutTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工人施工开始时间,工人所有任务单中最早开始时间
|
||||||
|
*/
|
||||||
|
private Date constructionStartTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工人施工结束时间
|
||||||
|
*/
|
||||||
|
private Date constructionEndTime;
|
||||||
|
/**
|
||||||
|
* 在岗、待岗
|
||||||
|
*/
|
||||||
|
private Integer occupyStatus;
|
||||||
|
/**
|
||||||
|
* 提醒推送未备案消息次数。(xxljob在给未备案的工人发送消息。为了避免多次提醒。这里记录了一个提醒的次数。)
|
||||||
|
* 参考 maokai代码:cn.axzo.apollo.labour.service.job.PushSupervisionMsgJob#execute
|
||||||
|
*/
|
||||||
|
private Integer pushSupervisionMsgCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
@Data
|
||||||
|
/**
|
||||||
|
* 项目小组人员Profile
|
||||||
|
*/
|
||||||
|
public static class ProjectGroupWorkerProfile {
|
||||||
|
|
||||||
|
// 新冗余字段
|
||||||
|
/**
|
||||||
|
* 项目小组人员id
|
||||||
|
*/
|
||||||
|
private Long projectGroupWorkerId;
|
||||||
|
/**
|
||||||
|
* 状态 状态 0-有效 1-无效
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map<Integer, Class<?>> typeClassMapping = ImmutableMap.of(
|
||||||
|
NodeTypeEnum.PROJECT_TEAM.getValue(), ProjectWorkerProfile.class,
|
||||||
|
NodeTypeEnum.PROJECT_GROUP.getValue(), ProjectGroupWorkerProfile.class
|
||||||
|
);
|
||||||
|
|
||||||
|
public static Class<?> resolveProfileClass(Integer nodeType) {
|
||||||
|
if (nodeType == null) {
|
||||||
|
return JSONObject.class;
|
||||||
|
}
|
||||||
|
return typeClassMapping.getOrDefault(nodeType, JSONObject.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -262,7 +262,13 @@ public interface NodeUserQueryRepository {
|
|||||||
private Collection<String> orgUserStatus; // TODO: 待实现
|
private Collection<String> orgUserStatus; // TODO: 待实现
|
||||||
|
|
||||||
@CriteriaField(ignore = true)
|
@CriteriaField(ignore = true)
|
||||||
List<SFunction<OrganizationalNodeUser, ?>> selects;
|
private List<SFunction<OrganizationalNodeUser, ?>> selects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直接返回空
|
||||||
|
*/
|
||||||
|
@CriteriaField(ignore = true)
|
||||||
|
private Boolean returnEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
|||||||
@ -33,6 +33,9 @@ public class NodeUserQueryRepositoryImpl implements NodeUserQueryRepository {
|
|||||||
public PageResp<NodeUserResp> page(ListReq req) {
|
public PageResp<NodeUserResp> page(ListReq req) {
|
||||||
IPage<OrganizationalNodeUser> page = PageConverter.toMybatis(req, OrganizationalNodeUser.class);
|
IPage<OrganizationalNodeUser> page = PageConverter.toMybatis(req, OrganizationalNodeUser.class);
|
||||||
PageResp<NodeUserResp> emptyPage = PageResp.<NodeUserResp>builder().size(req.getPageSize()).current(req.getPage()).total(0L).data(ImmutableList.of()).build();
|
PageResp<NodeUserResp> emptyPage = PageResp.<NodeUserResp>builder().size(req.getPageSize()).current(req.getPage()).total(0L).data(ImmutableList.of()).build();
|
||||||
|
if (BooleanUtil.isTrue(req.getReturnEmpty())) {
|
||||||
|
return emptyPage;
|
||||||
|
}
|
||||||
LambdaQueryWrapper<OrganizationalNodeUser> wrapper = QueryWrapperHelper.fromBean(req, OrganizationalNodeUser.class).lambda();
|
LambdaQueryWrapper<OrganizationalNodeUser> wrapper = QueryWrapperHelper.fromBean(req, OrganizationalNodeUser.class).lambda();
|
||||||
// 查询参数处理 ~
|
// 查询参数处理 ~
|
||||||
// keyword
|
// keyword
|
||||||
|
|||||||
@ -97,63 +97,8 @@ public class NodeUserServiceImpl implements NodeUserService {
|
|||||||
public PageResp<NodeUserDTO> page(ListNodeUserReq req) {
|
public PageResp<NodeUserDTO> page(ListNodeUserReq req) {
|
||||||
PageResp<NodeUserDTO> emptyPage = PageResp.<NodeUserDTO>builder().size(req.getPageSize())
|
PageResp<NodeUserDTO> emptyPage = PageResp.<NodeUserDTO>builder().size(req.getPageSize())
|
||||||
.current(req.getPage()).total(0L).data(ImmutableList.of()).build();
|
.current(req.getPage()).total(0L).data(ImmutableList.of()).build();
|
||||||
NodeUserQueryRepository.ListReq listReq = BeanUtil.toBean(req, NodeUserQueryRepository.ListReq.class);
|
// 构建 repository层查询参数
|
||||||
// jobCodes -> jobIds
|
NodeUserQueryRepository.ListReq listReq = resolveListReq(req);
|
||||||
if (CollUtil.isNotEmpty(req.getOrganizationalJobCodes())
|
|
||||||
|| StrUtil.isNotBlank(req.getOrganizationalJobCode())
|
|
||||||
|| StrUtil.isNotBlank(req.getOrganizationalJobNameLike())
|
|
||||||
|| StrUtil.isNotBlank(req.getOrganizationalJobName())) {
|
|
||||||
Set<Long> jobIds = jobQueryRepository.list(OrgJobQueryRepository.ListReq.builder()
|
|
||||||
.codes(req.getOrganizationalJobCodes())
|
|
||||||
.code(req.getOrganizationalJobCode())
|
|
||||||
.nameLike(req.getOrganizationalJobNameLike())
|
|
||||||
.name(req.getOrganizationalJobName())
|
|
||||||
.searchCount(false)
|
|
||||||
.build()).stream().map(OrgJobQueryRepository.JobResp::getId).collect(Collectors.toSet());
|
|
||||||
if (jobIds.isEmpty()) {
|
|
||||||
return emptyPage;
|
|
||||||
}
|
|
||||||
listReq.setOrganizationalJobIds(QueryConditionAssembler.assemble(listReq.getOrganizationalJobIds(), jobIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据managerPersonId进行查询 -> 找到 manage的nodeId,作为查询条件,往下查
|
|
||||||
if (req.getManagerPersonId() != null) {
|
|
||||||
Set<Long> managedOrgNodeId = nodeUserQueryRepository.list(NodeUserQueryRepository.ListReq.builder()
|
|
||||||
.manager(true)
|
|
||||||
.personId(req.getManagerPersonId())
|
|
||||||
.selects(ImmutableList.of(OrganizationalNodeUser::getOrganizationalNodeId))
|
|
||||||
.searchCount(false)
|
|
||||||
.pageSize(100000)
|
|
||||||
.build()).stream()
|
|
||||||
.map(NodeUserQueryRepository.NodeUserResp::getOrganizationalNodeId).collect(Collectors.toSet());
|
|
||||||
if (managedOrgNodeId.isEmpty()) {
|
|
||||||
return emptyPage;
|
|
||||||
}
|
|
||||||
listReq.setOrganizationalNodeIds(QueryConditionAssembler.assemble(listReq.getOrganizationalNodeIds(), managedOrgNodeId));
|
|
||||||
}
|
|
||||||
|
|
||||||
// subordinatePersonId
|
|
||||||
if (req.getSubordinatePersonId() != null) {
|
|
||||||
Set<Long> nodeIds = nodeUserQueryRepository.list(NodeUserQueryRepository.ListReq.builder()
|
|
||||||
.personId(req.getSubordinatePersonId())
|
|
||||||
.manager(false)
|
|
||||||
.selects(ImmutableList.of(OrganizationalNodeUser::getOrganizationalNodeId))
|
|
||||||
.searchCount(false)
|
|
||||||
.build())
|
|
||||||
.stream().map(NodeUserQueryRepository.NodeUserResp::getOrganizationalNodeId).collect(Collectors.toSet());
|
|
||||||
if (nodeIds.isEmpty()) {
|
|
||||||
return emptyPage;
|
|
||||||
}
|
|
||||||
// 查询 subordinatePersonId 所在节点的管理员
|
|
||||||
listReq.setOrganizationalNodeIds(QueryConditionAssembler.assemble(listReq.getOrganizationalNodeIds(), nodeIds));
|
|
||||||
listReq.setManager(true);
|
|
||||||
}
|
|
||||||
if (req.getDirectManagerPersonId() != null) {
|
|
||||||
listReq.setExtraQueries(QueryConditionAssembler.assemble(listReq.getExtraQueries(), ImmutableList.of(MybatisPlusOperatorProcessor.JSONQuery.builder()
|
|
||||||
.jsonPath("$.directManagerPersonId")
|
|
||||||
.data(req.getDirectManagerPersonId())
|
|
||||||
.build())));
|
|
||||||
}
|
|
||||||
|
|
||||||
PageResp<NodeUserQueryRepository.NodeUserResp> page = nodeUserQueryRepository.page(listReq);
|
PageResp<NodeUserQueryRepository.NodeUserResp> page = nodeUserQueryRepository.page(listReq);
|
||||||
if (CollUtil.isEmpty(page.getData())) {
|
if (CollUtil.isEmpty(page.getData())) {
|
||||||
@ -184,6 +129,71 @@ public class NodeUserServiceImpl implements NodeUserService {
|
|||||||
return new PageResp<>(page.getTotal(), page.getSize(), page.getCurrent(), records);
|
return new PageResp<>(page.getTotal(), page.getSize(), page.getCurrent(), records);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private NodeUserQueryRepository.ListReq resolveListReq(ListNodeUserReq req) {
|
||||||
|
NodeUserQueryRepository.ListReq listReq = BeanUtil.toBean(req, NodeUserQueryRepository.ListReq.class);
|
||||||
|
// jobCodes -> jobIds
|
||||||
|
if (CollUtil.isNotEmpty(req.getOrganizationalJobCodes())
|
||||||
|
|| StrUtil.isNotBlank(req.getOrganizationalJobCode())
|
||||||
|
|| StrUtil.isNotBlank(req.getOrganizationalJobNameLike())
|
||||||
|
|| StrUtil.isNotBlank(req.getOrganizationalJobName())) {
|
||||||
|
Set<Long> jobIds = jobQueryRepository.list(OrgJobQueryRepository.ListReq.builder()
|
||||||
|
.codes(req.getOrganizationalJobCodes())
|
||||||
|
.code(req.getOrganizationalJobCode())
|
||||||
|
.nameLike(req.getOrganizationalJobNameLike())
|
||||||
|
.name(req.getOrganizationalJobName())
|
||||||
|
.searchCount(false)
|
||||||
|
.build()).stream().map(OrgJobQueryRepository.JobResp::getId).collect(Collectors.toSet());
|
||||||
|
if (jobIds.isEmpty()) {
|
||||||
|
listReq.setReturnEmpty(true);
|
||||||
|
return listReq;
|
||||||
|
}
|
||||||
|
listReq.setOrganizationalJobIds(QueryConditionAssembler.assemble(listReq.getOrganizationalJobIds(), jobIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据managerPersonId进行查询 -> 找到 manage的nodeId,作为查询条件,往下查
|
||||||
|
if (req.getManagerPersonId() != null) {
|
||||||
|
Set<Long> managedOrgNodeId = nodeUserQueryRepository.list(NodeUserQueryRepository.ListReq.builder()
|
||||||
|
.manager(true)
|
||||||
|
.personId(req.getManagerPersonId())
|
||||||
|
.selects(ImmutableList.of(OrganizationalNodeUser::getOrganizationalNodeId))
|
||||||
|
.searchCount(false)
|
||||||
|
.pageSize(100000)
|
||||||
|
.build()).stream()
|
||||||
|
.map(NodeUserQueryRepository.NodeUserResp::getOrganizationalNodeId).collect(Collectors.toSet());
|
||||||
|
if (managedOrgNodeId.isEmpty()) {
|
||||||
|
listReq.setReturnEmpty(true);
|
||||||
|
return listReq;
|
||||||
|
}
|
||||||
|
listReq.setOrganizationalNodeIds(QueryConditionAssembler.assemble(listReq.getOrganizationalNodeIds(), managedOrgNodeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
// subordinatePersonId
|
||||||
|
if (req.getSubordinatePersonId() != null) {
|
||||||
|
Set<Long> nodeIds = nodeUserQueryRepository.list(NodeUserQueryRepository.ListReq.builder()
|
||||||
|
.personId(req.getSubordinatePersonId())
|
||||||
|
.manager(false)
|
||||||
|
.selects(ImmutableList.of(OrganizationalNodeUser::getOrganizationalNodeId))
|
||||||
|
.searchCount(false)
|
||||||
|
.build())
|
||||||
|
.stream().map(NodeUserQueryRepository.NodeUserResp::getOrganizationalNodeId).collect(Collectors.toSet());
|
||||||
|
if (nodeIds.isEmpty()) {
|
||||||
|
listReq.setReturnEmpty(true);
|
||||||
|
return listReq;
|
||||||
|
}
|
||||||
|
// 查询 subordinatePersonId 所在节点的管理员
|
||||||
|
listReq.setOrganizationalNodeIds(QueryConditionAssembler.assemble(listReq.getOrganizationalNodeIds(), nodeIds));
|
||||||
|
listReq.setManager(true);
|
||||||
|
}
|
||||||
|
// directManagerPersonId
|
||||||
|
if (req.getDirectManagerPersonId() != null) {
|
||||||
|
listReq.setExtraQueries(QueryConditionAssembler.assemble(listReq.getExtraQueries(), ImmutableList.of(MybatisPlusOperatorProcessor.JSONQuery.builder()
|
||||||
|
.jsonPath("$.directManagerPersonId")
|
||||||
|
.data(req.getDirectManagerPersonId())
|
||||||
|
.build())));
|
||||||
|
}
|
||||||
|
return listReq;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SearchEntNodeUserResp> searchEntUser(SearchEntNodeUserReq req) {
|
public List<SearchEntNodeUserResp> searchEntUser(SearchEntNodeUserReq req) {
|
||||||
return nodeUserFoundationService.searchEntUser(req);
|
return nodeUserFoundationService.searchEntUser(req);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user