From 3bf299afa4bace7c569b920acd4bf7aab33639dd Mon Sep 17 00:00:00 2001 From: dxfeng Date: Wed, 12 Jul 2023 16:13:08 +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 | 88 ++++++++++--------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index 9be33725..854821d1 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -234,7 +234,7 @@ public class ChartServiceImpl extends Service implements ChartService { if (hasVirtualFields) { sql = "select " + DEPARTMENT_ID + " as id,a.departmentname as name,fleader as bmfzr,isvirtual as isvitual from " + DEPARTMENT_TABLE + " a where a.id = '" + departmentId + "' and versionid = " + versionId; } else { - sql = "select " + DEPARTMENT_ID + " as id,a.departmentname as name,fleader as bmfzr from " + DEPARTMENT_TABLE + " a where a.id = '" + departmentId + "' and versionid = " + versionId; + sql = "select " + DEPARTMENT_ID + " as id,a.departmentname as name from " + DEPARTMENT_TABLE + " a where a.id = '" + departmentId + "' and versionid = " + versionId; } } rs.executeQuery(sql); @@ -278,38 +278,19 @@ public class ChartServiceImpl extends Service implements ChartService { // 遍历岗位、查询对应岗位下的人员 if (isRealTime) { if (isRealDimension) { - sql = "select a.id,a.lastname as name ,a.jobtitle ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? and a.jobtitle = ?"; + sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? and a.jobtitle = ?"; } else { - sql = "select a.id,a.lastname as name ,a.jobtitle ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? and a.jobtitle = ?"; + sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? and a.jobtitle = ?"; } } else { - //if (isRealDimension) { - // sql = "select a.id,a.lastname as name ,a.jobtitle ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? and a.jobtitle = ?"; - //} else { - // sql = "select a.id,a.lastname as name ,a.jobtitle ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? and a.jobtitle = ?"; - //} + sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear from jcl_chart_resource a where a.status < 4 and a.departmentid = ? and a.jobtitleid = ? and versionid = " + versionId; } for (ChartPO jobTitlePO : jobTitleList) { resourceNum = 0; rs.executeQuery(sql, departmentId, jobTitlePO.getFobjid()); + String parentId = departmentId + "_" + jobTitlePO.getFobjid(); while (rs.next()) { - String jobTitle = Util.null2String(rs.getString("jobtitle")); - ChartPO chartPO = new ChartPO(); - chartPO.setFtype("4"); - chartPO.setFobjid(rs.getString("id")); - chartPO.setId(chartPO.getFobjid()); - chartPO.setFname(rs.getString("name")); - // 岗位处理后的ID - chartPO.setParentId(departmentId + "_" + jobTitle); - chartPO.setExpand("0"); - chartPO.setHasChildren("0"); - chartPO.setBelongto(Util.null2String(rs.getString("belongto"))); - chartPO.setCompanyWorkYear(rs.getString("companyworkyear")); - try { - chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartPO.getId())); - } catch (Exception e) { - throw new RuntimeException(e); - } + ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), parentId, rs.getString("belongto"), rs.getString("companyworkyear")); resourceNum++; dataList.add(chartPO); } @@ -320,25 +301,18 @@ public class ChartServiceImpl extends Service implements ChartService { departmentChartPO.setHasChildren(CollectionUtils.isNotEmpty(jobTitleList) ? "1" : "0"); } else { // 直接查询岗位下的人员 - sql = "select a.id,a.lastname as name ,a.jobtitle ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? "; + if (isRealTime) { + if (isRealDimension) { + sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? "; + } else { + sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? "; + } + } else { + sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear from jcl_chart_resource a where a.status < 4 and a.departmentid = ? and versionid = " + versionId; + } rs.executeQuery(sql, departmentId); while (rs.next()) { - ChartPO chartPO = new ChartPO(); - chartPO.setFtype("4"); - chartPO.setFobjid(rs.getString("id")); - chartPO.setId(chartPO.getFobjid()); - chartPO.setFname(rs.getString("name")); - // 岗位处理后的ID - chartPO.setParentId(rootId); - chartPO.setExpand("0"); - chartPO.setHasChildren("0"); - chartPO.setBelongto(Util.null2String(rs.getString("belongto"))); - chartPO.setCompanyWorkYear(rs.getString("companyworkyear")); - try { - chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartPO.getId())); - } catch (Exception e) { - throw new RuntimeException(e); - } + ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), rootId, rs.getString("belongto"), rs.getString("companyworkyear")); dataList.add(chartPO); departmentOnJob++; } @@ -360,6 +334,36 @@ public class ChartServiceImpl extends Service implements ChartService { return rs.getString("recorddate"); } + /** + * 构建人员图谱元素 + * + * @param id 人员ID + * @param name 人员名称 + * @param parentId 父级ID + * @param belongTo 是否次账号 + * @param companyWorkYear 司龄 + * @return + */ + private ChartPO getResourceChartPO(String id, String name, String parentId, String belongTo, String companyWorkYear) { + ChartPO chartPO = new ChartPO(); + chartPO.setFtype("4"); + chartPO.setFobjid(id); + chartPO.setId(chartPO.getFobjid()); + chartPO.setFname(name); + // 岗位处理后的ID + chartPO.setParentId(parentId); + chartPO.setExpand("0"); + chartPO.setHasChildren("0"); + chartPO.setBelongto(Util.null2String(belongTo)); + chartPO.setCompanyWorkYear(companyWorkYear); + try { + chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartPO.getId())); + } catch (Exception e) { + throw new RuntimeException(e); + } + return chartPO; + } + /** * 获取历史顶部元素sql * -- 2.40.0.windows.1