From 62b25d6a65140872239f883855f2a4d0c5d08b30 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Wed, 12 Jul 2023 17:00:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9E=B6=E6=9E=84=E5=9B=BE?= =?UTF-8?q?=EF=BC=8C=E5=9B=9E=E6=BA=AF=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ChartServiceImpl.java | 44 ++++++++----------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index 862ff2a4..34a8a033 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -131,10 +131,10 @@ public class ChartServiceImpl extends Service implements ChartService { String isVirtual = Util.null2String(params.get("fisvitual")); showVirtual = "1".equals(isVirtual); //版本id - String id = Util.null2String(params.get("id")); + String versionId = Util.null2String(params.get("id")); // 初始化表名 - initTableNameByClass(dimension, id); + initTableNameByClass(dimension, versionId); String ids = (String) params.get("ids"); List dataList = new ArrayList<>(); @@ -146,28 +146,17 @@ public class ChartServiceImpl extends Service implements ChartService { if (s.contains("_")) { String fObjId = s.split("_")[1]; if (s.startsWith("s")) { - if (hasVirtualFields) { - if (showVirtual) { - rs.executeQuery("select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid where (a.canceled is null or a.canceled != '1') and a.supsubcomid = '" + fObjId + "'" + - " union select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid where (a.canceled is null or a.canceled != '1') and (a.supdepid is null or a.supdepid = '0') and subcompanyid1 = '" + fObjId + "'"); - } else { - rs.executeQuery("select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid where (a.canceled is null or a.canceled != '1') and (b.fblx is null or b.fblx != '1') and a.supsubcomid = '" + fObjId + "'" + - " union select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid where (a.canceled is null or a.canceled != '1') and (a.supdepid is null or a.supdepid = '0') and (b.bmlx is null or b.bmlx != '1') and subcompanyid1 = '" + fObjId + "'"); - } + if (isRealTime) { + rs.executeQuery(getRealTimeChildSql("", "1", fObjId)); } else { - rs.executeQuery("select a.id,a.subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " a where (canceled is null or canceled != '1') and supsubcomid = '" + fObjId + "'" + - " union select a.id,a.departmentname as name,'2' as type from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and (supdepid is null or supdepid = '0') and subcompanyid1 = '" + fObjId + "'"); + rs.executeQuery(getLastTimeChildSql("", "1", fObjId, versionId)); } } else if (s.startsWith("d")) { - if (hasVirtualFields) { - if (showVirtual) { - rs.executeQuery("select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid where (a.canceled is null or a.canceled != '1') and supdepid = '" + fObjId + "'"); - } else { - rs.executeQuery("select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where (canceled is null or canceled != '1') and (b.bmlx is null or b.bmlx != '1') and a.supdepid = '" + fObjId + "'"); - } + if (isRealTime) { + rs.executeQuery(getRealTimeChildSql("", "2", fObjId)); } else { - rs.executeQuery("select a.id,a.departmentname as name,'2' as type from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and supdepid = '" + fObjId + "'"); + rs.executeQuery(getLastTimeChildSql("", "2", fObjId, versionId)); } } while (rs.next()) { @@ -208,7 +197,7 @@ public class ChartServiceImpl extends Service implements ChartService { String detauleType = Util.null2String(params.get("detauleType")); if (!"chart".equals(detauleType)) { // 展示列表模块 - return ServiceUtil.getService(HrmResourceServiceImpl.class, user).chartResourceList(Integer.parseInt(departmentId),versionId,dimension); + return ServiceUtil.getService(HrmResourceServiceImpl.class, user).chartResourceList(Integer.parseInt(departmentId), versionId, dimension); } @@ -257,7 +246,7 @@ public class ChartServiceImpl extends Service implements ChartService { // 查询部门下的岗位 if (isRealTime) { sql = "select a.id,a.jobtitlename as name from hrmjobtitles a inner join jcl_org_job b on a.id = b.ec_jobtitle where b.ec_department = '" + departmentId + "'"; - }else{ + } else { sql = "select jobid as id ,jobname as name from jcl_chart_job where departmentid = '" + departmentId + "' and versionid = " + versionId; } rs.executeQuery(sql); @@ -501,7 +490,7 @@ public class ChartServiceImpl extends Service implements ChartService { } else { sql = "select " + SUB_COMPANY_ID + " as id,a.subcompanyname as name,'1' as type from " + SUB_COMPANY_TABLE + " a where (a.canceled is null or a.canceled != '1') and (a.supsubcompanyid is null or a.supsubcompanyid = '0') and versionid = " + versionId; } - if(!isRealDimension){ + if (!isRealDimension) { sql += " and companyid = " + fObjId; } break; @@ -524,7 +513,7 @@ public class ChartServiceImpl extends Service implements ChartService { if (showVirtual) { sql = "select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where (a.canceled is null or a.canceled != '1') and supdepartmentid = '" + fObjId + "' and versionid = " + versionId; } else { - sql = "select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " where (canceled is null or canceled != '1') and (isvirtual is null or isvirtual != '1') and a.supdepartmentid = '" + fObjId + "' and versionid = " + versionId; + sql = "select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type ,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and (isvirtual is null or isvirtual != '1') and a.supdepartmentid = '" + fObjId + "' and versionid = " + versionId; } } else { sql = "select " + DEPARTMENT_ID + " as id,a.departmentname as name,'2' as type from " + DEPARTMENT_TABLE + " a where (canceled is null or canceled != '1') and supdepartmentid = '" + fObjId + "' and versionid = " + versionId; @@ -544,14 +533,14 @@ public class ChartServiceImpl extends Service implements ChartService { * @param dataList 所有元素集合 * @param selectDepth 所选部门层级 */ - private void findChildData(ChartPO topChartPO, List dataList, Integer selectDepth,String versionId) { + private void findChildData(ChartPO topChartPO, List dataList, Integer selectDepth, String versionId) { String fType = topChartPO.getFtype(); String fObjId = topChartPO.getFobjid(); String sql = ""; if (isRealTime) { sql = getRealTimeChildSql(sql, fType, fObjId); } else { - sql = getLastTimeChildSql(sql, fType, fObjId,versionId); + sql = getLastTimeChildSql(sql, fType, fObjId, versionId); } if (StringUtils.isNotBlank(sql)) { @@ -573,7 +562,7 @@ public class ChartServiceImpl extends Service implements ChartService { } for (ChartPO chartPO : currentList) { if (inDepth(selectDepth, chartPO.getDepartmentDepth())) { - findChildData(chartPO, dataList, selectDepth,versionId); + findChildData(chartPO, dataList, selectDepth, versionId); } } dataList.addAll(currentList); @@ -682,6 +671,9 @@ public class ChartServiceImpl extends Service implements ChartService { * @return 人员名称 */ private String getDepartmentLeader(String ids) { + if (!isRealTime) { + return ids; + } if (StringUtils.isBlank(ids)) { return ""; }