From 0e93cbab0494284e80310b51b34fcebc36167f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 21 Apr 2025 10:37:44 +0800 Subject: [PATCH 1/8] t --- .../entity/salaryacct/param/SalaryAcctCalculateParam.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java index 52c3b7f13..d07b79a6b 100644 --- a/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java +++ b/src/com/engine/salary/entity/salaryacct/param/SalaryAcctCalculateParam.java @@ -20,7 +20,7 @@ import java.util.Collection; @Builder @NoArgsConstructor @AllArgsConstructor -public class SalaryAcctCalculateParam { +public class SalaryAcctCalculateParam { //核算人员的id,不是employeeId而是salaryAcctEmpId private Collection ids; From 552cee8a6f984b8c54138b71a4c63ff38aac6ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Mon, 21 Apr 2025 15:49:28 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E8=AE=A1=E7=A8=8E=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java index d5155f0ae..d5399daab 100644 --- a/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java +++ b/src/com/engine/salary/entity/salaryacct/bo/SalaryAcctConsolidatedTaxBO.java @@ -1,5 +1,6 @@ package com.engine.salary.entity.salaryacct.bo; +import cn.hutool.core.util.StrUtil; import com.engine.salary.constant.TaxDeclarationDataIndexConstant; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; @@ -73,6 +74,9 @@ public class SalaryAcctConsolidatedTaxBO { .filter(e -> Objects.equals(e.getSalaryItemId(), optional.get())) .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) .reduce(BigDecimal.ZERO, BigDecimal::add); + if (StrUtil.isBlank(resultValue)) { + resultValue = "0.00"; + } return new BigDecimal(resultValue).add(income).toPlainString(); } // 个税调差为0 @@ -98,6 +102,9 @@ public class SalaryAcctConsolidatedTaxBO { .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) .reduce(BigDecimal.ZERO, BigDecimal::add); } + if (StrUtil.isBlank(resultValue)) { + resultValue = "0.00"; + } return new BigDecimal(resultValue).add(refundedOrSupplementedTax).subtract(taxAdjustment).toPlainString(); } return resultValue; From 6532bfdd0775e9795f40ac2afaf37b5a67b2c2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Tue, 22 Apr 2025 15:33:28 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=8B=93=E6=89=91=E5=9B=BE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=9D=9E=E8=96=AA=E8=B5=84=E9=A1=B9=E7=9B=AE=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SalarySobItemServiceImpl.java | 221 ++++++++++++++++-- 1 file changed, 202 insertions(+), 19 deletions(-) diff --git a/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java index 781c99af5..15a14933e 100644 --- a/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java @@ -9,20 +9,29 @@ import com.engine.salary.biz.SalarySobItemGroupBiz; import com.engine.salary.biz.SalarySobItemHideBiz; import com.engine.salary.config.SalaryElogConfig; import com.engine.salary.constant.SalaryDefaultTenantConstant; +import com.engine.salary.entity.datacollection.AddUpDeduction; +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.datacollection.dto.AttendQuoteDataDTO; +import com.engine.salary.entity.datacollection.dto.AttendQuoteFieldListDTO; +import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.datacollection.po.VariableItemPO; +import com.engine.salary.entity.salaryacct.bo.CalculateFormulaVarBO; +import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculateBO; import com.engine.salary.entity.salaryacct.bo.SalaryAcctCalculatePriorityBO; import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig; +import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; -import com.engine.salary.entity.salaryarchive.config.ArchiveFieldConfig; +import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; import com.engine.salary.entity.salaryformula.ExpressFormula; -import com.engine.salary.entity.salaryformula.po.FormulaVar; import com.engine.salary.entity.salaryformula.config.FormluaConfig; import com.engine.salary.entity.salaryformula.po.FormulaPO; import com.engine.salary.entity.salaryformula.po.FormulaVar; -import com.engine.salary.entity.salaryitem.config.SalaryItemAllConfig; -import com.engine.salary.entity.salaryitem.param.SalaryItemSearchParam; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.salarysob.bo.SalarySobItemAggregateBO; import com.engine.salary.entity.salarysob.dto.SalaryItemTopologyDTO; +import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO; import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO; import com.engine.salary.entity.salarysob.dto.SalarySobItemFormDTO; import com.engine.salary.entity.salarysob.param.SalaryItemTopologyQueryParam; @@ -31,6 +40,7 @@ import com.engine.salary.entity.salarysob.po.*; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.OperateTypeEnum; import com.engine.salary.enums.SalaryValueTypeEnum; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum; import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum; import com.engine.salary.exception.SalaryRunTimeException; @@ -46,11 +56,13 @@ import com.engine.salary.util.valid.ValidUtil; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import weaver.general.BaseBean; import weaver.hrm.User; +import java.time.Month; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -121,6 +133,59 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe } // private LoggerTemplate salarySobLoggerTemplate; + private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) { + return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user); + } + + private SalaryAcctRecordService getSalaryAcctRecordService(User user) { + return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user); + } + + private SalarySobService getSalarySobService(User user) { + return ServiceUtil.getService(SalarySobServiceImpl.class, user); + } + + private SIAccountService getSIAccountService(User user) { + return ServiceUtil.getService(SIAccountServiceImpl.class, user); + } + + private AttendQuoteFieldService getAttendQuoteFieldService(User user) { + return ServiceUtil.getService(AttendQuoteFieldServiceImpl.class, user); + } + + private VariableItemService getVariableItemService(User user) { + return ServiceUtil.getService(VariableItemServiceImpl.class, user); + } + + private SalaryEmployeeService getSalaryEmployeeService(User user) { + return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user); + } + + private SalaryArchiveService getSalaryArchiveService(User user) { + return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user); + } + + private AddUpSituationService getAddUpSituationService(User user) { + return ServiceUtil.getService(AddUpSituationServiceImpl.class, user); + } + + private AddUpDeductionService getAddUpDeductionService(User user) { + return ServiceUtil.getService(AddUpDeductionServiceImpl.class, user); + } + + private OtherDeductionService getOtherDeductionService(User user) { + return ServiceUtil.getService(OtherDeductionServiceImpl.class, user); + } + + private AttendQuoteDataService getAttendQuoteDataService(User user) { + return ServiceUtil.getService(AttendQuoteDataServiceImpl.class, user); + } + + private VariableArchiveService getVariableArchiveService(User user) { + return ServiceUtil.getService(VariableArchiveServiceImpl.class, user); + } + + @Override public List list() { return salarySobItemMapper.listAll(); @@ -629,7 +694,7 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe } salarySobItemPO.setFormula(formulaPO); } - if(SalaryEntityUtil.isNotNullOrEmpty(salarySobItemPO.getSalaryItemId())){ + if (SalaryEntityUtil.isNotNullOrEmpty(salarySobItemPO.getSalaryItemId())) { SalaryItemPO salaryItemPO = itemIdMap.get(salarySobItemPO.getSalaryItemId()); salarySobItemPO.setSalaryItem(salaryItemPO); } @@ -677,7 +742,7 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe salarySobItemFormDTO .setId(salarySobItemPO.getId()) .setName(salaryItemPO.getName()) - .setItemHide(salarySobItemPO.getItemHide()==null?0:Integer.parseInt(salarySobItemPO.getItemHide().toString())) + .setItemHide(salarySobItemPO.getItemHide() == null ? 0 : Integer.parseInt(salarySobItemPO.getItemHide().toString())) .setDataType(salaryItemPO.getDataType()) .setRoundingMode(salarySobItemPO.getRoundingMode() == null ? salaryItemPO.getRoundingMode() : salarySobItemPO.getRoundingMode()) .setPattern(salarySobItemPO.getPattern() == null ? salaryItemPO.getPattern() : salarySobItemPO.getPattern()) @@ -726,7 +791,7 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe salaryItemTopologyDTO.setSalaryItemId(salaryItemPO.getId()); salaryItemTopologyDTO.setSalaryItemName(salaryItemPO.getName()); salaryItemTopologyDTO.setFormula(expressFormula); - salaryItemTopologyDTO.setResult(topologyData.getResultItemMap().getOrDefault(salaryItemPO.getId(), "")); + salaryItemTopologyDTO.setResult(topologyData.getResultItemMap().getOrDefault(SalaryFormulaReferenceEnum.SALARY_ITEM.getValue() + "_" + salaryItemPO.getCode(), "")); topology(salaryItemTopologyDTO, topologyData); @@ -767,7 +832,8 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe for (int i = 0; i < parameters.size(); i++) { FormulaVar formulaVar = parameters.get(i); String source = formulaVar.getSource(); - String fieldId = formulaVar.getFieldId().replace(source + "_", ""); + String fieldId = formulaVar.getFieldId(); + String code = fieldId.replace(source + "_", ""); String name = formulaVar.getName(); String fieldName = formulaVar.getFieldName(); //是否是薪资项目 @@ -785,26 +851,26 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe } ExpressFormula expressFormula; - if (salarySobItemCodeMap.containsKey(fieldId)) { + if (salarySobItemCodeMap.containsKey(code)) { // 如果薪资账套下重新定义了薪资项目的公式,则使用薪资账套下的公式,否则使用薪资项目本身的公式 - expressFormula = expressFormulaIdMap.get(salarySobItemCodeMap.get(fieldId).getFormulaId()); - } else if (salaryItemCodeMap.containsKey(fieldId)) { - expressFormula = expressFormulaIdMap.get(salaryItemCodeMap.get(fieldId).getFormulaId()); + expressFormula = expressFormulaIdMap.get(salarySobItemCodeMap.get(code).getFormulaId()); + } else if (salaryItemCodeMap.containsKey(code)) { + expressFormula = expressFormulaIdMap.get(salaryItemCodeMap.get(code).getFormulaId()); } else { expressFormula = null; } - SalaryItemPO salaryItemChild = isSalaryItemVar ? salaryItemCodeMap.get(fieldId) : new SalaryItemPO(); + SalaryItemPO salaryItemChild = isSalaryItemVar ? salaryItemCodeMap.get(code) : new SalaryItemPO(); SalaryItemTopologyDTO salaryItemTopologyChild = new SalaryItemTopologyDTO(); salaryItemTopologyChild.setSalaryItemId(isSalaryItemVar ? salaryItemChild.getId() : null); salaryItemTopologyChild.setSalaryItemName(isSalaryItemVar ? salaryItemChild.getName() : fieldName); salaryItemTopologyChild.setFormula(expressFormula); - salaryItemTopologyChild.setResult(isSalaryItemVar ? topologyData.getResultItemMap().getOrDefault(salaryItemChild.getId(), "") : ""); + salaryItemTopologyChild.setResult(topologyData.getResultItemMap().getOrDefault(fieldId, "")); salaryItemTopologyDTOChildren.add(salaryItemTopologyChild); if (isSalaryItemVar) { - SalaryItemPO salaryItemChildChild = salaryItemCodeMap.get(fieldId); + SalaryItemPO salaryItemChildChild = salaryItemCodeMap.get(code); SalaryValueTypeEnum salaryValueTypeEnum = SalaryValueTypeEnum.parseByValue(salaryItemChildChild.getValueType()); if (salaryValueTypeEnum != SalaryValueTypeEnum.INPUT) { topologyData.setSalaryItemId(salaryItemChildChild.getId()); @@ -849,9 +915,126 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe //薪资结果 Long acctEmpId = param.getAcctEmpId(); if (acctEmpId != null) { - List results = getSalaryAcctResultService(user).listBySalaryAcctEmployeeId(acctEmpId); - Map resultItemMap = SalaryEntityUtil.convert2Map(results, SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue); - topologyData.setResultItemMap(resultItemMap); + SalaryAcctEmployeePO acctEmployeePO = getSalaryAcctEmployeeService(user).getById(acctEmpId); + List acctEmployeePOS = new ArrayList<>(); + acctEmployeePOS.add(acctEmployeePO); + + Long salaryAcctRecordId = acctEmployeePO.getSalaryAcctRecordId(); + + // 1、查询薪资核算记录 + SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId); + if (Objects.isNull(salaryAcctRecordPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除")); + } + //查询对应账套 + SalarySobPO salarySobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId()); + if (Objects.isNull(salarySobPO)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资账套不存在或已被删除")); + } + + // 不是查询薪资账套下实时的薪资项目,而是查询发起薪资核算时存储的薪资项目快照 + SalaryAcctConfig salaryAcctSobConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(salaryAcctRecordId); + + // 1.1、如果薪资核算记录已经归档了,就不能继续核算 + if (!Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99148, "当前薪资核算记录已归档,请重新打开后再进行核算")); + } + // 2、查询薪资核算记录的薪资周期、考勤周期等 + SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(salaryAcctRecordId); + // 3、查询薪资核算记录所用薪资账套的薪资项目副本 + List salarySobItemPOS = salaryAcctSobConfig.getSalarySobItems(); + if (CollectionUtils.isEmpty(salarySobItemPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99151, "当前所用的薪资账套未选择任何薪资项目,无法核算")); + } + // 回算薪资项目 + List salarySobBackItems = Collections.emptyList(); + if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1)) { + salarySobBackItems = salaryAcctSobConfig.getSalarySobBackItems(); + } + // 4、查询当前租户的所有薪资项目 + List salaryItemPOS = getSalaryItemService(user).listAll(); + // 6、查询社保福利的所有字段 + Map welfareColumns = getSIAccountService(user).welfareColumns(); + // 7、查询考勤引用的所有字段 + List attendQuoteFieldListDTOS = getAttendQuoteFieldService(user).listAll(); + List variableItemPOS = getVariableItemService(user).listAll(); + + // 8、查询公式详情 + Set formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId); + formulaIds.addAll(SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getFormulaId)); + formulaIds.addAll(SalaryEntityUtil.properties(salarySobBackItems, SalarySobBackItemPO::getFormulaId)); + List formulas = getSalaryFormulaService(user).listExpressFormula(formulaIds); + // 本次运算的回算薪资项目所涉及的变量 +// Set issuedFieldIds = getIssuedFieldIds(salarySobBackItems); + + // 10、根据id查询其他合并计税的薪资核算记录 + List otherSalaryAcctRecordPOS = getSalaryAcctRecordService(user).listById4OtherConsolidatedTax(salaryAcctRecordPO.getId()); + + // 12.3、生成本次运算的key + String calculateKey = UUID.randomUUID().toString(); + // 12.5、多线程运算,运算结果存放在临时表中 + SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO() + .setSalaryAcctRecordPO(salaryAcctRecordPO) + .setSalarySobPO(salarySobPO) + .setSalarySobCycleDTO(salarySobCycleDTO) + .setOtherSalaryAcctRecordPOS(otherSalaryAcctRecordPOS) + .setSalarySobItemPOS(salarySobItemPOS) + .setSalaryItemIdWithPriorityList(new ArrayList<>()) + .setExpressFormulas(formulas) + .setSalaryItemPOS(salaryItemPOS) + .setSalarySobAdjustRulePOS(new ArrayList<>()) + .setWelfareColumns(MapUtils.emptyIfNull(welfareColumns)) + .setAttendQuoteFieldListDTOS(attendQuoteFieldListDTOS) + .setSalaryAcctEmployeePOS(acctEmployeePOS) + .setIssuedFieldIds(new HashSet<>()) + .setResults(null) + .setCalculateKey(calculateKey) + .setVariableItems(variableItemPOS) + .setTaxDeclarationFunction(null) + .setTaxIds(null); + + + List employeeIds = Collections.singletonList(acctEmployeePO.getEmployeeId()); + List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds); + Long taxAgentId = salaryAcctCalculateBO.getSalarySobPO().getTaxAgentId(); + List salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentId); + List addUpSituationPOS; + if (salarySobCycleDTO.getTaxCycle().getMonth() == Month.JANUARY) { + // 3.1、如果当前税款所属期是本年度第一个税款所属期,就不需要查询往期累计情况 + addUpSituationPOS = Collections.emptyList(); + } else { + addUpSituationPOS = getAddUpSituationService(user).getAddUpSituationList(salarySobCycleDTO.getTaxCycle().plusMonths(-1), employeeIds); + } + List addUpDeductionPOS = getAddUpDeductionService(user).getAddUpDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentId); + List otherDeductionPOS = getOtherDeductionService(user).getOtherDeductionList(salarySobCycleDTO.getTaxCycle(), employeeIds, taxAgentId); + List> welfareData = new ArrayList<>(); + welfareData.addAll(getSIAccountService(user).welfareData(salarySobCycleDTO.getSocialSecurityCycle().toString(), employeeIds, taxAgentId)); + List attendQuoteDataDTOS = getAttendQuoteDataService(user).getAttendQuoteData(salarySobCycleDTO.getSalaryMonth(), salarySobCycleDTO.getSalarySobId(), employeeIds); + List salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getId, Collectors.toList()); + List salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds); + Map empItemValueMap = SalaryEntityUtil.convert2Map(salaryAcctResultPOS, p -> p.getSalaryAcctEmpId() + "_" + p.getSalaryItemId(), SalaryAcctResultPO::getResultValue); + List> variableArchiveList = getVariableArchiveService(user).listBySalaryMonthAndEmployeeIds(salarySobCycleDTO.getSalaryMonth(), employeeIds, taxAgentId); + Map> collect = salaryAcctResultPOS.stream().collect(Collectors.groupingBy(k -> k.getEmployeeId() + "-" + k.getTaxAgentId() + "-" + k.getSalaryItemId())); + Map salaryAcctResultPOMap = new HashMap<>(); + for (Map.Entry> et : collect.entrySet()) { + salaryAcctResultPOMap.put(et.getKey(), et.getValue().get(0).getOriginResultValue()); + } + Set otherSalaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getOtherSalaryAcctRecordPOS(), SalaryAcctRecordPO::getId); + List otherSalaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIdsAndEmployeeIds(otherSalaryAcctRecordIds, employeeIds); + Map> otherSalaryAcctResultPOMap = SalaryEntityUtil.group2Map(otherSalaryAcctResultPOS, e -> e.getEmployeeId() + "_" + e.getTaxAgentId()); + List otherSalaryAcctEmployeePOS = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIdsAndEmployeeIds(otherSalaryAcctRecordIds, employeeIds); + Map> otherSalaryAcctEmployeePOMap = SalaryEntityUtil.group2Map(otherSalaryAcctEmployeePOS, salaryAcctEmployeePO -> salaryAcctEmployeePO.getEmployeeId() + "_" + salaryAcctEmployeePO.getTaxAgentId()); +// List lastMonthResultPOS = getSalaryAcctResultService(user).listBySobSalaryMonth(SalaryDateUtil.toDate(salarySobCycleDTO.getSalaryMonth().minusMonths(1), 1), salaryAcctCalculateBO.getSalarySobPO().getId(), employeeIds); + CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, salaryArchiveData, addUpSituationPOS, addUpDeductionPOS, otherDeductionPOS, welfareData, attendQuoteDataDTOS, salaryAcctResultPOS, variableArchiveList); + Map> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO); + + Map resultMap = new HashMap<>(); + formulaVarMap.entrySet().forEach(e -> { + e.getValue().forEach(f -> { + resultMap.put(f.getFieldId(), f.getFieldValue()); + }); + }); + topologyData.setResultItemMap(resultMap); } else { topologyData.setResultItemMap(new HashMap<>()); } @@ -885,7 +1068,7 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe /** * 核算结果 */ - Map resultItemMap; + Map resultItemMap; } From 7a7030a91ce428b69df20cd307b5ab8bca82e0bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Wed, 23 Apr 2025 17:39:30 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E7=94=B3=E6=8A=A5=E8=A1=A8=E7=A8=8E?= =?UTF-8?q?=E6=AC=BE=E6=89=80=E5=B1=9E=E6=9C=9F=E6=A3=80=E7=B4=A2=E5=92=8C?= =?UTF-8?q?=E7=94=B3=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/TaxDeclarationListDTO.java | 8 ++++---- .../param/TaxDeclarationListQueryParam.java | 17 +++++++---------- .../taxdeclaration/po/TaxDeclarationPO.java | 7 +++++++ .../taxdeclaration/TaxDeclarationMapper.xml | 6 ++++++ .../service/impl/TaxDeclarationServiceImpl.java | 7 ++----- .../salary/web/TaxDeclarationController.java | 5 +---- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java index f52ce6a86..420daca25 100644 --- a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java @@ -37,6 +37,10 @@ public class TaxDeclarationListDTO { @TableTitle(title = "薪资类型", dataIndex = "incomeCategory", key = "incomeCategory") private String incomeCategory; + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") + @TableTitle(title = "税款所属期", dataIndex = "taxCycle", key = "taxCycle") + private Date taxCycle; + @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") @TableTitle(title = "薪资所属月", dataIndex = "salaryMonth", key = "salaryMonth") private Date salaryMonth; @@ -47,10 +51,6 @@ public class TaxDeclarationListDTO { @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentName", key = "taxAgentName") private String taxAgentName; - @JsonFormat(pattern = "yyyy-MM", timezone = "GMT+8") - @TableTitle(title = "税款所属期", dataIndex = "taxCycle", key = "taxCycle") - private Date taxCycle; - //@TableTitle(title = "操作人id", dataIndex = "operateEmployeeId", key = "operateEmployeeId") private Long operateEmployeeId; diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java index 521fadd56..79b4ac79a 100644 --- a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java @@ -1,9 +1,12 @@ package com.engine.salary.entity.taxdeclaration.param; import com.engine.salary.common.BaseQueryParam; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; -import java.time.YearMonth; +import java.util.Date; /** * 个税申报记录查询条件 @@ -19,13 +22,7 @@ import java.time.YearMonth; @AllArgsConstructor public class TaxDeclarationListQueryParam extends BaseQueryParam { - //薪资所属月范围起点 - private YearMonth fromSalaryMonth; + private Date fromSalaryMonth; - //薪资所属月范围终点 - private YearMonth endSalaryMonth; - - private String fromSalaryMonthStr; - - private String endSalaryMonthStr; + private Date endSalaryMonth; } diff --git a/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java index 8319f9e4d..9950f55cd 100644 --- a/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java +++ b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java @@ -86,6 +86,13 @@ public class TaxDeclarationPO { LocalDateRange salaryMonths; + //"开始日期 + private Date taxCycleFromDate; + + //结束日期 + private Date taxCycleEndDate; + + private Collection taxAgentIds; } diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml index 1810e8970..b034b00ff 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml @@ -61,6 +61,12 @@ AND salary_month #{salaryMonths.endDate} + + AND tax_cycle = ]]> #{taxCycleFromDate} + + + AND tax_cycle #{taxCycleEndDate} + AND tax_agent_id IN diff --git a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java index 4388047f9..e47049045 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java @@ -114,15 +114,12 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration // 分页参数 TaxDeclarationPO po = TaxDeclarationPO.builder().build(); - LocalDateRange localDateRange = new LocalDateRange(); if (Objects.nonNull(queryParam.getFromSalaryMonth())) { - localDateRange.setFromDate(SalaryDateUtil.localDateToDate(queryParam.getFromSalaryMonth().atDay(1))); + po.setTaxCycleFromDate(queryParam.getFromSalaryMonth()); } if (Objects.nonNull(queryParam.getEndSalaryMonth())) { - localDateRange.setEndDate(SalaryDateUtil.localDateToDate(queryParam.getEndSalaryMonth().atEndOfMonth())); + po.setTaxCycleEndDate(queryParam.getEndSalaryMonth()); } - po.setSalaryMonths(localDateRange); - // 分权 Boolean openDevolution = getTaxAgentService(user).isNeedAuth(currentEmployeeId); diff --git a/src/com/engine/salary/web/TaxDeclarationController.java b/src/com/engine/salary/web/TaxDeclarationController.java index 6d2332dd4..1c65fd7a2 100644 --- a/src/com/engine/salary/web/TaxDeclarationController.java +++ b/src/com/engine/salary/web/TaxDeclarationController.java @@ -31,7 +31,6 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.text.ParseException; import java.time.LocalDate; @@ -58,10 +57,8 @@ public class TaxDeclarationController { @POST @Path("/list") @Produces(MediaType.APPLICATION_JSON) - public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationListQueryParam queryParam) throws ParseException { + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxDeclarationListQueryParam queryParam){ User user = HrmUserVarify.getUser(request, response); - queryParam.setFromSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getFromSalaryMonthStr() == null ? "" : queryParam.getFromSalaryMonthStr())); - queryParam.setEndSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getEndSalaryMonthStr() == null ? "" : queryParam.getEndSalaryMonthStr())); return new ResponseResult>(user).run(getTaxDeclarationWrapper(user)::listPage, queryParam); } From 0bdc48f1c20fc0be2bbe728d4d61c6e36ba0ec72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Thu, 24 Apr 2025 11:03:13 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=92=E6=A1=A3?= =?UTF-8?q?=E5=90=8E=E6=9F=A5=E7=9C=8B=E6=8B=93=E6=89=91=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/service/impl/SalarySobItemServiceImpl.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java b/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java index 15a14933e..3e4d548b5 100644 --- a/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java +++ b/src/com/engine/salary/service/impl/SalarySobItemServiceImpl.java @@ -40,7 +40,6 @@ import com.engine.salary.entity.salarysob.po.*; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.enums.OperateTypeEnum; import com.engine.salary.enums.SalaryValueTypeEnum; -import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum; import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum; import com.engine.salary.exception.SalaryRunTimeException; @@ -935,17 +934,10 @@ public class SalarySobItemServiceImpl extends Service implements SalarySobItemSe // 不是查询薪资账套下实时的薪资项目,而是查询发起薪资核算时存储的薪资项目快照 SalaryAcctConfig salaryAcctSobConfig = getSalaryAcctSobConfigService(user).getSalaryAcctConfig(salaryAcctRecordId); - // 1.1、如果薪资核算记录已经归档了,就不能继续核算 - if (!Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99148, "当前薪资核算记录已归档,请重新打开后再进行核算")); - } // 2、查询薪资核算记录的薪资周期、考勤周期等 SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(salaryAcctRecordId); // 3、查询薪资核算记录所用薪资账套的薪资项目副本 List salarySobItemPOS = salaryAcctSobConfig.getSalarySobItems(); - if (CollectionUtils.isEmpty(salarySobItemPOS)) { - throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99151, "当前所用的薪资账套未选择任何薪资项目,无法核算")); - } // 回算薪资项目 List salarySobBackItems = Collections.emptyList(); if (Objects.equals(salaryAcctRecordPO.getBackCalcStatus(), 1)) { From 22f494fe120376f975c8b46c78d463889e08db98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Thu, 24 Apr 2025 16:02:34 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8C=89=E7=85=A7?= =?UTF-8?q?=E6=89=A3=E7=BC=B4=E4=B9=89=E5=8A=A1=E4=BA=BA=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=A3=80=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../param/TaxDeclarationListQueryParam.java | 9 +++++++++ .../service/impl/TaxDeclarationServiceImpl.java | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java index 79b4ac79a..a7de714a9 100644 --- a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java @@ -1,11 +1,13 @@ package com.engine.salary.entity.taxdeclaration.param; import com.engine.salary.common.BaseQueryParam; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; + import java.util.Date; /** @@ -22,7 +24,14 @@ import java.util.Date; @AllArgsConstructor public class TaxDeclarationListQueryParam extends BaseQueryParam { + //薪资所属月范围起点 + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date fromSalaryMonth; + //薪资所属月范围终点 + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date endSalaryMonth; + + //个税扣缴义务人菜单") + private String taxAgentName; } diff --git a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java index e47049045..afe5a6991 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java @@ -1,5 +1,6 @@ package com.engine.salary.service.impl; +import cn.hutool.core.util.StrUtil; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.hrmelog.entity.dto.LoggerContext; @@ -9,6 +10,7 @@ import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; import com.engine.salary.entity.salaryitem.po.SalaryItemPO; import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO; import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; @@ -135,6 +137,15 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration // 查询个税申报表 List taxDeclarationPOS = getTaxDeclarationMapper().listSome(po); + + + if (StrUtil.isNotBlank(queryParam.getTaxAgentName())) { + List taxAgentPOs = getTaxAgentService(user).list(TaxAgentQueryParam.builder().name(queryParam.getTaxAgentName()).build()); + Set taxAgentIds = SalaryEntityUtil.properties(taxAgentPOs, TaxAgentPO::getId); + taxDeclarationPOS = taxDeclarationPOS.stream().filter(tax -> taxAgentIds.contains(tax.getTaxAgentId())).collect(Collectors.toList()); + } + + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), taxDeclarationPOS, TaxDeclarationPO.class); From ee3fd8da8e46cea728f10f04631b0938b04564cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Thu, 24 Apr 2025 16:19:23 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8C=89=E7=85=A7?= =?UTF-8?q?=E6=89=A3=E7=BC=B4=E4=B9=89=E5=8A=A1=E4=BA=BA=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=A3=80=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/service/impl/TaxDeclareRecordServiceImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java index af3d81c1c..cdec3def1 100644 --- a/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java @@ -1,5 +1,6 @@ package com.engine.salary.service.impl; +import cn.hutool.core.util.StrUtil; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.hrmelog.entity.dto.LoggerContext; @@ -23,6 +24,7 @@ import com.engine.salary.entity.salarysob.po.SalarySobAddUpRulePO; import com.engine.salary.entity.salarysob.po.SalarySobPO; import com.engine.salary.entity.salarysob.po.SalarySobTaxReportRulePO; import com.engine.salary.entity.taxagent.bo.TaxAgentTaxReturnBO; +import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.entity.taxagent.po.TaxAgentTaxReturnPO; import com.engine.salary.entity.taxapiflow.bo.TaxApiFlowBO; @@ -250,6 +252,13 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe } List taxDeclareRecordPOS = getTaxDeclareRecordMapper().listSome(build); + + if (StrUtil.isNotBlank(queryParam.getTaxAgentName())) { + List taxAgentPOs = getTaxAgentService(user).list(TaxAgentQueryParam.builder().name(queryParam.getTaxAgentName()).build()); + Set taxAgentIds = SalaryEntityUtil.properties(taxAgentPOs, TaxAgentPO::getId); + taxDeclareRecordPOS = taxDeclareRecordPOS.stream().filter(tax -> taxAgentIds.contains(tax.getTaxAgentId())).collect(Collectors.toList()); + } + return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), taxDeclareRecordPOS, TaxDeclareRecordPO.class); } From 8c4fbf79191d57391752e56537262a3894d97708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=B6=9B?= <15850646081@163.com> Date: Fri, 9 May 2025 11:45:06 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=8B=BC=E6=8E=A5=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java index 83892cf9a..504e7d3d7 100644 --- a/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java +++ b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java @@ -711,7 +711,7 @@ public enum IncomeCategoryEnum implements BaseEnum { } List rysbsblb = feedbackResponse.getBody().getRysbsblb(); if (CollectionUtil.isNotEmpty(rysbsblb)) { - String err = rysbsblb.stream().map(GetASynIndividualIncomeTaxFeedbackResponse.Body.rysbsb::getSbyy).collect(Collectors.joining(";")); + String err = rysbsblb.stream().map(sb -> Util.null2String(sb.getXm()) + Util.null2String(sb.getSbyy())).collect(Collectors.joining(";")); throw new OnlineCalculateTaxException(err); } }