保时捷人员组织架构后端代码编写
parent
9bf767afb5
commit
a54073c604
|
@ -36,6 +36,7 @@ DirectoryV2.xml
|
||||||
/lib/classbeanLib/ecology-dev-lib.jar
|
/lib/classbeanLib/ecology-dev-lib.jar
|
||||||
/lib/classbeanLib/web-inf-class-lib.jar
|
/lib/classbeanLib/web-inf-class-lib.jar
|
||||||
/lib/weaverLib/
|
/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,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;
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.api.youhong.ai.pcn.organization.orgchart.mapper;
|
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.Select;
|
||||||
import aiyh.utils.annotation.recordset.SqlMapper;
|
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.HrmResource;
|
||||||
|
@ -18,6 +19,23 @@ import java.util.List;
|
||||||
public interface OrgChartMapper {
|
public interface OrgChartMapper {
|
||||||
|
|
||||||
|
|
||||||
@Select("select * from hrmresource")
|
@Select("select hrm.id, " +
|
||||||
List<HrmResource> selectAll();
|
" hrm.messagerurl avatar," +
|
||||||
|
" hrm.lastname 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 or cus.SCOPEID = 3) " +
|
||||||
|
" inner join hrmdepartment dept on dept.id = hrm.DEPARTMENTID " +
|
||||||
|
"where hrm.status in (0, 1)")
|
||||||
|
List<HrmResource> selectAll(@ParamMapper("typeOfEmploymentFiled") String typeOfEmploymentField);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,4 +16,36 @@ import lombok.ToString;
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
public class HrmResource {
|
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;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
package com.api.youhong.ai.pcn.organization.orgchart.service;
|
package com.api.youhong.ai.pcn.organization.orgchart.service;
|
||||||
|
|
||||||
import aiyh.utils.Util;
|
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.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.vo.OrgChartNodeVo;
|
import com.api.youhong.ai.pcn.organization.orgchart.vo.OrgChartNodeVo;
|
||||||
|
import ebu7common.youhong.ai.bean.Builder;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>人员组织架构图逻辑处理</h1>
|
* <h1>人员组织架构图逻辑处理</h1>
|
||||||
|
@ -19,14 +28,99 @@ public class OrgChartService {
|
||||||
|
|
||||||
private final OrgChartMapper mapper = Util.getMapper(OrgChartMapper.class);
|
private final OrgChartMapper mapper = Util.getMapper(OrgChartMapper.class);
|
||||||
|
|
||||||
|
private final OrgChartMapStruct struct = OrgChartMapStruct.INSTANCE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取人员组织架构图数据</h2>
|
* <h2>获取人员组织架构图数据</h2>
|
||||||
*
|
*
|
||||||
* @param logInUser 当前登陆对象
|
* @param logInUser 当前登陆对象
|
||||||
* @return 组织架构图数据
|
* @return 组织架构图数据
|
||||||
|
* @author youHong.ai
|
||||||
*/
|
*/
|
||||||
public List<OrgChartNodeVo> getOrgChartTree(User logInUser) {
|
public List<OrgChartNodeVo> getOrgChartTree(User logInUser) {
|
||||||
int userId = logInUser.getUID();
|
int userId = logInUser.getUID();
|
||||||
return null;
|
String typeOfEmploymentField = Util.getCusConfigValue("typeOfEmploymentField");
|
||||||
|
Assert.notBlank(typeOfEmploymentField, "config [typeOfEmploymentField] is null or blank!");
|
||||||
|
List<HrmResource> hrmResourceList = mapper.selectAll(typeOfEmploymentField);
|
||||||
|
//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());
|
||||||
|
|
||||||
|
/* ******************* 转换dto为Vo并且设置根节点标识 ******************* */
|
||||||
|
List<OrgChartNodeVo> orgChartNodeVoList = hrmResourceDtoList.stream()
|
||||||
|
.map(struct::hrmResourceDtoToVo)
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,61 +18,57 @@ import java.util.List;
|
||||||
@ToString
|
@ToString
|
||||||
public class OrgChartNodeVo {
|
public class OrgChartNodeVo {
|
||||||
|
|
||||||
/**
|
/** 用户id */
|
||||||
* 人员id
|
|
||||||
*/
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
/**
|
/** 姓名 */
|
||||||
* 人员姓名
|
|
||||||
*/
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/** 上级 */
|
||||||
* 人员头像
|
private Integer managerId;
|
||||||
*/
|
|
||||||
private String avatar;
|
|
||||||
|
|
||||||
/**
|
/** 部门Id */
|
||||||
* 人员部门
|
private Integer departmentId;
|
||||||
*/
|
|
||||||
|
/** 部门名称 */
|
||||||
private String department;
|
private String department;
|
||||||
|
|
||||||
/**
|
/** 所有上级 */
|
||||||
* 人员职位
|
private List<Integer> managerIds;
|
||||||
*/
|
|
||||||
|
/** 职位名称 */
|
||||||
private String job;
|
private String job;
|
||||||
|
|
||||||
/**
|
/** 职位id */
|
||||||
* 人员国籍类型
|
private Integer jobId;
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
/**
|
/** 用工类型 */
|
||||||
* 是否展示
|
private Integer type;
|
||||||
*/
|
|
||||||
private Integer show;
|
|
||||||
|
|
||||||
/**
|
/** 是否是当前登陆用户的直接上级们 */
|
||||||
* 是否展示下级兄弟
|
private boolean currentParent;
|
||||||
*/
|
|
||||||
private Integer showBrother;
|
|
||||||
|
|
||||||
/**
|
/** 是否是当前登陆用户 */
|
||||||
* 是否是当前的登陆人员
|
|
||||||
*/
|
|
||||||
private boolean current;
|
private boolean current;
|
||||||
|
|
||||||
/**
|
/** 是否展示子节点 */
|
||||||
* 是否是当前登陆人员的直属上级
|
|
||||||
*/
|
|
||||||
private boolean currenParent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否展示子节点
|
|
||||||
*/
|
|
||||||
private Integer showChildren;
|
private Integer showChildren;
|
||||||
|
|
||||||
|
/** 是否展示子节点兄弟节点 */
|
||||||
|
private Integer showBrother;
|
||||||
|
|
||||||
|
/** 是否显示当前节点 */
|
||||||
|
private Integer show;
|
||||||
|
|
||||||
|
/** 是否是根节点 */
|
||||||
|
private Boolean isRoot;
|
||||||
|
|
||||||
|
/** 当前用户的所有下级的总数 */
|
||||||
|
private Integer childrenNum;
|
||||||
|
|
||||||
|
/** 头像地址 */
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子节点
|
* 子节点
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,12 +17,18 @@ public class Builder<T> {
|
||||||
|
|
||||||
private Supplier<T> constructor;
|
private Supplier<T> constructor;
|
||||||
|
|
||||||
|
private T target;
|
||||||
|
|
||||||
private List<Consumer<T>> propertiesInjects = new ArrayList<>();
|
private List<Consumer<T>> propertiesInjects = new ArrayList<>();
|
||||||
|
|
||||||
private Builder(Supplier<T> constructor) {
|
private Builder(Supplier<T> constructor) {
|
||||||
this.constructor = constructor;
|
this.constructor = constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Builder(T instance) {
|
||||||
|
this.target = instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>获取建造者对象</h2>
|
* <h2>获取建造者对象</h2>
|
||||||
|
@ -35,6 +41,10 @@ public class Builder<T> {
|
||||||
return new Builder<T>(constructor);
|
return new Builder<T>(constructor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> Builder<T> startSet(T instance) {
|
||||||
|
return new Builder<T>(instance);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h2>设置值方法</h2>
|
* <h2>设置值方法</h2>
|
||||||
*
|
*
|
||||||
|
@ -56,11 +66,26 @@ public class Builder<T> {
|
||||||
* @return 目标对象
|
* @return 目标对象
|
||||||
*/
|
*/
|
||||||
public T build() {
|
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));
|
this.propertiesInjects.forEach(inject -> inject.accept(instance));
|
||||||
return 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
|
@FunctionalInterface
|
||||||
public interface PropertiesInject<T, V> {
|
public interface PropertiesInject<T, V> {
|
||||||
void accept(T setFun, V value);
|
void accept(T setFun, V value);
|
||||||
|
|
|
@ -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 aiyh.utils.httpUtil.util.HttpUtils;
|
||||||
import basetest.BaseTest;
|
import basetest.BaseTest;
|
||||||
import com.alibaba.fastjson.JSON;
|
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 com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import ebu7common.youhong.ai.bean.Builder;
|
import ebu7common.youhong.ai.bean.Builder;
|
||||||
import ebu7common.youhong.ai.sftp.SftpConnectUtil;
|
import ebu7common.youhong.ai.sftp.SftpConnectUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import weaver.conn.RecordSet;
|
import weaver.conn.RecordSet;
|
||||||
import weaver.general.GCONST;
|
import weaver.general.GCONST;
|
||||||
|
import weaver.hrm.User;
|
||||||
import weaver.xiao.commons.config.entity.MultipartFile;
|
import weaver.xiao.commons.config.entity.MultipartFile;
|
||||||
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
import weaver.xiao.commons.config.entity.RequestMappingConfig;
|
||||||
import weaver.xiao.commons.config.service.DealWithMapping;
|
import weaver.xiao.commons.config.service.DealWithMapping;
|
||||||
|
@ -188,4 +191,13 @@ public class TestOrganization extends BaseTest {
|
||||||
e.printStackTrace();
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue