diff --git a/src/com/engine/salary/service/impl/TaxDeclarationValueServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationValueServiceImpl.java index 34191ae36..c569bbf0c 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationValueServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationValueServiceImpl.java @@ -41,8 +41,6 @@ import weaver.hrm.User; import java.util.*; import java.util.stream.Collectors; -import static weaver.conn.ExternalDataSourceManager.list; - /** * 个税申报表 *

Copyright: Copyright (c) 2023

@@ -332,20 +330,42 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar } public void contrast(Long taxDeclarationId) { - TaxDeclarationPO declarationPO = getTaxDeclarationService(user).getById(taxDeclarationId); - if (declarationPO == null) { + TaxDeclarationPO taxDeclaration = getTaxDeclarationService(user).getById(taxDeclarationId); + if (taxDeclaration == null) { throw new SalaryRunTimeException("无申报表"); } - TaxDeclarationPO taxDeclarationPO; - if (CollectionUtils.isNotEmpty(list)) { - if (list.size() > 1) { - throw new SalaryRunTimeException("存在多条正常工资薪金申报表数据"); - } - taxDeclarationPO = list.get(0); - } else { + List taxDeclarationValues = listByTaxDeclarationId(taxDeclaration.getId()); + + // 查询个税申报表表头 + IncomeCategoryEnum incomeCategoryEnum = SalaryEnumUtil.enumMatchByValue(taxDeclaration.getIncomeCategory(), IncomeCategoryEnum.class); + List taxReportColumns = getTaxReportColumnService(user).listByIncomeCategory(incomeCategoryEnum, 0); + // 人员id + Set employeeIds = SalaryEntityUtil.properties(taxDeclarationValues, TaxDeclarationValuePO::getEmployeeId); + // 查询报送的人员 + List employeeDeclares = getEmployeeDeclareService(user).listByTaxCycleAndTaxAgentIdAndEmployeeIds(taxDeclaration.getTaxCycle(), taxDeclaration.getTaxAgentId(), employeeIds); + // 查询人员信息 + List simpleEmployeeIds = taxDeclarationValues.stream() + .filter(taxDeclarationValue -> taxDeclarationValue.getEmployeeType() == null || Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())) + .map(TaxDeclarationValuePO::getEmployeeId) + .distinct() + .collect(Collectors.toList()); + List simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds); + // 查询人员薪资(身份证号码等) + List simpleUserInfos = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds); + // 查询外部人员 + List extEmployeeIds = taxDeclarationValues.stream() + .filter(taxDeclarationValue -> Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue())) + .map(TaxDeclarationValuePO::getEmployeeId) + .collect(Collectors.toList()); + List extEmployees = getExtEmpService(user).getExtEmpByIds(extEmployeeIds); + + // 列表表头 + List weaTableColumns = TaxDeclarationValueList.buildTableColumns(taxReportColumns); + // 列表数据 + List> data = TaxDeclarationValueList.buildTableData(incomeCategoryEnum, taxReportColumns, taxDeclarationValues, + employeeDeclares, simpleEmployees, simpleUserInfos, extEmployees); - } } }