From 0bb2abc28155e40bc3b619c58b90a43efbbb4fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Tue, 14 Jan 2025 14:56:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OtherDeductionDetailDeleteParam.java | 2 + .../salary/service/OtherDeductionService.java | 41 +++++++ .../impl/OtherDeductionServiceImpl.java | 112 +++++++++++++++++- 3 files changed, 150 insertions(+), 5 deletions(-) diff --git a/src/com/engine/salary/entity/datacollection/param/OtherDeductionDetailDeleteParam.java b/src/com/engine/salary/entity/datacollection/param/OtherDeductionDetailDeleteParam.java index 447c04b87..c97a0b9a7 100644 --- a/src/com/engine/salary/entity/datacollection/param/OtherDeductionDetailDeleteParam.java +++ b/src/com/engine/salary/entity/datacollection/param/OtherDeductionDetailDeleteParam.java @@ -23,4 +23,6 @@ public class OtherDeductionDetailDeleteParam { // 主键id private List ids; + + private Long mainId; } diff --git a/src/com/engine/salary/service/OtherDeductionService.java b/src/com/engine/salary/service/OtherDeductionService.java index c8e72bb1e..c02d4a948 100644 --- a/src/com/engine/salary/service/OtherDeductionService.java +++ b/src/com/engine/salary/service/OtherDeductionService.java @@ -3,6 +3,7 @@ package com.engine.salary.service; import com.engine.salary.entity.datacollection.dto.*; import com.engine.salary.entity.datacollection.param.*; import com.engine.salary.entity.datacollection.po.*; +import com.engine.salary.enums.datacollection.TaxFreeTypeEnum; import com.engine.salary.util.page.PageInfo; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -125,35 +126,75 @@ public interface OtherDeductionService { String extendToLastMonth(OtherDeductionExtendLastParam param); PageInfo freeIncomeList(OtherDeductionDetailQueryParam param); + PageInfo derateDeductionList(OtherDeductionDetailQueryParam param); + PageInfo endowmentInsuranceList(OtherDeductionDetailQueryParam param); + PageInfo grantDonationList(OtherDeductionDetailQueryParam param); + PageInfo healthInsuranceList(OtherDeductionDetailQueryParam param); + PageInfo otherDerateDeductionList(OtherDeductionDetailQueryParam param); + PageInfo personalPensionList(OtherDeductionDetailQueryParam param); List queryFreeIncomes(OtherDeductionFreeListQueryParam param); + List queryDerateDeductions(OtherDeductionFreeListQueryParam param); + List queryEndowmentInsurances(OtherDeductionFreeListQueryParam param); + List queryGrantDonations(OtherDeductionFreeListQueryParam param); + List queryHealthInsurances(OtherDeductionFreeListQueryParam param); + List queryOtherDerateDeductions(OtherDeductionFreeListQueryParam param); + List queryPersonalPensions(OtherDeductionFreeListQueryParam param); void saveFreeIncome(FreeIncomeSaveParam param); + void saveEndowmentInsurance(EndowmentInsuranceSaveParam param); + void saveGrantDonation(GrantDonationSaveParam param); + void saveHealthInsurance(HealthInsuranceSaveParam param); + void saveOtherDerateDeduction(OtherDerateDeductionSaveParam param); + void saveDerateDeduction(DerateDeductionSaveParam param); + void savePersonalPension(PersonalPensionSaveParam param); void deleteFreeIncome(OtherDeductionDetailDeleteParam param); + void deleteEndowmentInsurance(OtherDeductionDetailDeleteParam param); + void deleteGrantDonation(OtherDeductionDetailDeleteParam param); + void deleteHealthInsurance(OtherDeductionDetailDeleteParam param); + void deleteOtherDerateDeduction(OtherDeductionDetailDeleteParam param); + void deleteDerateDeduction(OtherDeductionDetailDeleteParam param); + void deletePersonalPension(OtherDeductionDetailDeleteParam param); + void syncMain(Long mainId, List taxFreeTypes); + + void syncFreeIncome(OtherDeductionPO mainPO); + + void syncEndowmentInsurance(OtherDeductionPO mainPO); + + void syncGrantDonation(OtherDeductionPO mainPO); + + void syncHealthInsurance(OtherDeductionPO mainPO); + + void syncOtherDerateDeduction(OtherDeductionPO mainPO); + + void syncDerateDeduction(OtherDeductionPO mainPO); + + void syncPersonalPension(OtherDeductionPO mainPO); + } diff --git a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java index 09853cdbb..387d4ffd9 100644 --- a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java @@ -21,6 +21,7 @@ import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.OperateTypeEnum; import com.engine.salary.enums.UserStatusEnum; import com.engine.salary.enums.datacollection.DataCollectionEmployeeTypeEnum; +import com.engine.salary.enums.datacollection.TaxFreeTypeEnum; import com.engine.salary.enums.sicategory.DeleteTypeEnum; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.datacollection.*; @@ -2550,11 +2551,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction getFreeIncomeMapper().updateIgnoreNull(po); } - List freeIncomePOS = getFreeIncomeMapper().listSome(FreeIncomePO.builder().mainId(mainId).build()); - String sum = freeIncomePOS.stream().filter(po -> NumberUtil.isNumber(po.getFreeAmount())).map(po -> new BigDecimal(po.getFreeAmount())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString(); - deductionPO.setFreeIncome(sum); -// getOtherDeductionMapper().updateData(); - + syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.FREE_INCOME)); } @Override @@ -2606,6 +2603,8 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction getEndowmentInsuranceMapper().updateIgnoreNull(po); } + + syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.ENDOWMENT_INSURANCE)); } @Override @@ -2659,6 +2658,8 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction getGrantDonationMapper().updateIgnoreNull(po); } + + syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.GRANT_DONATION)); } @Override @@ -2708,6 +2709,8 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction getHealthInsuranceMapper().updateIgnoreNull(po); } + + syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.HEALTH_INSURANCE)); } @Override @@ -2751,6 +2754,8 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction getOtherDerateDeductionMapper().updateIgnoreNull(po); } + + syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.OTHER_DERATE_DEDUCTION)); } @Override @@ -2796,6 +2801,8 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction getDerateDeductionMapper().updateIgnoreNull(po); } + + syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.DERATE_DEDUCTION)); } @Override @@ -2841,41 +2848,136 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction getPersonalPensionMapper().updateIgnoreNull(po); } + + syncMain(mainId, Collections.singletonList(TaxFreeTypeEnum.PERSONAL_PENSION)); } @Override public void deleteFreeIncome(OtherDeductionDetailDeleteParam param) { getFreeIncomeMapper().deleteByIds(param.getIds()); + syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.FREE_INCOME)); } @Override public void deleteEndowmentInsurance(OtherDeductionDetailDeleteParam param) { getEndowmentInsuranceMapper().deleteByIds(param.getIds()); + syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.ENDOWMENT_INSURANCE)); } @Override public void deleteGrantDonation(OtherDeductionDetailDeleteParam param) { getGrantDonationMapper().deleteByIds(param.getIds()); + syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.GRANT_DONATION)); } @Override public void deleteHealthInsurance(OtherDeductionDetailDeleteParam param) { getHealthInsuranceMapper().deleteByIds(param.getIds()); + syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.HEALTH_INSURANCE)); } @Override public void deleteOtherDerateDeduction(OtherDeductionDetailDeleteParam param) { getOtherDerateDeductionMapper().deleteByIds(param.getIds()); + syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.OTHER_DERATE_DEDUCTION)); } @Override public void deleteDerateDeduction(OtherDeductionDetailDeleteParam param) { getDerateDeductionMapper().deleteByIds(param.getIds()); + syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.DERATE_DEDUCTION)); } @Override public void deletePersonalPension(OtherDeductionDetailDeleteParam param) { getPersonalPensionMapper().deleteByIds(param.getIds()); + syncMain(param.getMainId(), Collections.singletonList(TaxFreeTypeEnum.PERSONAL_PENSION)); + } + + @Override + public void syncMain(Long mainId,List taxFreeTypes) { + OtherDeductionPO deductionPO = getById(mainId); + if (deductionPO == null) { + throw new SalaryRunTimeException("主表不存在!"); + } + + if(taxFreeTypes.contains(TaxFreeTypeEnum.FREE_INCOME)){ + syncFreeIncome(deductionPO); + } + if(taxFreeTypes.contains(TaxFreeTypeEnum.HEALTH_INSURANCE)){ + syncEndowmentInsurance(deductionPO); + } + if(taxFreeTypes.contains(TaxFreeTypeEnum.ENDOWMENT_INSURANCE)){ + syncGrantDonation(deductionPO); + } + if(taxFreeTypes.contains(TaxFreeTypeEnum.GRANT_DONATION)){ + syncHealthInsurance(deductionPO); + } + if(taxFreeTypes.contains(TaxFreeTypeEnum.DERATE_DEDUCTION)){ + syncDerateDeduction(deductionPO); + } + if(taxFreeTypes.contains(TaxFreeTypeEnum.OTHER_DERATE_DEDUCTION)){ + syncOtherDerateDeduction(deductionPO); + } + if(taxFreeTypes.contains(TaxFreeTypeEnum.PERSONAL_PENSION)){ + syncPersonalPension(deductionPO); + } + } + + @Override + public void syncFreeIncome(OtherDeductionPO mainPO) { + List freeIncomePOS = getFreeIncomeMapper().listSome(FreeIncomePO.builder().mainId(mainPO.getId()).build()); + String sum = freeIncomePOS.stream().filter(po -> NumberUtil.isNumber(po.getFreeAmount())).map(po -> new BigDecimal(po.getFreeAmount())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString(); + mainPO.setFreeIncome(sum); + getOtherDeductionMapper().updateData(Collections.singletonList(mainPO)); + } + + @Override + public void syncEndowmentInsurance(OtherDeductionPO mainPO) { + List endowmentInsurancePOS = getEndowmentInsuranceMapper().listSome(EndowmentInsurancePO.builder().mainId(mainPO.getId()).build()); + String sum = endowmentInsurancePOS.stream().filter(po -> NumberUtil.isNumber(po.getCurrentDeduction())).map(po -> new BigDecimal(po.getCurrentDeduction())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString(); + mainPO.setTaxDelayEndowmentInsurance(sum); + getOtherDeductionMapper().updateData(Collections.singletonList(mainPO)); + } + + @Override + public void syncGrantDonation(OtherDeductionPO mainPO) { + List grantDonationPOS = getGrantDonationMapper().listSome(GrantDonationPO.builder().mainId(mainPO.getId()).build()); + String sum = grantDonationPOS.stream().filter(po -> NumberUtil.isNumber(po.getActualDeduction())).map(po -> new BigDecimal(po.getActualDeduction())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString(); + mainPO.setDeductionAllowedDonation(sum); + getOtherDeductionMapper().updateData(Collections.singletonList(mainPO)); + } + + @Override + public void syncHealthInsurance(OtherDeductionPO mainPO) { + List healthInsurancePOS = getHealthInsuranceMapper().listSome(HealthInsurancePO.builder().mainId(mainPO.getId()).build()); + String sum = healthInsurancePOS.stream().filter(po -> NumberUtil.isNumber(po.getCurrentDeduction())).map(po -> new BigDecimal(po.getCurrentDeduction())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString(); + mainPO.setBusinessHealthyInsurance(sum); + getOtherDeductionMapper().updateData(Collections.singletonList(mainPO)); + } + + @Override + public void syncOtherDerateDeduction(OtherDeductionPO mainPO) { + List otherDerateDeductionPOS = getOtherDerateDeductionMapper().listSome(OtherDerateDeductionPO.builder().mainId(mainPO.getId()).build()); + String sum = otherDerateDeductionPOS.stream().filter(po -> NumberUtil.isNumber(po.getOtherDeduction())).map(po -> new BigDecimal(po.getOtherDeduction())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString(); + mainPO.setOtherDeduction(sum); + getOtherDeductionMapper().updateData(Collections.singletonList(mainPO)); + } + + @Override + public void syncDerateDeduction(OtherDeductionPO mainPO) { + List derateDeductionPOS = getDerateDeductionMapper().listSome(DerateDeductionPO.builder().mainId(mainPO.getId()).build()); + String sum = derateDeductionPOS.stream().filter(po -> NumberUtil.isNumber(po.getDerateAmount())).map(po -> new BigDecimal(po.getDerateAmount())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString(); + mainPO.setDerateDeduction(sum); + getOtherDeductionMapper().updateData(Collections.singletonList(mainPO)); + } + + @Override + public void syncPersonalPension(OtherDeductionPO mainPO) { + List personalPensionPOS = getPersonalPensionMapper().listSome(PersonalPensionPO.builder().mainId(mainPO.getId()).build()); + String sum = personalPensionPOS.stream().filter(po -> NumberUtil.isNumber(po.getPayAmount())).map(po -> new BigDecimal(po.getPayAmount())).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString(); + mainPO.setPrivatePension(sum); + getOtherDeductionMapper().updateData(Collections.singletonList(mainPO)); } }