diff --git a/src/com/api/browser/service/impl/JobBrowserService.java b/src/com/api/browser/service/impl/JobBrowserService.java index c192a099..f1f74e25 100644 --- a/src/com/api/browser/service/impl/JobBrowserService.java +++ b/src/com/api/browser/service/impl/JobBrowserService.java @@ -19,12 +19,14 @@ import com.engine.organization.mapper.department.DepartmentMapper; 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.detach.DetachUtil; import com.engine.organization.util.tree.SearchTreeUtil; import org.apache.commons.lang.StringUtils; import weaver.conn.RecordSet; import weaver.general.Util; import java.util.*; +import java.util.stream.Collectors; /** * @author:dxfeng @@ -134,6 +136,9 @@ public class JobBrowserService extends BrowserService { * @return */ private List getCurrentTreeNode(SearchTreeParams params) { + // 分权 + DetachUtil detachUtil = new DetachUtil(user.getUID()); + List jclRoleLevelList = Arrays.asList(detachUtil.getJclRoleLevels().split(",")).stream().map(Long::parseLong).collect(Collectors.toList()); List treeNodes = new ArrayList<>(); if (StringUtils.isBlank(params.getId())) { // 集团总部 @@ -142,18 +147,32 @@ public class JobBrowserService extends BrowserService { treeNodes.add(topGroup); } else { // 分部存在下级的ID - List compHasSubs = MapperProxyFactory.getProxy(CompMapper.class).hasSubs(); + List compHasSubs; + if (detachUtil.isDETACH()) { + compHasSubs = MapperProxyFactory.getProxy(CompMapper.class).hasDetachSubs(jclRoleLevelList); + } else { + compHasSubs = MapperProxyFactory.getProxy(CompMapper.class).hasSubs(); + } // 部门存在下级的ID List hasSubDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).hasSubs(); if ("0".equals(params.getId())) { - List compList = MapperProxyFactory.getProxy(CompMapper.class).listParent(); + List compList; + if (detachUtil.isDETACH()) { + compList = MapperProxyFactory.getProxy(CompMapper.class).getCompsByIds(jclRoleLevelList); + detachUtil.filterCompanyList(compList); + }else{ + compList = MapperProxyFactory.getProxy(CompMapper.class).listParent(); + } // 获取顶层分部 compList.stream().sorted(Comparator.comparing(CompPO::getShowOrder)).forEach(item -> buildCompNodes(treeNodes, compHasSubs, item)); } else if ("1".equals(params.getType())) { // 当前节点下的元素 CompPO compBuild = CompPO.builder().parentCompany(Long.parseLong(params.getId())).forbiddenTag(0).deleteType(0).build(); List compList = MapperProxyFactory.getProxy(CompMapper.class).listByFilter(compBuild, "show_order"); + if (detachUtil.isDETACH()) { + detachUtil.filterCompanyList(compList); + } DepartmentPO departmentBuild = DepartmentPO.builder().parentComp(Long.parseLong(params.getId())).forbiddenTag(0).deleteType(0).build(); List departmentList = MapperProxyFactory.getProxy(DepartmentMapper.class).listByFilter(departmentBuild, "show_order"); compList.forEach(item -> buildCompNodes(treeNodes, compHasSubs, item)); diff --git a/src/com/engine/organization/mapper/comp/CompMapper.java b/src/com/engine/organization/mapper/comp/CompMapper.java index 5642ba8e..1f636132 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.java +++ b/src/com/engine/organization/mapper/comp/CompMapper.java @@ -32,6 +32,8 @@ public interface CompMapper { List hasSubs(); + List hasDetachSubs(@Param("companyIds") Collection companyIds); + /** * 根据搜索条件查询数据 * diff --git a/src/com/engine/organization/mapper/comp/CompMapper.xml b/src/com/engine/organization/mapper/comp/CompMapper.xml index 12d4a722..ad6b65d5 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.xml +++ b/src/com/engine/organization/mapper/comp/CompMapper.xml @@ -442,6 +442,25 @@ #{uuid} + update jcl_org_comp