人员树接口

pull/108/MERGE^2
dxfeng 3 years ago
parent d4e93eded4
commit b8f866e28b

@ -118,13 +118,17 @@ public class DepartmentBO {
return singleDeptTreeVOS.stream().peek(e -> e.setChildren(collects.get(e.getId()))).filter(item -> parentComp.equals(item.getParentComp())).collect(Collectors.toList());
}
public static List<SearchTree> buildSetToSearchTree(Set<DepartmentPO> departmentPOS) {
return buildSetToSearchTree(departmentPOS, true);
}
public static List<SearchTree> buildSetToSearchTree(Set<DepartmentPO> departmentPOS, boolean isLeaf) {
return departmentPOS.stream().map(item -> {
SearchTree tree = new SearchTree();
tree.setCanClick(true);
tree.setCanceled(false);
tree.setIcon("icon-coms-Branch");
tree.setIcon(isLeaf ? "icon-coms-Branch" : "icon-coms-LargeArea");
tree.setId(item.getId().toString());
tree.setIsParent(false);
tree.setIsVirtual("0");

@ -4,6 +4,7 @@ import com.engine.organization.entity.job.dto.JobListDTO;
import com.engine.organization.entity.job.param.JobSearchParam;
import com.engine.organization.entity.job.po.JobPO;
import com.engine.organization.entity.job.vo.SingleJobTreeVO;
import com.engine.organization.entity.searchtree.SearchTree;
import com.engine.organization.mapper.job.JobMapper;
import com.engine.organization.transmethod.JobTransMethod;
import com.engine.organization.util.db.MapperProxyFactory;
@ -142,4 +143,22 @@ public class JobBO {
}
}
public static List<SearchTree> buildSetToSearchTree(Set<JobPO> builderJobs) {
return builderJobs.stream().map(item -> {
SearchTree tree = new SearchTree();
tree.setCanClick(true);
tree.setCanceled(false);
tree.setIcon("icon-coms-Branch");
tree.setId(item.getId().toString());
tree.setIsParent(false);
tree.setIsVirtual("0");
tree.setName(item.getJobName());
tree.setPid(null == item.getParentJob() ? "0" : item.getParentJob().toString());
tree.setSelected(false);
tree.setType("3");
tree.setParentComp(null == item.getParentDept() ? "0" : item.getParentDept().toString());
return tree;
}).collect(Collectors.toList());
}
}

@ -52,6 +52,8 @@ public interface DepartmentMapper {
*/
List<Map<String, Object>> listDeptsByIds(@Param("ids") Collection<Long> ids);
List<DepartmentPO> getDeptsByIds(@Param("ids") Collection<Long> ids);
/**
* ID
*

@ -125,6 +125,16 @@
from JCL_ORG_STAFF
where delete_type = 0
</select>
<select id="getDeptsByIds" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_org_dept t
where delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</select>
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.department.po.DepartmentPO"
keyProperty="id"

@ -30,6 +30,13 @@ public interface JobMapper {
*/
List<JobListDTO> listNoFilter();
/**
*
* @param jobPO
* @return
*/
List<JobPO> listPOsByFilter(JobPO jobPO);
/**
*
*

@ -295,6 +295,31 @@
from jcl_org_job t
where delete_type = 0
</select>
<select id="listPOsByFilter" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
FROM jcl_org_job t
WHERE t.delete_type = 0
<include refid="likeSQL"/>
<if test=" parentComp != null ">
and t.parent_comp = #{parentComp}
</if>
<if test=" parentDept != null ">
and t.parent_dept = #{parentDept}
</if>
<if test=" sequenceId != null ">
and t.sequence_id = #{sequenceId}
</if>
<if test=" schemeId != null ">
and t.scheme_id = #{schemeId}
</if>
<if test=" isKey != null ">
and t.is_key = #{isKey}
</if>
<if test=" forbiddenTag != null ">
and t.forbidden_tag = #{forbiddenTag}
</if>
</select>
<sql id="likeSQL">

@ -0,0 +1,21 @@
package com.engine.organization.service;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import java.util.Map;
/**
* @author:dxfeng
* @createTime: 2022/06/20
* @version: 1.0
*/
public interface HrmResourceService {
/**
*
*
* @param params
* @return
*/
public Map<String, Object> getSearchTree(SearchTreeParams params);
}

@ -205,6 +205,8 @@ public class ExtServiceImpl extends Service implements ExtService {
}
map.put(key, value);
}
// 遍历Map
if (null != id) {
// 判断更新还是插入
int count = getExtMapper().countExtById(tableName, id);

@ -0,0 +1,213 @@
package com.engine.organization.service.impl;
import com.engine.core.impl.Service;
import com.engine.organization.entity.DeleteParam;
import com.engine.organization.entity.company.bo.CompBO;
import com.engine.organization.entity.company.po.CompPO;
import com.engine.organization.entity.department.bo.DepartmentBO;
import com.engine.organization.entity.department.po.DepartmentPO;
import com.engine.organization.entity.job.bo.JobBO;
import com.engine.organization.entity.job.po.JobPO;
import com.engine.organization.entity.searchtree.SearchTree;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.mapper.comp.CompMapper;
import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.mapper.job.JobMapper;
import com.engine.organization.service.HrmResourceService;
import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.tree.SearchTreeUtil;
import org.apache.commons.collections.CollectionUtils;
import weaver.general.StringUtil;
import weaver.general.Util;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author:dxfeng
* @createTime: 2022/06/20
* @version: 1.0
*/
public class HrmResourceServiceImpl extends Service implements HrmResourceService {
/**
*
* <p>
* 0
* 1
* 2
* 3
*/
private static final String TYPE_COMP = "1";
private static final String TYPE_DEPT = "2";
private static final String TYPE_JOB = "3";
private DepartmentMapper getDepartmentMapper() {
return MapperProxyFactory.getProxy(DepartmentMapper.class);
}
private CompMapper getCompMapper() {
return MapperProxyFactory.getProxy(CompMapper.class);
}
private JobMapper getJobMapper() {
return MapperProxyFactory.getProxy(JobMapper.class);
}
@Override
public Map<String, Object> getSearchTree(SearchTreeParams params) {
String keyword = params.getKeyword();
String id = params.getId();
String type = Util.null2String(params.getType());
List<SearchTree> treeList = getFilterCompany(id, type, keyword);
return SearchTreeUtil.getSearchTree(type, treeList);
}
public List<SearchTree> getFilterCompany(String id, String type, String keyword) {
List<SearchTree> searchTree = new ArrayList<>();
// 通过分部、公司 组装数据
if (StringUtil.isEmpty(id) || TYPE_COMP.equals(type)) {
Long parentCompId = StringUtil.isEmpty(id) ? null : Long.parseLong(id);
DepartmentPO departmentBuild = DepartmentPO.builder().deptName(keyword).parentComp(parentCompId).build();
CompPO compBuild = CompPO.builder().compName(keyword).parentCompany(parentCompId).build();
// 所属分部下的岗位
JobPO jobBuild = JobPO.builder().jobName(keyword).parentComp(parentCompId).build();
searchTree = buildTreeByCompAndDept(departmentBuild, compBuild, jobBuild);
} else if (TYPE_DEPT.equals(type)) {
Long parentDeptId = Long.parseLong(id);
DepartmentPO departmentBuild = DepartmentPO.builder().deptName(keyword).parentDept(parentDeptId).build();
// 所属分部下的岗位
JobPO jobBuild = JobPO.builder().jobName(keyword).parentDept(parentDeptId).build();
searchTree = buildTreeByDeptAndJob(departmentBuild, jobBuild);
} else if (TYPE_JOB.equals(type)) {
// 查询部门信息
List<JobPO> filterDeparts = getJobMapper().listPOsByFilter(JobPO.builder().jobName(keyword).parentJob(Long.parseLong(id)).build());
Set<JobPO> builderJobs = new HashSet<>();
for (JobPO departmentPO : filterDeparts) {
buildParentJobs(departmentPO, builderJobs);
}
searchTree = SearchTreeUtil.builderTreeMode(JobBO.buildSetToSearchTree(builderJobs));
}
return searchTree;
}
/**
*
*
* @param departmentBuild
* @param compBuild
* @param jobBuild
* @return
*/
private List<SearchTree> buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild, JobPO jobBuild) {
List<JobPO> jobPOS = getJobMapper().listPOsByFilter(jobBuild);
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild);
// 添加父级岗位
Set<JobPO> builderJobs = new HashSet<>();
for (JobPO jobPO : jobPOS) {
buildParentJobs(jobPO, builderJobs);
}
// 添加岗位的上级部门或分部
List<SearchTree> jobTrees = SearchTreeUtil.builderTreeMode(JobBO.buildSetToSearchTree(builderJobs));
String parentDeptS = jobTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
if (!StringUtil.isEmpty(parentDeptS)) {
List<DepartmentPO> compsByIds = getDepartmentMapper().getDeptsByIds(DeleteParam.builder().ids(parentDeptS).build().getIds());
if (CollectionUtils.isNotEmpty(compsByIds)) {
filterDeparts.addAll(compsByIds);
}
}
// 查询分部信息
List<CompPO> filterComps = getCompMapper().listByFilter(compBuild);
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts);
}
List<SearchTree> deptTrees = SearchTreeUtil.builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts,false));
// 添加部门的上级分部
String parentCompS = deptTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
if (!StringUtil.isEmpty(parentCompS)) {
List<CompPO> compsByIds = getCompMapper().getCompsByIds(DeleteParam.builder().ids(parentCompS).build().getIds());
if (CollectionUtils.isNotEmpty(compsByIds)) {
filterComps.addAll(compsByIds);
}
}
Set<CompPO> builderComps = new HashSet<>();
for (CompPO compPO : filterComps) {
buildParentComps(compPO, builderComps);
}
List<SearchTree> searchTrees = SearchTreeUtil.builderTreeMode(deptTrees, jobTrees);
return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps), searchTrees);
}
private List<SearchTree> buildTreeByDeptAndJob(DepartmentPO departmentBuild, JobPO jobBuild) {
List<JobPO> jobPOS = getJobMapper().listPOsByFilter(jobBuild);
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild);
// 添加父级岗位
Set<JobPO> builderJobs = new HashSet<>();
for (JobPO jobPO : jobPOS) {
buildParentJobs(jobPO, builderJobs);
}
// 添加岗位的上级部门或分部
List<SearchTree> jobTrees = SearchTreeUtil.builderTreeMode(JobBO.buildSetToSearchTree(builderJobs));
String parentDeptS = jobTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
if (!StringUtil.isEmpty(parentDeptS)) {
List<DepartmentPO> compsByIds = getDepartmentMapper().getDeptsByIds(DeleteParam.builder().ids(parentDeptS).build().getIds());
if (CollectionUtils.isNotEmpty(compsByIds)) {
filterDeparts.addAll(compsByIds);
}
}
// 查询分部信息
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts);
}
return SearchTreeUtil.builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts,false), jobTrees);
}
private void buildParentJobs(JobPO jobPO, Set<JobPO> builderJobs) {
builderJobs.add(jobPO);
if (SearchTreeUtil.isTop(jobPO.getParentJob())) {
return;
}
JobPO parentJob = getJobMapper().getJobById(jobPO.getParentJob());
if (null != parentJob) {
buildParentJobs(parentJob, builderJobs);
}
}
/**
*
*
* @param departmentPO
* @param builderDeparts
*/
private void buildParentDepts(DepartmentPO departmentPO, Set<DepartmentPO> builderDeparts) {
builderDeparts.add(departmentPO);
if (SearchTreeUtil.isTop(departmentPO.getParentDept())) {
return;
}
DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getParentDept());
if (null != parentDept) {
buildParentDepts(parentDept, builderDeparts);
}
}
/**
*
*
* @param compPO
* @param builderComps
*/
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps) {
builderComps.add(compPO);
if (SearchTreeUtil.isTop(compPO.getParentCompany())) {
return;
}
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
if (null != parentComp) {
buildParentComps(parentComp, builderComps);
}
}
}
Loading…
Cancel
Save