diff --git a/src/com/engine/junchuang/service/OrgChartServiceImpl.java b/src/com/engine/junchuang/service/OrgChartServiceImpl.java index b8e2475..575b24b 100644 --- a/src/com/engine/junchuang/service/OrgChartServiceImpl.java +++ b/src/com/engine/junchuang/service/OrgChartServiceImpl.java @@ -37,7 +37,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { DetachUtil detachUtil = new DetachUtil(user); - if (detachUtil.isDETACH()) { + if (detachUtil.isDetach()) { String companyIds = detachUtil.getCompanyIds(); String departmentIds = detachUtil.getDepartmentIds(); if (StringUtils.isNotBlank(departmentIds)) { @@ -138,8 +138,9 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { for (String id : split) { String whereSql = userWhereSql(request2Map); String bmfzr = ""; - - if (!id.contains("_") && Integer.parseInt(id) > 100000000 && Integer.parseInt(id) < 200000000) { + if (id.contains("_")) { + whereSql += " and t.id != '" + id.split("_")[1] + "'"; + } else if (Integer.parseInt(id) > 100000000 && Integer.parseInt(id) < 200000000) { rs.executeQuery("select bmfzr from hrmdepartmentdefined where deptid =? ", Integer.parseInt(id) - 100000000); if (rs.next()) { bmfzr = rs.getString("bmfzr"); @@ -147,7 +148,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { } - if (detachUtil.isDETACH()) { + if (detachUtil.isDetach()) { if ("0".equals(id)) { whereSql += " and t.ftype = 1 and t.fobjid in(" + detachUtil.getCompanyIds() + ")"; } else { @@ -439,11 +440,12 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { manageDeptId = id; id = id.split("_")[0]; //sql += " and ftype = 3 "; + sql += " and t.id != '" + id.split("_")[1] + "'"; } DetachUtil detachUtil = new DetachUtil(user); - if (detachUtil.isDETACH()) { + if (detachUtil.isDetach()) { if ("0".equals(id)) { sql += " and t.ftype = 1 and t.fobjid in(" + detachUtil.getCompanyIds() + ")"; } else { diff --git a/src/com/engine/junchuang/util/detach/DetachUtil.java b/src/com/engine/junchuang/util/detach/DetachUtil.java index b48e8d0..f4614cf 100644 --- a/src/com/engine/junchuang/util/detach/DetachUtil.java +++ b/src/com/engine/junchuang/util/detach/DetachUtil.java @@ -15,37 +15,43 @@ import java.util.*; * @version: 1.0 */ public class DetachUtil { - private boolean DETACH = true; + private boolean detach = true; private final Set companyIds = new HashSet<>(); private final Set departmentIds = new HashSet<>(); public DetachUtil(User user) { if (1 == user.getUID() || user.isAdmin()) { - DETACH = false; + detach = false; } - if (DETACH) { + if (detach) { try { RecordSet rs = new RecordSet(); + // 查询建模表、添加相应的权限 + rs.executeQuery("select fbqx from uf_zzjgtqx where yh = ? ", user.getUID()); + if (rs.next()) { + String fbqx = rs.getString("fbqx"); + if (StringUtils.isNotBlank(fbqx)) { + String[] manageCompanyIds = fbqx.split(","); + for (String companyId : manageCompanyIds) { + rs.executeQuery("select id from hrmdepartment where subcompanyid1 = ? ", companyId); + while (rs.next()) { + getDetachDepartment(rs.getString("id")); + } + getDetachCompany(companyId); + } + } + } + + + // 拥有所辖部门及所在部门的权限 rs.executeQuery("select a.id, a.subcompanyid1 from hrmdepartment a inner join hrmdepartmentdefined b on a.id = b.deptid where a.id = ? or b.bmfzr = ? ", String.valueOf(user.getUserDepartment()), String.valueOf(user.getUID())); while (rs.next()) { String departmentId = rs.getString("id"); - String allSupDepartment = new DepartmentComInfo().getAllSupDepartment(departmentId); - if (StringUtils.isNotBlank(allSupDepartment)) { - List ids = Arrays.asList(allSupDepartment.split(",")); - departmentIds.addAll(ids); - } - ArrayList childDeptIds = new ArrayList<>(); - new DepartmentComInfo().getAllChildDeptByDepId(childDeptIds, departmentId); - departmentIds.addAll(childDeptIds); - departmentIds.add(departmentId); + getDetachDepartment(departmentId); + String subCompanyId = rs.getString("subcompanyid1"); - String allSupCompany = new SubCompanyComInfo().getAllSupCompany(subCompanyId); - if (StringUtils.isNotBlank(allSupCompany)) { - List ids = Arrays.asList(allSupCompany.split(",")); - companyIds.addAll(ids); - } - companyIds.add(subCompanyId); + getDetachCompany(subCompanyId); } } catch (Exception e) { throw new RuntimeException(e); @@ -53,8 +59,8 @@ public class DetachUtil { } } - public boolean isDETACH() { - return DETACH; + public boolean isDetach() { + return detach; } public String getCompanyIds() { @@ -70,4 +76,31 @@ public class DetachUtil { } return ""; } + + private void getDetachDepartment(String departmentId) throws Exception { + if (StringUtils.isBlank(departmentId)) { + return; + } + String allSupDepartment = new DepartmentComInfo().getAllSupDepartment(departmentId); + if (StringUtils.isNotBlank(allSupDepartment)) { + List ids = Arrays.asList(allSupDepartment.split(",")); + departmentIds.addAll(ids); + } + ArrayList childDeptIds = new ArrayList<>(); + new DepartmentComInfo().getAllChildDeptByDepId(childDeptIds, departmentId); + departmentIds.addAll(childDeptIds); + departmentIds.add(departmentId); + } + + private void getDetachCompany(String companyId) throws Exception { + if (StringUtils.isBlank(companyId)) { + return; + } + String allSupCompany = new SubCompanyComInfo().getAllSupCompany(companyId); + if (StringUtils.isNotBlank(allSupCompany)) { + List ids = Arrays.asList(allSupCompany.split(",")); + companyIds.addAll(ids); + } + companyIds.add(companyId); + } }