From 7da6fd7997329874ba73cac3a0bb83cfeb4cca7a Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Wed, 15 Nov 2023 17:06:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9E=B6=E6=9E=84=E5=9B=BE?= =?UTF-8?q?=E4=B8=80=E7=BA=A7=E5=88=86=E9=83=A8=E5=88=86=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ChartServiceImpl.java | 15 ++++++-- .../service/impl/OrgChartServiceImpl.java | 36 +++++++------------ 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index cb6eb0ee..b6ea57f8 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -15,6 +15,7 @@ import com.engine.organization.util.OrganizationCommonUtil; import com.engine.organization.util.OrganizationDateUtil; import com.engine.organization.util.db.DBType; import com.engine.organization.util.db.MapperProxyFactory; +import com.engine.organization.util.detach.DetachUtil; import lombok.SneakyThrows; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -140,7 +141,6 @@ public class ChartServiceImpl extends Service implements ChartService { findChildData(topChartPO, dataList, Integer.parseInt(depth), id, hideDepartment); } - result.put("api_status", true); result.put("data", dataList); return result; @@ -1298,6 +1298,13 @@ public class ChartServiceImpl extends Service implements ChartService { } else { sql = "select a.id,a.subcompanyname as name,'1' as type,b.on_job_num,b.staff_num from " + SUB_COMPANY_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=1 where (a.canceled is null or a.canceled != '1') and (a.supsubcomid is null or a.supsubcomid = '0') and a.companyid = '" + fObjId + "'"; } + + // 一级分部数据分权处理 + if (isRealTime && user.getUID() != 1 && isRealDimension) { + DetachUtil detachUtil = new DetachUtil(user); + String ids = detachUtil.getJclRoleLevels(); + sql = sql + " and a.id in ("+ids+")"; + } break; case "1": if (hasVirtualFields) { @@ -1427,11 +1434,14 @@ public class ChartServiceImpl extends Service implements ChartService { filterAndAddData(currentList, chartPO, hideDepartment); //currentList.add(chartPO); } + + for (ChartPO chartPO : currentList) { if (inDepth(selectDepth, chartPO.getDepartmentDepth())) { findChildData(chartPO, dataList, selectDepth, versionId, hideDepartment); } } + dataList.addAll(currentList); } @@ -1671,12 +1681,13 @@ public class ChartServiceImpl extends Service implements ChartService { * @param hideDepartment */ private void filterAndAddData(List currentList, ChartPO chartPO, boolean hideDepartment) { + if (hideDepartment) { if ("2".equals(chartPO.getFtype())) { return; } - } + currentList.add(chartPO); } } diff --git a/src/com/engine/organization/service/impl/OrgChartServiceImpl.java b/src/com/engine/organization/service/impl/OrgChartServiceImpl.java index 8df27278..323ad9d6 100644 --- a/src/com/engine/organization/service/impl/OrgChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/OrgChartServiceImpl.java @@ -58,39 +58,27 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { item.put("companyname", rs.getString("companyname")); fclasslist.add(item); } - String sql = "select id, fnumber, fname, ftype from jcl_org_map where ftype in (0, 1) "; - // 分部分权过滤 - DetachUtil detachUtil = new DetachUtil(user); - if (detachUtil.isDETACH()) { - String jclRoleLevels = detachUtil.getJclRoleLevels(); - if (StringUtils.isNotBlank(jclRoleLevels)) { - sql = "select id, fnumber, fname, ftype from jcl_org_map where (ftype = 0 or (ftype = 1 and fobjid in(" + jclRoleLevels + "))) "; - } else { - sql = "select id, fnumber, fname, ftype from jcl_org_map where ftype = 0 "; - } - } - rs.executeQuery(sql + " and fdateend > " + DBType.get(new RecordSet().getDBType()).currentDate() + " order by ftype , id,fdateend desc "); - Set companySet = new HashSet<>(); - int ckey = 0; - while (rs.next()) { - OrgSelectItem item = new OrgSelectItem(); - item.setKey(ckey++); - item.setId(rs.getString("id")); - item.setFnumber(rs.getString("fnumber")); - item.setFname(rs.getString("fname")); - companySet.add(item); + List companyTree = new ArrayList<>(); + String 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") + " = '0'"; + // 一级分部数据分权处理 + String dimension = Util.null2String(request2Map.get("fclass")); + //版本id + String id = Util.null2String(request2Map.get("id")); + boolean isRealDimension = StringUtils.isBlank(dimension) || "0".equals(dimension); + boolean isRealTime = StringUtils.isBlank(id) || "0".equals(id); + if (isRealTime && user.getUID() != 1 && isRealDimension) { + DetachUtil detachUtil = new DetachUtil(user); + String ids = detachUtil.getJclRoleLevels(); + sql = sql + " and id in ("+ids+")"; } - List companyTree = new ArrayList<>(); - 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") + " = '0'"; rs.executeQuery(sql); 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("select id from hrmsubcompany where (canceled is null or canceled != '1') and supsubcomid = ?", rs.getString("id"))).build()); } result.put("api_status", true); result.put("fclasslist", fclasslist); - result.put("companylist", companySet); result.put("companyTree", companyTree); return result; }