From 6c54bae6f2bc3386882cdb00359517ff6969693d Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Thu, 23 Jan 2025 13:39:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E8=BF=9C=E7=BB=84=E7=BB=87=E6=9E=B6?= =?UTF-8?q?=E6=9E=84=E5=9B=BE=E7=BC=96=E5=88=B6=E7=BB=9F=E8=AE=A1=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/staff/po/ModeStaffPO.java | 32 +++++++++++++++++++ .../service/impl/ChartServiceImpl.java | 31 ++++++++++++++---- 2 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 src/com/engine/organization/entity/staff/po/ModeStaffPO.java diff --git a/src/com/engine/organization/entity/staff/po/ModeStaffPO.java b/src/com/engine/organization/entity/staff/po/ModeStaffPO.java new file mode 100644 index 00000000..701324d7 --- /dev/null +++ b/src/com/engine/organization/entity/staff/po/ModeStaffPO.java @@ -0,0 +1,32 @@ +package com.engine.organization.entity.staff.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author liang.cheng + * @Date 2025/1/22 16:52 + * @Description: 中远建模编制 + * @Version 1.0 + */ + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class ModeStaffPO { + + private Integer count; + + private String monthYear; + + @Override + public String toString() { + return "ModeStaffPO{" + + "count=" + count + + ", monthYear='" + monthYear + '\'' + + '}'; + } +} diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index 84bc589f..4d496539 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -6,6 +6,7 @@ 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.entity.staff.po.ModeStaffPO; import com.engine.organization.enums.ModuleTypeEnum; import com.engine.organization.mapper.hrmresource.SystemDataMapper; import com.engine.organization.service.ChartService; @@ -754,7 +755,6 @@ public class ChartServiceImpl extends Service implements ChartService { ArrayList list = new ArrayList<>(); list.add(stp.getDataId()); BaseBean bb = new BaseBean(); - if (ModuleTypeEnum.departmentfielddefined.getValue().equals(stp.getType())) { dept.getAllChildDeptByDepId(list,String.valueOf(stp.getDataId())); String value = StringUtils.join(list,","); @@ -765,13 +765,32 @@ public class ChartServiceImpl extends Service implements ChartService { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); String currentYearMonth = currentDateTime.format(formatter); - // 部门编制人数向下汇总 - List bzList = new ArrayList<>(); - rs.executeQuery("select bzrs from uf_bzgljmb where bm in ("+value+") and ny = ?",currentYearMonth); + // 部门编制人数向下汇总 20250122 优化需求 + List bzList = new ArrayList<>(); + rs.executeQuery("select bzrs,ny from uf_bzgljmb where bm in ("+value+")"); while (rs.next()) { - bzList.add(Util.getIntValue(rs.getString("bzrs"), 0)); + int bzrs = Util.getIntValue(rs.getString("bzrs"), 0); + String ny = Util.null2String(rs.getString("ny")); + if(StringUtils.isNotEmpty(ny)) { + bzList.add(ModeStaffPO.builder().count(bzrs).monthYear(ny).build()); + } + } + + int sum = 0; + if (bzList.size() > 0) { + Map> groupedByMonthYear = bzList.stream() + .collect(Collectors.groupingBy(ModeStaffPO::getMonthYear)); + + // 获取最新的 monthYear + String latestMonthYear = groupedByMonthYear.keySet().stream() + .max(String::compareTo) + .orElse(null); + + List modeStaffPOS = groupedByMonthYear.get(latestMonthYear); + sum = modeStaffPOS.stream().mapToInt(ModeStaffPO::getCount).sum(); } - int sum = bzList.stream().mapToInt(Integer::intValue).sum(); + + stp.setStaffNum(sum); }