diff --git a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java index 9e42fc722..f1cc39d43 100644 --- a/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java +++ b/src/com/engine/salary/entity/salaryarchive/bo/SalaryArchiveExcelBO.java @@ -824,20 +824,22 @@ public class SalaryArchiveExcelBO extends Service { Map errorMessageMap = Maps.newHashMap(); errorMessageMap.put("message", rowindex + key + salaryItemNoBeforeCurrentEffectiveTime); excelComments.add(errorMessageMap); -// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryItemNoBeforeCurrentEffectiveTime, errorCount + 1, errorCount + 1, effectiveTimeIndex, effectiveTimeIndex); isError = true; } else if (salaryItemAdjustValid.isSame()) { - Map errorMessageMap = Maps.newHashMap(); - errorMessageMap.put("message", rowindex + key + salaryItemAdjustNoSame); - excelComments.add(errorMessageMap); -// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryItemAdjustNoSame, errorCount + 1, errorCount + 1, j, j); - isError = true; +// Map errorMessageMap = Maps.newHashMap(); +// errorMessageMap.put("message", rowindex + key + salaryItemAdjustNoSame); +// excelComments.add(errorMessageMap); +// isError = true; + + //调整前后相同的值都不做处理 + cellVal = ""; } else if (salaryItemAdjustValid.isSameIneffective()) { - Map errorMessageMap = Maps.newHashMap(); - errorMessageMap.put("message", rowindex + key + salaryItemAdjustNoSameIneffective); - excelComments.add(errorMessageMap); -// SalaryArchiveExcelBO.createExcelComment(excelComments, salaryItemAdjustNoSameIneffective, errorCount + 1, errorCount + 1, j, j); - isError = true; +// Map errorMessageMap = Maps.newHashMap(); +// errorMessageMap.put("message", rowindex + key + salaryItemAdjustNoSameIneffective); +// excelComments.add(errorMessageMap); +// isError = true; + //调整前后相同的值都不做处理 + cellVal = ""; } } // 导入时不需要处理的薪资项目 diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index 713185ddf..f3b6e671a 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -71,8 +71,8 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe return ServiceUtil.getService(SalarySendServiceImpl.class, user); } - private SalarySysConfService getSalarySysConfService(User user){ - return ServiceUtil.getService(SalarySysConfServiceImpl.class,user); + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); } // private SalaryCheckResultService salaryCheckResultService; @@ -132,7 +132,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe } @Override - public List listByTaxCycle(LocalDateRange taxCycleDateRange,Collection salarySobIds) { + public List listByTaxCycle(LocalDateRange taxCycleDateRange, Collection salarySobIds) { return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().taxCycleDateRange(taxCycleDateRange).salarySobIds(salarySobIds).build()); } @@ -170,12 +170,15 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId); if (needAuth) { List salarySobPOS = getSalarySobService(user).listByAdmin(); - Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + List salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId, Collectors.toList()); if (CollectionUtils.isEmpty(salarySobIds)) { return new PageInfo<>(); } - + Collection sobIds = po.getSalarySobIds(); + if (CollectionUtils.isNotEmpty(sobIds)) { + salarySobIds = (List) SalaryEntityUtil.intersectionForList(salarySobIds, sobIds); + } po.setSalarySobIds(salarySobIds); } @@ -226,7 +229,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe // 查询相同税款所属期内的薪资类型为工资薪金的账套的所有核算记录 Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); LocalDateRange taxCycleDateRange = SalaryDateUtil.localDate2Range(salaryAcctRecordPO.getTaxCycle()); - List salaryAcctRecordPOS = listByTaxCycle(taxCycleDateRange,salarySobIds); + List salaryAcctRecordPOS = listByTaxCycle(taxCycleDateRange, salarySobIds); // 除开本次薪资核算记录之外的其他薪资核算记录 return salaryAcctRecordPOS.stream().filter(po -> !Objects.equals(po.getId(), salaryAcctRecordPO.getId())).collect(Collectors.toList()); } @@ -259,7 +262,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe } // 查询税款所属期所在年的所有薪资核算记录 - List salaryAcctRecordPOS = listByTaxCycle(yearRange,Collections.singleton(saveParam.getSalarySobId())); + List salaryAcctRecordPOS = listByTaxCycle(yearRange, Collections.singleton(saveParam.getSalarySobId())); // 计算当前所选的薪资账套是当前薪资所属月的核算次数 long acctTimes = salaryAcctRecordPOS.stream() @@ -310,12 +313,12 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe List salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId); Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); //获取账套下的所有核算结果 - List salaryAcctRecords = listByTaxCycle(taxCycleYearRange,salarySobIds); + List salaryAcctRecords = listByTaxCycle(taxCycleYearRange, salarySobIds); // 获取个税申报功能状态 TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration(); - if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())){ + if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())) { // 关闭了个税申报功能 // 如果某个月(薪资所属期)还未归档,不可以新建之后月份的薪资核算 SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() @@ -323,10 +326,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe && e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) .findAny() .orElse(null); - if(Objects.nonNull(notArchivedSalaryAcctRecordPO)){ + if (Objects.nonNull(notArchivedSalaryAcctRecordPO)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算") - .replace("{0}",SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}",salarySobCycleDTO.getTaxCycle().toString())); + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); } // 如果有某个月(薪资所属期)已经归档了,不可以新建之前月份的薪资核算 SalaryAcctRecordPO havaSalaryAcctRecordPO = salaryAcctRecords.stream() @@ -334,14 +337,14 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) .findAny() .orElse(null); - if(Objects.nonNull(havaSalaryAcctRecordPO)){ + if (Objects.nonNull(havaSalaryAcctRecordPO)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98755, "薪资所属期{0}的薪资核算结果已经归档,不能新建薪资所属期{1}的薪资核算") - .replace("{0}",SalaryDateUtil.localDate2YearMonth(havaSalaryAcctRecordPO.getSalaryMonth()).toString()) - .replace("{1}",salarySobCycleDTO.getSalaryMonth().toString())); + .replace("{0}", SalaryDateUtil.localDate2YearMonth(havaSalaryAcctRecordPO.getSalaryMonth()).toString()) + .replace("{1}", salarySobCycleDTO.getSalaryMonth().toString())); } } - if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())){ + if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())) { // 开启了个税申报功能 // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() @@ -377,7 +380,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); } } - if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())){ + if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())) { // 重启了个税申报功能(不去校验重启之前是否申报数据) // 如果某个月(薪资所属期)还未归档,不可以新建之后月份的薪资核算 SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() @@ -385,10 +388,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe && e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) .findAny() .orElse(null); - if(Objects.nonNull(notArchivedSalaryAcctRecordPO)){ + if (Objects.nonNull(notArchivedSalaryAcctRecordPO)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算") - .replace("{0}",SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}",salarySobCycleDTO.getTaxCycle().toString())); + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); } // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() @@ -404,7 +407,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 //获取账套下从重启月至所在年的最后一天的所有核算结果 Date taxDeclarationRebootDate = getSalarySysConfService(user).getTaxDeclarationRebootDate(); - if(taxDeclarationRebootDate == null){ + if (taxDeclarationRebootDate == null) { throw new SalaryRunTimeException("个税申报功能异常"); } @@ -413,7 +416,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe .endDate(SalaryDateUtil.getLastDayOfYear(taxDeclarationRebootDate)) .build(); // List salaryAcctRebootRecords = listByTaxCycle(taxCycleRebootYearRange,salarySobIds); - List salaryAcctRebootRecords = listByCreateDate(taxCycleRebootYearRange,salarySobIds); + List salaryAcctRebootRecords = listByCreateDate(taxCycleRebootYearRange, salarySobIds); SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRebootRecords.stream() .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) @@ -442,7 +445,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe } private List listByCreateDate(LocalDateRange taxCycleRebootYearRange, Set salarySobIds) { - return getSalaryAcctRecordMapper().listByCreateDate(taxCycleRebootYearRange,salarySobIds); + return getSalaryAcctRecordMapper().listByCreateDate(taxCycleRebootYearRange, salarySobIds); } @@ -541,7 +544,6 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe getSalarySendService(user).generateSalaryBill(salaryAcctRecordId); - // 记录日志 // String targetName = getLogTargetNameById(salaryAcctRecordId); // LoggerContext loggerContext = new LoggerContext<>(); @@ -604,7 +606,6 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe } - private void reCalcOrBackCalc(SalaryAcctRecordPO salaryAcctRecordPO, boolean isReCalc) { // 如果薪资核算记录还未归档,不允许重新核算 if (Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) { @@ -622,7 +623,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe //查询扣缴义务人下的所有账套 List salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId); Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); - List salaryAcctRecordPOS = listByTaxCycle(yearRange,salarySobIds); + List salaryAcctRecordPOS = listByTaxCycle(yearRange, salarySobIds); List selfSalaryAcctRecordPOS = filterByAuthority(salaryAcctRecordPOS); // 如果已经存在之后月份的薪资核算记录了,就不允许重新核算本月了 @@ -654,7 +655,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe List needUpdateSalaryAcctRecordIds = selfSalaryAcctRecordPOS.stream().filter(po -> po.getTaxCycle().equals(salaryAcctRecordPO.getTaxCycle())) .map(SalaryAcctRecordPO::getId).collect(Collectors.toList()); if (Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())) { - if(needUpdateSalaryAcctRecordIds != null && needUpdateSalaryAcctRecordIds.size()>0){ + if (needUpdateSalaryAcctRecordIds != null && needUpdateSalaryAcctRecordIds.size() > 0) { // 更新薪资核算记录的状态 updateStatusByIds(needUpdateSalaryAcctRecordIds, SalaryAcctRecordStatusEnum.ARCHIVED); } @@ -730,14 +731,14 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe // 获取该账套该月核算的所有记录 List salaryAcctRecordPOS = getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().salaryMonth(salaryAcctRecordPO.getSalaryMonth()).salarySobId(salaryAcctRecordPO.getSalarySobId()).deleteType(0).build()); // 只有该账套在此月的最后一次核算才能进行回算 - if(!salaryAcctRecordPO.getAcctTimes().equals(salaryAcctRecordPOS.size())){ - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0,"只有核算次数为最后一次时,才能进行回算")); + if (!salaryAcctRecordPO.getAcctTimes().equals(salaryAcctRecordPOS.size())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "只有核算次数为最后一次时,才能进行回算")); } // 只有正常核算全部发送完才能进行回算 SalarySendPO build = SalarySendPO.builder().salaryAccountingId(salaryAcctRecordId).deleteType(0).build(); List salarySends = getSalarySendMapper().listSome(build); salarySends.stream().forEach(salarySend -> { - if(salarySend.getSendNum() < salarySend.getSendTotal()){ + if (salarySend.getSendNum() < salarySend.getSendTotal()) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(139702, "正常核算工资单尚未全部发送完成,不能进行回算")); } }); diff --git a/src/com/engine/salary/util/SalaryEntityUtil.java b/src/com/engine/salary/util/SalaryEntityUtil.java index 5b6bc0299..695dc2c2e 100644 --- a/src/com/engine/salary/util/SalaryEntityUtil.java +++ b/src/com/engine/salary/util/SalaryEntityUtil.java @@ -163,6 +163,7 @@ public class SalaryEntityUtil { /** * LinkedHashMap有序去重 + * * @param keyExtractor * @param * @return @@ -174,6 +175,7 @@ public class SalaryEntityUtil { /** * ConcurrentHashMap无序去重 + * * @param keyExtractor * @param * @return @@ -325,4 +327,26 @@ public class SalaryEntityUtil { return new Double("0.0"); } + /** + * 两个集合交集,(forEasy) + * + * @param arr1 + * @param arr2 + * @return + */ + public static Collection intersectionForList(Collection arr1, Collection arr2) { + + Collection resultList = new ArrayList<>(); + + if (CollectionUtils.isEmpty(arr1) || CollectionUtils.isEmpty(arr1)) { + return resultList; + } + arr1.forEach(a1 -> { + if (arr2.contains(a1)) { + resultList.add(a1); + } + }); + return resultList; + } + } diff --git a/src/com/engine/salary/wrapper/SalaryItemWrapper.java b/src/com/engine/salary/wrapper/SalaryItemWrapper.java index bf57ed267..58c829c07 100644 --- a/src/com/engine/salary/wrapper/SalaryItemWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryItemWrapper.java @@ -31,6 +31,7 @@ import com.engine.salary.util.valid.RuntimeTypeEnum; import com.engine.salary.util.valid.ValidUtil; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.math.NumberUtils; +import org.apache.commons.lang3.StringUtils; import weaver.hrm.User; import java.util.*; @@ -96,7 +97,7 @@ public class SalaryItemWrapper extends Service { List salaryItemListDTOS = SalaryItemBO.convert2ListDTO(salaryItemList, expressFormulas, sysSalaryItemPOS); //薪资档案引用时不能删除 salaryItemListDTOS.forEach(dto -> { - if (dto.getUseInEmployeeSalary() == 1) { + if (dto.getUseInEmployeeSalary() == 1|| StringUtils.isNotBlank(dto.getSystemName())) { dto.setCanDelete(false); } });