分权开发
This commit is contained in:
parent
40f1f097e6
commit
0b3cd0641b
|
|
@ -48,8 +48,10 @@ public class CompBO {
|
|||
// 兼容MySQL
|
||||
usedIds.addAll(MapperProxyFactory.getProxy(CompMapper.class).listUsedIds());
|
||||
List<String> collect = Arrays.stream(String.join(",", usedIds).split(",")).collect(Collectors.toList());
|
||||
return dtoList.stream().peek(e -> {
|
||||
Set<Long> leafs = new HashSet<>();
|
||||
List<CompListDTO> collectTree = dtoList.stream().peek(e -> {
|
||||
List<CompListDTO> childList = collects.get(e.getId());
|
||||
leafs.add(e.getId());
|
||||
if (CollectionUtils.isNotEmpty(childList)) {
|
||||
e.setChildren(childList);
|
||||
e.setIsUsed(1);
|
||||
|
|
@ -60,7 +62,8 @@ public class CompBO {
|
|||
e.setIsUsed(0);
|
||||
}
|
||||
}
|
||||
}).filter(item -> null == item.getParentCompany() || 0 == item.getParentCompany()).collect(Collectors.toList());
|
||||
}).collect(Collectors.toList());
|
||||
return collectTree.stream().filter(item->!leafs.contains(item.getParentCompany())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<CompListDTO> buildCompDTOList(Collection<CompPO> list, List<CompPO> filterList) {
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public interface CompMapper {
|
|||
* @param id
|
||||
* @return
|
||||
*/
|
||||
CompPO listById(@Param("id") long id);
|
||||
CompPO listById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据UUID查询数据
|
||||
|
|
|
|||
|
|
@ -23,4 +23,6 @@ public interface ManagerDetachMapper {
|
|||
List<ManagerDetachPO> selectByIds(@Param("ids")Collection<Long> ids);
|
||||
|
||||
ManagerDetachPO getDetachById(@Param("id") Integer id);
|
||||
|
||||
List<ManagerDetachPO> getDetachListById(@Param("ecManager") Integer ecManager);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,4 +214,11 @@
|
|||
WHERE delete_type = 0
|
||||
AND id = #{id}
|
||||
</select>
|
||||
<select id="getDetachListById" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="baseColumns"/>
|
||||
from jcl_org_detach t
|
||||
WHERE delete_type = 0
|
||||
and ec_manager = #{ecManager}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -34,6 +34,7 @@ import com.engine.organization.thread.OrganizationSyncEc;
|
|||
import com.engine.organization.util.*;
|
||||
import com.engine.organization.util.coderule.CodeRuleUtil;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import com.engine.organization.util.detach.DetachUtil;
|
||||
import com.engine.organization.util.page.Column;
|
||||
import com.engine.organization.util.page.PageInfo;
|
||||
import com.engine.organization.util.page.PageUtil;
|
||||
|
|
@ -113,10 +114,13 @@ public class CompServiceImpl extends Service implements CompService {
|
|||
PageInfo<CompListDTO> pageInfos;
|
||||
String orderSql = PageInfoSortUtil.getSortSql(params.getSortParams());
|
||||
List<CompPO> allList = getCompMapper().list(orderSql);
|
||||
new DetachUtil(user.getUID()).filterCompanyList(allList);
|
||||
// 通过子级遍历父级元素
|
||||
if (filter) {
|
||||
// 根据条件获取元素
|
||||
List<CompPO> filterCompPOs = getCompMapper().listByFilter(compPO, orderSql);
|
||||
new DetachUtil(user.getUID()).filterCompanyList(filterCompPOs);
|
||||
|
||||
// 添加父级元素
|
||||
List<CompListDTO> compListDTOS = CompBO.buildCompDTOList(allList, filterCompPOs);
|
||||
List<CompListDTO> subList = PageUtil.subList(params.getCurrent(), params.getPageSize(), compListDTOS);
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ import com.engine.organization.thread.OrganizationSyncEc;
|
|||
import com.engine.organization.util.*;
|
||||
import com.engine.organization.util.coderule.CodeRuleUtil;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import com.engine.organization.util.detach.DetachUtil;
|
||||
import com.engine.organization.util.page.Column;
|
||||
import com.engine.organization.util.page.PageInfo;
|
||||
import com.engine.organization.util.page.PageUtil;
|
||||
|
|
@ -177,10 +178,12 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
PageInfo<DepartmentListDTO> pageInfos;
|
||||
String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams());
|
||||
List<DepartmentPO> allList = getDepartmentMapper().list(orderSql);
|
||||
new DetachUtil(user.getUID()).filterDepartmentList(allList);
|
||||
// 通过子级遍历父级元素
|
||||
if (filter) {
|
||||
// 根据条件获取元素
|
||||
List<DepartmentPO> filterDeptPOs = getDepartmentMapper().listByFilter(departmentPO, orderSql);
|
||||
new DetachUtil(user.getUID()).filterDepartmentList(filterDeptPOs);
|
||||
// 添加父级元素
|
||||
List<DepartmentListDTO> compListDTOS = DepartmentBO.buildDeptDTOList(allList, filterDeptPOs);
|
||||
List<DepartmentListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), compListDTOS);
|
||||
|
|
@ -835,11 +838,16 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
// 查询部门信息
|
||||
Long parentCompId = StringUtil.isEmpty(id) ? null : Long.parseLong(id);
|
||||
CompPO compBuild = CompPO.builder().compName(keyword).parentCompany(parentCompId).forbiddenTag(0).build();
|
||||
List<CompPO> allCompanys = getCompMapper().list("show_order");
|
||||
new DetachUtil(user.getUID()).filterCompanyList(allCompanys);
|
||||
List<CompPO> filterComps = getCompMapper().listByFilter(compBuild, "show_order");
|
||||
new DetachUtil(user.getUID()).filterCompanyList(filterComps);
|
||||
|
||||
Map<Long, CompPO> allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1));
|
||||
|
||||
Set<CompPO> builderComps = new HashSet<>();
|
||||
for (CompPO compPO : filterComps) {
|
||||
buildParentComps(compPO, builderComps);
|
||||
buildParentComps(compPO, builderComps,allMaps);
|
||||
}
|
||||
return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps));
|
||||
|
||||
|
|
@ -851,14 +859,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
* @param compPO
|
||||
* @param builderComps
|
||||
*/
|
||||
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps) {
|
||||
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps, Map<Long, CompPO> allMaps) {
|
||||
builderComps.add(compPO);
|
||||
if (SearchTreeUtil.isTop(compPO.getParentCompany())) {
|
||||
return;
|
||||
}
|
||||
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
|
||||
CompPO parentComp = allMaps.get(compPO.getParentCompany());
|
||||
if (null != parentComp && 0 == parentComp.getForbiddenTag()) {
|
||||
buildParentComps(parentComp, builderComps);
|
||||
buildParentComps(parentComp, builderComps, allMaps);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,10 +21,13 @@ import com.engine.organization.util.OrganizationFormItemUtil;
|
|||
import com.engine.organization.util.db.DBType;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import com.engine.organization.util.relation.EcHrmRelationUtil;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Author weaver_cl
|
||||
|
|
@ -118,6 +121,7 @@ public class ManagerDetachServiceImpl extends Service implements ManagerDetachSe
|
|||
.ecManager(param.getEcManager())
|
||||
.jclManager(getHrmResourceMapper().getJclResourceId(String.valueOf(param.getEcManager())).intValue())
|
||||
.ecRolelevel(param.getEcRolelevel())
|
||||
// TODO 遍历存储
|
||||
.jclRolelevel(EcHrmRelationUtil.getJclCompanyId(param.getEcRolelevel()) != null ? String.valueOf(EcHrmRelationUtil.getJclCompanyId(param.getEcRolelevel()).getId()) : null)
|
||||
.manageModule("组织管理")
|
||||
.creator((long)user.getUID())
|
||||
|
|
@ -156,4 +160,23 @@ public class ManagerDetachServiceImpl extends Service implements ManagerDetachSe
|
|||
}
|
||||
return sqlWhere;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询当前人员所辖分部JCL_ID
|
||||
* @param uId
|
||||
* @return
|
||||
*/
|
||||
public static List<Long> getJclRoleLevels(Integer uId) {
|
||||
List<Long> ecRoleLevels = new ArrayList<>();
|
||||
ManagerDetachMapper mangeDetachMapper = MapperProxyFactory.getProxy(ManagerDetachMapper.class);
|
||||
List<ManagerDetachPO> detachListById = mangeDetachMapper.getDetachListById(uId);
|
||||
for (ManagerDetachPO managerDetachPO : detachListById) {
|
||||
List<Long> ids = Stream.of(managerDetachPO.getJclRolelevel().split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
ecRoleLevels.addAll(ids);
|
||||
}
|
||||
}
|
||||
return ecRoleLevels;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
package com.engine.organization.util.detach;
|
||||
|
||||
import com.engine.organization.entity.company.po.CompPO;
|
||||
import com.engine.organization.entity.department.po.DepartmentPO;
|
||||
import com.engine.organization.entity.job.po.JobPO;
|
||||
import com.engine.organization.service.impl.ManagerDetachServiceImpl;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2022/10/28
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class DetachUtil {
|
||||
// private static final boolean IS_DETACH = "true".equals(new BaseBean().getPropValue("", ""));
|
||||
private boolean IS_DETACH = true;
|
||||
|
||||
private static List<Long> ecRoleLevels = null;
|
||||
|
||||
public DetachUtil(Integer uId) {
|
||||
ecRoleLevels = ManagerDetachServiceImpl.getJclRoleLevels(uId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分权配置过滤分部
|
||||
*/
|
||||
public void filterCompanyList(List<CompPO> companyList) {
|
||||
if (IS_DETACH && CollectionUtils.isNotEmpty(companyList)) {
|
||||
companyList.removeIf(item -> !ecRoleLevels.contains(item.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分权配置过滤分部
|
||||
*/
|
||||
public void filterDepartmentList(List<DepartmentPO> departmentList) {
|
||||
if (IS_DETACH && CollectionUtils.isNotEmpty(departmentList)) {
|
||||
departmentList.removeIf(item -> !ecRoleLevels.contains(item.getParentComp()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分权配置过滤分部
|
||||
*/
|
||||
public void filterJobList(List<JobPO> jobList) {
|
||||
if (IS_DETACH && CollectionUtils.isNotEmpty(jobList)) {
|
||||
jobList.removeIf(item -> !ecRoleLevels.contains(item.getParentComp()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -89,11 +89,15 @@ public class SearchTreeUtil {
|
|||
public static List<SearchTree> builderTreeMode(List<SearchTree> treeList) {
|
||||
List<SearchTree> sortedList = treeList.stream().sorted(Comparator.comparing(SearchTree::getOrderNum)).collect(Collectors.toList());
|
||||
Map<String, List<TreeNode>> collects = sortedList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
|
||||
return sortedList.stream().peek(e -> e.setSubs(collects.get(e.getId()))).peek(item -> {
|
||||
if (CollectionUtils.isNotEmpty(item.getSubs())) {
|
||||
item.setIsParent(true);
|
||||
Set<String> leafIds = new HashSet<>();
|
||||
List<SearchTree> collect = sortedList.stream().peek(e -> {
|
||||
e.setSubs(collects.get(e.getId()));
|
||||
leafIds.add(e.getId());
|
||||
if (CollectionUtils.isNotEmpty(e.getSubs())) {
|
||||
e.setIsParent(true);
|
||||
}
|
||||
}).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
|
||||
}).collect(Collectors.toList());
|
||||
return collect.stream().filter(item -> !leafIds.contains(item.getPid())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -119,7 +123,7 @@ public class SearchTreeUtil {
|
|||
if (CollectionUtils.isNotEmpty(e.getSubs())) {
|
||||
treeNodes.addAll(e.getSubs());
|
||||
}
|
||||
e.setSubs( new ArrayList<>(treeNodes));
|
||||
e.setSubs(new ArrayList<>(treeNodes));
|
||||
}).peek(item -> {
|
||||
if (CollectionUtils.isNotEmpty(item.getSubs())) {
|
||||
item.setIsParent(true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue