From 76b435cf8186db39e9d973386d702143e973c45b Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Tue, 19 Dec 2023 17:25:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9E=B6=E6=9E=84=E5=9B=BE?= =?UTF-8?q?=E5=88=86=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/OrgChartServiceImpl.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/com/engine/organization/service/impl/OrgChartServiceImpl.java b/src/com/engine/organization/service/impl/OrgChartServiceImpl.java index 323ad9d6..14c8b6b1 100644 --- a/src/com/engine/organization/service/impl/OrgChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/OrgChartServiceImpl.java @@ -98,8 +98,19 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { // 是否展示当前数据 boolean isSearchCurrent = StringUtils.isBlank(id) || "0".equals(id); String sql; + String judgeTreeLeafSql; if (isSearchCurrent) { sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompany where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = ? "; + boolean isRealDimension = StringUtils.isBlank(fclass) || "0".equals(fclass); + boolean isRealTime = StringUtils.isBlank(id) || "0".equals(id); + judgeTreeLeafSql = sql; + if (isRealTime && user.getUID() != 1 && isRealDimension) { + DetachUtil detachUtil = new DetachUtil(user); + String ids = detachUtil.getJclRoleLevels(); + if ("0".equals(subcompany)) { + sql = sql + " and id in ("+ids+")"; + } + } if (StringUtils.isNotBlank(fclass) && !"0".equals(fclass)) { sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompanyvirtual where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = ? and companyid = '" + fclass + "'"; } @@ -110,10 +121,11 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { } // 添加时间轴条件 sql += " and versionid = " + id; + judgeTreeLeafSql = sql; } rs.executeQuery(sql,subcompany); while (rs.next()) { - companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf(sql, rs.getString("id"))).build()); + companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf(judgeTreeLeafSql, rs.getString("id"))).build()); } result.put("companyTree", companyTree); return result;