feat(REQ-3282): 完善一批查询接口
This commit is contained in:
parent
f35e31b4d5
commit
692035078f
@ -4,19 +4,84 @@ Content-Type: application/json
|
||||
Accept: application/json
|
||||
|
||||
{
|
||||
// "id": 984,
|
||||
"realNameLike": "周阳",
|
||||
"phone": "18530039500",
|
||||
"idNumber": "410205198601221016",
|
||||
"personId": 5354,
|
||||
"includeDeleted": true,
|
||||
"pageSize": 2,
|
||||
"needs": {
|
||||
"job": true
|
||||
,
|
||||
"node": true ,
|
||||
"unit": true
|
||||
// "personIds": [9000398681,9000400039],
|
||||
// "personIds": [9000400039],
|
||||
// "realNameLike": "周建镐",
|
||||
"organizationalNodeId": 10456,
|
||||
// "subordinatePersonId": 42936,
|
||||
// "managerPersonId": 44364,
|
||||
// "directManagerPersonId": 9000404206,
|
||||
"organizationalUnitIds": [
|
||||
5144
|
||||
],
|
||||
"workspaceOuPairs": [
|
||||
{
|
||||
"workspaceId": 335,
|
||||
"ouId": 5144
|
||||
}
|
||||
],
|
||||
// "includeDeleted": true,
|
||||
// "deletedOnly": true,
|
||||
// "phone": "18530039500",
|
||||
// "idNumber": "410205198601221016",
|
||||
// "personId": 5354,
|
||||
// "includeDeleted": true,
|
||||
// "findByTopNodeId": true,
|
||||
"findByAncestorNodeId": true,
|
||||
// "pageSize": 2,
|
||||
"needs": {
|
||||
// "job": true,
|
||||
// "node": true ,
|
||||
// "ancestorNode": true,
|
||||
// "unit": true,
|
||||
// "cooperateShip": true,
|
||||
// "subordinateUsers": true
|
||||
},
|
||||
// "filterIncludeUnitTypes": [1,2],
|
||||
// "filterExcludeUnitTypes": [2],
|
||||
// "distinctRule": {
|
||||
// "distinctByFields": [
|
||||
// "identityId",
|
||||
// "identityType"
|
||||
// ]
|
||||
// },
|
||||
"filterIncludeWorkspaceTypes": [
|
||||
1,
|
||||
2,
|
||||
6
|
||||
],
|
||||
// "filterIncludeCooperateTypes": [1,2, 6],
|
||||
// "filterExcludeCooperateTypes": [6],
|
||||
// "filterDirectManagerNotNull": true,
|
||||
"filterNodeStates": [
|
||||
1
|
||||
],
|
||||
// "filterTopNodeOnly": true,
|
||||
//
|
||||
//
|
||||
//
|
||||
"a": "a"
|
||||
}
|
||||
|
||||
###
|
||||
# 分页列表接口
|
||||
POST {{host}}/api/node-user/list
|
||||
Content-Type: application/json
|
||||
Accept: application/json
|
||||
|
||||
{
|
||||
// "id": 984,
|
||||
"organizationalNodeId": 436,
|
||||
"activeFlag": 1,
|
||||
"searchCount": true,
|
||||
"needs": {
|
||||
"childNodeUser": true
|
||||
},
|
||||
"distinctRule": {
|
||||
"distinctByFields": [
|
||||
"identityId",
|
||||
"identityType"
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
package cn.axzo.orgmanax.dto.common;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
@ -24,23 +21,13 @@ public class DistinctRule implements Serializable {
|
||||
private Collection<String> distinctByFields;
|
||||
|
||||
/**
|
||||
* 合并规则,1 = 保留第一个,2 = 保留最后一个,默认为2。
|
||||
*
|
||||
* @see MergeType
|
||||
* 如果重复,是否覆盖。是 表示 用后面的覆盖前面的,否则保留前面的。默认为true(不传=true)
|
||||
*/
|
||||
private Integer mergeType;
|
||||
private Boolean override;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public enum MergeType {
|
||||
FIRST(1, "保留第一个"), LAST(2, "保留最后一个");
|
||||
private final Integer value;
|
||||
private final String desc;
|
||||
}
|
||||
|
||||
public Integer getMergeType() {
|
||||
public Boolean getOverride() {
|
||||
// 不指定,取最后一个
|
||||
return ObjectUtils.firstNonNull(mergeType, MergeType.LAST.getValue());
|
||||
return BooleanUtils.isNotFalse(override);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
package cn.axzo.orgmanax.dto.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@Data
|
||||
public class PersonProfileBriefDTO implements Serializable {
|
||||
private Long id;
|
||||
private String realName;
|
||||
private String phone;
|
||||
private String idNumber;
|
||||
private String avatarUrl;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package cn.axzo.orgmanax.dto.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@Data
|
||||
public class WorkspaceBriefDTO implements Serializable {
|
||||
private Long id;
|
||||
private Integer type;
|
||||
private String name;
|
||||
}
|
||||
@ -2,7 +2,11 @@ package cn.axzo.orgmanax.dto.node.req;
|
||||
|
||||
import cn.axzo.foundation.page.PageReqV2;
|
||||
import cn.axzo.orgmanax.dto.common.WorkspaceOuPair;
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -125,5 +129,4 @@ public class ListNodeReq extends PageReqV2 {
|
||||
*/
|
||||
private Long personId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,144 @@
|
||||
package cn.axzo.orgmanax.dto.nodeuser.dto;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class NodeUserBriefDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* identity_id
|
||||
*/
|
||||
private Long identityId;
|
||||
|
||||
/**
|
||||
* 身份类型 0-无效类型, 1-工人, 2-班组长, 3-从业人员, 4-政务人员,5-运营人员
|
||||
*/
|
||||
private Integer identityType;
|
||||
|
||||
/**
|
||||
* 自然人id
|
||||
*/
|
||||
private Long personId;
|
||||
|
||||
/**
|
||||
* 主电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 单位id
|
||||
*/
|
||||
private Long organizationalUnitId;
|
||||
|
||||
/**
|
||||
* 组织节点id
|
||||
*/
|
||||
private Long organizationalNodeId;
|
||||
|
||||
/**
|
||||
* 顶级节点id
|
||||
*/
|
||||
private Long topNodeId;
|
||||
|
||||
/**
|
||||
* 部门管理员 1是 0否
|
||||
*/
|
||||
private Object manager;
|
||||
|
||||
/**
|
||||
* 岗位id
|
||||
*/
|
||||
private Long organizationalJobId;
|
||||
|
||||
/**
|
||||
* 工作台ID
|
||||
*/
|
||||
private Long workspaceId;
|
||||
|
||||
/**
|
||||
* 0:普通岗位、1:主岗位
|
||||
*/
|
||||
private Integer primaryJob;
|
||||
|
||||
/**
|
||||
* 是否允许进入工地 1.允许 2.不允许
|
||||
*/
|
||||
private Integer isAllowed;
|
||||
|
||||
/**
|
||||
* 加入时间
|
||||
*/
|
||||
private Date joinAt;
|
||||
|
||||
/**
|
||||
* 离开时间
|
||||
*/
|
||||
private Date leaveAt;
|
||||
|
||||
/**
|
||||
* 迁移数据临时源id
|
||||
*/
|
||||
private Long tempSourceId;
|
||||
|
||||
/**
|
||||
* 数据同步ID
|
||||
*/
|
||||
private Long syncDataId;
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
private String jobNumber;
|
||||
|
||||
/**
|
||||
* 状态 0正常 其它删除
|
||||
*/
|
||||
private Long isDelete = 0L;
|
||||
|
||||
/**
|
||||
* 扩展字段
|
||||
*/
|
||||
private JSONObject extra;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateAt;
|
||||
|
||||
/**
|
||||
* 1-活跃用户,0-非活跃用户
|
||||
*/
|
||||
private Integer activeFlag;
|
||||
|
||||
/**
|
||||
* 部门人员信息,json,不同部门类型的部门用户,格式不一。
|
||||
*/
|
||||
private JSONObject profile;
|
||||
}
|
||||
@ -1,11 +1,12 @@
|
||||
package cn.axzo.orgmanax.dto.nodeuser.dto;
|
||||
|
||||
import cn.axzo.orgmanax.dto.common.PersonProfileBriefDTO;
|
||||
import cn.axzo.orgmanax.dto.common.WorkspaceBriefDTO;
|
||||
import cn.axzo.orgmanax.dto.cooperateship.dto.OrgCooperateShipDTO;
|
||||
import cn.axzo.orgmanax.dto.job.dto.OrgJobBriefDTO;
|
||||
import cn.axzo.orgmanax.dto.node.dto.OrgNodeBriefDTO;
|
||||
import cn.axzo.orgmanax.dto.node.dto.OrgNodeDTO;
|
||||
import cn.axzo.orgmanax.dto.nodeuser.req.ListNodeUserReq;
|
||||
import cn.axzo.orgmanax.dto.unit.dto.OrgUnitBriefDTO;
|
||||
import cn.axzo.orgmanax.dto.unit.dto.OrgUnitDTO;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -14,6 +15,7 @@ import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ -153,6 +155,10 @@ public class NodeUserDTO implements Serializable {
|
||||
* 需指定{@link ListNodeUserReq.Needs#getNode()} 为true才会返回
|
||||
*/
|
||||
private OrgNodeBriefDTO node;
|
||||
/**
|
||||
* 需指定{@link ListNodeUserReq.Needs#getAncestorNodes()} 为true才会返回
|
||||
*/
|
||||
private List<OrgNodeBriefDTO> ancestorNodes;
|
||||
/**
|
||||
* 需指定{@link ListNodeUserReq.Needs#getUnit()} 为true才会返回
|
||||
*/
|
||||
@ -161,4 +167,23 @@ public class NodeUserDTO implements Serializable {
|
||||
* 需指定{@link ListNodeUserReq.Needs#getJob()} 为true才会返回
|
||||
*/
|
||||
private OrgJobBriefDTO job;
|
||||
/**
|
||||
* 需指定{@link ListNodeUserReq.Needs#getWorkspace()} 为true才会返回
|
||||
*/
|
||||
private WorkspaceBriefDTO workspace;
|
||||
/**
|
||||
* 需指定{@link ListNodeUserReq.Needs#getPersonProfile()} 为true才会返回
|
||||
*/
|
||||
private PersonProfileBriefDTO personProfile;
|
||||
/**
|
||||
* 需指定{@link ListNodeUserReq.Needs#getCooperateShip()} 为true才会返回。
|
||||
* 注意:平台班组是不会返回这个的。
|
||||
*/
|
||||
private OrgCooperateShipDTO cooperateShip;
|
||||
/**
|
||||
* 需指定{@link ListNodeUserReq.Needs#getDirectSubordinateUsers()} 为true才会返回。
|
||||
* 注意:平台班组是不会返回这个的。
|
||||
*/
|
||||
private List<NodeUserBriefDTO> subordinateUsers;
|
||||
|
||||
}
|
||||
|
||||
@ -165,33 +165,37 @@ public class ListNodeUserReq extends PageReqV2 {
|
||||
// ~ 需特殊实现的查询字段。(非CriteriaField直接可查询的字段)
|
||||
private Collection<WorkspaceOuPair> workspaceOuPairs;
|
||||
/**
|
||||
* leaderPersonId. 根据personId=leaderPersonId and manager = true,查询node。然后查询整个node下面的人
|
||||
* managerPersonId. 根据personId=managerPersonId and manager = true,查询node。然后将organizationalNodeIds作为参数往下查询
|
||||
*/
|
||||
private Long leaderPersonId;
|
||||
private Long managerPersonId;
|
||||
/**
|
||||
* 下属personId,根据personId=subordinatePersonId,查询到node,然后返回node的manager。
|
||||
*/
|
||||
private Long subordinatePersonId; // TODO: 待实现
|
||||
private Long subordinatePersonId;
|
||||
/**
|
||||
* 直属上级personId,(directManagerPersonId等于自己的)。
|
||||
* 使用该字段的时候,建议和 {@link #getOrganizationalUnitId()} 、 {@link #getWorkspaceId()} 共同使用
|
||||
*/
|
||||
private Long directManagerPersonId;
|
||||
|
||||
// 岗位code
|
||||
private String organizationalJobCode; // TODO: 待实现
|
||||
private String organizationalJobCode;
|
||||
|
||||
private Collection<String> organizationalJobCodes; // TODO: 待实现
|
||||
private String organizationalJobName; // TODO: 待实现
|
||||
private String organizationalJobNameLike; // TODO: 待实现
|
||||
private Boolean onlyHasJob; // TODO: 待实现
|
||||
private Collection<String> organizationalJobCodes;
|
||||
private String organizationalJobName;
|
||||
private String organizationalJobNameLike;
|
||||
private Boolean onlyHasJob;
|
||||
|
||||
private Collection<IdentityPair> identityPairs; // TODO: 待实现
|
||||
private Collection<IdentityPair> identityPairs;
|
||||
|
||||
/**
|
||||
* 查询返回数据包含,逻辑删除数据,即查询未删除和已删除的数据。
|
||||
*/
|
||||
private Boolean includeDeleted; // TODO: 待实现
|
||||
private Boolean includeDeleted;
|
||||
/**
|
||||
* 仅查询已删除的数据
|
||||
*/
|
||||
private Boolean deletedOnly; // TODO: 待实现
|
||||
|
||||
private Integer nodeState; // TODO: 待实现
|
||||
private Boolean deletedOnly;
|
||||
|
||||
/**
|
||||
* keyword。用 idNumber,phone,jobNumber精确匹配,或者realName模糊匹配
|
||||
@ -216,30 +220,47 @@ public class ListNodeUserReq extends PageReqV2 {
|
||||
|
||||
// ~ 结束。
|
||||
|
||||
// ~ 后置过滤的字段
|
||||
// ~ 后置过滤的字段,filter的参数会破坏分页。如有强分页场景,需谨慎使用
|
||||
/**
|
||||
* 包含的单位类型
|
||||
* XXX:filter的参数会破坏分页。如有强分页场景,需谨慎使用
|
||||
*/
|
||||
private Collection<Integer> filterIncludeUnitTypes; // TODO: 待实现
|
||||
private Collection<Integer> filterIncludeUnitTypes;
|
||||
/**
|
||||
* 排除的单位类型
|
||||
* XXX:filter的参数会破坏分页。如有强分页场景,需谨慎使用
|
||||
*/
|
||||
private Collection<Integer> filterExcludeUnitTypes; // TODO: 待实现
|
||||
private Integer filterIncludeWorkspaceType; // TODO: 待实现
|
||||
private Collection<Integer> filterExcludeUnitTypes;
|
||||
/**
|
||||
* 包含的协作类型
|
||||
* XXX:filter的参数会破坏分页。如有强分页场景,需谨慎使用
|
||||
*/
|
||||
private Integer filterIncludeCooperateType; // TODO: 待实现
|
||||
private Collection<Integer> filterIncludeCooperateTypes; // TODO: 待实现
|
||||
private Collection<Integer> filterExcludeCooperateTypes; // TODO: 待实现
|
||||
private Collection<Integer> filterIncludeWorkspaceTypes;
|
||||
/**
|
||||
* 排除的协作类型
|
||||
* XXX:filter的参数会破坏分页。如有强分页场景,需谨慎使用
|
||||
*/
|
||||
private Collection<Integer> filterIncludeCooperateTypes;
|
||||
/**
|
||||
* 排除的协作类型
|
||||
* XXX:filter的参数会破坏分页。如有强分页场景,需谨慎使用
|
||||
*/
|
||||
private Collection<Integer> filterExcludeCooperateTypes;
|
||||
/**
|
||||
* 是否只返回顶级节点
|
||||
* XXX:filter的参数会破坏分页。如有强分页场景,需谨慎使用
|
||||
*/
|
||||
private Boolean filterTopNodeOnly; // TODO: 待实现
|
||||
private Boolean filterTopNodeOnly;
|
||||
/**
|
||||
* 返回directManager不为空的
|
||||
* XXX:filter的参数会破坏分页。如有强分页场景,需谨慎使用
|
||||
*/
|
||||
private Boolean filterDirectManagerNotNull; // TODO: 待实现
|
||||
private Boolean filterDirectManagerNotNull;
|
||||
/**
|
||||
* 按照nodeState过滤
|
||||
* XXX:filter的参数会破坏分页。如有强分页场景,需谨慎使用
|
||||
*/
|
||||
private Collection<Integer> filterNodeStates;
|
||||
/**
|
||||
* 数据权限
|
||||
*/
|
||||
@ -250,13 +271,19 @@ public class ListNodeUserReq extends PageReqV2 {
|
||||
* 根据顶级节点查人,指定该值为true了,会根据nodeUser查询topNodeId,然后根据topNodeId进一步查询人员
|
||||
* 即:nodeUser.topNodeId 作为参数。之前的nodeId参数不再使用
|
||||
*/
|
||||
private Boolean findByTopNodeId; // TODO: 待实现
|
||||
private Boolean findByTopNodeId;
|
||||
|
||||
/**
|
||||
* 根据当前节点,进一步查询当前节点及以下的节点
|
||||
* 即:nodeUser.organizationalNodeId 作为参数。查询子孙及节点
|
||||
*/
|
||||
private Boolean findByAncestorNodeId;
|
||||
|
||||
/**
|
||||
* 去重规则,如果指定该值,会按照去重规则进行去重。
|
||||
* 使用该参数,会影响分页准确性。不建议分页时使用(先查询分页数据,再去重)。
|
||||
*/
|
||||
private DistinctRule distinctRule; // TODO: 待实现
|
||||
private DistinctRule distinctRule;
|
||||
|
||||
// 指定聚合信息
|
||||
/**
|
||||
@ -279,14 +306,18 @@ public class ListNodeUserReq extends PageReqV2 {
|
||||
* 是否返回部门信息
|
||||
*/
|
||||
private Boolean node;
|
||||
/**
|
||||
* 是否需要部门及父级部门信息,默认不返回
|
||||
*/
|
||||
private Boolean ancestorNodes;
|
||||
/**
|
||||
* 返回node and path
|
||||
*/
|
||||
private Boolean nodeAndPath;
|
||||
private Boolean nodeAndPath; // TODO : 待实现
|
||||
/**
|
||||
* 返回参与项目数量
|
||||
*/
|
||||
private Boolean projectOrgCnt;
|
||||
private Boolean projectOrgCnt; // TODO : 待实现
|
||||
/**
|
||||
* 是否返回岗位信息
|
||||
*/
|
||||
@ -294,30 +325,28 @@ public class ListNodeUserReq extends PageReqV2 {
|
||||
/**
|
||||
* 是否岗位组信息,对应返回字段里面的organizationalJobWorkspaceType
|
||||
*/
|
||||
private Boolean jobGroup;
|
||||
private Boolean jobGroup; // TODO : 待实现
|
||||
|
||||
/**
|
||||
* 是否查询下级组织人员。所在节点的下级节点的
|
||||
* 是否返回下级组织人员。所在节点的下级节点的
|
||||
*/
|
||||
private Boolean childNodeUser;
|
||||
private Boolean childNodeUser; // TODO: 待实现
|
||||
|
||||
/**
|
||||
* 是否查询下属。(directManagerPersonId等于自己的)
|
||||
* 是否查询下属。(同单位,directManagerPersonId等于自己的)
|
||||
*/
|
||||
private Boolean subordinate;
|
||||
private Boolean directSubordinateUsers;
|
||||
|
||||
/**
|
||||
* 是否需要角色信息
|
||||
*/
|
||||
private Boolean role;
|
||||
/**
|
||||
* 是否需要部门及父级部门信息,默认不返回
|
||||
*/
|
||||
private Boolean ancestorNode;
|
||||
private Boolean role; // TODO : 待实现
|
||||
|
||||
private Boolean cooperateShip;
|
||||
|
||||
private Boolean personProfile;
|
||||
|
||||
private Boolean workspace;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,20 +1,16 @@
|
||||
package cn.axzo.orgmanax.infra.client.profile;
|
||||
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileIdentityProfilePostReq;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileGetIdentityProfileLiteReq;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileGetIdentityProfileLiteResp;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileGetPersonProfileListReq;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfilePersonResp;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.model.IdentityPair;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileIdentityResp;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* //TODO liuyang
|
||||
@ -28,48 +24,28 @@ public class PersonProfileGateway {
|
||||
private final ProfileUserProfileClient profileUserProfileClient;
|
||||
|
||||
public ProfilePersonResp getPersonProfile(Long personId) {
|
||||
return listPersonProfiles(ListPersonProfileReq.builder().id(personId).build())
|
||||
return listPersonProfiles(ProfileGetPersonProfileListReq.builder().personId(personId).build())
|
||||
.stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public List<ProfilePersonResp> listPersonProfiles(ListPersonProfileReq req) {
|
||||
// TODO 需要对接新的profile收口查询接口
|
||||
return profileUserProfileClient.getPersonProfiles(ImmutableList.of(req.getId()));
|
||||
public List<ProfilePersonResp> listPersonProfiles(ProfileGetPersonProfileListReq req) {
|
||||
try {
|
||||
return profileUserProfileClient.getPersonProfileList(req);
|
||||
} catch (Throwable e) {
|
||||
log.warn("listPersonProfiles error: {}", e.getMessage(), e);
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
public ProfileIdentityResp getIdentityProfile(Long personId, Integer identityType) {
|
||||
return listIdentityProfiles(ListIdentityProfileReq.builder()
|
||||
.personId(personId)
|
||||
.identityType(identityType)
|
||||
.build()).stream().findFirst().orElse(null);
|
||||
public ProfileGetIdentityProfileLiteResp getIdentityProfile(Long personId, Integer identityType) {
|
||||
return listIdentityProfiles(ProfileGetIdentityProfileLiteReq.builder()
|
||||
.personIds(ImmutableList.of(personId))
|
||||
.build()).stream()
|
||||
.filter(p -> identityType == null || Objects.equals(p.getIdentityType() == null ? null : p.getIdentityType().getCode(), identityType))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public List<ProfileIdentityResp> listIdentityProfiles(ListIdentityProfileReq req) {
|
||||
// TODO 需要对接新的profile收口查询接口
|
||||
ProfileIdentityProfilePostReq r = new ProfileIdentityProfilePostReq();
|
||||
r.setIdentityIds(ImmutableList.of(req.getIdentityId()));
|
||||
r.setIdentityType(req.getIdentityType());
|
||||
return profileUserProfileClient.postProfileByIdentityIdsAndIdentityTypeExcludeIsDelete(r);
|
||||
public List<ProfileGetIdentityProfileLiteResp> listIdentityProfiles(ProfileGetIdentityProfileLiteReq req) {
|
||||
return profileUserProfileClient.getIdentityProfileLite(req);
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public static class ListPersonProfileReq {
|
||||
private Long id;
|
||||
private Collection<Long> ids;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public static class ListIdentityProfileReq {
|
||||
private Long personId;
|
||||
private Long identityId;
|
||||
private Integer identityType;
|
||||
private Collection<IdentityPair> identityPairs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public interface ProfileUserProfileClient {
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
List<ProfileGetIdentityProfileLiteResp> test(ProfileGetIdentityProfileLiteReq req);
|
||||
List<ProfileGetIdentityProfileLiteResp> getIdentityProfileLite(ProfileGetIdentityProfileLiteReq req);
|
||||
|
||||
/**
|
||||
* 批量获取用户身份接口 排除删除字段
|
||||
|
||||
@ -40,7 +40,7 @@ public class ProfileGetPersonProfileListReq {
|
||||
/**
|
||||
* 批量身份证号
|
||||
*/
|
||||
private List<String> idNumbers;
|
||||
private Collection<String> idNumbers;
|
||||
|
||||
/**
|
||||
* phone 或者realName去查询
|
||||
@ -55,5 +55,8 @@ public class ProfileGetPersonProfileListReq {
|
||||
/**
|
||||
* 真实姓名全匹配的列表
|
||||
*/
|
||||
private List<String> eqRealNames;
|
||||
private Collection<String> eqRealNames;
|
||||
|
||||
private Long personId;
|
||||
private Collection<Long> personIds;
|
||||
}
|
||||
@ -1,14 +1,14 @@
|
||||
package cn.axzo.orgmanax.infra.client.workspace;
|
||||
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.feign.WorkspaceV2Api;
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.req.ListWorkspaceReq;
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.req.WorkspaceDetailReq;
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.req.WorkspaceListReq;
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.req.WorkspaceUpsertReq;
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.resp.WorkspaceDetailListResp;
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.resp.WorkspaceDTO;
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.resp.WorkspaceDetailResp;
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.resp.WorkspaceUpsertResp;
|
||||
import cn.axzo.orgmanax.infra.client.RpcWrapper;
|
||||
import lombok.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -46,7 +46,7 @@ public class WorkspaceGateway {
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public List<WorkspaceDetailListResp> list(WorkspaceListReq request) {
|
||||
return RpcWrapper.wrapApiResult(() -> workspaceV2Api.list(request));
|
||||
public List<WorkspaceDTO> list(ListWorkspaceReq request) {
|
||||
return RpcWrapper.wrapApiResult(() -> workspaceV2Api.listV2(request));
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,11 +144,6 @@ public interface NodeQueryRepository {
|
||||
@Builder.Default
|
||||
private Boolean isSelectTopNodeOnly = false;
|
||||
|
||||
/**
|
||||
* 是否返回祖先节点 TODO:liuyang
|
||||
*/
|
||||
private Boolean needAncestorNode;
|
||||
|
||||
/**
|
||||
* 根据workspace和ouId组合查询
|
||||
*/
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.orgmanax.infra.dao.nodeuser.repository;
|
||||
|
||||
import cn.axzo.foundation.dao.support.mysql.MybatisPlusOperatorProcessor;
|
||||
import cn.axzo.foundation.dao.support.wrapper.CriteriaField;
|
||||
import cn.axzo.foundation.dao.support.wrapper.Operator;
|
||||
import cn.axzo.foundation.page.PageReqV2;
|
||||
@ -9,6 +10,7 @@ import cn.axzo.orgmanax.dto.common.WorkspaceOuPair;
|
||||
import cn.axzo.orgmanax.infra.dao.nodeuser.entity.OrganizationalNodeUser;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.google.common.base.Preconditions;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -224,49 +226,25 @@ public interface NodeUserQueryRepository {
|
||||
@CriteriaField(field = "updateAt", operator = Operator.LE)
|
||||
private Date updateAtLe;
|
||||
|
||||
|
||||
// ~ 需特殊实现的查询字段。(非CriteriaField直接可查询的字段)
|
||||
@CriteriaField(ignore = true)
|
||||
private Collection<WorkspaceOuPair> workspaceOuPairs;
|
||||
/**
|
||||
* leaderPersonId. 根据personId=leaderPersonId and manager = true,查询node。然后查询整个node下面的人
|
||||
*/
|
||||
@CriteriaField(ignore = true) // TODO: 待实现
|
||||
private Long leaderPersonId;
|
||||
/**
|
||||
* 下属personId,根据personId=subordinatePersonId,查询到node,然后返回node的manager。
|
||||
*/
|
||||
@CriteriaField(ignore = true)
|
||||
private Long subordinatePersonId; // TODO: 待实现
|
||||
// 岗位code
|
||||
@CriteriaField(ignore = true)
|
||||
private String organizationalJobCode; // TODO: 待实现
|
||||
private Boolean onlyHasJob;
|
||||
|
||||
@CriteriaField(ignore = true)
|
||||
private Collection<String> organizationalJobCodes; // TODO: 待实现
|
||||
@CriteriaField(ignore = true)
|
||||
private String organizationalJobName; // TODO: 待实现
|
||||
@CriteriaField(ignore = true)
|
||||
private String organizationalJobNameLike; // TODO: 待实现
|
||||
@CriteriaField(ignore = true)
|
||||
private Boolean onlyHasJob; // TODO: 待实现
|
||||
|
||||
@CriteriaField(ignore = true)
|
||||
private Collection<IdentityPair> identityPairs; // TODO: 待实现
|
||||
private Collection<IdentityPair> identityPairs;
|
||||
|
||||
/**
|
||||
* 查询返回数据包含,逻辑删除数据,即查询未删除和已删除的数据。
|
||||
*/
|
||||
@CriteriaField(ignore = true)
|
||||
private Boolean includeDeleted; // TODO: 待实现
|
||||
private Boolean includeDeleted;
|
||||
/**
|
||||
* 仅查询已删除的数据
|
||||
*/
|
||||
@CriteriaField(ignore = true)
|
||||
private Boolean deletedOnly; // TODO: 待实现
|
||||
|
||||
@CriteriaField(ignore = true)
|
||||
private Integer nodeState; // TODO: 待实现
|
||||
private Boolean deletedOnly;
|
||||
|
||||
/**
|
||||
* keyword。用 idNumber,phone,jobNumber精确匹配,或者realName模糊匹配
|
||||
@ -274,11 +252,17 @@ public interface NodeUserQueryRepository {
|
||||
@CriteriaField(ignore = true)
|
||||
private String keyword;
|
||||
|
||||
@CriteriaField(field = "extra", operator = Operator.JSON_QUERY)
|
||||
private Collection<MybatisPlusOperatorProcessor.JSONQuery> extraQueries;
|
||||
|
||||
/**
|
||||
* orgUserStatus
|
||||
*/
|
||||
@CriteriaField(ignore = true)
|
||||
private Collection<String> orgUserStatus; // TODO: 待实现
|
||||
|
||||
@CriteriaField(ignore = true)
|
||||
List<SFunction<OrganizationalNodeUser, ?>> selects;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
|
||||
@ -9,10 +9,12 @@ import cn.axzo.orgmanax.infra.dao.nodeuser.repository.NodeUserQueryRepository;
|
||||
import cn.axzo.trade.datasecurity.core.util.DataSecurityHelper;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -31,24 +33,55 @@ public class NodeUserQueryRepositoryImpl implements NodeUserQueryRepository {
|
||||
public PageResp<NodeUserResp> page(ListReq req) {
|
||||
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();
|
||||
QueryWrapper<OrganizationalNodeUser> wrapper = QueryWrapperHelper.fromBean(req, OrganizationalNodeUser.class);
|
||||
LambdaQueryWrapper<OrganizationalNodeUser> wrapper = QueryWrapperHelper.fromBean(req, OrganizationalNodeUser.class).lambda();
|
||||
// 查询参数处理 ~
|
||||
// keyword
|
||||
if (StrUtil.isNotBlank(req.getKeyword())) {
|
||||
String encryptedKeyword = DataSecurityHelper.encrypt(req.getKeyword());
|
||||
wrapper.and(w -> {
|
||||
w.like("real_name", req.getKeyword())
|
||||
.or().eq("phone", encryptedKeyword)
|
||||
.or().eq("job_number", req.getKeyword())
|
||||
.or().eq("id_number", encryptedKeyword);
|
||||
w.like(OrganizationalNodeUser::getRealName, req.getKeyword())
|
||||
.or().eq(OrganizationalNodeUser::getPhone, encryptedKeyword)
|
||||
.or().eq(OrganizationalNodeUser::getJobNumber, req.getKeyword())
|
||||
.or().eq(OrganizationalNodeUser::getIdNumber, encryptedKeyword);
|
||||
});
|
||||
}
|
||||
// workspaceOuPairs
|
||||
if (CollUtil.isNotEmpty(req.getWorkspaceOuPairs())) {
|
||||
wrapper.and(w -> {
|
||||
req.getWorkspaceOuPairs()
|
||||
.stream().filter(wu -> wu.getOuId() != null || wu.getWorkspaceId() != null)
|
||||
.forEach(wu -> w.or(wi -> wi
|
||||
.eq(wu.getWorkspaceId() != null, OrganizationalNodeUser::getWorkspaceId, wu.getWorkspaceId())
|
||||
.eq(wu.getOuId() != null, OrganizationalNodeUser::getOrganizationalUnitId, wu.getOuId())));
|
||||
});
|
||||
}
|
||||
// identityPairs
|
||||
if (CollUtil.isNotEmpty(req.getIdentityPairs())) {
|
||||
wrapper.and(w -> {
|
||||
req.getIdentityPairs()
|
||||
.stream().filter(ip -> ip.getIdentityId() != null || ip.getIdentityType() != null)
|
||||
.forEach(ip -> w.or(wi -> wi
|
||||
.eq(ip.getIdentityId() != null, OrganizationalNodeUser::getIdentityId, ip.getIdentityId())
|
||||
.eq(ip.getIdentityType() != null, OrganizationalNodeUser::getIdentityType, ip.getIdentityType())));
|
||||
});
|
||||
}
|
||||
|
||||
// only has job
|
||||
if (BooleanUtil.isTrue(req.getOnlyHasJob())) {
|
||||
wrapper.gt(OrganizationalNodeUser::getOrganizationalJobId, 0);
|
||||
}
|
||||
|
||||
// 处理删除标记
|
||||
if (BooleanUtil.isTrue(req.getDeletedOnly())) {
|
||||
wrapper.ne("is_delete", 0);
|
||||
wrapper.ne(OrganizationalNodeUser::getIsDelete, 0);
|
||||
}
|
||||
if (!BooleanUtil.isTrue(req.getIncludeDeleted())) {
|
||||
wrapper.eq("is_delete", 0);
|
||||
wrapper.eq(OrganizationalNodeUser::getIsDelete, 0);
|
||||
}
|
||||
|
||||
// selects
|
||||
if (ArrayUtil.isNotEmpty(req.getSelects())) {
|
||||
wrapper.select(req.getSelects().toArray(new SFunction[0]));
|
||||
}
|
||||
IPage<NodeUserResp> results = nodeUserDao.page(page, wrapper)
|
||||
.convert(e -> BeanUtil.toBean(e, NodeUserResp.class));
|
||||
|
||||
@ -7,9 +7,11 @@ import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.orgmanax.dto.job.enums.OrgJobTypeEnum;
|
||||
import cn.axzo.orgmanax.infra.dao.orgjob.entity.OrgJob;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -66,6 +68,8 @@ public interface OrgJobQueryRepository {
|
||||
*/
|
||||
@CriteriaField(ignore = true)
|
||||
private String keyword;
|
||||
@CriteriaField(field = "name")
|
||||
private String name;
|
||||
@CriteriaField(field = "name", operator = Operator.LIKE)
|
||||
private String nameLike;
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import cn.axzo.foundation.dao.support.mysql.QueryWrapperHelper;
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.orgmanax.dto.orguser.req.ListOrgUserReq;
|
||||
import cn.axzo.orgmanax.infra.client.profile.PersonProfileGateway;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileGetPersonProfileListReq;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfilePersonResp;
|
||||
import cn.axzo.orgmanax.infra.dao.orguser.dao.OrgUserDao;
|
||||
import cn.axzo.orgmanax.infra.dao.orguser.entity.OrgUser;
|
||||
@ -57,8 +58,8 @@ public class OrgUserQueryRepositoryImpl implements OrgUserQueryRepository {
|
||||
return;
|
||||
}
|
||||
Set<Long> personIds = records.stream().map(OrgUser::getPersonId).collect(Collectors.toSet());
|
||||
Map<Long, ProfilePersonResp> personsById = profileGateway.listPersonProfiles(PersonProfileGateway.ListPersonProfileReq.builder()
|
||||
.ids(personIds)
|
||||
Map<Long, ProfilePersonResp> personsById = profileGateway.listPersonProfiles(ProfileGetPersonProfileListReq.builder()
|
||||
.personIds(personIds)
|
||||
.build()).stream().collect(Collectors.toMap(ProfilePersonResp::getId, Function.identity()));
|
||||
|
||||
records.forEach(r -> r.setPersonProfile(personsById.get(r.getPersonId())));
|
||||
|
||||
@ -180,7 +180,7 @@ public class ProfileUserProfileClientImpl implements ProfileUserProfileClient {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ProfileGetIdentityProfileLiteResp> test(ProfileGetIdentityProfileLiteReq req) {
|
||||
public List<ProfileGetIdentityProfileLiteResp> getIdentityProfileLite(ProfileGetIdentityProfileLiteReq req) {
|
||||
IdentityProfileLiteQueryVO rpcReq = BeanUtil.copyProperties(req, IdentityProfileLiteQueryVO.class);
|
||||
List<IdentityProfileLiteQueryDto> result = RpcWrapper.commonRes(() -> userProfileServiceApi.getIdentityProfileLite(rpcReq));
|
||||
return BeanUtil.copyToList(result, ProfileGetIdentityProfileLiteResp.class);
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
package cn.axzo.orgmanax.server.node.service;
|
||||
|
||||
import cn.axzo.foundation.dao.support.wrapper.CriteriaField;
|
||||
import cn.axzo.foundation.exception.Axssert;
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.orgmanax.common.config.BizResultCode;
|
||||
import cn.axzo.orgmanax.dto.node.dto.OrgNodeDTO;
|
||||
import cn.axzo.orgmanax.dto.node.req.ListNodeReq;
|
||||
import cn.axzo.orgmanax.dto.node.req.ProcessNodeReq;
|
||||
import cn.axzo.orgmanax.dto.node.dto.OrgNodeDTO;
|
||||
import cn.axzo.orgmanax.common.config.BizResultCode;
|
||||
import cn.axzo.orgmanax.infra.dao.node.entity.OrganizationalNode;
|
||||
import cn.axzo.orgmanax.server.node.service.processor.NodeProcessor;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cn.axzo.orgmanax.server.node.service.processor.impl;
|
||||
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.req.ListWorkspaceReq;
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.req.WorkspaceListReq;
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.resp.WorkspaceDTO;
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.resp.WorkspaceDetailListResp;
|
||||
import cn.axzo.orgmanax.dto.cooperateship.enums.CooperateShipTypeEnum;
|
||||
import cn.axzo.orgmanax.common.config.BizResultCode;
|
||||
@ -61,7 +63,7 @@ public class CreateNodeProcessor implements NodeProcessor {
|
||||
}
|
||||
|
||||
// 查询单位工作台类型
|
||||
WorkspaceDetailListResp workspace = workspaceGateway.list(WorkspaceListReq.builder()
|
||||
WorkspaceDTO workspace = workspaceGateway.list(ListWorkspaceReq.builder()
|
||||
.type(Workspace.WorkspaceTypeEnum.GENERAL_ENT.value)
|
||||
.organizationUnitId(node.getOrganizationalUnitId())
|
||||
.build()).stream().findFirst().orElseThrow(() -> BizResultCode.ENTITY_NOT_FOUND.toException("没有企业工作台"));
|
||||
|
||||
@ -8,7 +8,7 @@ import cn.axzo.orgmanax.dto.nodeuser.enums.NodeUserTypeEnum;
|
||||
import cn.axzo.orgmanax.dto.nodeuser.req.SearchEntNodeUserReq;
|
||||
import cn.axzo.orgmanax.dto.nodeuser.resp.SearchEntNodeUserResp;
|
||||
import cn.axzo.orgmanax.infra.client.profile.PersonProfileGateway;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileIdentityResp;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileGetIdentityProfileLiteResp;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfilePersonResp;
|
||||
import cn.axzo.orgmanax.infra.dao.cooperateship.entity.SaasCooperateShip;
|
||||
import cn.axzo.orgmanax.infra.dao.cooperateship.repository.CooperateShipQueryRepository;
|
||||
@ -70,14 +70,14 @@ public class NodeUserFoundationServiceImpl implements NodeUserFoundationService
|
||||
ProfilePersonResp personProfile = profileGateway.getPersonProfile(param.getPersonId());
|
||||
Axssert.checkNonNull(personProfile, "用户不存在");
|
||||
// 人员身份是否存在
|
||||
ProfileIdentityResp identityProfile = profileGateway.getIdentityProfile(param.getPersonId(), param.getIdentityType());
|
||||
ProfileGetIdentityProfileLiteResp identityProfile = profileGateway.getIdentityProfile(param.getPersonId(), param.getIdentityType());
|
||||
Axssert.checkNonNull(personProfile, "用户身份不存在");
|
||||
|
||||
// 转换为领域对象
|
||||
// 持久化 -> mapstruct?
|
||||
OrganizationalNodeUser nodeUser = param.toEntity();
|
||||
// assemble person info
|
||||
nodeUser.setIdentityId(identityProfile.getId());
|
||||
nodeUser.setIdentityId(identityProfile.getIdentityId());
|
||||
nodeUser.setPhone(personProfile.getPhone());
|
||||
nodeUser.setRealName(personProfile.getRealName());
|
||||
nodeUser.setIdNumber(personProfile.getIdNumber());
|
||||
@ -123,13 +123,13 @@ public class NodeUserFoundationServiceImpl implements NodeUserFoundationService
|
||||
ProfilePersonResp personProfile = profileGateway.getPersonProfile(dbNodeUser.getPersonId());
|
||||
Axssert.checkNonNull(personProfile, "用户不存在");
|
||||
// 人员身份是否存在
|
||||
ProfileIdentityResp identityProfile = profileGateway.getIdentityProfile(dbNodeUser.getPersonId(), dbNodeUser.getIdentityType());
|
||||
ProfileGetIdentityProfileLiteResp identityProfile = profileGateway.getIdentityProfile(dbNodeUser.getPersonId(), dbNodeUser.getIdentityType());
|
||||
Axssert.checkNonNull(personProfile, "用户身份不存在");
|
||||
|
||||
// 转换为领域对象
|
||||
// 持久化 -> mapstruct?
|
||||
// assemble person info
|
||||
updateReq.setIdentityId(identityProfile.getId());
|
||||
updateReq.setIdentityId(identityProfile.getIdentityId());
|
||||
updateReq.setPhone(personProfile.getPhone());
|
||||
updateReq.setRealName(personProfile.getRealName());
|
||||
updateReq.setIdNumber(personProfile.getIdNumber());
|
||||
@ -146,6 +146,7 @@ public class NodeUserFoundationServiceImpl implements NodeUserFoundationService
|
||||
|
||||
/**
|
||||
* 根据条件聚合查询节点用户
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
|
||||
@ -1,20 +1,35 @@
|
||||
package cn.axzo.orgmanax.server.nodeuser.service.impl;
|
||||
|
||||
import cn.axzo.apollo.workspace.api.v2.workspace.req.ListWorkspaceReq;
|
||||
import cn.axzo.foundation.dao.support.mysql.MybatisPlusOperatorProcessor;
|
||||
import cn.axzo.foundation.dao.support.wrapper.Operator;
|
||||
import cn.axzo.foundation.exception.Axssert;
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.orgmanax.common.config.BizResultCode;
|
||||
import cn.axzo.orgmanax.dto.common.PersonProfileBriefDTO;
|
||||
import cn.axzo.orgmanax.dto.common.WorkspaceBriefDTO;
|
||||
import cn.axzo.orgmanax.dto.cooperateship.dto.OrgCooperateShipDTO;
|
||||
import cn.axzo.orgmanax.dto.job.dto.OrgJobBriefDTO;
|
||||
import cn.axzo.orgmanax.dto.node.dto.OrgNodeBriefDTO;
|
||||
import cn.axzo.orgmanax.dto.node.dto.OrgNodeDTO;
|
||||
import cn.axzo.orgmanax.dto.node.req.ListNodeReq;
|
||||
import cn.axzo.orgmanax.dto.nodeuser.dto.NodeUserBriefDTO;
|
||||
import cn.axzo.orgmanax.dto.nodeuser.dto.NodeUserDTO;
|
||||
import cn.axzo.orgmanax.dto.nodeuser.req.ListNodeUserReq;
|
||||
import cn.axzo.orgmanax.dto.nodeuser.req.ProcessNodeUserReq;
|
||||
import cn.axzo.orgmanax.dto.nodeuser.req.SearchEntNodeUserReq;
|
||||
import cn.axzo.orgmanax.dto.nodeuser.resp.SearchEntNodeUserResp;
|
||||
import cn.axzo.orgmanax.dto.unit.dto.OrgUnitBriefDTO;
|
||||
import cn.axzo.orgmanax.infra.client.profile.PersonProfileGateway;
|
||||
import cn.axzo.orgmanax.infra.client.profile.dto.ProfileGetPersonProfileListReq;
|
||||
import cn.axzo.orgmanax.infra.client.workspace.WorkspaceGateway;
|
||||
import cn.axzo.orgmanax.infra.dao.cooperateship.repository.CooperateShipQueryRepository;
|
||||
import cn.axzo.orgmanax.infra.dao.node.repository.NodeQueryRepository;
|
||||
import cn.axzo.orgmanax.infra.dao.nodeuser.entity.OrganizationalNodeUser;
|
||||
import cn.axzo.orgmanax.infra.dao.nodeuser.repository.NodeUserQueryRepository;
|
||||
import cn.axzo.orgmanax.infra.dao.orgjob.repository.OrgJobQueryRepository;
|
||||
import cn.axzo.orgmanax.infra.dao.unit.repository.UnitQueryRepository;
|
||||
import cn.axzo.orgmanax.server.node.service.NodeService;
|
||||
import cn.axzo.orgmanax.server.nodeuser.foundation.NodeUserFoundationService;
|
||||
import cn.axzo.orgmanax.server.nodeuser.service.NodeUserService;
|
||||
import cn.axzo.orgmanax.server.nodeuser.service.processor.NodeUserProcessor;
|
||||
@ -23,15 +38,19 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@ -42,15 +61,15 @@ import java.util.stream.Collectors;
|
||||
public class NodeUserServiceImpl implements NodeUserService {
|
||||
|
||||
private final NodeUserQueryRepository nodeUserQueryRepository;
|
||||
@Autowired
|
||||
private NodeQueryRepository nodeQueryRepository;
|
||||
@Autowired
|
||||
private OrgJobQueryRepository jobQueryRepository;
|
||||
@Autowired
|
||||
private UnitQueryRepository unitQueryRepository;
|
||||
private final NodeQueryRepository nodeQueryRepository;
|
||||
private final OrgJobQueryRepository jobQueryRepository;
|
||||
private final UnitQueryRepository unitQueryRepository;
|
||||
private final CooperateShipQueryRepository cooperateShipQueryRepository;
|
||||
private final WorkspaceGateway workspaceGateway;
|
||||
private final PersonProfileGateway personProfileGateway;
|
||||
private final ApplicationContext applicationContext;
|
||||
private final NodeUserFoundationService nodeUserFoundationService;
|
||||
|
||||
private final NodeService nodeService;
|
||||
|
||||
@Override
|
||||
public NodeUserProcessor.ProcessResult process(ProcessNodeUserReq req) {
|
||||
@ -82,24 +101,86 @@ public class NodeUserServiceImpl implements NodeUserService {
|
||||
// jobCodes -> jobIds
|
||||
if (CollUtil.isNotEmpty(req.getOrganizationalJobCodes())
|
||||
|| StrUtil.isNotBlank(req.getOrganizationalJobCode())
|
||||
|| StrUtil.isNotBlank(req.getOrganizationalJobNameLike())) {
|
||||
|| 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(req.getOrganizationalJobIds(), jobIds));
|
||||
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);
|
||||
if (CollUtil.isEmpty(page.getData())) {
|
||||
return emptyPage;
|
||||
}
|
||||
|
||||
// findBy查询,根据查询条件二次查询
|
||||
page = handleFindBy(page, req, listReq);
|
||||
|
||||
List<NodeUserDTO> records = BeanUtil.copyToList(CollUtil.emptyIfNull(page.getData()), NodeUserDTO.class);
|
||||
|
||||
// assemble data if needed
|
||||
assembleUnit(req, records);
|
||||
assembleJob(req, records);
|
||||
assembleNode(req, records);
|
||||
assemble(req, records);
|
||||
|
||||
// filter data if needed -> XXX: filter的参数会破坏分页。
|
||||
records = filterRecords(req, records);
|
||||
|
||||
// distinct
|
||||
if (req.getDistinctRule() != null && CollUtil.isNotEmpty(req.getDistinctRule().getDistinctByFields())) {
|
||||
records = CollUtil.distinct(records, r -> {
|
||||
JSONObject json = (JSONObject) JSON.toJSON(r);
|
||||
return req.getDistinctRule().getDistinctByFields().stream()
|
||||
.map(i -> StrUtil.emptyIfNull(StrUtil.toStringOrNull(json.get(i))))
|
||||
.collect(Collectors.joining(","));
|
||||
}, req.getDistinctRule().getOverride());
|
||||
}
|
||||
|
||||
return new PageResp<>(page.getTotal(), page.getSize(), page.getCurrent(), records);
|
||||
}
|
||||
|
||||
@ -108,11 +189,152 @@ public class NodeUserServiceImpl implements NodeUserService {
|
||||
return nodeUserFoundationService.searchEntUser(req);
|
||||
}
|
||||
|
||||
private void assembleUnit(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||
if (CollUtil.isEmpty(records) || req.getNeeds() == null) {
|
||||
/**
|
||||
* 处理 findBy 查询。通过查询结果,再次查询的情况。如 findByTopNodeId 和 findByAncestorNodeId
|
||||
*
|
||||
* @return page 。
|
||||
*/
|
||||
private PageResp<NodeUserQueryRepository.NodeUserResp> handleFindBy(PageResp<NodeUserQueryRepository.NodeUserResp> page,
|
||||
ListNodeUserReq req,
|
||||
NodeUserQueryRepository.ListReq listReq) {
|
||||
// 都为false,无需处理
|
||||
if (!BooleanUtil.isTrue(req.getFindByTopNodeId())
|
||||
&& !BooleanUtil.isTrue(req.getFindByAncestorNodeId())) {
|
||||
return page;
|
||||
}
|
||||
NodeUserQueryRepository.ListReq findByReq = null;
|
||||
// findByTopNodeId
|
||||
if (BooleanUtil.isTrue(req.getFindByTopNodeId())) {
|
||||
Set<Long> toFindTopNodeIds = page.getData().stream().map(NodeUserQueryRepository.NodeUserResp::getTopNodeId)
|
||||
.filter(Objects::nonNull).filter(id -> id > 0).collect(Collectors.toSet());
|
||||
if (!toFindTopNodeIds.isEmpty()) {
|
||||
findByReq = Optional.ofNullable(findByReq).orElseGet(() -> BeanUtil.toBean(listReq, NodeUserQueryRepository.ListReq.class));
|
||||
findByReq.setOrganizationalNodeIds(null);
|
||||
findByReq.setOrganizationalNodeId(null);
|
||||
findByReq.setTopNodeIds(toFindTopNodeIds);
|
||||
}
|
||||
}
|
||||
// findByAncestorNodeId
|
||||
if (BooleanUtil.isTrue(req.getFindByAncestorNodeId())) {
|
||||
Set<Long> nodeIds = page.getData().stream().map(NodeUserQueryRepository.NodeUserResp::getOrganizationalNodeId)
|
||||
.filter(Objects::nonNull).filter(id -> id > 0).collect(Collectors.toSet());
|
||||
Set<Long> descendantNodeIds = nodeService.list(ListNodeReq.builder()
|
||||
.ids(nodeIds)
|
||||
.includeDescendants(true)
|
||||
.build()).stream().flatMap(node -> CollUtil.emptyIfNull(node.getDescendantNodes()).stream().map(OrgNodeDTO::getId))
|
||||
.collect(Collectors.toSet());
|
||||
if (!descendantNodeIds.isEmpty()) {
|
||||
findByReq = Optional.ofNullable(findByReq).orElseGet(() -> BeanUtil.toBean(listReq, NodeUserQueryRepository.ListReq.class));
|
||||
findByReq.setOrganizationalNodeIds(null);
|
||||
findByReq.setOrganizationalNodeId(null);
|
||||
findByReq.setOrganizationalNodeIds(Sets.union(descendantNodeIds, nodeIds));
|
||||
}
|
||||
}
|
||||
if (findByReq == null) {
|
||||
return page;
|
||||
}
|
||||
return nodeUserQueryRepository.page(findByReq);
|
||||
}
|
||||
|
||||
private void assemble(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||
assembleUnit(req, records);
|
||||
assembleJob(req, records);
|
||||
assembleNode(req, records);
|
||||
assembleAncestorNode(req, records);
|
||||
assembleWorkspace(req, records);
|
||||
assemblePersonProfile(req, records);
|
||||
assembleCooperateShip(req, records);
|
||||
assembleSubordinateUsers(req, records);
|
||||
}
|
||||
|
||||
private List<NodeUserDTO> filterRecords(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||
// filterNodeStates
|
||||
if (CollUtil.isNotEmpty(req.getFilterNodeStates())) {
|
||||
records = records.stream()
|
||||
.filter(r -> r.getNode() != null
|
||||
&& r.getNode().getNodeState() != null
|
||||
&& req.getFilterNodeStates().contains(r.getNode().getNodeState()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
// filterTopNodeOnly
|
||||
if (BooleanUtil.isTrue(req.getFilterTopNodeOnly())) {
|
||||
records = records.stream().filter(r -> Objects.equals(r.getOrganizationalNodeId(), r.getTopNodeId())).collect(Collectors.toList());
|
||||
}
|
||||
// filterDirectManagerNotNull
|
||||
if (BooleanUtil.isTrue(req.getFilterDirectManagerNotNull())) {
|
||||
records = records.stream()
|
||||
.filter(r -> r.getExtra() != null && r.getExtra().getLongValue("directManagerPersonId") > 0L)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
// filterIncludeWorkspaceTypes
|
||||
if (CollUtil.isNotEmpty(req.getFilterIncludeWorkspaceTypes())) {
|
||||
records = records.stream()
|
||||
.filter(r -> r.getWorkspace() != null
|
||||
&& r.getWorkspace().getType() != null
|
||||
&& req.getFilterIncludeWorkspaceTypes().contains(r.getWorkspace().getType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
// filterIncludeUnitTypes & filterExcludeUnitTypes
|
||||
if (CollUtil.isNotEmpty(req.getFilterIncludeUnitTypes())) {
|
||||
records = records.stream()
|
||||
.filter(r -> r.getUnit() != null
|
||||
&& r.getUnit().getType() != null
|
||||
&& req.getFilterIncludeUnitTypes().contains(r.getUnit().getType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(req.getFilterExcludeUnitTypes())) {
|
||||
records = records.stream()
|
||||
.filter(r -> r.getUnit() != null
|
||||
&& r.getUnit().getType() != null
|
||||
&& !req.getFilterExcludeUnitTypes().contains(r.getUnit().getType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
// filterIncludeCooperateTypes & filterExcludeCooperateTypes
|
||||
if (CollUtil.isNotEmpty(req.getFilterIncludeCooperateTypes())) {
|
||||
records = records.stream()
|
||||
.filter(r -> r.getCooperateShip() != null
|
||||
&& r.getCooperateShip().getCooperateType() != null
|
||||
&& req.getFilterIncludeCooperateTypes().contains(r.getCooperateShip().getCooperateType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(req.getFilterExcludeCooperateTypes())) {
|
||||
records = records.stream()
|
||||
.filter(r -> r.getCooperateShip() != null
|
||||
&& r.getCooperateShip().getCooperateType() != null
|
||||
&& !req.getFilterExcludeCooperateTypes().contains(r.getCooperateShip().getCooperateType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
private void assembleCooperateShip(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return;
|
||||
}
|
||||
if (!BooleanUtil.isTrue(req.getNeeds().getUnit())) {
|
||||
boolean need = CollUtil.isNotEmpty(req.getFilterIncludeCooperateTypes())
|
||||
|| CollUtil.isNotEmpty(req.getFilterExcludeCooperateTypes())
|
||||
|| (req.getNeeds() != null && BooleanUtil.isTrue(req.getNeeds().getCooperateShip()));
|
||||
if (!need) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<Long> topNodeIds = records.stream().map(NodeUserDTO::getTopNodeId).collect(Collectors.toSet());
|
||||
Map<Long, OrgCooperateShipDTO> cooperateShipByNodeId = cooperateShipQueryRepository.list(CooperateShipQueryRepository.ListReq.builder()
|
||||
.organizationNodeIds(topNodeIds)
|
||||
.build()).stream().map(e -> BeanUtil.toBean(e, OrgCooperateShipDTO.class))
|
||||
.collect(Collectors.toMap(OrgCooperateShipDTO::getOrganizationalNodeId, Function.identity()));
|
||||
|
||||
records.forEach(r -> r.setCooperateShip(cooperateShipByNodeId.get(r.getTopNodeId())));
|
||||
}
|
||||
|
||||
private void assembleUnit(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return;
|
||||
}
|
||||
boolean need = CollUtil.isNotEmpty(req.getFilterIncludeUnitTypes())
|
||||
|| CollUtil.isNotEmpty(req.getFilterExcludeUnitTypes())
|
||||
|| (req.getNeeds() != null && BooleanUtil.isTrue(req.getNeeds().getUnit()));
|
||||
if (!need) {
|
||||
return;
|
||||
}
|
||||
Set<Long> unitIds = records.stream().map(NodeUserDTO::getOrganizationalUnitId).collect(Collectors.toSet());
|
||||
@ -142,10 +364,12 @@ public class NodeUserServiceImpl implements NodeUserService {
|
||||
}
|
||||
|
||||
private void assembleNode(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||
if (CollUtil.isEmpty(records) || req.getNeeds() == null) {
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return;
|
||||
}
|
||||
if (!BooleanUtil.isTrue(req.getNeeds().getNode()) && !BooleanUtil.isTrue(req.getNeeds().getAncestorNode())) {
|
||||
boolean need = CollUtil.isNotEmpty(req.getFilterNodeStates())
|
||||
|| (req.getNeeds() != null && BooleanUtil.isTrue(req.getNeeds().getNode()));
|
||||
if (!need) {
|
||||
return;
|
||||
}
|
||||
Set<Long> nodeIds = records.stream().map(NodeUserDTO::getOrganizationalNodeId).collect(Collectors.toSet());
|
||||
@ -159,4 +383,94 @@ public class NodeUserServiceImpl implements NodeUserService {
|
||||
records.forEach(r -> r.setNode(nodesById.get(r.getOrganizationalNodeId())));
|
||||
}
|
||||
|
||||
private void assembleAncestorNode(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return;
|
||||
}
|
||||
boolean need = (req.getNeeds() != null && BooleanUtil.isTrue(req.getNeeds().getAncestorNodes()));
|
||||
if (!need) {
|
||||
return;
|
||||
}
|
||||
Set<Long> nodeIds = records.stream().map(NodeUserDTO::getOrganizationalNodeId).collect(Collectors.toSet());
|
||||
// assemble node
|
||||
Map<Long, OrgNodeDTO> nodesById = nodeService.list(ListNodeReq.builder()
|
||||
.ids(nodeIds)
|
||||
.includeAncestors(true)
|
||||
.build()).stream()
|
||||
.collect(Collectors.toMap(OrgNodeDTO::getId, Function.identity()));
|
||||
|
||||
records.forEach(r -> {
|
||||
OrgNodeDTO node = nodesById.get(r.getOrganizationalNodeId());
|
||||
r.setAncestorNodes(node == null || CollUtil.isEmpty(node.getAncestorNodes()) ?
|
||||
ImmutableList.of() : BeanUtil.copyToList(node.getAncestorNodes(), OrgNodeBriefDTO.class));
|
||||
});
|
||||
}
|
||||
|
||||
private void assembleWorkspace(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return;
|
||||
}
|
||||
boolean need = CollUtil.isNotEmpty(req.getFilterIncludeWorkspaceTypes())
|
||||
|| (req.getNeeds() != null && BooleanUtil.isTrue(req.getNeeds().getWorkspace()));
|
||||
if (!need) {
|
||||
return;
|
||||
}
|
||||
Set<Long> workspaceIds = records.stream().map(NodeUserDTO::getWorkspaceId)
|
||||
.filter(id -> id != null && id > 0L)
|
||||
.collect(Collectors.toSet());
|
||||
if (workspaceIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<Long, WorkspaceBriefDTO> workspaceById = workspaceGateway.list(ListWorkspaceReq.builder()
|
||||
.ids(workspaceIds)
|
||||
.build())
|
||||
.stream().map(workspace -> BeanUtil.toBean(workspace, WorkspaceBriefDTO.class))
|
||||
.collect(Collectors.toMap(WorkspaceBriefDTO::getId, Function.identity()));
|
||||
records.forEach(r -> r.setWorkspace(workspaceById.get(r.getWorkspaceId())));
|
||||
}
|
||||
|
||||
private void assemblePersonProfile(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return;
|
||||
}
|
||||
boolean need = (req.getNeeds() != null && BooleanUtil.isTrue(req.getNeeds().getPersonProfile()));
|
||||
if (!need) {
|
||||
return;
|
||||
}
|
||||
Set<Long> personIds = records.stream().map(NodeUserDTO::getPersonId).collect(Collectors.toSet());
|
||||
Map<Long, PersonProfileBriefDTO> personsById = personProfileGateway.listPersonProfiles(ProfileGetPersonProfileListReq.builder()
|
||||
.personIds(personIds)
|
||||
.build())
|
||||
.stream().map(e -> BeanUtil.toBean(e, PersonProfileBriefDTO.class))
|
||||
.collect(Collectors.toMap(PersonProfileBriefDTO::getId, Function.identity()));
|
||||
records.forEach(r -> r.setPersonProfile(personsById.get(r.getPersonId())));
|
||||
}
|
||||
|
||||
private void assembleSubordinateUsers(ListNodeUserReq req, List<NodeUserDTO> records) {
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return;
|
||||
}
|
||||
boolean need = (req.getNeeds() != null && BooleanUtil.isTrue(req.getNeeds().getDirectSubordinateUsers()));
|
||||
if (!need) {
|
||||
return;
|
||||
}
|
||||
Set<Long> personIds = records.stream()
|
||||
.map(NodeUserDTO::getPersonId).collect(Collectors.toSet());
|
||||
|
||||
// 根据单位 + personIds 查询直属下级。 可能会多查询。后续取值的时候,会过滤掉多查出来的数据
|
||||
Set<Long> unitIds = records.stream().map(NodeUserDTO::getOrganizationalUnitId).collect(Collectors.toSet());
|
||||
|
||||
Map<String, List<NodeUserBriefDTO>> subordinateUsers = nodeUserQueryRepository.list(NodeUserQueryRepository.ListReq.builder()
|
||||
.organizationalUnitIds(unitIds)
|
||||
.extraQueries(ImmutableList.of(MybatisPlusOperatorProcessor.JSONQuery.builder()
|
||||
.jsonPath("$.directManagerPersonId")
|
||||
.operator(Operator.IN)
|
||||
.data(personIds)
|
||||
.build()))
|
||||
.build()).stream()
|
||||
.map(e -> BeanUtil.toBean(e, NodeUserBriefDTO.class))
|
||||
.collect(Collectors.groupingBy(e -> e.getOrganizationalUnitId() + ":" + e.getExtra().getLongValue("directManagerPersonId")));
|
||||
|
||||
records.forEach(r -> r.setSubordinateUsers(subordinateUsers.getOrDefault(r.getOrganizationalUnitId() + ":" + r.getPersonId(), ImmutableList.of())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
||||
@EnableFeignClients(basePackages = {"cn.axzo"})
|
||||
@Log4j2
|
||||
@EnableAsync
|
||||
public class MaokaiTestApplication {
|
||||
public class OrgmanaxTestApplication {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.setProperty("rocket.consumer.listeners.disable", "true");
|
||||
@ -32,7 +32,7 @@ public class MaokaiTestApplication {
|
||||
System.setProperty("rocketmq.name-server", "172.16.2.82:9876");
|
||||
System.setProperty("logback.path", "/tmp");
|
||||
|
||||
SpringApplication application = new SpringApplication(MaokaiTestApplication.class);
|
||||
SpringApplication application = new SpringApplication(OrgmanaxTestApplication.class);
|
||||
ApplicationContext applicationContext = application.run(args);
|
||||
Environment env = applicationContext.getEnvironment();
|
||||
log.info(
|
||||
Loading…
Reference in New Issue
Block a user