Compare commits
3 Commits
ff371a3cc9
...
26c7992abd
Author | SHA1 | Date |
---|---|---|
youHong.ai | 26c7992abd | |
youHong.ai | a54073c604 | |
youHong.ai | 9bf767afb5 |
|
@ -36,6 +36,7 @@ DirectoryV2.xml
|
|||
/lib/classbeanLib/ecology-dev-lib.jar
|
||||
/lib/classbeanLib/web-inf-class-lib.jar
|
||||
/lib/weaverLib/
|
||||
*.groovy
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
</content>
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,60 @@
|
|||
package aiyh.utils.action;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
/**
|
||||
* <h1>基础定时任务模板方法</h1>
|
||||
*
|
||||
* <p>create: 2022-12-04 13:52</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
public abstract class CusBaseCronJob extends BaseCronJob {
|
||||
|
||||
|
||||
Logger log = Util.getLogger();
|
||||
|
||||
|
||||
@Override
|
||||
public final void execute() {
|
||||
try {
|
||||
Util.verifyRequiredField(this);
|
||||
} catch (CustomerException e) {
|
||||
log.error("require param is not configuration! " + e.getMessage());
|
||||
}
|
||||
try {
|
||||
this.runCode();
|
||||
} catch (Exception e) {
|
||||
this.exceptionCallback(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>运行代码</h2>
|
||||
* <i>2022/12/4 13:59</i>
|
||||
* ******************************************
|
||||
*
|
||||
* @author youHong.ai
|
||||
* ******************************************
|
||||
*/
|
||||
public abstract void runCode();
|
||||
|
||||
|
||||
/**
|
||||
* <h2>程序异常回调</h2>
|
||||
* <i>2022/12/4 13:59</i>
|
||||
* ******************************************
|
||||
*
|
||||
* @param e 异常类
|
||||
* @author youHong.ai
|
||||
* ******************************************
|
||||
*/
|
||||
public void exceptionCallback(Throwable e) {
|
||||
log.error("execute cronJon failure! error detail msg \n" + Util.getErrString(e));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package aiyh.utils.httpUtil;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* <h1>文件上传类</h1>
|
||||
*
|
||||
* <p>create: 2022-11-21 11:54</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@ToString
|
||||
public class HttpMultipartFile {
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
String fileName;
|
||||
/**
|
||||
* 上传文件的key
|
||||
*/
|
||||
String fileKey;
|
||||
/**
|
||||
* 文件流信息
|
||||
*/
|
||||
InputStream stream;
|
||||
|
||||
Long fileSize;
|
||||
}
|
|
@ -1,5 +1,10 @@
|
|||
package aiyh.utils.recordset;
|
||||
|
||||
import aiyh.utils.annotation.BooleanConverter;
|
||||
import aiyh.utils.annotation.BooleanConverterEnum;
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import com.google.common.base.Strings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import weaver.conn.RecordSet;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -13,11 +18,51 @@ import java.lang.reflect.Field;
|
|||
public class BooleanTypeHandler implements TypeHandler{
|
||||
@Override
|
||||
public Object getValue(RecordSet rs, String fieldName, Field declaredField) {
|
||||
return rs.getBoolean(fieldName);
|
||||
return getBoolean(declaredField, rs.getString(fieldName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(RecordSet rs, int index,Field declaredField) {
|
||||
return rs.getBoolean(index);
|
||||
return getBoolean(declaredField, rs.getString(index));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Object getBoolean(Field declaredField, String fieldValue) {
|
||||
try {
|
||||
BooleanConverter annotation = declaredField.getAnnotation(BooleanConverter.class);
|
||||
BooleanConverterEnum value = annotation.value();
|
||||
String trueStr = annotation.trueStr();
|
||||
String falseStr = annotation.falseStr();
|
||||
String trueInteger = annotation.trueInteger();
|
||||
String falseInteger = annotation.falseInteger();
|
||||
boolean defaultValue = annotation.defaultValue();
|
||||
String booleanVal = null;
|
||||
try {
|
||||
booleanVal = fieldValue;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
boolean hasValueTrue = annotation.hasValueTrue();
|
||||
if (value == BooleanConverterEnum.STRING) {
|
||||
if (booleanVal == null || booleanVal.equals(falseStr)) {
|
||||
return false;
|
||||
} else if ((hasValueTrue && !Strings.isNullOrEmpty(booleanVal)) || booleanVal.equals(trueStr)) {
|
||||
return true;
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
} else if (value == BooleanConverterEnum.INTEGER) {
|
||||
if (booleanVal == null || booleanVal.equals(falseInteger)) {
|
||||
return false;
|
||||
} else if ((hasValueTrue && !Strings.isNullOrEmpty(booleanVal)) || booleanVal.equals(trueInteger)) {
|
||||
return true;
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}else {
|
||||
return defaultValue;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new CustomerException("不支持的类型转换!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package com.api.youhong.ai.pcn.organization.orgchart.controller;
|
||||
|
||||
import aiyh.utils.ApiResult;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.service.OrgChartService;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.vo.OrgChartNodeVo;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <h1>人员组织架构图后端接口</h1>
|
||||
*
|
||||
* <p>create: 2022-12-01 11:58</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Path("/aiyh/orgchart/")
|
||||
public class OrgChartController {
|
||||
|
||||
private final OrgChartService service = new OrgChartService();
|
||||
|
||||
|
||||
@Path("get")
|
||||
@GET
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getOrgChartTree(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
User logInUser = HrmUserVarify.getUser(request, response);
|
||||
List<OrgChartNodeVo> treeList = service.getOrgChartTree(logInUser);
|
||||
return ApiResult.success(treeList);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.api.youhong.ai.pcn.organization.orgchart.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* <h1>人员组织架构图人员信息dto</h1>
|
||||
*
|
||||
* <p>create: 2022-12-02 12:26</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class HrmResourceDto {
|
||||
|
||||
/** 用户id */
|
||||
private Integer id;
|
||||
|
||||
/** 姓名 */
|
||||
private String lastName;
|
||||
|
||||
/** 所有上级 */
|
||||
private String managerStr;
|
||||
|
||||
/** 职位id */
|
||||
private Integer jobTitleId;
|
||||
|
||||
/** 上级 */
|
||||
private Integer managerId;
|
||||
|
||||
/** 部门id */
|
||||
private Integer departmentId;
|
||||
|
||||
/** 部门名称 */
|
||||
private String departmentName;
|
||||
|
||||
/** 职位名称 */
|
||||
private String jobTitleName;
|
||||
|
||||
/** 用工类型 */
|
||||
private Integer typeOfEmployment;
|
||||
|
||||
/** 是否是当前登陆用户的直接上级们 */
|
||||
private boolean currentParent;
|
||||
|
||||
/** 是否是当前登陆用户 */
|
||||
private boolean current;
|
||||
|
||||
/** 是否展示子节点 */
|
||||
private Integer showChildren;
|
||||
|
||||
/** 是否展示子节点兄弟节点 */
|
||||
private Integer showBrother;
|
||||
|
||||
/** 是否显示当前节点 */
|
||||
private Integer show;
|
||||
|
||||
/** 头像地址 */
|
||||
private String avatar;
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.api.youhong.ai.pcn.organization.orgchart.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.ParamMapper;
|
||||
import aiyh.utils.annotation.recordset.Select;
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.pojo.HrmResource;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.pojo.ShowPointOrAll;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <h1>人员组织架构图查询</h1>
|
||||
*
|
||||
* <p>create: 2022-12-01 12:14</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@SqlMapper
|
||||
public interface OrgChartMapper {
|
||||
|
||||
|
||||
/**
|
||||
* <h2>查询所有的在职状态人员</h2>
|
||||
* <i>2022/12/5 11:05</i>
|
||||
* ******************************************
|
||||
*
|
||||
* @param typeOfEmploymentField 人员自定义字段
|
||||
* @return List<HrmResource> 返回的人员信息
|
||||
* @author youHong.ai
|
||||
* ******************************************
|
||||
*/
|
||||
@Select("select hrm.id, " +
|
||||
" hrm.messagerurl avatar," +
|
||||
" cus.$t{lastNameEnField} last_name, " +
|
||||
" hrm.managerstr manager_str, " +
|
||||
" hrm.jobtitle job_title_id, " +
|
||||
" hrm.managerid manager_id, " +
|
||||
" hrm.departmentid department_id, " +
|
||||
" dept.DEPARTMENTNAME department_name, " +
|
||||
" job.JOBTITLENAME job_title_name, " +
|
||||
" cus.$t{typeOfEmploymentFiled} type_of_employment " +
|
||||
"from hrmresource hrm " +
|
||||
" inner join hrmjobtitles job on hrm.JOBTITLE = job.id " +
|
||||
" inner join cus_fielddata cus on cus.ID = hrm.ID " +
|
||||
" and cus.SCOPE = 'HrmCustomFieldByInfoType' " +
|
||||
" and cus.SCOPEID = -1 " +
|
||||
" inner join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " +
|
||||
"where hrm.status in (0, 1)")
|
||||
List<HrmResource> selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField,
|
||||
@ParamMapper("lastNameEnField") String lastNameEnField);
|
||||
|
||||
|
||||
/**
|
||||
* <h2>查询当前人员配置信息,是否全部展开,是否显示小红点点</h2>
|
||||
* <i>2022/12/5 11:51</i>
|
||||
* ******************************************
|
||||
*
|
||||
* @param userId 当前用户id
|
||||
* @return ShowPointOrAll 展示与否的人员信息
|
||||
* @author youHong.ai
|
||||
* ******************************************
|
||||
*/
|
||||
@Select("select id,resources,show_all,show_type from uf_show_point_or_all " +
|
||||
"where concat(',',resources,',') like concat('%,',#{userId},',%')")
|
||||
ShowPointOrAll selectShowPointOrAll(@ParamMapper("userId") int userId);
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.api.youhong.ai.pcn.organization.orgchart.mapstruct;
|
||||
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.dto.HrmResourceDto;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.pojo.HrmResource;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.vo.OrgChartNodeVo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* <h1>mapstruct映射关系</h1>
|
||||
*
|
||||
* <p>create: 2022-12-02 12:29</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
public interface OrgChartMapStruct {
|
||||
|
||||
OrgChartMapStruct INSTANCE = Mappers.getMapper(OrgChartMapStruct.class);
|
||||
|
||||
|
||||
/**
|
||||
* <h2>hrmResource 对象转换为Dto对象</h2>
|
||||
*
|
||||
* @param hrmResource hrmResource对象
|
||||
* @return dto对象
|
||||
*/
|
||||
@Mapping(target = "showChildren", ignore = true)
|
||||
@Mapping(target = "showBrother", ignore = true)
|
||||
@Mapping(target = "show", ignore = true)
|
||||
@Mapping(target = "currentParent", ignore = true)
|
||||
@Mapping(target = "current", ignore = true)
|
||||
HrmResourceDto hrmResourceToDto(HrmResource hrmResource);
|
||||
|
||||
|
||||
@Mapping(target = "childrenNum", ignore = true)
|
||||
@Mapping(target = "isRoot", ignore = true)
|
||||
@Mapping(target = "managerIds", expression = "java(OrgChartMapStructConvert.getManagerIds(dto.getManagerStr()))")
|
||||
@Mapping(target = "jobId", source = "jobTitleId")
|
||||
@Mapping(target = "type", source = "typeOfEmployment")
|
||||
@Mapping(target = "name", source = "lastName")
|
||||
@Mapping(target = "job", source = "jobTitleName")
|
||||
@Mapping(target = "department", source = "departmentName")
|
||||
@Mapping(target = "children", ignore = true)
|
||||
OrgChartNodeVo hrmResourceDtoToVo(HrmResourceDto dto);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.api.youhong.ai.pcn.organization.orgchart.mapstruct;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <h1>自定义转换规则</h1>
|
||||
*
|
||||
* <p>create: 2022-12-03 12:40</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
public class OrgChartMapStructConvert {
|
||||
|
||||
|
||||
/**
|
||||
* <h2>获取上级id数组</h2>
|
||||
* <i>2022/12/3 12:43</i>
|
||||
* ******************************************
|
||||
*
|
||||
* @param managerStr 所有上级id逗号分割的字符串
|
||||
* @return List<Integer> 上级id数组
|
||||
* @author youHong.ai
|
||||
* ******************************************
|
||||
*/
|
||||
public static List<Integer> getManagerIds(String managerStr) {
|
||||
if (Objects.isNull(managerStr) || "".equals(managerStr)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
managerStr = Util.removeSeparator(managerStr, ",");
|
||||
return Arrays.stream(managerStr.split(","))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.api.youhong.ai.pcn.organization.orgchart.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* <h1>人员数据信息</h1>
|
||||
*
|
||||
* <p>create: 2022-12-01 15:10</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@ToString
|
||||
public class HrmResource {
|
||||
|
||||
/** 用户id */
|
||||
private Integer id;
|
||||
|
||||
/** 姓名 */
|
||||
private String lastName;
|
||||
|
||||
/** 头像地址 */
|
||||
private String avatar;
|
||||
|
||||
/** 所有上级 */
|
||||
private String managerStr;
|
||||
|
||||
/** 职位id */
|
||||
private Integer jobTitleId;
|
||||
|
||||
/** 上级 */
|
||||
private Integer managerId;
|
||||
|
||||
/** 部门id */
|
||||
private Integer departmentId;
|
||||
|
||||
/** 部门名称 */
|
||||
private String departmentName;
|
||||
|
||||
/** 职位名称 */
|
||||
private String jobTitleName;
|
||||
|
||||
/** 用工类型 */
|
||||
private Integer typeOfEmployment;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.api.youhong.ai.pcn.organization.orgchart.pojo;
|
||||
|
||||
import aiyh.utils.annotation.BooleanConverter;
|
||||
import aiyh.utils.annotation.BooleanConverterEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* <h1>全部展开或展示不同人员的点</h1>
|
||||
*
|
||||
* <p>create: 2022-12-05 10:51</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class ShowPointOrAll {
|
||||
/** id */
|
||||
private Integer id;
|
||||
|
||||
/** 多人力资源的人员id */
|
||||
private String resources;
|
||||
|
||||
/** 是否全部展开 */
|
||||
@BooleanConverter(BooleanConverterEnum.INTEGER)
|
||||
private boolean showAll;
|
||||
|
||||
/** 是否显示不同的人员标识 */
|
||||
@BooleanConverter(BooleanConverterEnum.INTEGER)
|
||||
private boolean showType;
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
package com.api.youhong.ai.pcn.organization.orgchart.service;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.dto.HrmResourceDto;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.mapper.OrgChartMapper;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.mapstruct.OrgChartMapStruct;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.pojo.HrmResource;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.pojo.ShowPointOrAll;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.vo.OrgChartNodeVo;
|
||||
import ebu7common.youhong.ai.bean.Builder;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <h1>人员组织架构图逻辑处理</h1>
|
||||
*
|
||||
* <p>create: 2022-12-01 12:00</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
public class OrgChartService {
|
||||
|
||||
private final OrgChartMapper mapper = Util.getMapper(OrgChartMapper.class);
|
||||
|
||||
private final OrgChartMapStruct struct = OrgChartMapStruct.INSTANCE;
|
||||
|
||||
/**
|
||||
* <h2>获取人员组织架构图数据</h2>
|
||||
*
|
||||
* @param logInUser 当前登陆对象
|
||||
* @return 组织架构图数据
|
||||
* @author youHong.ai
|
||||
*/
|
||||
public List<OrgChartNodeVo> getOrgChartTree(User logInUser) {
|
||||
int userId = logInUser.getUID();
|
||||
String typeOfEmploymentField = Util.getCusConfigValue("typeOfEmploymentField");
|
||||
Assert.notBlank(typeOfEmploymentField, "config [typeOfEmploymentField] is null or blank!");
|
||||
String lastNameEnField = Util.getCusConfigValue("lastNameEnField");
|
||||
Assert.notBlank(lastNameEnField, "config [lastNameEnField] is null or blank!");
|
||||
List<HrmResource> hrmResourceList = mapper.selectAll(typeOfEmploymentField, lastNameEnField);
|
||||
//List<HrmResourceDto> hrmResourceDtoList = new ArrayList();
|
||||
AtomicReference<HrmResourceDto> currentUser = new AtomicReference<>();
|
||||
/* ******************* 将pojo转换为Dto对象,对节点属性默认值赋值,找出当前用户并设置显示 ******************* */
|
||||
List<HrmResourceDto> hrmResourceDtoList = hrmResourceList.stream()
|
||||
.map(struct::hrmResourceToDto)
|
||||
.peek(item -> Builder.startSet(item)
|
||||
.with(HrmResourceDto::setShow, 0)
|
||||
.with(HrmResourceDto::setShowBrother, 0)
|
||||
.with(HrmResourceDto::setShowChildren, 0)
|
||||
.endSet())
|
||||
.collect(Collectors.toList());
|
||||
hrmResourceDtoList.stream()
|
||||
.filter(item -> item.getId() == userId)
|
||||
.forEach(item -> {
|
||||
Builder.startSet(item)
|
||||
.with(HrmResourceDto::setShow, 1)
|
||||
.with(HrmResourceDto::setShowBrother, 1)
|
||||
.with(HrmResourceDto::setShowChildren, 1)
|
||||
.with(HrmResourceDto::setCurrent, true)
|
||||
.endSet();
|
||||
currentUser.set(item);
|
||||
});
|
||||
Assert.notNull(currentUser, "not find current login user info!");
|
||||
/* ******************* 查找当前登陆人员的所有上级 ******************* */
|
||||
String currentUserManagerStr = currentUser.get().getManagerStr();
|
||||
if (Objects.isNull(currentUserManagerStr)) {
|
||||
currentUserManagerStr = "";
|
||||
}
|
||||
currentUserManagerStr = Util.removeSeparator(currentUserManagerStr, ",");
|
||||
List<Integer> currentUserManagerList = Arrays.stream(currentUserManagerStr.split(","))
|
||||
.map(Integer::parseInt)
|
||||
.collect(Collectors.toList());
|
||||
/* ******************* 对当前用户的所有直接上级设置标识 ******************* */
|
||||
hrmResourceDtoList.stream()
|
||||
.filter(item -> currentUserManagerList.contains(item.getId()))
|
||||
.forEach(item -> Builder.startSet(item)
|
||||
.with(HrmResourceDto::setShowChildren, 1)
|
||||
.with(HrmResourceDto::setCurrentParent, true)
|
||||
.endSet());
|
||||
|
||||
/* ******************* 查询当前用户的是否全部展示或显示小红点的配置信息 ******************* */
|
||||
ShowPointOrAll showPointOrAll = mapper.selectShowPointOrAll(userId);
|
||||
List<OrgChartNodeVo> orgChartNodeVoList = null;
|
||||
if (Objects.isNull(showPointOrAll)) {
|
||||
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
|
||||
orgChartNodeVoList = hrmResourceDtoList.stream()
|
||||
.map(struct::hrmResourceDtoToVo)
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
|
||||
orgChartNodeVoList = hrmResourceDtoList.stream()
|
||||
.map(struct::hrmResourceDtoToVo)
|
||||
.peek(item -> {
|
||||
if (showPointOrAll.isShowAll()) {
|
||||
Builder.startSet(item)
|
||||
.with(OrgChartNodeVo::setShow, 1)
|
||||
.with(OrgChartNodeVo::setShowBrother, 1)
|
||||
.with(OrgChartNodeVo::setShowChildren, 1)
|
||||
.endSet();
|
||||
}
|
||||
if (!showPointOrAll.isShowType()) {
|
||||
item.setType(-1);
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
return Util.listToTree(orgChartNodeVoList, OrgChartNodeVo::getId,
|
||||
OrgChartNodeVo::getManagerId, OrgChartNodeVo::getChildren,
|
||||
OrgChartNodeVo::setChildren,
|
||||
parentId -> parentId == null || parentId <= 0)
|
||||
.stream()
|
||||
.peek(item -> item.setIsRoot(true))
|
||||
.peek(item -> recursionChildrenNums(item, 0))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>计算节点所有子节点的数量</h2>
|
||||
* <i>2022/12/3 17:55</i>
|
||||
* ******************************************
|
||||
*
|
||||
* @param chartNodeVo 节点对象
|
||||
* @return Integer 对应节点的所有子节点的数量
|
||||
* @author youHong.ai
|
||||
* ******************************************
|
||||
*/
|
||||
private Integer recursionChildrenNums(OrgChartNodeVo chartNodeVo, int n) {
|
||||
List<OrgChartNodeVo> children = chartNodeVo.getChildren();
|
||||
if (Objects.isNull(children) || children.size() == 0) {
|
||||
chartNodeVo.setChildrenNum(0);
|
||||
return 0;
|
||||
}
|
||||
n += children.size();
|
||||
for (OrgChartNodeVo child : children) {
|
||||
child.setChildrenNum(recursionChildrenNums(child, 0));
|
||||
n += child.getChildrenNum();
|
||||
}
|
||||
chartNodeVo.setChildrenNum(n);
|
||||
return n;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
package com.api.youhong.ai.pcn.organization.orgchart.vo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <h1>人员组织架构图节点VO对象</h1>
|
||||
*
|
||||
* <p>create: 2022-12-01 12:23</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@ToString
|
||||
public class OrgChartNodeVo {
|
||||
|
||||
/** 用户id */
|
||||
private Integer id;
|
||||
|
||||
/** 姓名 */
|
||||
private String name;
|
||||
|
||||
/** 上级 */
|
||||
private Integer managerId;
|
||||
|
||||
/** 部门Id */
|
||||
private Integer departmentId;
|
||||
|
||||
/** 部门名称 */
|
||||
private String department;
|
||||
|
||||
/** 所有上级 */
|
||||
private List<Integer> managerIds;
|
||||
|
||||
/** 职位名称 */
|
||||
private String job;
|
||||
|
||||
/** 职位id */
|
||||
private Integer jobId;
|
||||
|
||||
/** 用工类型 */
|
||||
private Integer type;
|
||||
|
||||
/** 是否是当前登陆用户的直接上级们 */
|
||||
private boolean currentParent;
|
||||
|
||||
/** 是否是当前登陆用户 */
|
||||
private boolean current;
|
||||
|
||||
/** 是否展示子节点 */
|
||||
private Integer showChildren;
|
||||
|
||||
/** 是否展示子节点兄弟节点 */
|
||||
private Integer showBrother;
|
||||
|
||||
/** 是否显示当前节点 */
|
||||
private Integer show;
|
||||
|
||||
/** 是否是根节点 */
|
||||
private Boolean isRoot;
|
||||
|
||||
/** 当前用户的所有下级的总数 */
|
||||
private Integer childrenNum;
|
||||
|
||||
/** 头像地址 */
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
private List<OrgChartNodeVo> children;
|
||||
}
|
|
@ -17,12 +17,18 @@ public class Builder<T> {
|
|||
|
||||
private Supplier<T> constructor;
|
||||
|
||||
private T target;
|
||||
|
||||
private List<Consumer<T>> propertiesInjects = new ArrayList<>();
|
||||
|
||||
private Builder(Supplier<T> constructor) {
|
||||
this.constructor = constructor;
|
||||
}
|
||||
|
||||
private Builder(T instance) {
|
||||
this.target = instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>获取建造者对象</h2>
|
||||
|
@ -35,6 +41,10 @@ public class Builder<T> {
|
|||
return new Builder<T>(constructor);
|
||||
}
|
||||
|
||||
public static <T> Builder<T> startSet(T instance) {
|
||||
return new Builder<T>(instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h2>设置值方法</h2>
|
||||
*
|
||||
|
@ -56,11 +66,26 @@ public class Builder<T> {
|
|||
* @return 目标对象
|
||||
*/
|
||||
public T build() {
|
||||
T instance = this.constructor.get();
|
||||
T instance;
|
||||
if (this.target == null) {
|
||||
instance = this.constructor.get();
|
||||
} else {
|
||||
instance = target;
|
||||
}
|
||||
this.propertiesInjects.forEach(inject -> inject.accept(instance));
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void endSet() {
|
||||
T instance;
|
||||
if (this.target == null) {
|
||||
instance = this.constructor.get();
|
||||
} else {
|
||||
instance = target;
|
||||
}
|
||||
this.propertiesInjects.forEach(inject -> inject.accept(instance));
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PropertiesInject<T, V> {
|
||||
void accept(T setFun, V value);
|
||||
|
|
|
@ -308,6 +308,24 @@ public class DealWithMapping extends ToolUtil {
|
|||
return rootList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <h2>方法重载 通过主表数据map转为请求参数</h2>
|
||||
*
|
||||
* @param mainMap 主表数据集合
|
||||
* @param requestMappingConfig 配置树
|
||||
* @return 请求参数
|
||||
*/
|
||||
public Map<String, Object> getRequestParam(Map<String, Object> mainMap, RequestMappingConfig requestMappingConfig) {
|
||||
this.fileInputStreams.clear();
|
||||
this.multipartFileList.clear();
|
||||
this.fileNames.clear();
|
||||
Map<String, Object> requestParam = new HashMap<>();
|
||||
List<MappingDetail> configDetail = requestMappingConfig.getConfigDetail();
|
||||
this.objValueDeal(mainMap, null, configDetail, requestParam);
|
||||
return requestParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析请求参数配置树,转换成请求参数
|
||||
*
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package weaver.youhong.ai.xinbake.schedule.hrmresource;
|
||||
|
||||
import aiyh.utils.Util;
|
||||
import aiyh.utils.action.CusBaseCronJob;
|
||||
import org.apache.log4j.Logger;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
import weaver.youhong.ai.xinbake.schedule.hrmresource.mapper.UpdateManagerIdMapper;
|
||||
|
||||
/**
|
||||
* <h1>更新人员组织架构的上级Id</h1>
|
||||
*
|
||||
* <p>create: 2022-12-04 13:49</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
public class UpdateManagerId extends CusBaseCronJob {
|
||||
|
||||
|
||||
private final UpdateManagerIdMapper mapper = Util.getMapper(UpdateManagerIdMapper.class);
|
||||
|
||||
|
||||
@Override
|
||||
public void runCode() {
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package weaver.youhong.ai.xinbake.schedule.hrmresource.mapper;
|
||||
|
||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
||||
|
||||
/**
|
||||
* <h1>更新人员组织架构上级id数据库操作</h1>
|
||||
*
|
||||
* <p>create: 2022-12-04 13:50</p>
|
||||
*
|
||||
* @author youHong.ai
|
||||
*/
|
||||
|
||||
@SqlMapper
|
||||
public interface UpdateManagerIdMapper {
|
||||
}
|
|
@ -5,12 +5,15 @@ import aiyh.utils.httpUtil.ResponeVo;
|
|||
import aiyh.utils.httpUtil.util.HttpUtils;
|
||||
import basetest.BaseTest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.service.OrgChartService;
|
||||
import com.api.youhong.ai.pcn.organization.orgchart.vo.OrgChartNodeVo;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import ebu7common.youhong.ai.bean.Builder;
|
||||
import ebu7common.youhong.ai.sftp.SftpConnectUtil;
|
||||
import org.junit.Test;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.GCONST;
|
||||
import weaver.hrm.User;
|
||||
import weaver.xiao.commons.config.entity.MultipartFile;
|
||||
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
||||
import weaver.xiao.commons.config.service.DealWithMapping;
|
||||
|
@ -188,4 +191,13 @@ public class TestOrganization extends BaseTest {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOrgChart() {
|
||||
User user = new User(88);
|
||||
OrgChartService orgChartService = new OrgChartService();
|
||||
List<OrgChartNodeVo> orgChartTree = orgChartService.getOrgChartTree(user);
|
||||
System.out.println(JSON.toJSONString(orgChartTree));
|
||||
}
|
||||
}
|
||||
|
|
3
常用信息.md
3
常用信息.md
|
@ -416,7 +416,8 @@ from workflow_nodebase nb
|
|||
> 维护人员:xuanran.wang
|
||||
|
||||
```java
|
||||
User logInUser=HrmUserVarify.getUser(request,response));
|
||||
//@Context HttpServletRequest request, @Context HttpServletResponse response
|
||||
User logInUser=HrmUserVarify.getUser(request,response);
|
||||
// 传入id会将此人员信息带出
|
||||
User user=new User(id);
|
||||
// 获取人员id
|
||||
|
|
Loading…
Reference in New Issue