From 6349b0ce04b1a8e7b72a4c3ae70db517002f1af7 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Thu, 20 Jun 2024 18:14:15 +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=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/entity/chart/ChartPO.java | 6 ++ .../mapper/resource/HrmResourceMapper.java | 2 + .../mapper/resource/HrmResourceMapper.xml | 10 +++ .../service/HrmResourceService.java | 2 +- .../service/impl/ChartServiceImpl.java | 75 ++++++++++++++++--- .../service/impl/HrmResourceServiceImpl.java | 11 ++- 6 files changed, 89 insertions(+), 17 deletions(-) diff --git a/src/com/engine/organization/entity/chart/ChartPO.java b/src/com/engine/organization/entity/chart/ChartPO.java index da8b4d17..c4fd3cea 100644 --- a/src/com/engine/organization/entity/chart/ChartPO.java +++ b/src/com/engine/organization/entity/chart/ChartPO.java @@ -47,6 +47,12 @@ public class ChartPO { // 部门层级 private int departmentDepth; + //账号类型 + private String accountType; + + //直接上级 + private String managerId; + // 在编数 private int onJobNum; // 编制数 diff --git a/src/com/engine/organization/mapper/resource/HrmResourceMapper.java b/src/com/engine/organization/mapper/resource/HrmResourceMapper.java index 0b0dfde1..5e6039bc 100644 --- a/src/com/engine/organization/mapper/resource/HrmResourceMapper.java +++ b/src/com/engine/organization/mapper/resource/HrmResourceMapper.java @@ -86,5 +86,7 @@ public interface HrmResourceMapper { */ List selectByDepartmentId(@Param("departmentId")Integer departmentId); + List selectByIdAndStatus(@Param("statusList") List statusList,@Param("departmentId")Integer departmentId); + } diff --git a/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml b/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml index 6d8072a3..8097bea6 100644 --- a/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml +++ b/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml @@ -453,4 +453,14 @@ from hrmresource where departmentid = #{departmentId} and status < 4 order by id + + \ No newline at end of file diff --git a/src/com/engine/organization/service/HrmResourceService.java b/src/com/engine/organization/service/HrmResourceService.java index a6a3fc7f..7cba3ccf 100644 --- a/src/com/engine/organization/service/HrmResourceService.java +++ b/src/com/engine/organization/service/HrmResourceService.java @@ -176,7 +176,7 @@ public interface HrmResourceService { * @param: [departmentId] * @return: java.util.Map */ - Map chartResourceList(Integer departmentId,String versionId,String dimension); + Map chartResourceList(Integer departmentId,String versionId,String dimension,String statusValue); } diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index 284dc846..9ed942ac 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -229,9 +229,27 @@ public class ChartServiceImpl extends Service implements ChartService { OrganizationAssert.isFalse(StringUtils.isBlank(rootId) || !rootId.startsWith("d_"), SystemEnv.getHtmlLabelName(547440,user.getLanguage())); String departmentId = rootId.split("_")[1]; String detauleType = Util.null2String(params.get("detauleType")); + + //人员性质 + String statusValue = Util.null2String(params.get("statusValue")); + + //显示模式 + String typeValue = Util.null2String(params.get("typeValue")); + //显示人员上下级 + boolean isManager = false; + //显示次账号 + boolean isBelongTo = true; + if (typeValue.contains("isManager")) { + isManager = true; + } + + if (!typeValue.contains("isBelongTo")) { + isBelongTo = false; + } + 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,statusValue); } @@ -304,19 +322,28 @@ public class ChartServiceImpl extends Service implements ChartService { // 遍历岗位、查询对应岗位下的人员 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 = ? and a.jobtitle = ?"; + sql = "select a.id,a.lastname as name,a.belongto ,a.companyworkyear,a.dsporder,a.accounttype from hrmresource a where a.status in ("+statusValue+") and a.departmentid = ? and a.jobtitle = ?"; } 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 = ? and a.jobtitle = ?"; + sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear,a.accounttype from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status in ("+statusValue+") and b.departmentid = ? and a.jobtitle = ?"; } } 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 a.jobtitleid = ? and versionid = " + versionId; + sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear,a.accounttype from jcl_chart_resource a where a.status in ("+statusValue+") and a.departmentid = ? and a.jobtitleid = ? and versionid = " + versionId; } + + if (!isBelongTo) { + sql += " and (a.accounttype = 0 or a.accounttype is null)"; + } + if (isRealTime) { + sql += " order by dsporder"; + } + for (ChartPO jobTitlePO : jobTitleList) { resourceNum = 0; rs.executeQuery(sql, departmentId, jobTitlePO.getFobjid()); String parentId = departmentId + "_" + jobTitlePO.getFobjid(); while (rs.next()) { - ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), parentId, rs.getString("belongto"), rs.getString("companyworkyear")); + String accountType = Util.null2String(rs.getString("accounttype")); + ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), parentId, rs.getString("belongto"), rs.getString("companyworkyear"),accountType); resourceNum++; dataList.add(chartPO); } @@ -326,23 +353,46 @@ public class ChartServiceImpl extends Service implements ChartService { } departmentChartPO.setHasChildren(CollectionUtils.isNotEmpty(jobTitleList) ? "1" : "0"); } else { - // 直接查询岗位下的人员 + // 直接查询部门下的人员 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 = ? "; + sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear,a.accounttype,a.managerid from hrmresource a where a.status in ("+statusValue+") 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 = ? "; + sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear,a.accounttype,b.managerid from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status in ("+statusValue+") 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; + sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear,a.accounttype,a.manager as managerid from jcl_chart_resource a where a.status in ("+statusValue+") and a.departmentid = ? and versionid = " + versionId; } + if (!isBelongTo) { + sql += " and (a.accounttype = 0 or a.accounttype is null)"; + } + if (isRealTime) { + sql += " order by dsporder"; + } + rs.executeQuery(sql, departmentId); + List personList = new ArrayList<>(); while (rs.next()) { - ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), rootId, rs.getString("belongto"), rs.getString("companyworkyear")); - dataList.add(chartPO); + String accountType = Util.null2String(rs.getString("accounttype")); + String managerId = Util.null2String(rs.getString("managerid")); + ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), rootId, rs.getString("belongto"), rs.getString("companyworkyear"),accountType); + chartPO.setManagerId(managerId); + personList.add(chartPO); departmentOnJob++; } + + if(isManager) { + personList.forEach(element -> personList.stream() + .filter(other -> element.getManagerId().equals(other.getId())) + .findFirst() + .ifPresent(matched -> element.setParentId(matched.getId()))); + } + + dataList.addAll(personList); + } + + departmentChartPO.setFonjob(departmentOnJob); @@ -370,7 +420,7 @@ public class ChartServiceImpl extends Service implements ChartService { * @param companyWorkYear 司龄 * @return */ - private ChartPO getResourceChartPO(String id, String name, String parentId, String belongTo, String companyWorkYear) { + private ChartPO getResourceChartPO(String id, String name, String parentId, String belongTo, String companyWorkYear,String accountType) { ChartPO chartPO = new ChartPO(); chartPO.setFtype("4"); chartPO.setFobjid(id); @@ -382,6 +432,7 @@ public class ChartServiceImpl extends Service implements ChartService { chartPO.setHasChildren("0"); chartPO.setBelongto(Util.null2String(belongTo)); chartPO.setCompanyWorkYear(companyWorkYear); + chartPO.setAccountType("1".equals(accountType) ? "次账号" : "主账号"); try { chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartPO.getId())); } catch (Exception e) { diff --git a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java index 6c664d03..0d0f18a7 100644 --- a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java +++ b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java @@ -462,7 +462,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic } @Override - public Map chartResourceList(Integer departmentId, String versionId, String dimension) { + public Map chartResourceList(Integer departmentId, String versionId, String dimension,String statusValue) { Map dataMap = new HashMap<>(); List resourceListColumns = getTableColumns(); List resourceChartPOS = new ArrayList<>(); @@ -471,10 +471,13 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic if ("0".equals(dimension)) { if ("0".equals(versionId)) { //当前数据 - resourceChartPOS = getHrmResourceMapper().selectByDepartmentId(departmentId); + List statusList = Arrays.stream(statusValue.split(",")) + .map(String::trim) + .collect(Collectors.toList()); + resourceChartPOS = getHrmResourceMapper().selectByIdAndStatus(statusList,departmentId); resourceChartVOS = ResourceChartBO.convertToVO(resourceChartPOS); } else { - rs.executeQuery("select resourceid,workcode,lastname,sex,department,subcompany,jobtitle,mobile from jcl_chart_resource where departmentid = ? and versionid = ?", departmentId, versionId); + rs.executeQuery("select resourceid,workcode,lastname,sex,department,subcompany,jobtitle,mobile from jcl_chart_resource where status in ("+statusValue+") and departmentid = ? and versionid = ?", departmentId, versionId); while (rs.next()) { ResourceChartVO build = ResourceChartVO.builder() .id((long) Util.getIntValue(rs.getString("resourceid"))) @@ -492,7 +495,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic } } else { rs.executeQuery("select h.id,h.workcode,h.lastname,h.sex,h.departmentid,h.subcompanyid1,h.jobtitle,h.status,h.mobile " + - " from hrmresourcevirtual v inner join hrmresource h on v.resourceid = h.id and v.virtualtype = ? and v.departmentid = ?", dimension, departmentId); + " from hrmresourcevirtual v inner join hrmresource h on v.resourceid = h.id and h.status in ("+statusValue+") and v.virtualtype = ? and v.departmentid = ?", dimension, departmentId); while (rs.next()) { ResourceChartPO build = ResourceChartPO.builder() .id((long) Util.getIntValue(rs.getString("id")))