From 5926697c295890559b88987166cab9b6ef423056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Thu, 15 Jun 2023 17:34:52 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/salary/cache/SalaryCacheKey.java | 9 +++ .../SalaryStatisticsReportDataQueryParam.java | 6 +- .../SalaryStatisticsReportService.java | 6 ++ .../SalaryStatisticsReportServiceImpl.java | 23 ++++++++ .../SalaryStatisticsReportWrapper.java | 56 +++++++++++++++---- 5 files changed, 86 insertions(+), 14 deletions(-) diff --git a/src/com/engine/salary/cache/SalaryCacheKey.java b/src/com/engine/salary/cache/SalaryCacheKey.java index 76d19ea7d..c5acbdfba 100644 --- a/src/com/engine/salary/cache/SalaryCacheKey.java +++ b/src/com/engine/salary/cache/SalaryCacheKey.java @@ -55,5 +55,14 @@ public class SalaryCacheKey { */ public final static String CUSTOM_DATA = "CUSTOM_DATA"; + /** + * 报表主键 + */ + public final static String SALARY_REPORT_IDS = "SALARY_REPORT_IDS"; + + public final static String SALARY_REPORT_CONDITIONS = "SALARY_REPORT_CONDITIONS_"; + + public final static String SALARY_REPORT_DATA = "SALARY_REPORT_DATA_"; + } diff --git a/src/com/engine/salary/report/entity/param/SalaryStatisticsReportDataQueryParam.java b/src/com/engine/salary/report/entity/param/SalaryStatisticsReportDataQueryParam.java index 3874c0cac..e5882d3df 100644 --- a/src/com/engine/salary/report/entity/param/SalaryStatisticsReportDataQueryParam.java +++ b/src/com/engine/salary/report/entity/param/SalaryStatisticsReportDataQueryParam.java @@ -2,10 +2,7 @@ package com.engine.salary.report.entity.param; import com.engine.salary.common.BaseQueryParam; import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; import java.util.Date; import java.util.List; @@ -22,6 +19,7 @@ import java.util.List; @Builder @NoArgsConstructor @AllArgsConstructor +@ToString //"薪酬统计报表数据查询参数 public class SalaryStatisticsReportDataQueryParam extends BaseQueryParam { //报表id diff --git a/src/com/engine/salary/report/service/SalaryStatisticsReportService.java b/src/com/engine/salary/report/service/SalaryStatisticsReportService.java index 842317cf7..2d0e144a2 100644 --- a/src/com/engine/salary/report/service/SalaryStatisticsReportService.java +++ b/src/com/engine/salary/report/service/SalaryStatisticsReportService.java @@ -91,4 +91,10 @@ public interface SalaryStatisticsReportService { * @return */ PageInfo> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List salaryStatisticsItemPOS); + + + /** + * 清除报表缓存 + */ + void removeReportCache(); } diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java index ce8491b15..7cee8bc4b 100644 --- a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java @@ -3,6 +3,7 @@ package com.engine.salary.report.service.impl; import com.alibaba.fastjson.JSON; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.salary.cache.SalaryCacheKey; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; @@ -41,6 +42,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import weaver.general.Util; import weaver.hrm.User; +import weaver.wechat.util.Utils; import java.util.*; import java.util.stream.Collectors; @@ -95,6 +97,10 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); } + private SalaryCacheService getSalaryCacheService(User user) { + return ServiceUtil.getService(SalaryCacheServiceImpl.class, user); + } + // private ExtEmployeeService extEmployeeService; // // private HrmCommonEmployeeService hrmCommonEmployeeService; @@ -431,6 +437,23 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary return pageInfo; } + @Override + public void removeReportCache() { + //获取所有缓存报表的id + String salaryReportIds = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_IDS)); + Arrays.asList(salaryReportIds.split(",")).forEach(id -> { + //报表下条件id + String salaryReportConditions = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id); + Arrays.asList(salaryReportConditions.split(",")).forEach(paramMd5 -> + //条件对应的结果 + getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_DATA + paramMd5) + ); + getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id); + }); + getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_IDS); + } + + /** * 获取根据维度值过滤出的本次核算人员信息 * @param listByDimensionValue 根据维度筛选后的薪资核算人员 diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java index 32d0e7914..ce1d797ec 100644 --- a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java @@ -1,11 +1,13 @@ package com.engine.salary.report.wrapper; +import cn.hutool.crypto.SecureUtil; import com.alibaba.fastjson.JSONArray; import com.cloudstore.eccom.pc.table.WeaTable; import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.salary.cache.SalaryCacheKey; import com.engine.salary.component.WeaFormOption; import com.engine.salary.component.WeaTableColumnGroup; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; @@ -26,9 +28,11 @@ import com.engine.salary.report.service.impl.SalaryStatisticsReportServiceImpl; import com.engine.salary.report.service.impl.SubTableExportServiceImpl; import com.engine.salary.service.SalaryAcctEmployeeService; import com.engine.salary.service.SalaryAcctResultService; +import com.engine.salary.service.SalaryCacheService; import com.engine.salary.service.SalaryItemService; import com.engine.salary.service.impl.SalaryAcctEmployeeServiceImpl; import com.engine.salary.service.impl.SalaryAcctResultServiceImpl; +import com.engine.salary.service.impl.SalaryCacheServiceImpl; import com.engine.salary.service.impl.SalaryItemServiceImpl; import com.engine.salary.util.*; import com.engine.salary.util.excel.ExcelUtilPlus; @@ -41,10 +45,12 @@ import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.general.PageIdConst; import weaver.hrm.User; +import weaver.wechat.util.Utils; import java.util.*; import java.util.stream.Collectors; + /** * 薪酬统计维度 *

Copyright: Copyright (c) 2022

@@ -78,11 +84,15 @@ public class SalaryStatisticsReportWrapper extends Service { } private SalaryAcctResultService getSalaryAcctResultService(User user) { - return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); } private SalaryItemService getSalaryItemService(User user) { - return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user); + return ServiceUtil.getService(SalaryItemServiceImpl.class, user); + } + + private SalaryCacheService getSalaryCacheService(User user) { + return ServiceUtil.getService(SalaryCacheServiceImpl.class, user); } /** @@ -136,11 +146,11 @@ public class SalaryStatisticsReportWrapper extends Service { List salaryStatisticsReports = getSalaryStatisticsReportService(user).listAll(); salaryStatisticsReports.stream().forEach(report -> Collections.addAll(haveUsedDimIds, report.getDimension().split(","))); statsDimOptions.stream().forEach(option -> { - if (defaultDimensionIds.contains(Long.valueOf(option.getId()))){ + if (defaultDimensionIds.contains(Long.valueOf(option.getId()))) { // 默认维度不允许修改、删除 option.setCanDelete(false); option.setCanEdit(false); - }else if(haveUsedDimIds.contains(option.getId())){ + } else if (haveUsedDimIds.contains(option.getId())) { // 被薪资统计报表引用的不能删除 option.setCanEdit(true); option.setCanDelete(false); @@ -234,8 +244,8 @@ public class SalaryStatisticsReportWrapper extends Service { * @return */ public Map getData(SalaryStatisticsReportDataQueryParam param) { - - if (param.getId() == null || param.getDimensionId() == null) { + Long id = param.getId(); + if (id == null || param.getDimensionId() == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); } SalaryStatisticsDimensionPO dimension = getSalaryStatisticsDimensionService(user).getById(param.getDimensionId()); @@ -245,10 +255,26 @@ public class SalaryStatisticsReportWrapper extends Service { // weaTable对象 Map weaTable = new HashMap<>(); // 查询报表配置 - SalaryStatisticsReportPO po = this.getSalaryStatisticsReportService(user).getById(param.getId()); + SalaryStatisticsReportPO po = this.getSalaryStatisticsReportService(user).getById(id); if (po == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在")); } + + + String paramMd5 = SecureUtil.md5(param.toString()); + + //已缓存的报表id + String salaryReportIds = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_IDS)); + String salaryReportConditions = ""; + if (StringUtils.isNotBlank(salaryReportIds) && salaryReportIds.contains(id + "")) { + //报表中缓存的条件 + salaryReportConditions = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id)); + if (StringUtils.isNotBlank(salaryReportConditions) && salaryReportConditions.contains(paramMd5)) { + return getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_DATA + paramMd5); + } + } + + // 查询自定义统计项目 List salaryStatisticsItemList = this.getSalaryStatisticsItemService(user).listByStatisticsReportId(po.getId()); // 列表data @@ -265,10 +291,19 @@ public class SalaryStatisticsReportWrapper extends Service { resultMap.put("columns", weaTableColumns); resultMap.put("pageInfo", page); resultMap.put("countResult", countResultMap); - resultMap.put("reportId", param.getId()); + resultMap.put("reportId", id); + + + getSalaryCacheService(user).set(SalaryCacheKey.SALARY_REPORT_IDS, salaryReportIds + "," + id); + getSalaryCacheService(user).set(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id, salaryReportConditions + "," + paramMd5); + getSalaryCacheService(user).set(SalaryCacheKey.SALARY_REPORT_DATA + paramMd5, resultMap); + + return resultMap; } + + /** * 导出报表数据 * @@ -344,6 +379,7 @@ public class SalaryStatisticsReportWrapper extends Service { /** * 获取报表透视数据 + * * @param param * @return */ @@ -371,9 +407,9 @@ public class SalaryStatisticsReportWrapper extends Service { List weaTableColumns = buildDataPerspectiveTableColumns(itemList); WeaTable table = new WeaTable(); - String pageId="a4f85an7-9576-4125-adn9-7d06e7sy69f2"; + String pageId = "a4f85an7-9576-4125-adn9-7d06e7sy69f2"; table.setPageID(pageId); - table.setPageUID(pageId+user.getUID()); + table.setPageUID(pageId + user.getUID()); table.setPagesize(PageIdConst.getPageSize(pageId, user.getUID())); table.setBackfields(""); From 5e6a65e47e7808038485158c72eaa5afe562b749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Thu, 15 Jun 2023 18:48:31 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E7=BC=93=E5=AD=98=EF=BC=8C=E6=9A=82=E5=AD=98=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/dto/SalaryReportCacheInfo.java | 34 ++++ .../SalaryStatisticsReportService.java | 5 +- .../SalaryStatisticsReportServiceImpl.java | 186 +++++++++--------- .../SalaryStatisticsReportWrapper.java | 12 +- .../impl/SalaryAcctResultServiceImpl.java | 24 +++ 5 files changed, 166 insertions(+), 95 deletions(-) create mode 100644 src/com/engine/salary/report/entity/dto/SalaryReportCacheInfo.java diff --git a/src/com/engine/salary/report/entity/dto/SalaryReportCacheInfo.java b/src/com/engine/salary/report/entity/dto/SalaryReportCacheInfo.java new file mode 100644 index 000000000..855a73542 --- /dev/null +++ b/src/com/engine/salary/report/entity/dto/SalaryReportCacheInfo.java @@ -0,0 +1,34 @@ +package com.engine.salary.report.entity.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * 分析图数据展示范围设置 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +//"报表查询入参") +public class SalaryReportCacheInfo { + + List reports; + + class Report { + String key; + List conditions; + } + + + class Condition { + String key; + Map result; + } + +} diff --git a/src/com/engine/salary/report/service/SalaryStatisticsReportService.java b/src/com/engine/salary/report/service/SalaryStatisticsReportService.java index 2d0e144a2..e15572e0d 100644 --- a/src/com/engine/salary/report/service/SalaryStatisticsReportService.java +++ b/src/com/engine/salary/report/service/SalaryStatisticsReportService.java @@ -75,11 +75,10 @@ public interface SalaryStatisticsReportService { * * @param dimension * @param param - * @param salaryStatisticsReport * @param salaryStatisticsItemList * @return */ - PageInfo> buildReportRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataQueryParam param, SalaryStatisticsReportPO salaryStatisticsReport, List salaryStatisticsItemList); + PageInfo> buildReportRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataQueryParam param, List salaryStatisticsItemList); /** * 构建数据透视记录 @@ -97,4 +96,6 @@ public interface SalaryStatisticsReportService { * 清除报表缓存 */ void removeReportCache(); + + } diff --git a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java index 7cee8bc4b..c9a2711e9 100644 --- a/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java +++ b/src/com/engine/salary/report/service/impl/SalaryStatisticsReportServiceImpl.java @@ -181,18 +181,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98080, "名称不允许重复")); } Long id = IdGenerator.generate(); - SalaryStatisticsReportPO poNew = SalaryStatisticsReportPO.builder() - .id(id) - .reportName(saveParam.getReportName()) - .dimension(StringUtils.join(saveParam.getDimensionIds(), ",")) - .createTime(now) - .creator((long) user.getUID()) - .updateTime(now) - .deleteType(0) - .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .salaryStartMonth(SalaryDateUtil.getFirstDayDateOfYear(new Date())) - .salaryEndMonth(SalaryDateUtil.getLastDayOfYear(new Date())) - .build(); + SalaryStatisticsReportPO poNew = SalaryStatisticsReportPO.builder().id(id).reportName(saveParam.getReportName()).dimension(StringUtils.join(saveParam.getDimensionIds(), ",")).createTime(now).creator((long) user.getUID()).updateTime(now).deleteType(0).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).salaryStartMonth(SalaryDateUtil.getFirstDayDateOfYear(new Date())).salaryEndMonth(SalaryDateUtil.getLastDayOfYear(new Date())).build(); getSalaryStatisticsReportMapper().insertIgnoreNull(poNew); // 记录日志 @@ -213,14 +202,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary if (Objects.isNull(param.getSalaryStartMonth()) || Objects.isNull(param.getSalaryEndMonth())) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100294, "薪资所属月必传")); } - if ((CollectionUtils.isNotEmpty(param.getTaxAgent()) && param.getTaxAgent().size() > 10) - || (CollectionUtils.isNotEmpty(param.getIncomeCategory()) && param.getIncomeCategory().size() > 10) - || (CollectionUtils.isNotEmpty(param.getSubCompany()) && param.getSubCompany().size() > 10) - || (CollectionUtils.isNotEmpty(param.getGrade()) && param.getGrade().size() > 10) - || (CollectionUtils.isNotEmpty(param.getPosition()) && param.getPosition().size() > 10) - || (CollectionUtils.isNotEmpty(param.getStatus()) && param.getStatus().size() > 10) - || (CollectionUtils.isNotEmpty(param.getEmployee()) && param.getEmployee().size() > 10) - ) { + if ((CollectionUtils.isNotEmpty(param.getTaxAgent()) && param.getTaxAgent().size() > 10) || (CollectionUtils.isNotEmpty(param.getIncomeCategory()) && param.getIncomeCategory().size() > 10) || (CollectionUtils.isNotEmpty(param.getSubCompany()) && param.getSubCompany().size() > 10) || (CollectionUtils.isNotEmpty(param.getGrade()) && param.getGrade().size() > 10) || (CollectionUtils.isNotEmpty(param.getPosition()) && param.getPosition().size() > 10) || (CollectionUtils.isNotEmpty(param.getStatus()) && param.getStatus().size() > 10) || (CollectionUtils.isNotEmpty(param.getEmployee()) && param.getEmployee().size() > 10)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(182014, "统计数据范围条件数量过多")); } @@ -318,8 +300,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary String resultType = "success"; // 单个设为定薪提示 if (total > 1) { - resultMsg = SalaryI18nUtil.getI18nLabel(134807, "成功条数") + ": " + (success) + "; " - + SalaryI18nUtil.getI18nLabel(134808, "失败条数") + ": " + (total - success); + resultMsg = SalaryI18nUtil.getI18nLabel(134807, "成功条数") + ": " + (success) + "; " + SalaryI18nUtil.getI18nLabel(134808, "失败条数") + ": " + (total - success); if ((total - success) > 0) { resultType = "info"; } @@ -332,14 +313,13 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary } @Override - public PageInfo> buildReportRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataQueryParam param, SalaryStatisticsReportPO po, List salaryStatisticsItemList) { + public PageInfo> buildReportRecords(SalaryStatisticsDimensionPO dimension, SalaryStatisticsReportDataQueryParam param, List salaryStatisticsItemList) { Map checkMap = SalaryStatisticsReportBO.checkLoad(salaryStatisticsItemList); // 如果一个都没有,直接返回 if (!checkMap.get("isNow")) { return new PageInfo>(); } - // 参数转换 - SalaryStatisticsReportBO.poToQueryParam(param, po); + // 获取本期报表分权后的核算人员 List list = getSalaryAcctEmployeeService(user).listBySalaryStatisticsReportParam(param); @@ -350,14 +330,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary // 获取去年同期报表分权后的核算人员 List sameList = checkMap.get("isSame") ? getSalaryAcctEmployeeService(user).listBySalaryStatisticsReportParam(sameParam) : Lists.newArrayList(); - SalaryStatisticsReportDataDTO salaryStatisticsReportData = SalaryStatisticsReportDataDTO.builder() - .list(list) - .lastList(lastList) - .sameList(sameList) - .salaryStatisticsItemList(salaryStatisticsItemList) - .employeeId((long) user.getUID()) - .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .build(); + SalaryStatisticsReportDataDTO salaryStatisticsReportData = SalaryStatisticsReportDataDTO.builder().list(list).lastList(lastList).sameList(sameList).salaryStatisticsItemList(salaryStatisticsItemList).employeeId((long) user.getUID()).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).build(); List allList = Lists.newArrayList(); allList.addAll(list); @@ -380,8 +353,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary @Override public PageInfo> buildDataPerspectiveRecords(SalaryStatisticsDataPerspectiveQueryParam param, SalaryStatisticsReportPO reportPO, SalaryStatisticsDimensionPO dimension, List salaryStatisticsItemPOS) { // 获取报表统计薪资项目 - List salaryItemIds = salaryStatisticsItemPOS.stream().filter(item -> StringUtils.isNotBlank(item.getItemValue())).map(p -> p.getItemValue().split(",")) - .flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList()); + List salaryItemIds = salaryStatisticsItemPOS.stream().filter(item -> StringUtils.isNotBlank(item.getItemValue())).map(p -> p.getItemValue().split(",")).flatMap(Arrays::stream).map(Long::valueOf).collect(Collectors.toList()); // 参数转换 param.setSalaryStartMonth(SalaryDateUtil.getFormatYearMonth(reportPO.getSalaryStartMonth())); param.setSalaryEndMonth(SalaryDateUtil.getFormatYearMonth(reportPO.getSalaryEndMonth())); @@ -392,25 +364,17 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary param.setEmployee(((List) JSON.parseArray(reportPO.getEmployeeSetting(), Map.class)).stream().map(m -> Long.valueOf(m.get(key).toString())).collect(Collectors.toList())); param.setHiredate(JSON.parseArray(reportPO.getHiredateSetting(), Date.class)); SalaryStatisticsReportDataQueryParam queryParam = new SalaryStatisticsReportDataQueryParam(); - com.mzlion.core.utils.BeanUtils.copyProperties(param,queryParam); + com.mzlion.core.utils.BeanUtils.copyProperties(param, queryParam); // 获取本期报表分权后的核算人员 List salaryAcctEmployeeList = getSalaryAcctEmployeeService(user).listBySalaryStatisticsReportParam(queryParam); // 设置dimensionValue为维度值 - SalaryStatisticsReportDataDTO salaryStatisticsReportData = SalaryStatisticsReportDataDTO.builder() - .list(salaryAcctEmployeeList) - .lastList(Collections.emptyList()) - .sameList(Collections.emptyList()) - .salaryStatisticsItemList(salaryStatisticsItemPOS) - .employeeId((long) user.getUID()) - .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) - .dimensionValue(param.getDimensionValue()) - .build(); + SalaryStatisticsReportDataDTO salaryStatisticsReportData = SalaryStatisticsReportDataDTO.builder().list(salaryAcctEmployeeList).lastList(Collections.emptyList()).sameList(Collections.emptyList()).salaryStatisticsItemList(salaryStatisticsItemPOS).employeeId((long) user.getUID()).tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).dimensionValue(param.getDimensionValue()).build(); // 获取根据维度值过滤出的本次核算人员信息 calculateReportRecordsByDimension(dimension, SalaryStatisticsReportDataQueryParam.builder().build(), salaryStatisticsReportData, Collections.EMPTY_MAP); List listByDimensionValue = salaryStatisticsReportData.getListByDimensionValue(); - if(CollectionUtils.isEmpty(listByDimensionValue)){ + if (CollectionUtils.isEmpty(listByDimensionValue)) { throw new SalaryRunTimeException("该维度值中无数据!"); } // 同一个人放在一起 @@ -441,23 +405,65 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary public void removeReportCache() { //获取所有缓存报表的id String salaryReportIds = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_IDS)); - Arrays.asList(salaryReportIds.split(",")).forEach(id -> { - //报表下条件id - String salaryReportConditions = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id); - Arrays.asList(salaryReportConditions.split(",")).forEach(paramMd5 -> - //条件对应的结果 - getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_DATA + paramMd5) - ); - getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id); - }); - getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_IDS); + if (StringUtils.isNotBlank(salaryReportIds)) { + Arrays.asList(salaryReportIds.split(",")).forEach(id -> { + if (StringUtils.isNotBlank(id)) { + //报表下条件id + String salaryReportConditions = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id); + if (StringUtils.isNotBlank(salaryReportConditions)) { + Arrays.asList(salaryReportConditions.split(",")).forEach(paramMd5 -> { + if (StringUtils.isNotBlank(paramMd5)) { + //条件对应的结果 + getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_DATA + paramMd5); + } + } + ); + getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id); + } + } + }); + getSalaryCacheService(user).remove(SalaryCacheKey.SALARY_REPORT_IDS); + } + + } + + public List getReportCache() { + List report = new ArrayList<>(); + + //获取所有缓存报表的id + String salaryReportIds = Utils.null2String(getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_IDS)); + if (StringUtils.isNotBlank(salaryReportIds)) { + Arrays.asList(salaryReportIds.split(",")).forEach(id -> { + if (StringUtils.isNotBlank(id)) { + //报表下条件id + String salaryReportConditions = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_CONDITIONS + id); + List c= new ArrayList<>(); + if (StringUtils.isNotBlank(salaryReportConditions)) { + Arrays.asList(salaryReportConditions.split(",")).forEach(paramMd5 -> { + if (StringUtils.isNotBlank(paramMd5)) { + Map data = getSalaryCacheService(user).get(SalaryCacheKey.SALARY_REPORT_DATA + paramMd5); + Map kv= new HashMap<>(); + kv.put(paramMd5,data); + c.add(kv); + } + } + ); + report.add(c); + } + } + }); + } + + return report; + } /** * 获取根据维度值过滤出的本次核算人员信息 + * * @param listByDimensionValue 根据维度筛选后的薪资核算人员 - * @param map 薪资核算结果 + * @param map 薪资核算结果 */ private List> buildResultRecords(List listByDimensionValue, Map> map) { // 获取人员信息 @@ -488,7 +494,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary resultMap.put("departmentName", emp == null ? "" : emp.getDepartmentName()); resultMap.put("salaryMonth", SalaryDateUtil.getFormatYearMonth(se.getSalaryMonth())); resultMap.put("taxAgent", taxAgentMap.get(se.getTaxAgentId())); - resultMap.put("salarySob",SalarySobMap.get(se.getSalarySobId())); + resultMap.put("salarySob", SalarySobMap.get(se.getSalarySobId())); resultMap.put("acctTimes", salaryAcctRecordMap.get(se.getSalaryAcctRecordId())); resultList.add(resultMap); } @@ -571,12 +577,12 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary List salaryMonthList = listMap.keySet().stream().sorted().collect(Collectors.toList()); String dimensionValue = data.getDimensionValue(); salaryMonthList.forEach(k -> { - if(dimensionValue == null ){ + if (dimensionValue == null) { Map temp = new HashMap<>(); temp.put(DM, SalaryDateUtil.getFormatYearMonth(k)); temp.putAll(SalaryStatisticsReportBO.calculateItem(listMap.get(k), lastListMap.get(ReportTimeUtil.getLastYearMonth(k)), sameListMap.get(ReportTimeUtil.getSameYearMonth(k)), salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if( StringUtils.equals(dimensionValue,SalaryDateUtil.getFormatYearMonth(k)) ){ + } else if (StringUtils.equals(dimensionValue, SalaryDateUtil.getFormatYearMonth(k))) { data.setListByDimensionValue(listMap.get(k)); } }); @@ -596,12 +602,12 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary Map taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentList, TaxAgentPO::getId, TaxAgentPO::getName); String dimensionValue = data.getDimensionValue(); listMap.forEach((k, v) -> { - if(dimensionValue == null ){ + if (dimensionValue == null) { Map temp = new HashMap<>(); temp.put(DM, taxAgentMap.get(k)); temp.putAll(SalaryStatisticsReportBO.calculateItem(v, lastListMap.get(k), sameListMap.get(k), salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if(StringUtils.equals(dimensionValue, taxAgentMap.get(k))){ + } else if (StringUtils.equals(dimensionValue, taxAgentMap.get(k))) { data.setListByDimensionValue(v); } }); @@ -668,7 +674,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary String dimensionValue = data.getDimensionValue(); subComIds.forEach(subComId -> { - if(dimensionValue == null ){ + if (dimensionValue == null) { List subComEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); List lastSubComEmployeePOS = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); List sameSubComEmployeePOS = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); @@ -676,13 +682,13 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary temp.put(DM, subComIdNameMap.get(subComId)); temp.putAll(SalaryStatisticsReportBO.calculateItem(subComEmployeePOS, lastSubComEmployeePOS, sameSubComEmployeePOS, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if( StringUtils.equals(dimensionValue, subComIdNameMap.get(subComId)) ){ + } else if (StringUtils.equals(dimensionValue, subComIdNameMap.get(subComId))) { List subComEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdSubComMap.get(po.getEmployeeId()), subComId)).collect(Collectors.toList()); data.setListByDimensionValue(subComEmployeePOS); } }); - if(dimensionValue == null){ + if (dimensionValue == null) { List noGroupingList = data.getList().stream().filter(po -> empIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); @@ -692,7 +698,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(noGrouping); } - }else if( StringUtils.equals(dimensionValue, "无分组") ){ + } else if (StringUtils.equals(dimensionValue, "无分组")) { List noGroupingList = data.getList().stream().filter(po -> empIdSubComMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); data.setListByDimensionValue(noGroupingList); } @@ -737,7 +743,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary String dimensionValue = data.getDimensionValue(); departIds.forEach(departId -> { - if(dimensionValue == null ){ + if (dimensionValue == null) { List departEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdDepartIdMap.get(po.getEmployeeId()), departId)).collect(Collectors.toList()); List lastDepartEmployeePOS = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdDepartIdMap.get(po.getEmployeeId()), departId)).collect(Collectors.toList()); List sameDepartEmployeePOS = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdDepartIdMap.get(po.getEmployeeId()), departId)).collect(Collectors.toList()); @@ -745,13 +751,13 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary temp.put(DM, departIdNameMap.get(departId)); temp.putAll(SalaryStatisticsReportBO.calculateItem(departEmployeePOS, lastDepartEmployeePOS, sameDepartEmployeePOS, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if( StringUtils.equals(dimensionValue, departIdNameMap.get(departId)) ){ + } else if (StringUtils.equals(dimensionValue, departIdNameMap.get(departId))) { List departEmployeePOS = data.getList().stream().filter(po -> Objects.equals(empIdDepartIdMap.get(po.getEmployeeId()), departId)).collect(Collectors.toList()); data.setListByDimensionValue(departEmployeePOS); } }); - if(dimensionValue == null ){ + if (dimensionValue == null) { List noGroupingList = data.getList().stream().filter(po -> empIdDepartIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdDepartIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); List sameNoGroupingList = data.getSameList().stream().filter(po -> lastEmpIdDepartIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); @@ -761,7 +767,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(noGrouping); } - }else if( StringUtils.equals(dimensionValue, "无分组") ){ + } else if (StringUtils.equals(dimensionValue, "无分组")) { List noGroupingList = data.getList().stream().filter(po -> empIdDepartIdMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); data.setListByDimensionValue(noGroupingList); } @@ -979,13 +985,13 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary String dimensionValue = data.getDimensionValue(); employeeListMap.forEach((k, v) -> { - if(dimensionValue == null ){ + if (dimensionValue == null) { Map temp = new HashMap<>(); // temp.put(DM, Objects.nonNull(employeeByIdMap.get(k)) ? employeeByIdMap.get(k) : employeeExtByIdMap.get(k)); temp.put(DM, employeeByIdMap.get(k)); temp.putAll(SalaryStatisticsReportBO.calculateItem(v, lastEmployeeListMap.get(k), sameEmployeeListMap.get(k), salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if( StringUtils.equals(dimensionValue, employeeByIdMap.get(k)) ){ + } else if (StringUtils.equals(dimensionValue, employeeByIdMap.get(k))) { data.setListByDimensionValue(v); } }); @@ -1006,7 +1012,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary String dimensionValue = data.getDimensionValue(); quarters.forEach(k -> { - if(dimensionValue == null ){ + if (dimensionValue == null) { List listYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getQuarter(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); List lastListYear = data.getLastList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getQuarter(ReportTimeUtil.getPlusYearMonth(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth()), 3)))).collect(Collectors.toList()); List sameListYear = data.getSameList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getQuarter(ReportTimeUtil.getPlusYearMonth(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth()), 12)))).collect(Collectors.toList()); @@ -1014,7 +1020,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary temp.put(DM, k); temp.putAll(SalaryStatisticsReportBO.calculateItem(listYear, lastListYear, sameListYear, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if(StringUtils.equals(dimensionValue, k)){ + } else if (StringUtils.equals(dimensionValue, k)) { List listYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getQuarter(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); data.setListByDimensionValue(listYear); } @@ -1035,7 +1041,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary String dimensionValue = data.getDimensionValue(); halfYears.forEach(k -> { - if(dimensionValue == null){ + if (dimensionValue == null) { List listHalfYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getHalfYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); List lastListHalfYear = data.getLastList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getHalfYear(ReportTimeUtil.getPlusYearMonth(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth()), 6)))).collect(Collectors.toList()); List sameListHalfYear = data.getSameList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getHalfYear(ReportTimeUtil.getPlusYearMonth(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth()), 12)))).collect(Collectors.toList()); @@ -1043,7 +1049,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary temp.put(DM, k); temp.putAll(SalaryStatisticsReportBO.calculateItem(listHalfYear, lastListHalfYear, sameListHalfYear, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if(StringUtils.equals(dimensionValue, k)){ + } else if (StringUtils.equals(dimensionValue, k)) { List listHalfYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getHalfYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); data.setListByDimensionValue(listHalfYear); } @@ -1064,7 +1070,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary String dimensionValue = data.getDimensionValue(); years.forEach(k -> { - if(dimensionValue == null ){ + if (dimensionValue == null) { List listYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); List lastListYear = data.getLastList().stream().filter(sa -> Objects.equals(ReportTimeUtil.getLastYear(k), ReportTimeUtil.getYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); List sameListYear = data.getSameList().stream().filter(sa -> Objects.equals(ReportTimeUtil.getLastYear(k), ReportTimeUtil.getYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); @@ -1072,7 +1078,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary temp.put(DM, k); temp.putAll(SalaryStatisticsReportBO.calculateItem(listYear, lastListYear, sameListYear, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if( StringUtils.equals(dimensionValue, k) ){ + } else if (StringUtils.equals(dimensionValue, k)) { List listYear = data.getList().stream().filter(sa -> Objects.equals(k, ReportTimeUtil.getYear(SalaryDateUtil.getFormatYearMonth(sa.getSalaryMonth())))).collect(Collectors.toList()); data.setListByDimensionValue(listYear); } @@ -1720,7 +1726,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary String dimensionValue = data.getDimensionValue(); workYears.forEach(k -> { - if(dimensionValue == null ){ + if (dimensionValue == null) { List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); @@ -1728,13 +1734,13 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary temp.put(DM, k); temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if( Double.compare(Double.valueOf(dimensionValue), k) == 0 ){ + } else if (Double.compare(Double.valueOf(dimensionValue), k) == 0) { List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdWorkYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); data.setListByDimensionValue(salaryAcctEmployees); } }); - if(dimensionValue == null ){ + if (dimensionValue == null) { List noGroupingList = data.getList().stream().filter(po -> empIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); List sameNoGroupingList = data.getSameList().stream().filter(po -> lastEmpIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); @@ -1744,7 +1750,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(noGrouping); } - }else if( StringUtils.equals(dimensionValue, "无分组") ){ + } else if (StringUtils.equals(dimensionValue, "无分组")) { List noGroupingList = data.getList().stream().filter(po -> empIdWorkYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); data.setListByDimensionValue(noGroupingList); } @@ -1788,7 +1794,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary String dimensionValue = data.getDimensionValue(); companyYears.forEach(k -> { - if(dimensionValue == null ){ + if (dimensionValue == null) { List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); List lastSalaryAcctEmployees = data.getLastList().stream().filter(po -> Objects.equals(lastEmpIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); List sameSalaryAcctEmployees = data.getSameList().stream().filter(po -> Objects.equals(sameEmpIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); @@ -1796,13 +1802,13 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary temp.put(DM, k); temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if( StringUtils.equals(dimensionValue, k) ){ + } else if (StringUtils.equals(dimensionValue, k)) { List salaryAcctEmployees = data.getList().stream().filter(po -> Objects.equals(empIdCompanyYearMap.get(po.getEmployeeId()), k)).collect(Collectors.toList()); data.setListByDimensionValue(salaryAcctEmployees); } }); - if(dimensionValue == null ){ + if (dimensionValue == null) { List noGroupingList = data.getList().stream().filter(po -> empIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); List lastNoGroupingList = data.getLastList().stream().filter(po -> lastEmpIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); List sameNoGroupingList = data.getSameList().stream().filter(po -> sameEmpIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); @@ -1812,7 +1818,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary noGrouping.putAll(SalaryStatisticsReportBO.calculateItem(noGroupingList, lastNoGroupingList, sameNoGroupingList, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(noGrouping); } - }else if( StringUtils.equals(dimensionValue, "无分组")){ + } else if (StringUtils.equals(dimensionValue, "无分组")) { List noGroupingList = data.getList().stream().filter(po -> empIdCompanyYearMap.get(po.getEmployeeId()) == null).collect(Collectors.toList()); data.setListByDimensionValue(noGroupingList); } @@ -1856,7 +1862,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary } String dimensionValue = data.getDimensionValue(); groups.forEach(k -> { - if(dimensionValue == null ){ + if (dimensionValue == null) { List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); List lastSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getLastList(), lastEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); List sameSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getSameList(), sameEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); @@ -1864,7 +1870,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary temp.put(DM, k.getStartValue() + "-" + k.getEndValue()); temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if( StringUtils.equals(dimensionValue, k.getStartValue() + "-" + k.getEndValue()) ){ + } else if (StringUtils.equals(dimensionValue, k.getStartValue() + "-" + k.getEndValue())) { List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupSpacing(k, groupBelong, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); data.setListByDimensionValue(salaryAcctEmployees); } @@ -1937,7 +1943,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary String dimensionValue = data.getDimensionValue(); groups.forEach(k -> { - if(dimensionValue == null ){ + if (dimensionValue == null) { List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, groupBelong, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); List lastSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, groupBelong, dimension.getDimCode(), data.getLastList(), lastEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); List sameSalaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, groupBelong, dimension.getDimCode(), data.getSameList(), sameEmpIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); @@ -1945,7 +1951,7 @@ public class SalaryStatisticsReportServiceImpl extends Service implements Salary temp.put(DM, k.getValue()); temp.putAll(SalaryStatisticsReportBO.calculateItem(salaryAcctEmployees, lastSalaryAcctEmployees, sameSalaryAcctEmployees, salaryAcctResultValueMap, data.getSalaryStatisticsItemList())); records.add(temp); - }else if( StringUtils.equals(dimensionValue, k.getValue()) ){ + } else if (StringUtils.equals(dimensionValue, k.getValue())) { List salaryAcctEmployees = SalaryStatisticsReportBO.listAcctEmpByRationGroupIndividual(k, groupBelong, dimension.getDimCode(), data.getList(), empIdYearMap, salaryAcctResultValueMap, data.getSalaryStatisticsItemList()); data.setListByDimensionValue(salaryAcctEmployees); } diff --git a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java index ce1d797ec..8b2f1b08b 100644 --- a/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java +++ b/src/com/engine/salary/report/wrapper/SalaryStatisticsReportWrapper.java @@ -260,6 +260,9 @@ public class SalaryStatisticsReportWrapper extends Service { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161845, "薪酬统计报表不存在")); } + // 参数转换 + SalaryStatisticsReportBO.poToQueryParam(param, po); + String paramMd5 = SecureUtil.md5(param.toString()); @@ -278,7 +281,7 @@ public class SalaryStatisticsReportWrapper extends Service { // 查询自定义统计项目 List salaryStatisticsItemList = this.getSalaryStatisticsItemService(user).listByStatisticsReportId(po.getId()); // 列表data - PageInfo> page = this.getSalaryStatisticsReportService(user).buildReportRecords(dimension, param, po, salaryStatisticsItemList); + PageInfo> page = this.getSalaryStatisticsReportService(user).buildReportRecords(dimension, param, salaryStatisticsItemList); // 组装合计 Map countResultMap = SalaryStatisticsReportBO.buildTotal(page, salaryStatisticsItemList, (long) user.getUID()); @@ -303,7 +306,6 @@ public class SalaryStatisticsReportWrapper extends Service { } - /** * 导出报表数据 * @@ -323,10 +325,14 @@ public class SalaryStatisticsReportWrapper extends Service { if (dimension == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(161300, "统计维度不存在")); } + + // 参数转换 + SalaryStatisticsReportBO.poToQueryParam(param, po); + // 查询自定义统计项目 List salaryStatisticsItemList = this.getSalaryStatisticsItemService(user).listByStatisticsReportId(po.getId()); // 列表data - PageInfo> page = this.getSalaryStatisticsReportService(user).buildReportRecords(dimension, param, po, salaryStatisticsItemList); + PageInfo> page = this.getSalaryStatisticsReportService(user).buildReportRecords(dimension, param, salaryStatisticsItemList); // 组装合计 Map countResultMap = SalaryStatisticsReportBO.buildTotal(page, salaryStatisticsItemList, (long) user.getUID()); List> list = page.getList(); diff --git a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java index 2c04d6137..b23942d95 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java @@ -29,6 +29,8 @@ import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; import com.engine.salary.enums.salarysob.IncomeCategoryEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper; +import com.engine.salary.report.service.SalaryStatisticsReportService; +import com.engine.salary.report.service.impl.SalaryStatisticsReportServiceImpl; import com.engine.salary.service.*; import com.engine.salary.sys.constant.SalarySysConstant; import com.engine.salary.sys.entity.po.SalarySysConfPO; @@ -167,6 +169,10 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); } + private SalaryStatisticsReportService getSalaryStatisticsReportService(User user) { + return ServiceUtil.getService(SalaryStatisticsReportServiceImpl.class, user); + } + private SalaryCheckResultService salaryCheckResultService; @@ -584,6 +590,9 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS); } + //删除报表缓存 + getSalaryStatisticsReportService(user).removeReportCache(); + // 存储薪资核算结果数据来源日志 salaryAcctResultPOS = getSalaryAcctRecordService(user).listBySalaryAcctEmpId(saveParam.getSalaryAcctEmpId()); saveSalaryAcctResultLog(salaryAcctResultPOSOld,salaryAcctResultPOS); @@ -638,6 +647,9 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe encryptUtil.encryptList(list, SalaryAcctResultPO.class); List> partition = Lists.partition(list, 100); partition.forEach(getSalaryAcctResultMapper()::batchInsert); + + //删除报表缓存 + getSalaryStatisticsReportService(user).removeReportCache(); } } @@ -645,17 +657,26 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe @Override public void deleteBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds) { getSalaryAcctResultMapper().deleteBySalaryAcctEmpIds(salaryAcctEmployeeIds); + + //删除报表缓存 + getSalaryStatisticsReportService(user).removeReportCache(); } @Override public void deleteByAcctEmployeeIdsAndSalaryItemIds(Collection salaryAcctEmployeeIds, Collection salaryItemIds) { getSalaryAcctResultMapper().deleteByAcctEmpIdsAndSalaryItemIds(salaryAcctEmployeeIds, salaryItemIds); + + //删除报表缓存 + getSalaryStatisticsReportService(user).removeReportCache(); } @Override public void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { getSalaryAcctResultMapper().deleteBySalaryAcctRecordIds(salaryAcctRecordIds); + + //删除报表缓存 + getSalaryStatisticsReportService(user).removeReportCache(); } @Override @@ -976,6 +997,9 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe for (List subSalaryAcctResultValues : partition) { getSalaryAcctResultMapper().batchUpdateOriginResultValue(subSalaryAcctResultValues); } + + //删除报表缓存 + getSalaryStatisticsReportService(user).removeReportCache(); } private Set canLockSalaryItemIds(Long salarySobId) { From ec67c89e7df35b1bc005cd40bf63c706e82477ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Fri, 16 Jun 2023 13:49:40 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E6=8E=92=E9=99=A4?= =?UTF-8?q?=E6=8E=89=E6=9C=AA=E5=BD=92=E6=A1=A3=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SalaryAcctEmployeeServiceImpl.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java index 79f5de0a6..37889bc2e 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctEmployeeServiceImpl.java @@ -583,7 +583,25 @@ public class SalaryAcctEmployeeServiceImpl extends Service implements SalaryAcct // lambdaQueryChainWrapper.in(SalaryAcctEmployeePO::getIncomeCategory, param.getIncomeCategory().stream().map(Object::toString).collect(Collectors.toList())); // } - List list = getSalaryAcctEmployeeMapper().listSome(lambdaQueryChainWrapper); + //排除未归档数据 + List salaryAcctRecordPOS = getSalaryAcctRecordService(user).listAll(); + List salaryAcctRecordIds = salaryAcctRecordPOS.stream() + .filter(po -> !Objects.equals(po.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) + .map(SalaryAcctRecordPO::getId) + .collect(Collectors.toList()); + + List list = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(salaryAcctRecordIds)) { + //分片查询 + List> partition = Lists.partition(salaryAcctRecordIds, 500); + List empList = new ArrayList<>(); + partition.forEach(part -> { + lambdaQueryChainWrapper.setSalaryAcctRecordIds(salaryAcctRecordIds); + empList.addAll(getSalaryAcctEmployeeMapper().listSome(lambdaQueryChainWrapper)); + }); + list = empList; + } + if (CollectionUtils.isEmpty(list)) { return Lists.newArrayList(); } From 16cf63018f42913f57a548b6599db8e6d4d04438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 19 Jun 2023 09:54:02 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=A0=B8=E7=AE=97?= =?UTF-8?q?=E6=88=96=E8=80=85=E5=9B=9E=E7=AE=97=E6=97=B6=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SalaryAcctRecordServiceImpl.java | 12 ++++++++++++ .../impl/SalaryAcctResultServiceImpl.java | 16 ---------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index 434b74638..190f9a842 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -18,6 +18,8 @@ import com.engine.salary.enums.salarysob.IncomeCategoryEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; import com.engine.salary.mapper.salarybill.SalarySendMapper; +import com.engine.salary.report.service.SalaryStatisticsReportService; +import com.engine.salary.report.service.impl.SalaryStatisticsReportServiceImpl; import com.engine.salary.service.*; import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum; import com.engine.salary.sys.service.SalarySysConfService; @@ -96,6 +98,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe return ServiceUtil.getService(SalaryAcctReportServiceImpl.class, user); } + private SalaryStatisticsReportService getSalaryStatisticsReportService(User user) { + return ServiceUtil.getService(SalaryStatisticsReportServiceImpl.class, user); + } + @Override public SalaryAcctRecordPO getById(Long id) { @@ -551,6 +557,9 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe // 生成工资单 getSalarySendService(user).generateSalaryBill(salaryAcctRecordId); + //删除报表缓存 + getSalaryStatisticsReportService(user).removeReportCache(); + // 记录日志 // String targetName = getLogTargetNameById(salaryAcctRecordId); @@ -675,6 +684,9 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()); salaryAcctRecordPO.setUpdateTime(new Date()); getSalaryAcctRecordMapper().updateIgnoreNull(salaryAcctRecordPO); + + //删除报表缓存 + getSalaryStatisticsReportService(user).removeReportCache(); } diff --git a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java index b23942d95..19831f17c 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java @@ -590,8 +590,6 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe getSalaryAcctReportService(user).batchSave(salaryAcctResultReportPOS); } - //删除报表缓存 - getSalaryStatisticsReportService(user).removeReportCache(); // 存储薪资核算结果数据来源日志 salaryAcctResultPOS = getSalaryAcctRecordService(user).listBySalaryAcctEmpId(saveParam.getSalaryAcctEmpId()); @@ -648,8 +646,6 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe List> partition = Lists.partition(list, 100); partition.forEach(getSalaryAcctResultMapper()::batchInsert); - //删除报表缓存 - getSalaryStatisticsReportService(user).removeReportCache(); } } @@ -657,26 +653,17 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe @Override public void deleteBySalaryAcctEmployeeIds(Collection salaryAcctEmployeeIds) { getSalaryAcctResultMapper().deleteBySalaryAcctEmpIds(salaryAcctEmployeeIds); - - //删除报表缓存 - getSalaryStatisticsReportService(user).removeReportCache(); } @Override public void deleteByAcctEmployeeIdsAndSalaryItemIds(Collection salaryAcctEmployeeIds, Collection salaryItemIds) { getSalaryAcctResultMapper().deleteByAcctEmpIdsAndSalaryItemIds(salaryAcctEmployeeIds, salaryItemIds); - - //删除报表缓存 - getSalaryStatisticsReportService(user).removeReportCache(); } @Override public void deleteBySalaryAcctRecordIds(Collection salaryAcctRecordIds) { getSalaryAcctResultMapper().deleteBySalaryAcctRecordIds(salaryAcctRecordIds); - - //删除报表缓存 - getSalaryStatisticsReportService(user).removeReportCache(); } @Override @@ -997,9 +984,6 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe for (List subSalaryAcctResultValues : partition) { getSalaryAcctResultMapper().batchUpdateOriginResultValue(subSalaryAcctResultValues); } - - //删除报表缓存 - getSalaryStatisticsReportService(user).removeReportCache(); } private Set canLockSalaryItemIds(Long salarySobId) {