From fca321abeb82e9ec45f164970338e4dd060a94f8 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Wed, 24 Apr 2024 16:46:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E6=B5=B7=E4=B8=AD=E8=BF=9C=E9=87=8D?= =?UTF-8?q?=E5=B7=A5=E7=BB=84=E7=BB=87=E6=9E=B6=E6=9E=84=E5=9B=BE=E5=BC=80?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/entity/chart/ChartPO.java | 6 + .../chart/params/ModeHrmResourceParam.java | 25 ++ .../hrmresource/po/ResourceChartPO.java | 2 + .../organization/service/ChartService.java | 9 + .../service/ModeHrmResourceService.java | 36 +++ .../service/impl/ChartServiceImpl.java | 149 +++++++--- .../impl/ModeHrmResourceServiceImpl.java | 277 ++++++++++++++++++ .../service/impl/OrgChartServiceImpl.java | 5 + .../organization/wrapper/OrgChartWrapper.java | 4 +- 9 files changed, 478 insertions(+), 35 deletions(-) create mode 100644 src/com/engine/organization/entity/chart/params/ModeHrmResourceParam.java create mode 100644 src/com/engine/organization/service/ModeHrmResourceService.java create mode 100644 src/com/engine/organization/service/impl/ModeHrmResourceServiceImpl.java diff --git a/src/com/engine/organization/entity/chart/ChartPO.java b/src/com/engine/organization/entity/chart/ChartPO.java index da8b4d17..0527361b 100644 --- a/src/com/engine/organization/entity/chart/ChartPO.java +++ b/src/com/engine/organization/entity/chart/ChartPO.java @@ -52,6 +52,12 @@ public class ChartPO { // 编制数 private int staffNum; + //人员所属当前部门 + private String localDeptName; + + //岗位名称 + private String jobTitle; + public String getId() { if (StringUtils.isNotBlank(ftype)) { switch (ftype) { diff --git a/src/com/engine/organization/entity/chart/params/ModeHrmResourceParam.java b/src/com/engine/organization/entity/chart/params/ModeHrmResourceParam.java new file mode 100644 index 00000000..839a4f43 --- /dev/null +++ b/src/com/engine/organization/entity/chart/params/ModeHrmResourceParam.java @@ -0,0 +1,25 @@ +package com.engine.organization.entity.chart.params; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author liang.cheng + * @Date 2024/4/24 2:04 PM + * @Description: TODO + * @Version 1.0 + */ + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ModeHrmResourceParam { + + private String departmentId; + + + +} diff --git a/src/com/engine/organization/entity/hrmresource/po/ResourceChartPO.java b/src/com/engine/organization/entity/hrmresource/po/ResourceChartPO.java index 63868f50..d89c0787 100644 --- a/src/com/engine/organization/entity/hrmresource/po/ResourceChartPO.java +++ b/src/com/engine/organization/entity/hrmresource/po/ResourceChartPO.java @@ -32,6 +32,8 @@ public class ResourceChartPO { private Integer jobTitle; + private String jobBrowser; + private Integer status; private String mobile; diff --git a/src/com/engine/organization/service/ChartService.java b/src/com/engine/organization/service/ChartService.java index 114d6226..949cac41 100644 --- a/src/com/engine/organization/service/ChartService.java +++ b/src/com/engine/organization/service/ChartService.java @@ -91,4 +91,13 @@ public interface ChartService { * @return: java.util.Map */ Map recordStatistics(StatisticsParam param); + + /** + * @Description: 部门详细数据(二开) + * @Author: liang.cheng + * @Date: 2024/4/24 11:41 AM + * @param: [request2Map] + * @return: java.util.Map + */ + Map getDepartmentNewDetail(Map request2Map); } diff --git a/src/com/engine/organization/service/ModeHrmResourceService.java b/src/com/engine/organization/service/ModeHrmResourceService.java new file mode 100644 index 00000000..bea83a3e --- /dev/null +++ b/src/com/engine/organization/service/ModeHrmResourceService.java @@ -0,0 +1,36 @@ +package com.engine.organization.service; + +import com.engine.organization.entity.chart.params.ModeHrmResourceParam; + +import java.util.Map; + +/** + * @Author liang.cheng + * @Date 2024/4/24 2:00 PM + * @Description: 上海中远重工建模人员档案 + * @Version 1.0 + */ +public interface ModeHrmResourceService { + + + /** + * @Description: 列表人员 + * @Author: liang.cheng + * @Date: 2024/4/24 2:05 PM + * @param: [modeHrmResourceParam] + * @return: java.util.Map + */ + Map chartResourceList(ModeHrmResourceParam modeHrmResourceParam); + + + /** + * @Description: 架构图人员 + * @Author: liang.cheng + * @Date: 2024/4/24 2:06 PM + * @param: [modeHrmResourceParam] + * @return: java.util.Map + */ + Map chartResourceChart(ModeHrmResourceParam modeHrmResourceParam); + + +} diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index bb9755b2..73f9483c 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -4,10 +4,12 @@ import cn.hutool.core.thread.ThreadUtil; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.organization.entity.chart.*; +import com.engine.organization.entity.chart.params.ModeHrmResourceParam; import com.engine.organization.entity.chart.params.StatisticsParam; import com.engine.organization.enums.ModuleTypeEnum; import com.engine.organization.mapper.hrmresource.SystemDataMapper; import com.engine.organization.service.ChartService; +import com.engine.organization.service.ModeHrmResourceService; import com.engine.organization.service.OrgChartService; import com.engine.organization.util.HasRightUtil; import com.engine.organization.util.OrganizationAssert; @@ -86,8 +88,7 @@ public class ChartServiceImpl extends Service implements ChartService { } // 根结点 - String root = Util.null2String(params.get("root")); - root = StringUtils.isBlank(root) ? "0" : root; + String root = new BaseBean().getPropValue("hrmOrganization", "subCompanyId"); // 维度 String dimension = Util.null2String(params.get("fclass")); @@ -104,6 +105,13 @@ public class ChartServiceImpl extends Service implements ChartService { boolean hideDepartment = "1".equals(Util.null2String(params.get("hidedept"))); + //一级部门节点 + String department = Util.null2String(params.get("department")); + + //隐藏班组 + boolean showClass = "1".equals(Util.null2String(params.get("showClass"))); + + // 初始化表名 initTableNameByClass(dimension, id); @@ -139,7 +147,7 @@ public class ChartServiceImpl extends Service implements ChartService { // 向下查询数据 if (null != topChartPO) { - findChildData(topChartPO, dataList, Integer.parseInt(depth), id, hideDepartment); + findChildData(topChartPO, dataList, Integer.parseInt(depth), id, hideDepartment,department,showClass); } result.put("api_status", true); @@ -162,6 +170,12 @@ public class ChartServiceImpl extends Service implements ChartService { String versionId = Util.null2String(params.get("id")); boolean hideDepartment = "1".equals(Util.null2String(params.get("hidedept"))); + //一级部门节点 + String department = Util.null2String(params.get("department")); + + //显示班组 + boolean showClass = "1".equals(Util.null2String(params.get("showClass"))); + // 初始化表名 initTableNameByClass(dimension, versionId); @@ -176,14 +190,14 @@ public class ChartServiceImpl extends Service implements ChartService { String fObjId = s.split("_")[1]; if (s.startsWith("s")) { if (isRealTime) { - rs.executeQuery(getRealTimeChildSql("", "1", fObjId)); + rs.executeQuery(getRealTimeChildSql("", "1", fObjId,department,showClass)); } else { rs.executeQuery(getLastTimeChildSql("", "1", fObjId, versionId)); } } else if (s.startsWith("d")) { if (isRealTime) { - rs.executeQuery(getRealTimeChildSql("", "2", fObjId)); + rs.executeQuery(getRealTimeChildSql("", "2", fObjId,department,showClass)); } else { rs.executeQuery(getLastTimeChildSql("", "2", fObjId, versionId)); } @@ -347,6 +361,29 @@ public class ChartServiceImpl extends Service implements ChartService { return result; } + + + + @Override + public Map getDepartmentNewDetail(Map params) { + + String rootId = Util.null2String(params.get("rootId")); + + String departmentId = rootId.split("_")[1]; + + ModeHrmResourceParam build = ModeHrmResourceParam.builder().departmentId(departmentId).build(); + + String detauleType = Util.null2String(params.get("detauleType")); + if (!"chart".equals(detauleType)) { + // 展示列表模块 + return ServiceUtil.getService(ModeHrmResourceServiceImpl.class, user).chartResourceList(build); + }else { + return ServiceUtil.getService(ModeHrmResourceServiceImpl.class, user).chartResourceChart(build + ); + } + } + + @Override public String selectVersionDate(String id) { RecordSet rs = new RecordSet(); @@ -470,22 +507,60 @@ public class ChartServiceImpl extends Service implements ChartService { RecordSet rs = new RecordSet(); List departmentTree = new ArrayList<>(); + List topDepartmentTree = new ArrayList<>(); String subCompany = Util.null2String(params.get("subcompany")); - String dimension = Util.null2String(params.get("fclass")); - String versionId = Util.null2String(params.get("id")); if (StringUtils.isBlank(subCompany)) { subCompany = "0"; } - String sql = getDepartmentTreeSql(versionId, dimension, subCompany); + + DBType dbType = DBType.get(new RecordSet().getDBType()); + // 根据分部查询顶级部门 + String sql = "select id as id, id as value, departmentname as title, subcompanyid1 as pId from hrmdepartment where (canceled is null or canceled != '1') and (supdepid is null or supdepid =0) and" + dbType.ifNull("subcompanyid1", "0") + " = " + subCompany; rs.executeQuery(sql); while (rs.next()) { - departmentTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).disabled(!rs.getString("id").startsWith("d")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf(versionId, dimension, rs.getString("id"))).build()); + topDepartmentTree.add( + CompanyTreePO.builder() + .id(rs.getString("id")) + .pId(rs.getString("pId")) + .disabled(false) + .value(rs.getString("value")) + .title(rs.getString("title")) + .isLeaf(true) + .build() + ); } - result.put("departmentTree", departmentTree); + + //只查询一级部门 +// if (CollectionUtils.isNotEmpty(topDepartmentTree)) { +// sql = "select id as id, id as value, departmentname as title, supdepid as pId from hrmdepartment where (canceled is null or canceled != '1') and " + dbType.ifNull("supdepid", "0") + " = ?"; +// for (CompanyTreePO department : topDepartmentTree) { +// getChildDepartment(department, sql, departmentTree); +// } +// } + + result.put("departmentTree", topDepartmentTree); result.put("api_status", true); return result; } + private void getChildDepartment(CompanyTreePO parentDepartment, String sql, List departmentTree) { + RecordSet rs = new RecordSet(); + rs.executeQuery(sql, parentDepartment.getId()); + while (rs.next()) { + CompanyTreePO build = CompanyTreePO.builder() + .id(rs.getString("id")) + .pId(rs.getString("pId")) + .disabled(false) + .value(rs.getString("value")) + .title(rs.getString("title")) + .isLeaf(true) + .build(); + getChildDepartment(build, sql, departmentTree); + parentDepartment.setLeaf(false); + } + departmentTree.add(parentDepartment); + } + @Override public Map getMovingTree(Map params) { RecordSet rs = new RecordSet(); @@ -625,6 +700,8 @@ public class ChartServiceImpl extends Service implements ChartService { return result; } + + /** * 生成人数 * @param stp @@ -1262,26 +1339,13 @@ public class ChartServiceImpl extends Service implements ChartService { * @return 查询SQL */ private String getRealTimeTopSql(String root, String dimension) { - if ("0".equals(root)) { - // 查询集团数据 - if (isRealDimension) { - // 查询实际集团表 - return "select id,companyname as name,'0' as type from " + COMPANY_TABLE; - } else { - // 查询其他维度集团信息 - return "select id,companyname as name,'0' as type from " + COMPANY_TABLE + " where id = '" + dimension + "'"; - } + // 查询集团数据 + if (isRealDimension) { + // 查询实际集团表 + return "select id,companyname as name,'0' as type from " + COMPANY_TABLE; } else { - if (hasVirtualFields) { - if (showVirtual) { - return "select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual,c.on_job_num,c.staff_num from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid left join jcl_org_onjob c on a.id=c.data_id and c.type=1 where a.id = '" + root + "' order by showorder,id"; - } else { - return "select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual,c.on_job_num,c.staff_num from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid left join jcl_org_onjob c on a.id=c.data_id and c.type=1 where a.id = '" + root + "' and (b.fblx is null or b.fblx!='1') order by showorder,id"; - - } - } else { - return "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.id = '" + root + "' order by a.showorder,a.id"; - } + // 查询其他维度集团信息 + return "select id,companyname as name,'0' as type from " + COMPANY_TABLE + " where id = '" + dimension + "'"; } } @@ -1293,7 +1357,7 @@ public class ChartServiceImpl extends Service implements ChartService { * @param fObjId 上级元素ID * @return 查询SQL */ - private String getRealTimeChildSql(String sql, String fType, String fObjId) { + private String getRealTimeChildSql(String sql, String fType, String fObjId,String department,boolean showClass) { if (StringUtils.isNotBlank(fType)) { switch (fType) { case "0": @@ -1307,6 +1371,10 @@ public class ChartServiceImpl extends Service implements ChartService { 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 + "'"; } + //中远重工二开 只能查看某一分部(非标分权无效) + String subCompanyId = new BaseBean().getPropValue("hrmOrganization", "subCompanyId"); + sql = sql + " and a.id = "+subCompanyId; + // 一级分部数据分权处理 if (isRealTime && user.getUID() != 1 && isRealDimension) { DetachUtil detachUtil = new DetachUtil(user); @@ -1315,6 +1383,7 @@ public class ChartServiceImpl extends Service implements ChartService { sql = sql + " and a.id in (" + ids + ")"; } } + break; case "1": if (hasVirtualFields) { @@ -1329,7 +1398,13 @@ public class ChartServiceImpl extends Service implements ChartService { sql = "select a.id,a.subcompanyname as name,'1' as type,showorder,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 (canceled is null or canceled != '1') and supsubcomid = '" + fObjId + "'" + " union select a.id,a.departmentname as name,'2' as type,showorder,b.on_job_num,b.staff_num from " + DEPARTMENT_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=2 where (canceled is null or canceled != '1') and (supdepid is null or supdepid = '0') and subcompanyid1 = '" + fObjId + "'"; } - break; + + //指定筛选一级部门节点数据 + if (StringUtils.isNotEmpty(department)) { + sql += " and a.id = "+department; + } + + break; case "2": if (hasVirtualFields) { if (showVirtual) { @@ -1340,6 +1415,12 @@ public class ChartServiceImpl extends Service implements ChartService { } else { sql = "select a.id,a.departmentname as name,'2' as type,b.on_job_num,b.staff_num from " + DEPARTMENT_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=2 where (canceled is null or canceled != '1') and supdepid = '" + fObjId + "'"; } + + //隐藏班组数据 + if (!showClass) { + sql += " and (b.sfbz is null or b.sfbz != '1')"; + } + break; default: break; @@ -1414,12 +1495,12 @@ public class ChartServiceImpl extends Service implements ChartService { * @param selectDepth 所选部门层级 * @param hideDepartment */ - private void findChildData(ChartPO topChartPO, List dataList, Integer selectDepth, String versionId, boolean hideDepartment) { + private void findChildData(ChartPO topChartPO, List dataList, Integer selectDepth, String versionId, boolean hideDepartment,String department,boolean showClass) { String fType = topChartPO.getFtype(); String fObjId = topChartPO.getFobjid(); String sql = ""; if (isRealTime) { - sql = getRealTimeChildSql(sql, fType, fObjId); + sql = getRealTimeChildSql(sql, fType, fObjId,department,showClass); } else { sql = getLastTimeChildSql(sql, fType, fObjId, versionId); } @@ -1448,7 +1529,7 @@ public class ChartServiceImpl extends Service implements ChartService { for (ChartPO chartPO : currentList) { if (inDepth(selectDepth, chartPO.getDepartmentDepth())) { - findChildData(chartPO, dataList, selectDepth, versionId, hideDepartment); + findChildData(chartPO, dataList, selectDepth, versionId, hideDepartment,department,showClass); } } diff --git a/src/com/engine/organization/service/impl/ModeHrmResourceServiceImpl.java b/src/com/engine/organization/service/impl/ModeHrmResourceServiceImpl.java new file mode 100644 index 00000000..2198475e --- /dev/null +++ b/src/com/engine/organization/service/impl/ModeHrmResourceServiceImpl.java @@ -0,0 +1,277 @@ +package com.engine.organization.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import com.engine.core.impl.Service; +import com.engine.organization.entity.chart.ChartPO; +import com.engine.organization.entity.chart.ResourceListColumns; +import com.engine.organization.entity.chart.params.ModeHrmResourceParam; +import com.engine.organization.entity.hrmresource.po.ResourceChartPO; +import com.engine.organization.entity.hrmresource.vo.ResourceChartVO; +import com.engine.organization.mapper.hrmresource.SystemDataMapper; +import com.engine.organization.service.ModeHrmResourceService; +import com.engine.organization.util.db.MapperProxyFactory; +import lombok.SneakyThrows; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.resource.ResourceComInfo; + +import java.util.*; + +/** + * @Author liang.cheng + * @Date 2024/4/24 2:01 PM + * @Description: uf_zsygrzbdd 正式员工档案 uf_qlwbrydngljmb 外部人员档案 + * @Version 1.0 + */ +public class ModeHrmResourceServiceImpl extends Service implements ModeHrmResourceService { + + + @Override + public Map chartResourceList(ModeHrmResourceParam param) { + Map dataMap = new HashMap<>(4); + List resourceListColumns = getTableColumns(); + List allSupDepartment = getAllSupDepartment(param.getDepartmentId()); + List resourceChartPOS = new ArrayList<>(); + + resourceChartPOS.addAll(selectNbPerson(allSupDepartment)); + resourceChartPOS.addAll(selectWbPerson(allSupDepartment)); + + + List resourceChartVOS = convertToVO(resourceChartPOS); + dataMap.put("columns", resourceListColumns); + dataMap.put("dataSource", resourceChartVOS); + return dataMap; + } + + @Override + public Map chartResourceChart(ModeHrmResourceParam param) { + List dataList = new ArrayList<>(); + String departmentId = param.getDepartmentId(); + RecordSet rs = new RecordSet(); + rs.executeQuery("select a.id,a.departmentname as name,b.bmfzr\n" + + "from hrmdepartment a left join hrmdepartmentdefined b on a.id = b.deptid \n" + + "where a.id = ?",param.getDepartmentId()); + + //部门 + ChartPO departmentChartPO = new ChartPO(); + if (rs.next()) { + String fLeader = Util.null2String(rs.getString("bmfzr")); + departmentChartPO.setFtype("2"); + departmentChartPO.setFobjid(departmentId); + departmentChartPO.setExpand("1"); + departmentChartPO.setId("d_"+departmentId); + departmentChartPO.setFname(rs.getString("name")); + departmentChartPO.setFleader(getDepartmentLeader(fLeader)); + try { + departmentChartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(fLeader)); + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + + //人员 + List allSupDepartment = getAllSupDepartment(param.getDepartmentId()); + List resourceChartPOS = new ArrayList<>(); + resourceChartPOS.addAll(selectNbPerson(allSupDepartment)); + resourceChartPOS.addAll(selectWbPerson(allSupDepartment)); + List resourceChartVOS = convertToVO(resourceChartPOS); + + resourceChartVOS.forEach(item -> { + ChartPO chartPO = getResourceChartPO(item,departmentChartPO.getId()); + dataList.add(chartPO); + }); + + + + departmentChartPO.setFonjob(resourceChartVOS.size()); + dataList.add(departmentChartPO); + + + Map result = new HashMap<>(4); + result.put("api_status", true); + result.put("data", dataList); + return result; + } + + /** + * 正式员工 + * @param allSupDepartment + * @return + */ + private List selectNbPerson(Collection allSupDepartment) { + RecordSet rs = new RecordSet(); + List resourceChartPOS = new ArrayList<>(); + String join = CollectionUtil.join(allSupDepartment, ","); + rs.executeQuery("select id, gh,xm,xb,bm,gw,sjhm from uf_zsygrzbdd where bm in ("+join+")"); + while (rs.next()) { + ResourceChartPO build = ResourceChartPO.builder() + .id((long) Util.getIntValue(rs.getString("id"))) + .workCode(Util.null2String(rs.getString("gh"))) + .lastName(Util.null2String(rs.getString("xm"))) + .sex(Util.null2String(rs.getString("xb"))) + .departmentId(Util.getIntValue(rs.getString("bm"))) + .jobBrowser(Util.null2String(rs.getString("gw"))) + .mobile(Util.null2String(rs.getString("sjhm"))) + .build(); + resourceChartPOS.add(build); + } + + return resourceChartPOS; + } + + /** + * 外部员工 + * @param allSupDepartment + * @return + */ + private List selectWbPerson(Collection allSupDepartment) { + RecordSet rs = new RecordSet(); + List resourceChartPOS = new ArrayList<>(); + String join = CollectionUtil.join(allSupDepartment, ","); + rs.executeQuery("select id, gh,xm,xb,bmbz,gw,lxfs from uf_qlwbrydngljmb where bmbz in ("+join+")"); + while (rs.next()) { + ResourceChartPO build = ResourceChartPO.builder() + .id((long) Util.getIntValue(rs.getString("id"))) + .workCode(Util.null2String(rs.getString("gh"))) + .lastName(Util.null2String(rs.getString("xm"))) + .sex(Util.null2String(rs.getString("xb"))) + .departmentId(Util.getIntValue(rs.getString("bmbz"))) + .jobBrowser(Util.null2String(rs.getString("gw"))) + .mobile(Util.null2String(rs.getString("lxfs"))) + .build(); + resourceChartPOS.add(build); + } + + return resourceChartPOS; + + } + + + /** + * 列表表头 + * @return + */ + private List getTableColumns() { + List list = new ArrayList<>(); + list.add(ResourceListColumns.builder().title("序号").dataIndex("id").key("id").build()); + list.add(ResourceListColumns.builder().title("工号").dataIndex("workCode").key("workCode").build()); + list.add(ResourceListColumns.builder().title("姓名").dataIndex("lastName").key("lastName").build()); + list.add(ResourceListColumns.builder().title("性别").dataIndex("sex").key("sex").build()); + list.add(ResourceListColumns.builder().title("部门").dataIndex("departmentName").key("departmentName").build()); + list.add(ResourceListColumns.builder().title("分部").dataIndex("subcompanyName").key("subcompanyName").build()); + list.add(ResourceListColumns.builder().title("岗位").dataIndex("jobTitle").key("jobTitle").build()); + list.add(ResourceListColumns.builder().title("手机号").dataIndex("mobile").key("mobile").build()); + + return list; + + } + + /** + * 获取所有子部门和当前部门集合 + * @param departmentId + * @return + */ + @SneakyThrows + private List getAllSupDepartment(String departmentId){ + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + ArrayList subList = new ArrayList(); + departmentComInfo.getAllChildDeptByDepId(subList, departmentId); + subList.add(departmentId); + + return subList; + } + + /** + * 转换 + * @param resourceChartPOS + * @return + */ + @SneakyThrows + private List convertToVO(List resourceChartPOS) { + List resourceChartVOS = new ArrayList<>(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + for (ResourceChartPO item : resourceChartPOS) { + ResourceChartVO resourceChartVO = new ResourceChartVO(); + String departmentId =String.valueOf(item.getDepartmentId()); + String subCompanyname = subCompanyComInfo.getSubCompanyname(departmentComInfo.getSubcompanyid1(departmentId)); + + resourceChartVO.setId(item.getId()); + resourceChartVO.setWorkCode(item.getWorkCode()); + resourceChartVO.setLastName(item.getLastName()); + resourceChartVO.setSex("1".equals(item.getSex()) ? "女" : "男"); + resourceChartVO.setDepartmentName(departmentComInfo.getDepartmentName(departmentId)); + resourceChartVO.setSubcompanyName(subCompanyname); + resourceChartVO.setJobTitle(getJobBrowserName(item.getJobBrowser())); + resourceChartVO.setStatus(item.getStatus()); + resourceChartVO.setMobile(item.getMobile()); + resourceChartVOS.add(resourceChartVO); + } + return resourceChartVOS; + } + + + /** + * 自定义岗位名称 + * @param code + * @return + */ + private String getJobBrowserName(String code){ + + RecordSet rs = new RecordSet(); + rs.executeQuery("select gwmc from uf_gwmc where gwbm = ?",code); + rs.next(); + return Util.null2String(rs.getString("gwmc")); + } + + /** + * 获取部门负责人 + * + * @param ids 部门负责人ID + * @return 人员名称 + */ + private String getDepartmentLeader(String ids) { + if (StringUtils.isBlank(ids)) { + return ""; + } + List leaderList = new ArrayList<>(); + String[] split = ids.split(","); + for (String s : split) { + String lastName = MapperProxyFactory.getProxy(SystemDataMapper.class).getScHrmResourceNameById(s); + if (StringUtils.isNotBlank(lastName)) { + leaderList.add(lastName); + } + } + return StringUtils.join(leaderList, ","); + } + + + /** + * 构建人员图谱元素 + * @param item + * @return + */ + private ChartPO getResourceChartPO(ResourceChartVO item,String parentId) { + ChartPO chartPO = new ChartPO(); + chartPO.setFtype("4"); + chartPO.setFobjid(String.valueOf(item.getId())); + chartPO.setId(chartPO.getFobjid()); + chartPO.setFname(item.getLastName()); + chartPO.setParentId(parentId); + chartPO.setLocalDeptName(item.getDepartmentName()); + chartPO.setJobTitle(item.getJobTitle()); + chartPO.setExpand("1"); + chartPO.setHasChildren("0"); + try { + chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartPO.getId())); + } catch (Exception e) { + throw new RuntimeException(e); + } + return chartPO; + } + +} diff --git a/src/com/engine/organization/service/impl/OrgChartServiceImpl.java b/src/com/engine/organization/service/impl/OrgChartServiceImpl.java index 53ca2237..9d3c5367 100644 --- a/src/com/engine/organization/service/impl/OrgChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/OrgChartServiceImpl.java @@ -19,6 +19,7 @@ import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.detach.DetachUtil; import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; +import weaver.general.BaseBean; import weaver.general.Util; import weaver.hrm.User; @@ -79,7 +80,11 @@ public class OrgChartServiceImpl extends Service implements OrgChartService { 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()); } + + String root = new BaseBean().getPropValue("hrmOrganization", "subCompanyId"); + result.put("api_status", true); + result.put("root",root); result.put("fclasslist", fclasslist); result.put("companyTree", companyTree); return result; diff --git a/src/com/engine/organization/wrapper/OrgChartWrapper.java b/src/com/engine/organization/wrapper/OrgChartWrapper.java index e69da3bd..5e6f79f7 100644 --- a/src/com/engine/organization/wrapper/OrgChartWrapper.java +++ b/src/com/engine/organization/wrapper/OrgChartWrapper.java @@ -63,7 +63,9 @@ public class OrgChartWrapper extends Service { } public Map getDepartmentDetail(Map request2Map, User user) { - return getChartService(user).getDepartmentDetail(request2Map); + //上海中远重工项目二开 + return getChartService(user).getDepartmentNewDetail(request2Map); + //return getChartService(user).getDepartmentDetail(request2Map); } public Map versionRecord(Map request2Map, User user) {