部门、岗位接口开发;代码合并

pull/27/MERGE^2
dxfeng 3 years ago
parent 33f5ec9458
commit 92953661ff

@ -5,8 +5,6 @@ import com.engine.organization.entity.comp.dto.CompListDTO;
import com.engine.organization.entity.comp.param.CompSearchParam;
import com.engine.organization.entity.comp.po.CompPO;
import com.engine.organization.entity.searchtree.SearchTree;
import com.engine.organization.mapper.comp.CompMapper;
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils;
import weaver.crm.Maint.SectorInfoComInfo;
import weaver.general.StringUtil;
@ -63,23 +61,6 @@ public class CompBO {
}
public static List<SearchTree> buildListToSearchTree(List<CompPO> comps) {
return comps.stream().map(item -> {
SearchTree tree = new SearchTree();
tree.setCanClick(true);
tree.setCanceled(false);
tree.setIcon("icon-coms-LargeArea");
tree.setId(item.getId().toString());
tree.setIsParent(MapperProxyFactory.getProxy(CompMapper.class).countChildByPID(item.getId()) > 0);
tree.setIsVirtual("0");
tree.setName(item.getCompName());
tree.setPid(null == item.getParentCompany() ? "0" : item.getParentCompany().toString());
tree.setSelected(false);
tree.setType("1");
return tree;
}).collect(Collectors.toList());
}
public static List<TreeNode> buildSetToSearchTree(Set<CompPO> comps) {
return comps.stream().map(item -> {
SearchTree tree = new SearchTree();

@ -63,7 +63,7 @@ public class DepartmentBO {
return Collections.emptyList();
}
List<SingleDeptTreeVO> singleDeptTreeVOS = departmentPOs.stream().map(e -> SingleDeptTreeVO.builder().id(e.getId()).deptName(e.getDeptName()).parentComp(e.getParentComp()).parentDept(e.getParentDept()).parentDeptName(e.getParentDept() == null ? "" : getDeptNameById(e.getParentDept().intValue())).deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())).build()).collect(Collectors.toList());
List<SingleDeptTreeVO> singleDeptTreeVOS = departmentPOs.stream().map(e -> SingleDeptTreeVO.builder().id(e.getId()).deptName(e.getDeptName()).parentComp(e.getParentComp()).parentDept(e.getParentDept()).parentDeptName(e.getParentDept() == null ? "" : getDeptNameById(e.getParentDept().intValue())).deptPrincipalName(getEmployeeNameById(e.getDeptPrincipal())).build()).collect(Collectors.toList());
//获取非一级部门
Map<Long, List<SingleDeptTreeVO>> collects = singleDeptTreeVOS.stream().filter(item -> !parentComp.equals(item.getParentComp()) && null != item.getParentDept()).collect(Collectors.groupingBy(SingleDeptTreeVO::getParentDept));
@ -73,22 +73,6 @@ public class DepartmentBO {
}).filter(item -> parentComp.equals(item.getParentComp())).collect(Collectors.toList());
}
public static List<SearchTree> buildListToSearchTree(List<DepartmentPO> departmentPOS) {
return departmentPOS.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(MapperProxyFactory.getProxy(DepartmentMapper.class).countChildByPID(item.getId()) > 0);
tree.setIsVirtual("0");
tree.setName(item.getDeptName());
tree.setPid(null == item.getParentDept() ? (null == item.getParentComp() ? "0" : item.getParentComp().toString()) : item.getParentDept().toString());
tree.setSelected(false);
tree.setType("2");
return tree;
}).collect(Collectors.toList());
}
public static List<SearchTree> buildSetToSearchTree(Set<DepartmentPO> departmentPOS) {
return departmentPOS.stream().map(item -> {
@ -97,7 +81,7 @@ public class DepartmentBO {
tree.setCanceled(false);
tree.setIcon("icon-coms-Branch");
tree.setId(item.getId().toString());
tree.setIsParent(MapperProxyFactory.getProxy(DepartmentMapper.class).countChildByPID(item.getId()) > 0);
tree.setIsParent(false);
tree.setIsVirtual("0");
tree.setName(item.getDeptName());
tree.setPid(null == item.getParentDept() ? "0" : item.getParentDept().toString());

@ -86,6 +86,14 @@ public interface CompMapper {
*/
List<Map<String, Object>> listCompsByIds(@Param("ids") Collection<Long> ids);
/**
* ID
* @param ids
* @return
*/
List<CompPO> getCompsByIds(@Param("ids") Collection<Long> ids);
/**
* /

@ -208,6 +208,7 @@
#{id}
</foreach>
</select>
<select id="listChildByPID" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
@ -222,6 +223,16 @@
WHERE t.delete_type = 0
and parent_company = #{pid}
</select>
<select id="getCompsByIds" resultMap="BaseResultMap">
select
<include refid="baseColumns"/>
from jcl_org_comp t
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</select>
<update id="updateForbiddenTagById" parameterType="com.engine.organization.entity.sequence.po.SequencePO">
update jcl_org_comp

@ -15,7 +15,7 @@ import java.util.Map;
**/
public interface DepartmentMapper {
List<DepartmentPO> getDeptListByCompId();
List<DepartmentPO> getDeptListByCompId(@Param("parentComp") Integer parentComp);
List<DepartmentPO> getDeptListByPId(@Param("PId") Long PId);

@ -35,9 +35,10 @@
</sql>
<select id="getDeptListByCompId" resultType="com.engine.organization.entity.department.po.DepartmentPO">
select t.id, t.dept_name, t.parent_dept, t.dept_principal,t.parent_dept,t.parent_comp
select t.id, t.dept_name, t.parent_dept, t.dept_principal, t.parent_dept, t.parent_comp
from jcl_org_dept t
where delete_type = 0
and parent_comp = #{parentComp}
</select>
<select id="getDeptListByPId" resultType="com.engine.organization.entity.department.po.DepartmentPO">

@ -81,7 +81,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
//1.查询分部下所有部门
//PageUtil.start(param.getCurrent(), param.getPageSize());
List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId();
List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).list();
PageInfo<DepartmentPO> pageInfo = new PageInfo<>(departmentPOS);
List<SingleDeptTreeVO> singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS,param.getParentComp());
PageInfo<SingleDeptTreeVO> pageInfos = new PageInfo<>(singleDeptTreeVOS, SingleDeptTreeVO.class);

@ -2,6 +2,7 @@ package com.engine.organization.service.impl;
import com.api.hrm.bean.TreeNode;
import com.engine.core.impl.Service;
import com.engine.organization.entity.QueryParam;
import com.engine.organization.entity.comp.bo.CompBO;
import com.engine.organization.entity.comp.po.CompPO;
import com.engine.organization.entity.department.bo.DepartmentBO;
@ -13,7 +14,6 @@ import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.service.JobService;
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.StringUtil;
import weaver.general.Util;
@ -51,37 +51,20 @@ public class JobServiceImpl extends Service implements JobService {
String keyword = params.getKeyword();
String type = Util.null2String(params.getType());
String id = params.getId();
// 没有搜索条件查询
if (StringUtil.isEmpty(keyword)) {
// 无条件,初始化树结构
if (StringUtil.isEmpty(type)) {
dataMap.put("companys", companyList);
SearchTree rootCompany = getTopGroup();
rootCompany.setSubs(getCompany("", ""));
rootCompany.setIsParent(CollectionUtils.isNotEmpty(rootCompany.getSubs()));
Map<String, Object> rootCompanyMap = new HashMap<>();
rootCompanyMap.put("rootCompany", rootCompany);
dataMap.put("datas", rootCompanyMap);
} else {
// 根据ID查询
dataMap.put("datas", getCompany(id, type));
}
} else {
if (StringUtil.isEmpty(type)) {
List<TreeNode> collect = getFilterCompany(id, type, keyword);
SearchTree rootCompany = getTopGroup();
rootCompany.setSubs(collect);
rootCompany.setIsParent(CollectionUtils.isNotEmpty(rootCompany.getSubs()));
Map<String, Object> rootCompanyMap = new HashMap<>();
rootCompanyMap.put("rootCompany", rootCompany);
dataMap.put("datas", rootCompanyMap);
dataMap.put("companys", companyList);
} else {
dataMap.put("datas", getFilterCompany(id, type, keyword));
}
List<TreeNode> treeDatas = getFilterCompany(id, type, keyword);
// 未点击,初始化树结构
if (StringUtil.isEmpty(type)) {
dataMap.put("companys", companyList);
SearchTree rootCompany = getTopGroup();
rootCompany.setSubs(treeDatas);
rootCompany.setIsParent(CollectionUtils.isNotEmpty(rootCompany.getSubs()));
Map<String, Object> rootCompanyMap = new HashMap<>();
rootCompanyMap.put("rootCompany", rootCompany);
dataMap.put("datas", rootCompanyMap);
} else {
// 根据ID查询
dataMap.put("datas", treeDatas);
}
return dataMap;
@ -99,9 +82,7 @@ public class JobServiceImpl extends Service implements JobService {
return;
}
DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getParentDept());
if (null != parentDept) {
buildParentDepts(parentDept, builderDeparts);
}
buildParentDepts(parentDept, builderDeparts);
}
/**
@ -116,9 +97,7 @@ public class JobServiceImpl extends Service implements JobService {
return;
}
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
if (null != parentComp) {
buildParentComps(parentComp, builderComps);
}
buildParentComps(parentComp, builderComps);
}
/**
@ -146,99 +125,78 @@ public class JobServiceImpl extends Service implements JobService {
}
/**
*
* keyword
*
* @param id
* @param type
* @param keyword
* @return
*/
private List<TreeNode> getCompany(String id, String type) {
List<TreeNode> compSearchTree = new ArrayList<>();
List<CompPO> compPOS;
if (StringUtils.isAllEmpty(id, type)) {
compPOS = getCompMapper().listParent();
compSearchTree.addAll(CompBO.buildListToSearchTree(compPOS));
} else {
if (TYPE_COMP.equals(type)) {
compPOS = getCompMapper().listChildByPID(id);
// 获取该分部下的部门
List<DepartmentPO> deptListByCompId = getDepartmentMapper().getDeptListByCompId(Integer.parseInt(id)).stream().filter(item -> null == item.getParentDept()).collect(Collectors.toList());
compSearchTree.addAll(CompBO.buildListToSearchTree(compPOS));
compSearchTree.addAll(DepartmentBO.buildListToSearchTree(deptListByCompId));
} else if (TYPE_DEPT.equals(type)) {
List<DepartmentPO> deptListByCompId = getDepartmentMapper().getDeptListByPId(Long.parseLong(id));
compSearchTree.addAll(DepartmentBO.buildListToSearchTree(deptListByCompId));
}
}
return compSearchTree;
}
private List<TreeNode> getFilterCompany(String id, String type, String keyword) {
List<TreeNode> compSearchTree = new ArrayList<>();
if (StringUtils.isAllEmpty(id, type)) {
// 通过分部、公司 组装数据
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();
buildTreeByCompAndDept(departmentBuild, compBuild, compSearchTree);
} else if (TYPE_DEPT.equals(type)) {
//
// 查询部门信息
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).build());
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).parentDept(Long.parseLong(id)).build());
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts);
}
List<SearchTree> deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
// 查询分部信息
List<CompPO> filterComps = getCompMapper().listByFilter(CompPO.builder().compName(keyword).build());
Set<CompPO> builderComps = new HashSet<>();
for (CompPO compPO : filterComps) {
buildParentComps(compPO, builderComps);
}
List<TreeNode> compTrees = builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees);
// 排序,设置是否为叶子节点
List<TreeNode> collect = compTrees.stream().peek(item ->
List<TreeNode> collect = deptTrees.stream().peek(item ->
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
compSearchTree.addAll(collect);
}
} else {
if (TYPE_COMP.equals(type)) { // 查询部门信息
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).parentComp(Long.parseLong(id)).build());
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts);
}
List<SearchTree> deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
// 查询分部信息
List<CompPO> filterComps = getCompMapper().listByFilter(CompPO.builder().compName(keyword).parentCompany(Long.parseLong(id)).build());
Set<CompPO> builderComps = new HashSet<>();
for (CompPO compPO : filterComps) {
buildParentComps(compPO, builderComps);
}
List<TreeNode> compTrees = builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees);
}
return compSearchTree;
}
// 排序,设置是否为叶子节点
List<TreeNode> collect = compTrees.stream().peek(item ->
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
compSearchTree.addAll(collect);
}
} else if (TYPE_DEPT.equals(type)) {
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).parentDept(Long.parseLong(id)).build());
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts);
}
List<SearchTree> deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
// 排序,设置是否为叶子节点
List<TreeNode> collect = deptTrees.stream().peek(item ->
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
compSearchTree.addAll(collect);
}
/**
*
*
* @param departmentBuild
* @param compBuild
* @param compSearchTree
*/
private void buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild, List<TreeNode> compSearchTree) {
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild);
// 查询分部信息
List<CompPO> filterComps = getCompMapper().listByFilter(compBuild);
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts);
}
List<SearchTree> deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
// 添加部门的上级分部
String parentCompS = deptTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
if (!StringUtil.isEmpty(parentCompS)) {
List<CompPO> compsByIds = getCompMapper().getCompsByIds(QueryParam.builder().ids(parentCompS).build().getIds());
if (CollectionUtils.isNotEmpty(compsByIds)) {
filterComps.addAll(compsByIds);
}
}
return compSearchTree;
Set<CompPO> builderComps = new HashSet<>();
for (CompPO compPO : filterComps) {
buildParentComps(compPO, builderComps);
}
List<TreeNode> compTrees = builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees);
// 排序,设置是否为叶子节点
List<TreeNode> collect = compTrees.stream().peek(item ->
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
compSearchTree.addAll(collect);
}
}
/**
@ -270,7 +228,11 @@ public class JobServiceImpl extends Service implements JobService {
*/
private List<SearchTree> builderTreeMode(List<SearchTree> treeList) {
Map<String, List<TreeNode>> collects = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
return treeList.stream().peek(e -> e.setSubs(collects.get(e.getId()))).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
return treeList.stream().peek(e -> e.setSubs(collects.get(e.getId()))).peek(item -> {
if (CollectionUtils.isNotEmpty(item.getSubs())) {
item.setIsParent(true);
}
}).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
}
/**
@ -294,6 +256,10 @@ public class JobServiceImpl extends Service implements JobService {
treeNodes.addAll(childMap.get(e.getId()));
}
e.setSubs(treeNodes);
}).peek(item -> {
if (CollectionUtils.isNotEmpty(item.getSubs())) {
item.setIsParent(true);
}
}).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
}

Loading…
Cancel
Save