feat(REQ-3714) 工人退场流程优化 - organizational_node_user_extra迁移
This commit is contained in:
parent
179d6a3914
commit
2b4dfa50a8
@ -0,0 +1,102 @@
|
||||
package cn.axzo.orgmanax.dto.nodeuser.enums;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author haiyangjin
|
||||
* @date 2024/3/3
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public enum OrganizationalNodeUserStatusEnum implements Serializable {
|
||||
/**
|
||||
* 在岗 -> ACTIVE
|
||||
*/
|
||||
@Deprecated
|
||||
ON_DUTY("在岗"),
|
||||
/**
|
||||
* 退场
|
||||
*/
|
||||
QUIT("退场"),
|
||||
|
||||
INACTIVE("入场中"),
|
||||
|
||||
ACTIVE("已入场"),
|
||||
|
||||
LEAVE("离场"),
|
||||
|
||||
WITHDRAW("退场"),
|
||||
|
||||
JOINED("在职"),
|
||||
|
||||
NONE("非法值")
|
||||
;
|
||||
|
||||
private final String desc;
|
||||
|
||||
public static OrganizationalNodeUserStatusEnum from(OrgUserStatusEnum status) {
|
||||
switch (status) {
|
||||
case ACTIVE:
|
||||
return OrganizationalNodeUserStatusEnum.ACTIVE;
|
||||
case LEAVE:
|
||||
return OrganizationalNodeUserStatusEnum.LEAVE;
|
||||
case WITHDRAW:
|
||||
return OrganizationalNodeUserStatusEnum.WITHDRAW;
|
||||
case JOINED:
|
||||
return OrganizationalNodeUserStatusEnum.JOINED;
|
||||
case QUIT:
|
||||
return OrganizationalNodeUserStatusEnum.QUIT;
|
||||
default:
|
||||
return OrganizationalNodeUserStatusEnum.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean onDuty(OrganizationalNodeUserStatusEnum status) {
|
||||
return status == ON_DUTY
|
||||
|| status == ACTIVE
|
||||
|| status == JOINED;
|
||||
}
|
||||
|
||||
public static List<OrganizationalNodeUserStatusEnum> onDutyStatus() {
|
||||
return Lists.newArrayList(ON_DUTY_STATUS);
|
||||
}
|
||||
|
||||
public static Set<OrganizationalNodeUserStatusEnum> parseStatus(Collection<OrganizationalNodeUserStatusEnum> status) {
|
||||
if (CollUtil.isEmpty(status)) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return status.stream()
|
||||
.flatMap(e -> {
|
||||
if (ON_DUTY == e) {
|
||||
return onDutyStatus().stream();
|
||||
} else if (QUIT == e) {
|
||||
return Stream.of(e, WITHDRAW);
|
||||
}
|
||||
return Stream.of(e);
|
||||
})
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private static final ImmutableList<OrganizationalNodeUserStatusEnum> ON_DUTY_STATUS = ImmutableList.of(
|
||||
OrganizationalNodeUserStatusEnum.ON_DUTY,
|
||||
OrganizationalNodeUserStatusEnum.JOINED,
|
||||
OrganizationalNodeUserStatusEnum.ACTIVE
|
||||
);
|
||||
|
||||
public OrgUserStatusEnum toOrgUserStatusEnum() {
|
||||
return OrgUserStatusEnum.valueOf(this.name());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package cn.axzo.orgmanax.dto.nodeuser.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TagOperateEnum {
|
||||
|
||||
// 添加标签
|
||||
ADD("ADD", "添加标签"),
|
||||
// 移除标签
|
||||
REMOVE("REMOVE", "移除标签"),
|
||||
;
|
||||
private final String code;
|
||||
private final String desc;
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package cn.axzo.orgmanax.dto.nodeuser.req;
|
||||
|
||||
import cn.axzo.orgmanax.dto.nodeuser.enums.TagOperateEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 人员打标签接口
|
||||
*
|
||||
* @author : zhanghonghao@axzo.cn
|
||||
* @since : 2025/2/18
|
||||
*/
|
||||
@Data
|
||||
public class TagOperateReq {
|
||||
|
||||
private Long loginWorkspaceId;
|
||||
|
||||
private Long loginOuId;
|
||||
|
||||
/**
|
||||
* 人员列表
|
||||
*/
|
||||
@NotEmpty(message = "人员列表不能为空")
|
||||
private List<Long> personIds;
|
||||
|
||||
/**
|
||||
* 分组标签编码
|
||||
*/
|
||||
@NotNull(message = "分组标签编码不能为空")
|
||||
private String tagNodeCode;
|
||||
|
||||
/**
|
||||
* 标签值编码
|
||||
*/
|
||||
@NotNull(message = "标签值编码不能为空")
|
||||
private String tagValueCode;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
private TagOperateEnum operateType;
|
||||
|
||||
}
|
||||
@ -7,6 +7,7 @@ import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@ -14,6 +15,8 @@ import java.util.Date;
|
||||
@AllArgsConstructor
|
||||
public class OrgUserDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2687034361751211136L;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
@ -91,4 +94,8 @@ public class OrgUserDTO implements Serializable {
|
||||
*/
|
||||
private Long isDelete = 0L;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
private Set<String> tags;
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package cn.axzo.orgmanax.infra.config.type;
|
||||
|
||||
import cn.axzo.foundation.dao.support.mysql.type.BaseListTypeHandler;
|
||||
|
||||
/**
|
||||
* @author luofu
|
||||
* @version 1.0
|
||||
* @description 实体 Long列表的字段类型处理器
|
||||
* @date 2025/3/10
|
||||
*/
|
||||
public class LongListTypeHandler extends BaseListTypeHandler<Long> {
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package cn.axzo.orgmanax.infra.config.type;
|
||||
|
||||
import cn.axzo.foundation.dao.support.mysql.type.BaseSetTypeHandler;
|
||||
|
||||
/**
|
||||
* @author luofu
|
||||
* @version 1.0
|
||||
* @description 实体 String哈希类型字段处理器
|
||||
* @date 2025/3/10
|
||||
*/
|
||||
public class StringSetTypeHandler extends BaseSetTypeHandler<String> {
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package cn.axzo.orgmanax.infra.dao.nodeuser.dao;
|
||||
|
||||
import cn.axzo.orgmanax.infra.dao.nodeuser.entity.OrganizationalNodeUserExtra;
|
||||
import cn.axzo.orgmanax.infra.dao.nodeuser.mapper.OrganizationalNodeUserExtraMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author luofu
|
||||
* @date 2025/3/10
|
||||
*/
|
||||
@Repository("organizationalNodeUserExtraDao")
|
||||
public class NodeUserExtraDao extends ServiceImpl<OrganizationalNodeUserExtraMapper, OrganizationalNodeUserExtra> {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTagsMap(Map<Long, Set<String>> idTagsMap) {
|
||||
for (Map.Entry<Long, Set<String>> setEntry : idTagsMap.entrySet()) {
|
||||
updateTagsSet(setEntry.getKey(), setEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTagsSet(Long id, Set<String> tagsSet) {
|
||||
OrganizationalNodeUserExtra entity = new OrganizationalNodeUserExtra();
|
||||
entity.setId(id);
|
||||
entity.setTags(tagsSet);
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,223 @@
|
||||
package cn.axzo.orgmanax.infra.dao.nodeuser.entity;
|
||||
|
||||
import cn.axzo.foundation.dao.support.mysql.type.BaseListTypeHandler;
|
||||
import cn.axzo.orgmanax.dto.nodeuser.enums.OrganizationalNodeUserStatusEnum;
|
||||
import cn.axzo.orgmanax.infra.config.type.LongListTypeHandler;
|
||||
import cn.axzo.orgmanax.infra.config.type.StringSetTypeHandler;
|
||||
import cn.axzo.trade.datasecurity.core.annotation.CryptField;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 组织人员扩展表
|
||||
*
|
||||
* @author luofu
|
||||
* @since 2025/3/7
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName(value = "organizational_node_user_extra", autoResultMap = true)
|
||||
public class OrganizationalNodeUserExtra implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2582195210622831819L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(
|
||||
type = IdType.AUTO
|
||||
)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 自然人id
|
||||
*/
|
||||
@TableField("person_id")
|
||||
private Long personId;
|
||||
|
||||
/**
|
||||
* 主电话
|
||||
*/
|
||||
@CryptField
|
||||
@TableField("phone")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
@TableField("real_name")
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
@CryptField
|
||||
@TableField("id_number")
|
||||
private String idNumber;
|
||||
|
||||
/**
|
||||
* 单位id
|
||||
*/
|
||||
@TableField("organizational_unit_id")
|
||||
private Long organizationalUnitId;
|
||||
|
||||
/**
|
||||
* 当前所在组织节点id
|
||||
*/
|
||||
@TableField(value = "top_node_ids", typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> topNodeIds;
|
||||
|
||||
/**
|
||||
* 直属主管ID
|
||||
*/
|
||||
@TableField("direct_manager_person_id")
|
||||
private Long directManagerPersonId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableField(value = "node_ids", typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> nodeIds;
|
||||
|
||||
/**
|
||||
* 岗位IDs
|
||||
*/
|
||||
@TableField(value = "job_ids", typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> jobIds;
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
@TableField(value = "tags", typeHandler = StringSetTypeHandler.class)
|
||||
private Set<String> tags;
|
||||
|
||||
/**
|
||||
* 部门信息
|
||||
*/
|
||||
@TableField(value = "node_info", typeHandler = ListOrganizationNodeUserExtraNodeInfoHandler.class)
|
||||
private List<OrganizationNodeUserExtraNodeInfo> nodeInfo;
|
||||
|
||||
/**
|
||||
* 加入时间
|
||||
*/
|
||||
@TableField("join_at")
|
||||
private Date joinAt;
|
||||
|
||||
/**
|
||||
* 离开时间
|
||||
*/
|
||||
@TableField("leave_at")
|
||||
private Date leaveAt;
|
||||
|
||||
/**
|
||||
* workspace id
|
||||
*/
|
||||
@TableField("workspace_id")
|
||||
private Long workspaceId;
|
||||
|
||||
/**
|
||||
* workspace_type
|
||||
*/
|
||||
@TableField("workspace_type")
|
||||
private Integer workspaceType;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* @see OrganizationalNodeUserStatusEnum
|
||||
*/
|
||||
@TableField(value = "status")
|
||||
private OrganizationalNodeUserStatusEnum status;
|
||||
|
||||
/**
|
||||
* 扩展字段
|
||||
**/
|
||||
@TableField(value = "extra", typeHandler = FastjsonTypeHandler.class)
|
||||
private UserExtra extra;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateAt;
|
||||
|
||||
public List<Long> determineJobIds() {
|
||||
if (CollectionUtils.isEmpty(jobIds))
|
||||
return Collections.emptyList();
|
||||
return jobIds;
|
||||
}
|
||||
|
||||
public List<Long> determineNodeIds() {
|
||||
if (CollectionUtils.isEmpty(nodeIds))
|
||||
return Collections.emptyList();
|
||||
return nodeIds;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class UserExtra implements Serializable {
|
||||
private String desc;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class OrganizationNodeUserExtraNodeInfo implements Serializable {
|
||||
|
||||
/**
|
||||
* nodeId
|
||||
*/
|
||||
private Long nodeId;
|
||||
|
||||
/**
|
||||
* organization node user id
|
||||
*/
|
||||
private Long nodeUserId;
|
||||
|
||||
/**
|
||||
* 是否是部门管理员
|
||||
*/
|
||||
private Boolean manager;
|
||||
|
||||
/**
|
||||
* 是否是主岗位
|
||||
* 0:普通岗位、1:主岗位
|
||||
*/
|
||||
private Integer primaryJob;
|
||||
|
||||
/**
|
||||
* job id
|
||||
*/
|
||||
private Long jobId;
|
||||
}
|
||||
|
||||
public static class ListOrganizationNodeUserExtraNodeInfoHandler extends BaseListTypeHandler<OrganizationNodeUserExtraNodeInfo> {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package cn.axzo.orgmanax.infra.dao.nodeuser.mapper;
|
||||
|
||||
import cn.axzo.orgmanax.infra.dao.nodeuser.entity.OrganizationalNodeUserExtra;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 组织人员扩展表数据库访问层
|
||||
*
|
||||
* @author luofu
|
||||
* @since 2025/3/10
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrganizationalNodeUserExtraMapper extends BaseMapper<OrganizationalNodeUserExtra> {
|
||||
}
|
||||
@ -4,8 +4,23 @@ import cn.axzo.orgmanax.infra.dao.orguser.entity.OrgUser;
|
||||
import cn.axzo.orgmanax.infra.dao.orguser.mapper.OrgUserMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Repository
|
||||
public class OrgUserDao extends ServiceImpl<OrgUserMapper, OrgUser> {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTagsMap(Map<Long, Set<String>> idTagsMap) {
|
||||
for (Map.Entry<Long, Set<String>> setEntry : idTagsMap.entrySet()) {
|
||||
updateTagsSet(setEntry.getKey(), setEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTagsSet(Long id, Set<String> tagsSet) {
|
||||
OrgUser entity = OrgUser.builder().id(id).tags(tagsSet).build();
|
||||
updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package cn.axzo.orgmanax.infra.dao.orguser.entity;
|
||||
|
||||
import cn.axzo.orgmanax.infra.config.type.StringSetTypeHandler;
|
||||
import cn.axzo.trade.datasecurity.core.annotation.CryptField;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -14,6 +16,7 @@ import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 人员组织(OrgUser)表实体类
|
||||
@ -31,6 +34,8 @@ import java.util.Date;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class OrgUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6974404117487874584L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ -116,6 +121,10 @@ public class OrgUser implements Serializable {
|
||||
*/
|
||||
private Long isDelete = 0L;
|
||||
|
||||
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
@TableField(value = "tags", typeHandler = StringSetTypeHandler.class)
|
||||
private Set<String> tags;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user