From 7f77f4cb120f0c047e5f63b1b37a078a278bec88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Tue, 3 Sep 2024 09:21:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=B4=A6=E5=A5=97=E5=85=B3?= =?UTF-8?q?=E8=81=94=E6=89=A3=E7=BC=B4=E4=B9=89=E5=8A=A1=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salaryacct/bo/SalaryAcctRecordBO.java | 3 +- .../salary/service/SalarySobService.java | 1 + .../impl/SalaryAcctRecordServiceImpl.java | 238 ++++++++---------- .../service/impl/SalarySobServiceImpl.java | 11 + .../service/impl/TaxAgentServiceImpl.java | 13 +- .../wrapper/SalaryAcctRecordWrapper.java | 5 +- .../salary/wrapper/SalarySobWrapper.java | 22 +- 7 files changed, 142 insertions(+), 151 deletions(-) diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java index e0fad94bd..fc587cf43 100644 --- a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctRecordBO.java @@ -80,10 +80,11 @@ public class SalaryAcctRecordBO { btnList.add(new WeaTableOperate("查看", null, "3")); btnList.add(new WeaTableOperate("重新核算", null, "4")); } + String taxAgentName = salarySobPO.getTaxAgentIds().stream().map(id -> taxAgentMap.getOrDefault(id, "")).collect(Collectors.joining(",")); return SalaryAcctRecordListDTO.builder() .id(salaryAcctRecordPO.getId()) .salarySobName(Optional.ofNullable(salarySobPO).map(SalarySobPO::getName).orElse(StringUtils.EMPTY)) - .taxAgentName(taxAgentMap.get(Optional.ofNullable(salarySobPO).map(SalarySobPO::getTaxAgentId).orElse(0L))) + .taxAgentName(taxAgentName) .salaryMonth(SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()).toString()) .taxCycle(SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getTaxCycle()).toString()) .status(Optional.ofNullable(salaryAcctRecordStatusEnum) diff --git a/src/com/engine/salary/service/SalarySobService.java b/src/com/engine/salary/service/SalarySobService.java index 4f0523586..21f660f49 100644 --- a/src/com/engine/salary/service/SalarySobService.java +++ b/src/com/engine/salary/service/SalarySobService.java @@ -39,6 +39,7 @@ public interface SalarySobService { * @return */ List listByIds(Collection ids); + List listByIdsWithTax(Collection ids); /** * 根据名称精确匹配查询薪资账套 diff --git a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java index 89fad2ab7..08c6cabfa 100644 --- a/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalaryAcctRecordServiceImpl.java @@ -338,141 +338,115 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe } //获取账套所属个税扣缴义务人的核算记录 - SalarySobPO salarySobPO = getSalarySobService(user).getById(saveParam.getSalarySobId()); - Long taxAgentId = salarySobPO.getTaxAgentId(); - //查询扣缴义务人下的所有账套 - List salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId); - Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); - //获取账套下的所有核算结果 - List salaryAcctRecords = listByTaxCycle(taxCycleYearRange, salarySobIds); + SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(saveParam.getSalarySobId()); + List taxAgentIds = salarySobPO.getTaxAgentIds(); + taxAgentIds.forEach(taxAgentId->{ + //查询扣缴义务人下的所有账套 + List salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId); + Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); + //获取账套下的所有核算结果 + List salaryAcctRecords = listByTaxCycle(taxCycleYearRange, salarySobIds); - // 获取个税申报功能状态 - TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration(); + // 获取个税申报功能状态 + TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration(); -// if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())) { -// // 关闭了个税申报功能 -// // 如果某个月(薪资所属期)还未归档,不可以新建之后月份的薪资核算 -// SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() -// .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()) -// && e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) -// .findAny() -// .orElse(null); -// if (Objects.nonNull(notArchivedSalaryAcctRecordPO)) { -// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算") -// .replace("{0}", SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) -// .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); -// } -// // 如果有某个月(薪资所属期)已经归档了,不可以新建之前月份的薪资核算 -// SalaryAcctRecordPO havaSalaryAcctRecordPO = salaryAcctRecords.stream() -// .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) -// && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) -// .findAny() -// .orElse(null); -// if (Objects.nonNull(havaSalaryAcctRecordPO)) { -// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98755, "薪资所属期{0}的薪资核算结果已经归档,不能新建薪资所属期{1}的薪资核算") -// .replace("{0}", SalaryDateUtil.localDate2YearMonth(havaSalaryAcctRecordPO.getSalaryMonth()).toString()) -// .replace("{1}", salarySobCycleDTO.getSalaryMonth().toString())); -// } -// -// } - if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())) { - // 开启了个税申报功能 - // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 - SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) - && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) - .findAny() - .orElse(null); - if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); - } - // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 - SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) - && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) - .findAny() - .orElse(null); - if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); - } - // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 - SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) - && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) - .findAny() - .orElse(null); - if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); - } - } - if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())) { - // 重启了个税申报功能(不去校验重启之前是否申报数据) - // 如果某个月(薪资所属期)还未归档,不可以新建之后月份的薪资核算 - SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()) - && e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) - .findAny() - .orElse(null); - if (Objects.nonNull(notArchivedSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); - } - // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 - SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) - && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) - .findAny() - .orElse(null); - if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); - } - // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 - //获取账套下从重启月至所在年的最后一天的所有核算结果 - Date taxDeclarationRebootDate = getSalarySysConfService(user).getTaxDeclarationRebootDate(); - if (taxDeclarationRebootDate == null) { - throw new SalaryRunTimeException("个税申报功能异常"); + if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())) { + // 开启了个税申报功能 + // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 + SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) + && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 + SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 + SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) + .findAny() + .orElse(null); + if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } } + if (taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())) { + // 重启了个税申报功能(不去校验重启之前是否申报数据) + // 如果某个月(薪资所属期)还未归档,不可以新建之后月份的薪资核算 + SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()) + && e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(notArchivedSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)已经归档了,不可以新建之前月份的薪资核算 + SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()) + && e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1)))) + .findAny() + .orElse(null); + if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + // 如果某个月(税款所属期)还未申报,不可以新建之后月份的薪资核算 + //获取账套下从重启月至所在年的最后一天的所有核算结果 + Date taxDeclarationRebootDate = getSalarySysConfService(user).getTaxDeclarationRebootDate(); + if (taxDeclarationRebootDate == null) { + throw new SalaryRunTimeException("个税申报功能异常"); + } - LocalDateRange taxCycleRebootYearRange = LocalDateRange.builder() - .fromDate(taxDeclarationRebootDate) - .endDate(SalaryDateUtil.getLastDayOfYear(taxDeclarationRebootDate)) - .build(); + LocalDateRange taxCycleRebootYearRange = LocalDateRange.builder() + .fromDate(taxDeclarationRebootDate) + .endDate(SalaryDateUtil.getLastDayOfYear(taxDeclarationRebootDate)) + .build(); // List salaryAcctRebootRecords = listByTaxCycle(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)))) - .findAny() - .orElse(null); - if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + 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)))) + .findAny() + .orElse(null); + if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } + + // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 + SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() + .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) + && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) + .findAny() + .orElse(null); + if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") + .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) + .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); + } } - - // 如果某个月(税款所属期)已经申报了,不可以新建本月以及之前月份的薪资核算 - SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream() - .filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue()) - && e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0) - .findAny() - .orElse(null); - if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算") - .replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString()) - .replace("{1}", salarySobCycleDTO.getTaxCycle().toString())); - } - - } - + }); } private List listByCreateDate(LocalDateRange taxCycleRebootYearRange, Set salarySobIds) { @@ -658,10 +632,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe } // 查询税款所在年的该个税扣缴义务人所有薪资核算记录 // 获取账套所属个税扣缴义务人的核算记录 - SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); - Long taxAgentId = salarySobPO.getTaxAgentId(); + SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(salaryAcctRecordPO.getSalarySobId()); + List taxAgentIds = salarySobPO.getTaxAgentIds(); //查询扣缴义务人下的所有账套 - List salarySobPOS = getSalarySobService(user).listByTaxAgentId(taxAgentId); + List salarySobPOS = getSalarySobService(user).listByTaxAgentIds(taxAgentIds); Set salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId); List salaryAcctRecordPOS = listByTaxCycle(yearRange, salarySobIds); List selfSalaryAcctRecordPOS = filterByAuthority(salaryAcctRecordPOS); diff --git a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java index 064128c2a..3540c7151 100644 --- a/src/com/engine/salary/service/impl/SalarySobServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobServiceImpl.java @@ -195,6 +195,17 @@ public class SalarySobServiceImpl extends Service implements SalarySobService { return salarySobMapper.listSome(SalarySobPO.builder().ids(ids).build()); } + @Override + public List listByIdsWithTax(Collection ids) { + List collect = ids.stream().map(id -> { + SalarySobPO sobPO = getSalarySobMapper().getById(id); + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().sobId(id).build()); + sobPO.setTaxAgentIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList())); + return sobPO; + }).collect(Collectors.toList()); + return collect; + } + @Override public List listByName(String name) { if (StringUtils.isEmpty(name)) { diff --git a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java index f6e00b508..36b78998f 100644 --- a/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxAgentServiceImpl.java @@ -14,7 +14,7 @@ import com.engine.salary.entity.datacollection.po.OtherDeductionPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO; import com.engine.salary.entity.salarysob.config.SalarySobConfig; -import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.salarysob.po.SobTaxLinkPO; import com.engine.salary.entity.siaccount.param.InsuranceAccountBatchParam; import com.engine.salary.entity.siaccount.po.InsuranceAccountBatchPO; import com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO; @@ -39,6 +39,7 @@ import com.engine.salary.mapper.datacollection.AddUpDeductionMapper; import com.engine.salary.mapper.datacollection.AddUpSituationMapper; import com.engine.salary.mapper.datacollection.OtherDeductionMapper; import com.engine.salary.mapper.salarysob.SalarySobMapper; +import com.engine.salary.mapper.salarysob.SobTaxLinkMapper; import com.engine.salary.mapper.siaccount.InsuranceAccountBatchMapper; import com.engine.salary.mapper.siarchives.InsuranceBaseInfoMapper; import com.engine.salary.mapper.taxagent.TaxAgentMapper; @@ -125,6 +126,10 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService { return MapperProxyFactory.getProxy(SalarySobMapper.class); } + private SobTaxLinkMapper getSobTaxLinkMapper() { + return MapperProxyFactory.getProxy(SobTaxLinkMapper.class); + } + private TaxAgentMapper getTaxAgentMapper() { return MapperProxyFactory.getProxy(TaxAgentMapper.class); } @@ -568,8 +573,8 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService { } //账套 - List salarySobPOS = getSalarySobMapper().listSome(SalarySobPO.builder().taxAgentId(id).build()); - if (CollectionUtils.isNotEmpty(salarySobPOS)) { + List sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(id).build()); + if (CollectionUtils.isNotEmpty(sobTaxLinkPOS)) { throw new SalaryRunTimeException("存在账套引用"); } @@ -821,7 +826,7 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService { } @Override - public List parseConfig(List configs) { + public List parseConfig(List configs) { List results = new ArrayList<>(); List taxAgentPOS = listAll(); diff --git a/src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java b/src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java index def809a7d..dc27e7167 100644 --- a/src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java +++ b/src/com/engine/salary/wrapper/SalaryAcctRecordWrapper.java @@ -99,7 +99,7 @@ public class SalaryAcctRecordWrapper extends Service implements SalaryAcctRecord if (CollectionUtils.isNotEmpty(list)) { // 查询薪资账套 Set salarySobIds = SalaryEntityUtil.properties(list, SalaryAcctRecordPO::getSalarySobId); - List salarySobPOS = getSalarySobService(user).listByIds(salarySobIds); + List salarySobPOS = getSalarySobService(user).listByIdsWithTax(salarySobIds); // 查询薪资核算记录的创建人员的人员信息 List employeeIds = SalaryEntityUtil.properties(list, SalaryAcctRecordPO::getCreator, Collectors.toList()); List employeeComInfos = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); @@ -109,8 +109,7 @@ public class SalaryAcctRecordWrapper extends Service implements SalaryAcctRecord // 查询工资单的查询情况 List salarySendCheckResult = getSalarySendService(user).getSalarySendCheckResult(salaryAcctRecordIds); - Set taxAgentIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getTaxAgentId); - List taxAgentPOS = getTaxAgentService(user).listByIds(taxAgentIds); + List taxAgentPOS = getTaxAgentService(user).listAll(); // 转换成列表dto List salaryAcctRecordListDTOS = SalaryAcctRecordBO.convert2ListDTO(list, salarySobPOS, employeeComInfos, salaryAcctEmployeeCountDTOS, salarySendCheckResult, taxAgentPOS); diff --git a/src/com/engine/salary/wrapper/SalarySobWrapper.java b/src/com/engine/salary/wrapper/SalarySobWrapper.java index a63048567..8cdbe79cd 100644 --- a/src/com/engine/salary/wrapper/SalarySobWrapper.java +++ b/src/com/engine/salary/wrapper/SalarySobWrapper.java @@ -1,5 +1,6 @@ package com.engine.salary.wrapper; +import cn.hutool.core.collection.CollectionUtil; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.constant.SalaryDefaultTenantConstant; @@ -68,7 +69,6 @@ public class SalarySobWrapper extends Service { } - /** * 薪资账套列表 * @@ -85,7 +85,7 @@ public class SalarySobWrapper extends Service { List taxAgentPOS = getTaxAgentService(user).listAll(); Map taxAgentIdTONameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName); - List salarySobListDTOS = SalarySobBO.convert2ListDTO(page.getList(),taxAgentIdTONameMap); + List salarySobListDTOS = SalarySobBO.convert2ListDTO(page.getList(), taxAgentIdTONameMap); PageInfo dtoPage = new PageInfo<>(salarySobListDTOS, SalarySobListDTO.class); dtoPage.setTotal(page.getTotal()); dtoPage.setPageNum(page.getPageNum()); @@ -118,10 +118,10 @@ public class SalarySobWrapper extends Service { private void handleSalarySobBackItemHistory(SalarySobListQueryParam queryParam) { queryParam.setPageSize(100000); List list = getSalarySobService(user).listPageByParam(queryParam).getList(); - if(list != null && list.size()>0){ + if (list != null && list.size() > 0) { List salarySobIds = list.stream().map(SalarySobPO::getId).collect(Collectors.toList()); Long count = getSalarySobBackItemService(user).getCountBySalarySobIdIn(salarySobIds); - if(count.equals(0L)){ + if (count.equals(0L)) { // 薪资账套的默认的回算薪资项目 Set SalarySobBackItemIds = SalaryEntityUtil.properties(SalarySobBackItemBO.getDefault(), SalarySobDefaultBackItemPO::getSysSalaryItemId); // 获取薪资项目中是否已经添加回算薪资项目 @@ -139,7 +139,7 @@ public class SalarySobWrapper extends Service { List salarySobBackItems = new ArrayList<>(); // 获取默认添加后的回算薪资项目 List salaryBackItemPOS = getSalaryItemService(user).listBySysSalaryItemIds(SalarySobBackItemIds); - for(Long id : salarySobIds){ + for (Long id : salarySobIds) { for (SalarySobDefaultBackItemPO salarySobDefaultBackItemPO : SalarySobBackItemBO.getDefault()) { Date now = new Date(); Map sysSalaryItemMap = SalaryEntityUtil.convert2Map(salaryBackItemPOS, SalaryItemPO::getSysSalaryItemId); @@ -155,7 +155,7 @@ public class SalarySobWrapper extends Service { .valueType(salaryItemPO.getValueType()) .formulaId(salarySobDefaultBackItemPO.getFormulaId()) .backCalcType(salarySobDefaultBackItemPO.getBackCalcType()) - .creator((long)user.getUID()) + .creator((long) user.getUID()) .createTime(now) .updateTime(now) .deleteType(DeleteTypeEnum.NOT_DELETED.getValue()) @@ -195,7 +195,7 @@ public class SalarySobWrapper extends Service { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); } // 薪资装套po转换成薪资账套详情dto - basicForm = SalarySobBO.convert2FormDTO(basicForm,salarySobPO); + basicForm = SalarySobBO.convert2FormDTO(basicForm, salarySobPO); } // 转换成前端所需的数据格式 data.put("basicForm", basicForm); @@ -259,7 +259,7 @@ public class SalarySobWrapper extends Service { */ public boolean canEdit(Long id, Long employeeId) { // 查询薪资账套 - SalarySobPO salarySobPO = getSalarySobService(user).getById(id); + SalarySobPO salarySobPO = getSalarySobService(user).getByIdWithTax(id); if (Objects.isNull(salarySobPO)) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除")); } @@ -271,11 +271,11 @@ public class SalarySobWrapper extends Service { } Collection taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(employeeId); Set taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId); - - return taxAgentIds.contains(salarySobPO.getTaxAgentId())||Objects.isNull(salarySobPO.getTaxAgentId()); + Collection intersection = CollectionUtil.intersection(taxAgentIds, salarySobPO.getTaxAgentIds()); + return intersection.size() > 0; } public List listByTaxAgent(SalarySobQueryParam param) { - return getSalarySobService(user).list(param); + return getSalarySobService(user).list(param); } }