From f74d6da24c04b676813cbaf2f3d4e939c733f38a Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Mon, 29 Apr 2024 17:18:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E8=BF=9C=E9=87=8D=E5=B7=A5=E6=AD=A3?= =?UTF-8?q?=E5=BC=8F=E5=91=98=E5=B7=A5=E5=A2=9E=E5=8A=A0=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E6=80=A7=E8=B4=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organization/entity/chart/ChartPO.java | 5 +- .../entity/chart/DetailConditionVO.java | 27 +++++++ .../entity/chart/StatisticsVO.java | 1 - .../chart/params/ModeHrmResourceParam.java | 2 + .../service/ModeHrmResourceService.java | 9 +++ .../service/impl/ChartServiceImpl.java | 37 +++++++--- .../impl/ModeHrmResourceServiceImpl.java | 72 ++++++++++++++++--- .../organization/web/OrgChartController.java | 24 +++++++ 8 files changed, 156 insertions(+), 21 deletions(-) create mode 100644 src/com/engine/organization/entity/chart/DetailConditionVO.java diff --git a/src/com/engine/organization/entity/chart/ChartPO.java b/src/com/engine/organization/entity/chart/ChartPO.java index 0527361b..9880fc05 100644 --- a/src/com/engine/organization/entity/chart/ChartPO.java +++ b/src/com/engine/organization/entity/chart/ChartPO.java @@ -44,9 +44,12 @@ public class ChartPO { private String id; private String key; - // 部门层级 + // 部门深度 private int departmentDepth; + //部门层级 + private int deptLevel; + // 在编数 private int onJobNum; // 编制数 diff --git a/src/com/engine/organization/entity/chart/DetailConditionVO.java b/src/com/engine/organization/entity/chart/DetailConditionVO.java new file mode 100644 index 00000000..5ad76ad1 --- /dev/null +++ b/src/com/engine/organization/entity/chart/DetailConditionVO.java @@ -0,0 +1,27 @@ +package com.engine.organization.entity.chart; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author liang.cheng + * @Date 2024/4/29 2:15 PM + * @Description: + * @Version 1.0 + */ + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DetailConditionVO { + + private String label; + + private String value; + + private Boolean disabled; + +} diff --git a/src/com/engine/organization/entity/chart/StatisticsVO.java b/src/com/engine/organization/entity/chart/StatisticsVO.java index 80b90f55..c326d17b 100644 --- a/src/com/engine/organization/entity/chart/StatisticsVO.java +++ b/src/com/engine/organization/entity/chart/StatisticsVO.java @@ -1,6 +1,5 @@ package com.engine.organization.entity.chart; -import com.icbc.api.internal.apache.http.impl.cookie.S; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/src/com/engine/organization/entity/chart/params/ModeHrmResourceParam.java b/src/com/engine/organization/entity/chart/params/ModeHrmResourceParam.java index 839a4f43..b551ed47 100644 --- a/src/com/engine/organization/entity/chart/params/ModeHrmResourceParam.java +++ b/src/com/engine/organization/entity/chart/params/ModeHrmResourceParam.java @@ -20,6 +20,8 @@ public class ModeHrmResourceParam { private String departmentId; + private String nbValue; + private String wbValue; } diff --git a/src/com/engine/organization/service/ModeHrmResourceService.java b/src/com/engine/organization/service/ModeHrmResourceService.java index faa17371..50901bd6 100644 --- a/src/com/engine/organization/service/ModeHrmResourceService.java +++ b/src/com/engine/organization/service/ModeHrmResourceService.java @@ -41,4 +41,13 @@ public interface ModeHrmResourceService { * @return: int */ int selcetPersonCount(String departmentIds); + + /** + * @Description: 人员查询条件 + * @Author: liang.cheng + * @Date: 2024/4/29 2:23 PM + * @param: [request2Map, user] + * @return: java.util.Map + */ + Map getDeptDetailCondition(); } diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index 01e6c627..a4e88c11 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -208,8 +208,9 @@ public class ChartServiceImpl extends Service implements ChartService { } } while (rs.next()) { + String type = rs.getString("type"); ChartPO chartPO = new ChartPO(); - chartPO.setFtype(rs.getString("type")); + chartPO.setFtype(type); chartPO.setFobjid(rs.getString("id")); chartPO.setFname(rs.getString("name")); chartPO.setParentId(s); @@ -218,14 +219,19 @@ public class ChartServiceImpl extends Service implements ChartService { chartPO.setHasChildren(getHasChildren(chartPO.getFtype(), chartPO.getFobjid()).toString()); chartPO.setOnJobNum(isRealTime ? Util.getIntValue(rs.getString("on_job_num"),0) : Util.getIntValue(rs.getString("job_num"),0)); chartPO.setStaffNum(Util.getIntValue(rs.getString("staff_num"),0)); + + if ("2".equals(type)) { + chartPO.setDeptLevel(Util.getIntValue(rs.getString("bmcj"),0)); + } filterAndAddData(dataList, chartPO, hideDepartment); + //dataList.add(chartPO); } } } } - Map result = new HashMap<>(); + Map result = new HashMap<>(4); result.put("api_status", true); result.put("data", dataList); return result; @@ -373,12 +379,20 @@ public class ChartServiceImpl extends Service implements ChartService { public Map getDepartmentNewDetail(Map params) { String rootId = Util.null2String(params.get("rootId")); + String nbValue = Util.null2String(params.get("nbValue")); + String wbValue = Util.null2String(params.get("wbValue")); + + String departmentId = rootId.split("_")[1]; - ModeHrmResourceParam build = ModeHrmResourceParam.builder().departmentId(departmentId).build(); + ModeHrmResourceParam build = ModeHrmResourceParam.builder() + .nbValue(nbValue) + .wbValue(wbValue) + .departmentId(departmentId) + .build(); - String detauleType = Util.null2String(params.get("detauleType")); + String detauleType = Util.null2String(params.get("detailType")); if (!"chart".equals(detauleType)) { // 展示列表模块 return ServiceUtil.getService(ModeHrmResourceServiceImpl.class, user).chartResourceList(build); @@ -1395,8 +1409,8 @@ public class ChartServiceImpl extends Service implements ChartService { sql = "select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual,showorder,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.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,showorder,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 where (a.canceled is null or a.canceled != '1') and (a.supdepid is null or a.supdepid = '0') and subcompanyid1 = '" + fObjId + "'"; } else { - sql = "select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual,showorder,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.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,showorder,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 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 + "'"; + sql = "select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual,0,showorder,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.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,b.bmcj,showorder,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 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 + "'"; } } else { 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 + "'" + @@ -1414,7 +1428,7 @@ public class ChartServiceImpl extends Service implements ChartService { if (showVirtual) { sql = "select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 where (a.canceled is null or a.canceled != '1') and supdepid = '" + fObjId + "'"; } else { - sql = "select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 where (canceled is null or canceled != '1') and (b.bmlx is null or b.bmlx != '1') and a.supdepid = '" + fObjId + "'"; + sql = "select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual,b.bmcj,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 where (canceled is null or canceled != '1') and (b.bmlx is null or b.bmlx != '1') and a.supdepid = '" + fObjId + "'"; } } 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 + "'"; @@ -1514,8 +1528,9 @@ public class ChartServiceImpl extends Service implements ChartService { RecordSet recordSet = new RecordSet(); recordSet.executeQuery(sql); while (recordSet.next()) { + String type = recordSet.getString("type"); ChartPO chartPO = new ChartPO(); - chartPO.setFtype(recordSet.getString("type")); + chartPO.setFtype(type); chartPO.setFobjid(recordSet.getString("id")); chartPO.setFname(recordSet.getString("name")); chartPO.setOnJobNum(isRealTime ? Util.getIntValue(recordSet.getString("on_job_num"),0) : Util.getIntValue(recordSet.getString("job_num"),0)); @@ -1526,6 +1541,12 @@ public class ChartServiceImpl extends Service implements ChartService { chartPO.setDepartmentDepth(getDepartmentDepth(chartPO, topChartPO)); // 小于、等于所选层级元素展开 chartPO.setExpand(inDepth(selectDepth, chartPO.getDepartmentDepth()) ? "1" : "0"); + + + if ("2".equals(type)) { + chartPO.setDeptLevel(Util.getIntValue(recordSet.getString("bmcj"),0)); + } + filterAndAddData(currentList, chartPO, hideDepartment); //currentList.add(chartPO); } diff --git a/src/com/engine/organization/service/impl/ModeHrmResourceServiceImpl.java b/src/com/engine/organization/service/impl/ModeHrmResourceServiceImpl.java index 053ed862..0300e048 100644 --- a/src/com/engine/organization/service/impl/ModeHrmResourceServiceImpl.java +++ b/src/com/engine/organization/service/impl/ModeHrmResourceServiceImpl.java @@ -3,6 +3,7 @@ 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.DetailConditionVO; import com.engine.organization.entity.chart.ResourceListColumns; import com.engine.organization.entity.chart.params.ModeHrmResourceParam; import com.engine.organization.entity.hrmresource.po.ResourceChartPO; @@ -19,6 +20,7 @@ import weaver.hrm.company.SubCompanyComInfo; import weaver.hrm.resource.ResourceComInfo; import java.util.*; +import java.util.stream.Collectors; /** * @Author liang.cheng @@ -35,10 +37,10 @@ public class ModeHrmResourceServiceImpl extends Service implements ModeHrmResour List resourceListColumns = getTableColumns(); List allSupDepartment = getAllSupDepartment(param.getDepartmentId()); - List resourceChartNb = new ArrayList<>(selectNbPerson(allSupDepartment)); + List resourceChartNb = new ArrayList<>(selectNbPerson(allSupDepartment,param.getNbValue())); List resourceChartVOS = convertToVO(resourceChartNb,"1"); - List resourceChartWb = new ArrayList<>(selectWbPerson(allSupDepartment)); + List resourceChartWb = new ArrayList<>(selectWbPerson(allSupDepartment,param.getWbValue())); resourceChartVOS.addAll(convertToVO(resourceChartWb,"2")); @@ -76,10 +78,10 @@ public class ModeHrmResourceServiceImpl extends Service implements ModeHrmResour //人员 List allSupDepartment = getAllSupDepartment(param.getDepartmentId()); - List resourceChartNb = new ArrayList<>(selectNbPerson(allSupDepartment)); + List resourceChartNb = new ArrayList<>(selectNbPerson(allSupDepartment,param.getNbValue())); List resourceChartVOS = convertToVO(resourceChartNb,"1"); - List resourceChartWb = new ArrayList<>(selectWbPerson(allSupDepartment)); + List resourceChartWb = new ArrayList<>(selectWbPerson(allSupDepartment,param.getWbValue())); resourceChartVOS.addAll(convertToVO(resourceChartWb,"2")); resourceChartVOS.forEach(item -> { @@ -117,16 +119,56 @@ public class ModeHrmResourceServiceImpl extends Service implements ModeHrmResour return totalCount; } + @Override + public Map getDeptDetailCondition() { + RecordSet rs = new RecordSet(); + List nbCondition = new ArrayList<>(); + List nbValue = new ArrayList<>(); + List wbCondition = new ArrayList<>(); + + //内部职工 + rs.executeQuery("select mc,bh from uf_ygxz where sfqy = 0 and syfw = 0"); + while (rs.next()) { + String mc = Util.null2String(rs.getString("mc")); + String bh = Util.null2String(rs.getString("bh")); + nbCondition.add(DetailConditionVO.builder().label(mc).value(bh).build()); + nbValue.add(bh); + } + + //外部人员 + rs.executeQuery("select mc,bh from uf_ygxz where sfqy = 0 and syfw = 1"); + while (rs.next()) { + String mc = Util.null2String(rs.getString("mc")); + String bh = Util.null2String(rs.getString("bh")); + wbCondition.add(DetailConditionVO.builder().label(mc).value(bh).build()); + } + + Map datas = new HashMap<>(4); + datas.put("nbCondition",nbCondition); + datas.put("nbValue",nbValue); + datas.put("wbCondition",wbCondition); + return datas; + } + + /** * 正式员工 * @param allSupDepartment * @return */ - private List selectNbPerson(Collection allSupDepartment) { - RecordSet rs = new RecordSet(); + private List selectNbPerson(Collection allSupDepartment,String workType) { List resourceChartPOS = new ArrayList<>(); + if (StringUtils.isEmpty(workType)){ + return resourceChartPOS; + } + List result = Arrays.asList(workType.split(",")); + workType = result.stream() + .map(s -> "'" + s + "'") + .collect(Collectors.joining(",")); + + RecordSet rs = new RecordSet(); String join = CollectionUtil.join(allSupDepartment, ","); - rs.executeQuery("select id,gh,xm,xb,bm,gw,sjhm from uf_zsygrzbdd where zt < 4 and bm in ("+join+")"); + rs.executeQuery("select id,gh,xm,xb,bm,gw,sjhm from uf_zsygrzbdd where zt < 4 and bm in ("+join+") and ygxz in ("+workType+")"); while (rs.next()) { ResourceChartPO build = ResourceChartPO.builder() .id((long) Util.getIntValue(rs.getString("id"))) @@ -148,11 +190,19 @@ public class ModeHrmResourceServiceImpl extends Service implements ModeHrmResour * @param allSupDepartment * @return */ - private List selectWbPerson(Collection allSupDepartment) { - RecordSet rs = new RecordSet(); + private List selectWbPerson(Collection allSupDepartment,String workType) { List resourceChartPOS = new ArrayList<>(); + if (StringUtils.isEmpty(workType)){ + return resourceChartPOS; + } + List result = Arrays.asList(workType.split(",")); + workType = result.stream() + .map(s -> "'" + s + "'") + .collect(Collectors.joining(",")); + + RecordSet rs = new RecordSet(); String join = CollectionUtil.join(allSupDepartment, ","); - rs.executeQuery("select id, gh,xm,xb,bmbz,gw,lxfs from uf_qlwbrydngljmb where zt < 4 and bmbz in ("+join+")"); + rs.executeQuery("select id,gh,xm,xb,bmbz,gw,lxfs from uf_qlwbrydngljmb where zt < 4 and bmbz in ("+join+") and ygxz in ("+workType+")"); while (rs.next()) { ResourceChartPO build = ResourceChartPO.builder() .id((long) Util.getIntValue(rs.getString("id"))) @@ -294,7 +344,7 @@ public class ModeHrmResourceServiceImpl extends Service implements ModeHrmResour chartPO.setLocalDeptName(item.getDepartmentName()); chartPO.setJobTitle(item.getJobTitle()); chartPO.setExpand("1"); - chartPO.setHasChildren("0"); + chartPO.setHasChildren("false"); try { String resourceId = getResourceIdByWorkCode(item.getWorkCode()); chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(resourceId)); diff --git a/src/com/engine/organization/web/OrgChartController.java b/src/com/engine/organization/web/OrgChartController.java index f5c71c06..05ed4aca 100644 --- a/src/com/engine/organization/web/OrgChartController.java +++ b/src/com/engine/organization/web/OrgChartController.java @@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONObject; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; import com.engine.organization.entity.chart.params.StatisticsParam; +import com.engine.organization.service.ModeHrmResourceService; +import com.engine.organization.service.impl.ModeHrmResourceServiceImpl; import com.engine.organization.util.response.ReturnResult; import com.engine.organization.wrapper.OrgChartWrapper; import io.swagger.v3.oas.annotations.parameters.RequestBody; @@ -23,10 +25,15 @@ import java.util.Map; public class OrgChartController { + public OrgChartWrapper getOrgChartWrapper(User user) { return ServiceUtil.getService(OrgChartWrapper.class, user); } + private ModeHrmResourceService getModeHrmResourceService(User user) { + return ServiceUtil.getService(ModeHrmResourceServiceImpl.class, user); + } + /** * 获取组织维度信息 */ @@ -66,6 +73,23 @@ public class OrgChartController { return JSONObject.toJSONString(apidatas); } + @GET + @Path("/getDeptDetailCondition") + @Produces(MediaType.APPLICATION_JSON) + public String getDeptDetailCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap<>(4); + try { + User user = HrmUserVarify.getUser(request, response); + apidatas = getModeHrmResourceService(user).getDeptDetailCondition(); + } catch (Exception e) { + //异常处理 + e.printStackTrace(); + apidatas.put("api_status", false); + apidatas.put("api_errormsg", "catch exception : " + e.getMessage()); + } + return JSONObject.toJSONString(apidatas); + } + @GET @Path("/getDepartmentDetail") @Produces(MediaType.APPLICATION_JSON)