From b0084cad9cfebfca5d87725c0c5ef37cb16e02e4 Mon Sep 17 00:00:00 2001 From: Harryxzy Date: Thu, 11 May 2023 14:40:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E8=B5=84=E6=A0=B8=E7=AE=97=E7=BC=96?= =?UTF-8?q?=E8=BE=91=20=E6=89=8B=E5=8A=A8=E7=BC=96=E8=BE=91=E5=90=8E?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=94=81=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salaryacct/bo/SalaryAcctResultBO.java | 53 ++++++++++++++++--- .../dto/SalaryAcctResultDetailDTO.java | 22 ++++++++ .../impl/SalaryAcctResultServiceImpl.java | 25 +++++++-- 3 files changed, 91 insertions(+), 9 deletions(-) diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java index 96bd7353f..8822dcc6d 100644 --- a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctResultBO.java @@ -15,10 +15,7 @@ import com.engine.salary.entity.salarysob.dto.SalarySobEmpFieldDTO; import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; import com.engine.salary.entity.salarysob.dto.SalarySobItemDTO; import com.engine.salary.entity.salarysob.dto.SalarySobItemGroupDTO; -import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO; -import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO; -import com.engine.salary.entity.salarysob.po.SalarySobItemPO; -import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.salarysob.po.*; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.salaryaccounting.LockStatusEnum; import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; @@ -369,6 +366,7 @@ public class SalaryAcctResultBO { TaxAgentPO taxAgentPO, SalaryAcctEmployeePO salaryAcctEmployee, List salarySobEmpFields, + List salarySobItemGroupPOS, List salarySobItemPOS, List salaryItems, List salaryAcctResults, @@ -391,6 +389,26 @@ public class SalaryAcctResultBO { Map resultValueMap = SalaryEntityUtil.convert2Map(salaryAcctResults, SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue); Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId); Map salaryBackItemMap = SalaryEntityUtil.convert2Map(salaryBackItemPOS, SalaryItemPO::getId); + Map> salarySobItemPOMap = SalaryEntityUtil.group2Map(salarySobItemPOS, SalarySobItemPO::getSalarySobItemGroupId); + + // 对分组进行排序 + salarySobItemGroupPOS = sortGroup(salarySobItemGroupPOS); + // 对分组内薪资项目排序 + sortItem(salarySobItemPOMap); + // 根据账套分组封装薪资项目的值 + List itemsByGroup = new ArrayList<>(); + for(SalarySobItemGroupPO groupPO : salarySobItemGroupPOS){ + List groupItems = salarySobItemPOMap.getOrDefault(groupPO.getId(),Collections.emptyList()); + List items = groupItems.stream() + .map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap)) + .collect(Collectors.toList()); + itemsByGroup.add(SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemByGroupDTO.builder() + .salarySobItemGroupId(groupPO.getId()) + .salarySobItemGroupName(groupPO.getName()) + .salaryItems(items) + .sortedIndex(groupPO.getSortedIndex()).build() ); + } + // 公式项的值(不根据salaryItemPO的valueType判断是因为薪资项目的valueType属性改变后并不会同步更新薪资账套中的薪资项目的formulaId字段) List formulaItems = salarySobItemPOS.stream() .filter(salarySobItemPO -> salarySobItemPO.getFormulaId() > 0) @@ -415,10 +433,32 @@ public class SalaryAcctResultBO { .employeeInfos(employeeInfos) .formulaItems(formulaItems) .inputItems(inputItems) + .itemsByGroup(itemsByGroup) .issuedAndReissueItems(issuedAndReissueItems) .build(); } + private static List sortGroup(List salarySobItemGroupPOS) { + if(CollectionUtils.isEmpty(salarySobItemGroupPOS)){ + return Collections.emptyList(); + } + return salarySobItemGroupPOS.stream().sorted(Comparator.comparingInt(SalarySobItemGroupPO::getSortedIndex)).collect(Collectors.toList()); + } + + /** + * 薪资账套的薪资项目按照sortedIndex排序 + * + */ + private static void sortItem(Map> salarySobItemPOMap) { + for(Map.Entry> entry : salarySobItemPOMap.entrySet()){ + List items = entry.getValue(); + if (CollectionUtils.isNotEmpty(items)) { + List sortedValue = items.stream().sorted(Comparator.comparingInt(SalarySobItemPO::getSortedIndex)).collect(Collectors.toList()); + salarySobItemPOMap.put(entry.getKey(), sortedValue); + } + } + } + /** * 转换成薪资核算结果详情dto * @@ -436,7 +476,8 @@ public class SalaryAcctResultBO { .salaryItemName(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY)) .resultValue(resultValueMap.getOrDefault(salarySobItemPO.getSalaryItemId(), StringUtils.EMPTY)) .dataType(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getDataType).orElse(SalaryDataTypeEnum.NUMBER.getValue())) - .canEdit(Objects.equals(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getUseInEmployeeSalary).orElse(0), 0)) +// .canEdit(Objects.equals(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getUseInEmployeeSalary).orElse(0), 0)) + .canEdit(true) .build(); } @@ -492,7 +533,7 @@ public class SalaryAcctResultBO { .salaryAcctEmpId(salaryAcctEmployee.getId()) .employeeId(salaryAcctEmployee.getEmployeeId()) .taxAgentId(salaryAcctEmployee.getTaxAgentId()) - .resultValue(e.getResultValue()) + .resultValue(StringUtils.trim(e.getResultValue())) .originResultValue(salaryAcctResultOldPOMap.get(saveParam.getSalaryAcctEmpId() + "-" + e.getSalaryItemId())) .creator(employeeId) .createTime(now) diff --git a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultDetailDTO.java b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultDetailDTO.java index efd51c4a2..c8d16c683 100644 --- a/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultDetailDTO.java +++ b/src/com/engine/salary/entity/salaryacct/dto/SalaryAcctResultDetailDTO.java @@ -39,6 +39,9 @@ public class SalaryAcctResultDetailDTO { //输入项") private List inputItems; + // 根据账套分组的薪资项目 + private List itemsByGroup; + //已发补发 private List issuedAndReissueItems; @@ -66,4 +69,23 @@ public class SalaryAcctResultDetailDTO { //是否可编辑 private Boolean canEdit; } + + @Data + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class SalaryAcctResultDetailItemByGroupDTO { + + //薪资账套分组id") + private Long salarySobItemGroupId; + + //薪资项目分组名称") + private String salarySobItemGroupName; + + //分组中包含的薪资项目 + private List salaryItems; + + //分组顺序 + private Integer sortedIndex; + } } diff --git a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java index 5f10df7cc..f1ceef54e 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctResultServiceImpl.java @@ -156,6 +156,10 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user); } + private SalaryAcctResultService getSalaryAcctResultService(User user) { + return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user); + } + private SalaryCheckResultService salaryCheckResultService; @@ -271,7 +275,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe TaxAgentPO taxAgent = getTaxAgentService(user).getById(salaryAcctEmployeePO.getTaxAgentId()); // 转换成薪资核算结果详情dto - return SalaryAcctResultBO.convert2DetailDTO(simpleEmployee, taxAgent, salaryAcctEmployeePO, salarySobEmpFieldPOS, salarySobItemPOS, salaryItemPOS, salaryAcctResultPOS, salarySobBackItemPOList, salaryBackItemPOS, salaryBackItemFormula); + return SalaryAcctResultBO.convert2DetailDTO(simpleEmployee, taxAgent, salaryAcctEmployeePO, salarySobEmpFieldPOS, salarySobItemGroupPOS, salarySobItemPOS, salaryItemPOS, salaryAcctResultPOS, salarySobBackItemPOList, salaryBackItemPOS, salaryBackItemFormula); } @Override @@ -523,9 +527,24 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe encryptUtil.decryptList(salaryAcctResultPOSOld, SalaryAcctResultPO.class); // 保存参数转换成薪资核算结果po List salaryAcctResultPOS = SalaryAcctResultBO.convert2PO(salaryAcctResultPOSOld, saveParam, salaryAcctEmployeePO, (long) user.getUID()); + // 对比核算结果提取修改了哪些薪资项目 + Set needLockItems = new HashSet<>(); + Map oldResutMap = SalaryEntityUtil.convert2Map(salaryAcctResultPOSOld, SalaryAcctResultPO::getSalaryItemId); + salaryAcctResultPOS.stream().forEach(PO -> { + String oldValue = oldResutMap.get(PO.getSalaryItemId()).getResultValue(); + if(!StringUtils.equals(oldValue,PO.getResultValue())){ + needLockItems.add(PO.getSalaryItemId()); + } + }); + // 编辑的列都自动锁定 + SalaryAcctResultUpdateLockStatusParam updateLockStatusParam = SalaryAcctResultUpdateLockStatusParam.builder() + .salaryItemIds(needLockItems) + .salaryAcctRecordId(salaryAcctEmployeePO.getSalaryAcctRecordId()) + .lockStatus(LockStatusEnum.LOCK).build(); + getSalaryAcctResultService(user).updateLockStatusByParam(updateLockStatusParam); - SalaryAcctRecordPO byId = getSalaryAcctRecordService(user).getById(salaryAcctEmployeePO.getSalaryAcctRecordId()); +// SalaryAcctRecordPO byId = getSalaryAcctRecordService(user).getById(salaryAcctEmployeePO.getSalaryAcctRecordId()); // 若保存编辑时一同传已发补发,则删除以下代码 // if(byId.getBackCalcStatus() != null && Objects.equals(byId.getBackCalcStatus(),1)){ // // 是回算 @@ -927,4 +946,4 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe // } return salaryItemIds; } -} +} \ No newline at end of file