From 15723bc4645a3be15e4ff8bcace2e16c49e8308d Mon Sep 17 00:00:00 2001 From: liuliang <401809302@qq.com> Date: Tue, 29 Jul 2025 18:45:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executionHistory/executionHistory.lock | Bin 17 -> 17 bytes .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../AuthorizedStrengthController.java | 5 +- .../service/AuthorizedStrengthService.java | 3 +- .../impl/AuthorizedStrengthServiceImpl.java | 152 ++++++++++-------- 5 files changed, 94 insertions(+), 66 deletions(-) diff --git a/jcl-hrmorganization/buildSrc/.gradle/6.9.2/executionHistory/executionHistory.lock b/jcl-hrmorganization/buildSrc/.gradle/6.9.2/executionHistory/executionHistory.lock index 8a27974e47533297f674f7920104484caca45e01..9fec4ad38adbb924b999d82835984137785bfd3d 100644 GIT binary patch literal 17 UcmZQRqxM{9ma?om0|dMT04hHN^8f$< literal 17 UcmZQRqxM{9ma?om0|Ybx04df3iU0rr diff --git a/jcl-hrmorganization/buildSrc/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/jcl-hrmorganization/buildSrc/.gradle/buildOutputCleanup/buildOutputCleanup.lock index f6b596b270dc70816675cc45f3ece0ba3d0e0b57..3d73d17e994a14d0bae36c206a6e72f3700c5b92 100644 GIT binary patch literal 17 UcmZSH_)z4Cf1c`e1_*Ej05bmsC;$Ke literal 17 UcmZSH_)z4Cf1c`e1_-bR05bgqCIA2c diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/AuthorizedStrengthController.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/AuthorizedStrengthController.java index 3f06e94..ef9a258 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/AuthorizedStrengthController.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/controller/AuthorizedStrengthController.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import java.util.HashMap; +import java.util.List; import java.util.Map; @Slf4j @@ -31,7 +32,7 @@ public class AuthorizedStrengthController { @WeaPermission(publicPermission = true) @Produces(MediaType.APPLICATION_JSON) @PostMapping("/getDepartmentAuthorizedStrength") - public WeaResult> getDepartmentAuthorizedStrength(@RequestParam("developPlan") String developPlan, + public WeaResult>> getDepartmentAuthorizedStrength(@RequestParam("developPlan") String developPlan, @RequestParam("adjustDepartment") String adjustDepartment, @RequestParam("adjustYear") String adjustYear, @RequestParam("grade") String grade, @@ -44,7 +45,7 @@ public class AuthorizedStrengthController { paramMap.put("grade",grade); paramMap.put("position",position); - Map resultMap = authorizedStrengthService.getDepartmentAuthorizedStrength(paramMap); + List> resultMap = authorizedStrengthService.getDepartmentAuthorizedStrength(paramMap); return WeaResult.success(resultMap); diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/AuthorizedStrengthService.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/AuthorizedStrengthService.java index 7433391..e2a7406 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/AuthorizedStrengthService.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/AuthorizedStrengthService.java @@ -1,8 +1,9 @@ package com.weaver.seconddev.jcl.organization.service; +import java.util.List; import java.util.Map; public interface AuthorizedStrengthService { - Map getDepartmentAuthorizedStrength(Map params); + List> getDepartmentAuthorizedStrength(Map params); } diff --git a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/AuthorizedStrengthServiceImpl.java b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/AuthorizedStrengthServiceImpl.java index 79e557e..2aa2388 100644 --- a/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/AuthorizedStrengthServiceImpl.java +++ b/jcl-hrmorganization/secondev-jcl-hrmorganization/src/main/java/com/weaver/seconddev/jcl/organization/service/impl/AuthorizedStrengthServiceImpl.java @@ -29,99 +29,125 @@ public class AuthorizedStrengthServiceImpl implements AuthorizedStrengthService private static final Logger log = LoggerFactory.getLogger(AuthorizedStrengthServiceImpl.class); @Override - public Map getDepartmentAuthorizedStrength(Map params) { + public List> getDepartmentAuthorizedStrength(Map params) { log.error("params: [{}]",params); - String sql = "select * from e10_other_business.hr_est_cfg where org_id=? and plan_id=? and cfg_year=?"; - List> dataList = databaseUtils.getSqlList(sql, CommonUtils.getParamList(params.get("adjustDepartment"),params.get("developPlan"),params.get("adjustYear"))); + String sql = "select * from e10_other_business.hr_est_cfg where org_id in ("+params.get("adjustDepartment")+") and plan_id=? and cfg_year=?"; + List> dataList = databaseUtils.getSqlList(sql, CommonUtils.getParamList(params.get("developPlan"),params.get("adjustYear"))); log.error("hrestcfgList: [{}]",dataList); List cfgIds = dataList.stream().map(e->e.get("id").toString()).collect(Collectors.toList()); String currentDate = DateUtil.getCurrentMonth(); //人员编制统计数据 数据源 List> datasBySourceList = commonService.getListDatasBySourceName("人员编制统计数据","LOGIC","weaver-hr-service"); datasBySourceList = datasBySourceList.stream().filter(e->CommonUtils.null2String(e.get("year")).equals(params.get("adjustYear")) && - CommonUtils.null2String(((List>)e.get("orgId")).get(0).get("id")).equals(params.get("adjustDepartment")) && + params.get("adjustDepartment").contains(CommonUtils.null2String(((List>)e.get("orgId")).get(0).get("id"))) && CommonUtils.null2String(((List>)e.get("planId")).get(0).get("id")).equals(params.get("developPlan"))).collect(Collectors.toList()); +// Map>> datasBySourceCollect = datasBySourceList.stream().collect(Collectors.groupingBy(e->e.get("orgId").toString())); + //人员编制控编维度统计数据(月度周期) List> personYdzqMonthList = commonService.getListDatasBySourceName("人员编制控编维度统计数据","LOGIC","weaver-hr-service"); personYdzqMonthList = personYdzqMonthList.stream().filter(e->e.get("year").equals(params.get("adjustYear")) && - CommonUtils.null2String(((List>)e.get("orgId")).get(0).get("id")).equals(params.get("adjustDepartment")) && - CommonUtils.null2String(((List>)e.get("position")).get(0).get("id")).equals(params.get("position")) && - CommonUtils.null2String(((List>)e.get("grade")).get(0).get("id")).equals(params.get("grade"))).collect(Collectors.toList()); + params.get("adjustDepartment").contains(CommonUtils.null2String(((List>)e.get("orgId")).get(0).get("id"))) && + params.get("position").contains(CommonUtils.null2String(((List>)e.get("position")).get(0).get("id"))) && + params.get("grade").contains(CommonUtils.null2String(((List>)e.get("grade")).get(0).get("id")))).collect(Collectors.toList()); - sql = "select * from e10_other_business.hr_est_history where org_id=? and cfg_id in ("+String.join(",",cfgIds)+")"; - List> historyList = databaseUtils.getSqlList(sql,CommonUtils.getParamList(params.get("adjustDepartment"))); + sql = "select * from e10_other_business.hr_est_history where org_id in ("+params.get("adjustDepartment")+") and cfg_id in ("+String.join(",",cfgIds)+")"; + List> historyList = databaseUtils.getSqlList(sql); String startDate = params.get("adjustYear")+"-01"; List> deparmentAdjust = Lists.newArrayList(); List> jobAdjust = Lists.newArrayList(); log.error("datasBySourceList:[{}]",datasBySourceList); log.error("personYdzqMonthList:[{}]",personYdzqMonthList); + + sql = "select * from eteams.department"; + List> departmentList = databaseUtils.getSqlList(sql); + Map departmentMap = departmentList.stream().collect(Collectors.toMap(e->e.get("id").toString(),e->e.get("name").toString())); + for (int i=0;i<=11;i++){ - Map dataMap = Maps.newHashMap(); - Map dataMap2 = Maps.newHashMap(); + String date = DateUtil.nextMonth(startDate,i, DateUtil.yyyyMM); int monthValue = DateUtil.getTime(date).getMonthValue(); - List> hrestCfg = dataList.stream().filter(e->CommonUtils.null2String(e.get("cfg_month")).equals(String.valueOf(monthValue))).collect(Collectors.toList()); - if (hrestCfg.size() == 0){ - continue; - } - log.error("hrestCfg: [{}]",hrestCfg); - dataMap.put("monthvalue",monthValue); - dataMap.put("bz",hrestCfg.get(0).get("est_count")); - dataMap2.put("bz",hrestCfg.get(0).get("est_count")); - dataMap2.put("monthvalue",monthValue); - List> hresthistory = historyList.stream().filter(e->e.get("cfg_id").equals(hrestCfg.get(0).get("id")) && e.get("history_month").equals(date)).collect(Collectors.toList()); + Map>> dataCollect = dataList.stream().collect(Collectors.groupingBy(e->e.get("org_id").toString())); + for (Map.Entry>> entry: dataCollect.entrySet()){ + Map dataMap = Maps.newHashMap(); + Map dataMap2 = Maps.newHashMap(); + String org_id = entry.getKey(); + List> hrestCfgList = entry.getValue(); + List> hrestCfg = hrestCfgList.stream().filter(e->CommonUtils.null2String(e.get("cfg_month")).equals(String.valueOf(monthValue))).collect(Collectors.toList()); + if (hrestCfg.size() == 0){ + continue; + } + log.error("hrestCfg: [{}]",hrestCfg); + dataMap.put("monthvalue",monthValue); + dataMap.put("bz",hrestCfg.get(0).get("est_count")); + dataMap.put("org_id",org_id); + dataMap2.put("bz",hrestCfg.get(0).get("est_count")); + dataMap2.put("monthvalue",monthValue); + dataMap2.put("org_id",org_id); + List> hresthistory = historyList.stream().filter(e->e.get("cfg_id").equals(hrestCfg.get(0).get("id")) && e.get("history_month").equals(date)).collect(Collectors.toList()); - List> personYdzqMonth = personYdzqMonthList.stream().filter(e->e.get("month").equals(String.valueOf(monthValue)) && e.get("cfgId").equals(hrestCfg.get(0).get("id"))).collect(Collectors.toList()); - if (personYdzqMonth.size() > 0){ - dataMap2.put("zz",personYdzqMonth.get(0).get("numberingCount")); - dataMap2.put("zy",personYdzqMonth.get(0).get("NumberComponent")); - dataMap2.put("ysf",personYdzqMonth.get(0).get("preSubEmpCount")); - dataMap2.put("kybz",personYdzqMonth.get(0).get("estLackCount")); - }else { - dataMap2.put("zz",""); - dataMap2.put("zy",""); - dataMap2.put("ysf",""); - dataMap2.put("kybz",""); - } - - if (DateUtil.getTime(date).compareTo(DateUtil.getTime(currentDate))<0){ - //取历史 - if (hresthistory.size() > 0){ - dataMap.put("zz",hresthistory.get(0).get("est_count")); - dataMap.put("zy",hresthistory.get(0).get("pre_add_count")); - dataMap.put("ysf",hresthistory.get(0).get("pre_sub_count")); - int kybz = Integer.valueOf(dataMap.get("bz").toString())-Integer.valueOf(dataMap.get("zz").toString())-Integer.valueOf(dataMap.get("zy").toString()); - dataMap.put("kybz",kybz); + List> personYdzqMonth = personYdzqMonthList.stream().filter(e->e.get("month").equals(String.valueOf(monthValue)) && e.get("cfgId").equals(hrestCfg.get(0).get("id"))).collect(Collectors.toList()); + if (personYdzqMonth.size() > 0){ + dataMap2.put("zz",personYdzqMonth.get(0).get("numberingCount")); + dataMap2.put("zy",personYdzqMonth.get(0).get("NumberComponent")); + dataMap2.put("ysf",personYdzqMonth.get(0).get("preSubEmpCount")); + dataMap2.put("kybz",personYdzqMonth.get(0).get("estLackCount")); }else { - dataMap.put("zz",""); - dataMap.put("zy",""); - dataMap.put("ysf",""); - dataMap.put("kybz",""); + dataMap2.put("zz",""); + dataMap2.put("zy",""); + dataMap2.put("ysf",""); + dataMap2.put("kybz",""); } - }else { - //取数据源 - if (datasBySourceList.size() > 0){ - dataMap.put("zz",datasBySourceList.get(0).get("numberingCount")); - dataMap.put("zy",datasBySourceList.get(0).get("preAddEmpCount")); - dataMap.put("ysf",datasBySourceList.get(0).get("preSubEmpCount")); - dataMap.put("kybz",datasBySourceList.get(0).get("estLackCount")); + if (DateUtil.getTime(date).compareTo(DateUtil.getTime(currentDate))<0){ + //取历史 + if (hresthistory.size() > 0){ + dataMap.put("zz",hresthistory.get(0).get("est_count")); + dataMap.put("zy",hresthistory.get(0).get("pre_add_count")); + dataMap.put("ysf",hresthistory.get(0).get("pre_sub_count")); + int kybz = Integer.valueOf(dataMap.get("bz").toString())-Integer.valueOf(dataMap.get("zz").toString())-Integer.valueOf(dataMap.get("zy").toString()); + dataMap.put("kybz",kybz); + }else { + dataMap.put("zz",""); + dataMap.put("zy",""); + dataMap.put("ysf",""); + dataMap.put("kybz",""); + } + }else { - dataMap.put("zz",""); - dataMap.put("zy",""); - dataMap.put("ysf",""); - dataMap.put("kybz",""); + //取数据源 + if (datasBySourceList.size() > 0){ + dataMap.put("zz",datasBySourceList.get(0).get("numberingCount")); + dataMap.put("zy",datasBySourceList.get(0).get("preAddEmpCount")); + dataMap.put("ysf",datasBySourceList.get(0).get("preSubEmpCount")); + dataMap.put("kybz",datasBySourceList.get(0).get("estLackCount")); + }else { + dataMap.put("zz",""); + dataMap.put("zy",""); + dataMap.put("ysf",""); + dataMap.put("kybz",""); + } } + deparmentAdjust.add(dataMap); + jobAdjust.add(dataMap2); } - deparmentAdjust.add(dataMap); - jobAdjust.add(dataMap2); } - Map resultMap = Maps.newHashMap(); - resultMap.put("deparmentAdjust",deparmentAdjust); - resultMap.put("jobAdjust",jobAdjust); - return resultMap; + Map>> deparmentAdjustGroup= deparmentAdjust.stream().collect(Collectors.groupingBy(e->e.get("org_id").toString())); + Map>> jobAdjustGroup= jobAdjust.stream().collect(Collectors.groupingBy(e->e.get("org_id").toString())); + List> resultList = Lists.newArrayList(); + for (Map.Entry>> entry: deparmentAdjustGroup.entrySet()){ + Map dataMap = Maps.newHashMap(); + dataMap.put("departmentId",entry.getKey()); + dataMap.put("departmentName",departmentMap.get(entry.getKey())); + dataMap.put("deparmentAdjust",entry.getValue()); + dataMap.put("jobAdjust",jobAdjustGroup.get(entry.getKey())); + resultList.add(dataMap); + } + + + + return resultList; } }