diff --git a/src/com/api/browser/service/impl/JobBrowserService.java b/src/com/api/browser/service/impl/JobBrowserService.java index b7b4a7e5..d6a82a3d 100644 --- a/src/com/api/browser/service/impl/JobBrowserService.java +++ b/src/com/api/browser/service/impl/JobBrowserService.java @@ -128,7 +128,7 @@ public class JobBrowserService extends BrowserService { } } // 分权 - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); if (detachUtil.isDETACH()) { sqlWhere += " AND t.parent_comp in (" + detachUtil.getJclRoleLevels() + ")"; } @@ -143,7 +143,7 @@ public class JobBrowserService extends BrowserService { */ private List getCurrentTreeNode(SearchTreeParams params) { // 分权 - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); List jclRoleLevelList; if (StringUtils.isNotBlank(detachUtil.getJclRoleLevels())) { jclRoleLevelList = Arrays.stream(detachUtil.getJclRoleLevels().split(",")).map(Long::parseLong).collect(Collectors.toList()); diff --git a/src/com/engine/organization/entity/company/bo/CompBO.java b/src/com/engine/organization/entity/company/bo/CompBO.java index 98fd01c1..9281b193 100644 --- a/src/com/engine/organization/entity/company/bo/CompBO.java +++ b/src/com/engine/organization/entity/company/bo/CompBO.java @@ -110,7 +110,10 @@ public class CompBO { // 处理被引用数据 List usedIds = getCompMapper().listUsedId(); // 兼容MySQL - usedIds.addAll(getCompMapper().listUsedIds()); + List strings = getCompMapper().listUsedIds(); + if (CollectionUtils.isNotEmpty(strings)) { + usedIds.addAll(strings); + } List collect = Arrays.stream(String.join(",", usedIds).split(",")).collect(Collectors.toList()); Set leafs = new HashSet<>(); List collectTree = dtoList.stream().peek(e -> { diff --git a/src/com/engine/organization/entity/job/dto/JobListDTO.java b/src/com/engine/organization/entity/job/dto/JobListDTO.java index 6e8e74ab..0404210b 100644 --- a/src/com/engine/organization/entity/job/dto/JobListDTO.java +++ b/src/com/engine/organization/entity/job/dto/JobListDTO.java @@ -68,7 +68,7 @@ public class JobListDTO { //@TableTitle(title = "上级岗位", dataIndex = "parentJobName", key = "parentJobName") private String parentJobName; private Long parentJob; - private Integer parentComp; + private Integer ecCompany; /** * 是否关键岗 */ diff --git a/src/com/engine/organization/service/impl/CompServiceImpl.java b/src/com/engine/organization/service/impl/CompServiceImpl.java index 0a99ba57..60f25b97 100644 --- a/src/com/engine/organization/service/impl/CompServiceImpl.java +++ b/src/com/engine/organization/service/impl/CompServiceImpl.java @@ -74,13 +74,13 @@ public class CompServiceImpl extends Service implements CompService { String orderSql = PageInfoSortUtil.getSortSql(params.getSortParams(), " showorder "); List allList = getCompMapper().listAll(orderSql); - new DetachUtil(user.getUID()).filterCompanyList(allList); + new DetachUtil(user).filterCompanyList(allList); // 通过子级遍历父级元素 if (filter) { // 根据条件获取元素 List filterCompPOs = getCompMapper().listByFilter(companyPO, orderSql); - new DetachUtil(user.getUID()).filterCompanyList(filterCompPOs); + new DetachUtil(user).filterCompanyList(filterCompPOs); // 添加父级元素 List compListDTOS = CompBO.buildCompDTOList(allList, filterCompPOs); diff --git a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java index 24a91fba..67c8f8cb 100644 --- a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java +++ b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java @@ -133,12 +133,12 @@ public class DepartmentServiceImpl extends Service implements DepartmentService PageInfo pageInfos; String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams(), " showorder "); List allList = getDepartmentMapper().listAll(orderSql); - new DetachUtil(user.getUID()).filterDepartmentList(allList); + new DetachUtil(user).filterDepartmentList(allList); // 通过子级遍历父级元素 if (filter) { // 根据条件获取元素 List filterDeptPOs = getDepartmentMapper().listByFilter(departmentPO, orderSql); - new DetachUtil(user.getUID()).filterDepartmentList(filterDeptPOs); + new DetachUtil(user).filterDepartmentList(filterDeptPOs); // 添加父级元素 List compListDTOS = DepartmentBO.buildDeptDTOList(allList, filterDeptPOs); List subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), compListDTOS); @@ -705,9 +705,9 @@ public class DepartmentServiceImpl extends Service implements DepartmentService Integer parentCompId = StringUtil.isEmpty(id) ? null : Integer.parseInt(id); CompPO compBuild = CompPO.builder().subCompanyName(keyword).supSubComId(parentCompId).canceled(0).build(); List allCompanys = getCompMapper().listAll("showOrder"); - new DetachUtil(user.getUID()).filterCompanyList(allCompanys); + new DetachUtil(user).filterCompanyList(allCompanys); List filterComps = getCompMapper().listByFilter(compBuild, "showOrder"); - new DetachUtil(user.getUID()).filterCompanyList(filterComps); + new DetachUtil(user).filterCompanyList(filterComps); Map allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1)); diff --git a/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java b/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java index 02b959f3..a6d835a8 100644 --- a/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java +++ b/src/com/engine/organization/service/impl/ExportCommonServiceImpl.java @@ -29,7 +29,7 @@ public class ExportCommonServiceImpl extends Service implements ExportCommonServ public XSSFWorkbook resourceExport(List ids) { List hrmResourceVOS ; - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); if (detachUtil.isDETACH()) { if (StringUtils.isBlank(detachUtil.getJclRoleLevels())) { hrmResourceVOS = new ArrayList<>(); diff --git a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java index c83f6b63..ef98101e 100644 --- a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java +++ b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java @@ -473,7 +473,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic } // 分权查询 - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); String parentCompanyIds = detachUtil.getJclRoleLevels(); if (detachUtil.isDETACH()) { sqlWhere += " And t.subcompanyid1 in(" + parentCompanyIds + ")"; @@ -521,9 +521,9 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic */ private List buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild, JobPO jobBuild) { List jobPOS = getJobMapper().listPOsByFilter(jobBuild); - new DetachUtil(user.getUID()).filterJobList(jobPOS); + new DetachUtil(user).filterJobList(jobPOS); List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder"); - new DetachUtil(user.getUID()).filterDepartmentList(filterDeparts); + new DetachUtil(user).filterDepartmentList(filterDeparts); // 添加父级岗位 Set builderJobs = new HashSet<>(); for (JobPO jobPO : jobPOS) { @@ -553,7 +553,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic // 查询分部信息 List filterComps = getCompMapper().listByFilter(compBuild, "showorder"); - new DetachUtil(user.getUID()).filterCompanyList(filterComps); + new DetachUtil(user).filterCompanyList(filterComps); Set builderDeparts = new HashSet<>(); for (DepartmentPO departmentPO : filterDeparts) { buildParentDepts(departmentPO, builderDeparts); @@ -570,7 +570,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic } } List allCompanys = getCompMapper().listAll("showorder"); - new DetachUtil(user.getUID()).filterCompanyList(allCompanys); + new DetachUtil(user).filterCompanyList(allCompanys); Map allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1)); Set builderComps = new HashSet<>(); for (CompPO compPO : filterComps) { diff --git a/src/com/engine/organization/service/impl/JobServiceImpl.java b/src/com/engine/organization/service/impl/JobServiceImpl.java index 78c014ed..d54b60e2 100644 --- a/src/com/engine/organization/service/impl/JobServiceImpl.java +++ b/src/com/engine/organization/service/impl/JobServiceImpl.java @@ -156,12 +156,12 @@ public class JobServiceImpl extends Service implements JobService { PageInfo pageInfos; String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams(), " show_order "); List allList = getJobMapper().listNoFilter(orderSql); - new DetachUtil(user.getUID()).filterJobDTOList(allList); + new DetachUtil(user).filterJobDTOList(allList); // 通过子级遍历父级元素 if (filter) { // 根据条件获取元素 List filterJobPOs = getJobMapper().listByFilter(jobPO, orderSql); - new DetachUtil(user.getUID()).filterJobDTOList(allList); + new DetachUtil(user).filterJobDTOList(allList); // 添加父级元素 List jobListDTOS = JobBO.buildJobDTOList(allList, filterJobPOs); List subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), jobListDTOS); @@ -661,10 +661,10 @@ public class JobServiceImpl extends Service implements JobService { */ private List buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild) { List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder"); - new DetachUtil(user.getUID()).filterDepartmentList(filterDeparts); + new DetachUtil(user).filterDepartmentList(filterDeparts); // 查询分部信息 List filterComps = getCompMapper().listByFilter(compBuild, "showorder"); - new DetachUtil(user.getUID()).filterCompanyList(filterComps); + new DetachUtil(user).filterCompanyList(filterComps); Set builderDeparts = new HashSet<>(); for (DepartmentPO departmentPO : filterDeparts) { buildParentDepts(departmentPO, builderDeparts); @@ -679,7 +679,7 @@ public class JobServiceImpl extends Service implements JobService { } } List allCompanys = getCompMapper().listAll("showorder"); - new DetachUtil(user.getUID()).filterCompanyList(allCompanys); + new DetachUtil(user).filterCompanyList(allCompanys); Map allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1)); Set builderComps = new HashSet<>(); for (CompPO compPO : filterComps) { diff --git a/src/com/engine/organization/service/impl/OrgChartServiceImpl.java b/src/com/engine/organization/service/impl/OrgChartServiceImpl.java index 2d166f6b..24c5cbf4 100644 --- a/src/com/engine/organization/service/impl/OrgChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/OrgChartServiceImpl.java @@ -53,7 +53,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { String sql = "select id, fnumber, fname, ftype from jcl_org_map where ftype in (0, 1) "; // 分部分权过滤 - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); if (detachUtil.isDETACH()) { String jclRoleLevels = detachUtil.getJclRoleLevels(); if (StringUtils.isNotBlank(jclRoleLevels)) { @@ -165,7 +165,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { private void findCompanyItemByParantId(String id, int currentLevel, String level, RecordSet rs, List> list, String whereSql, boolean expand) { String sql = "select id, fname, ftype, fparentid,fobjid,fecid,fnumber,fisvitual from jcl_org_map " + whereSql; - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); if (detachUtil.isDETACH()) { if ("0".equals(id)) { sql += " and ftype = 1 and fobjid in(" + detachUtil.getJclRoleLevels() + ")"; @@ -373,7 +373,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { private void findUserItemByParantId(String id, int currentLevel, String level, RecordSet rs, List> list, String whereSql, boolean expand) { String sql = "select t.id, t.fname, t.ftype, t.fparentid, t.fobjparentid, t.fleader, t.fleadername, t.fleaderimg, t.fleaderjob, t.fplan, t.fonjob, t.fnumber, t.fobjid, t.fecid, t.fleaderlv, t.fleaderst, t.fisvitual from jcl_org_map t " + whereSql; - DetachUtil detachUtil = new DetachUtil(user.getUID()); + DetachUtil detachUtil = new DetachUtil(user); if (detachUtil.isDETACH()) { if ("0".equals(id)) { sql += " and t.ftype = 1 and t.fobjid in(" + detachUtil.getJclRoleLevels() + ")"; diff --git a/src/com/engine/organization/util/detach/DetachUtil.java b/src/com/engine/organization/util/detach/DetachUtil.java index c482fb33..8bdf643c 100644 --- a/src/com/engine/organization/util/detach/DetachUtil.java +++ b/src/com/engine/organization/util/detach/DetachUtil.java @@ -4,13 +4,15 @@ import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.po.DepartmentPO; import com.engine.organization.entity.job.dto.JobListDTO; import com.engine.organization.entity.job.po.JobPO; -import com.engine.organization.service.impl.ManagerDetachServiceImpl; -import com.weaver.general.BaseBean; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import weaver.hrm.User; +import weaver.hrm.moduledetach.ManageDetachComInfo; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @author:dxfeng @@ -18,18 +20,21 @@ import java.util.List; * @version: 1.0 */ public class DetachUtil { - private boolean DETACH = "true".equals(new BaseBean().getPropValue("hrmOrganization", "detach")); + private boolean DETACH; - private final List jclRoleLevels; + private List jclRoleLevels = new ArrayList<>(); - public DetachUtil(Integer uId) { - if (1 == uId) { + public DetachUtil(User user) { + ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo(); + DETACH = manageDetachComInfo.isUseManageDetach(); + if (1 == user.getUID()) { DETACH = false; } if (DETACH) { - jclRoleLevels = ManagerDetachServiceImpl.getJclRoleLevels(uId); - } else { - jclRoleLevels = new ArrayList<>(); + String detachableSubCompanyIds = manageDetachComInfo.getDetachableSubcompanyIds(user); + if (StringUtils.isNotBlank(detachableSubCompanyIds)) { + jclRoleLevels = Stream.of(detachableSubCompanyIds.split(",")).map(Integer::parseInt).collect(Collectors.toList()); + } } } @@ -56,7 +61,7 @@ public class DetachUtil { */ public void filterJobDTOList(List jobList) { if (DETACH && CollectionUtils.isNotEmpty(jobList)) { - jobList.removeIf(item -> !jclRoleLevels.contains(item.getParentComp())); + jobList.removeIf(item -> !jclRoleLevels.contains(item.getEcCompany())); } }