diff --git a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationValueList.java b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationValueList.java index f5e8acf8c..e99e15650 100644 --- a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationValueList.java +++ b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationValueList.java @@ -57,7 +57,6 @@ public class TaxDeclarationValueList { * @param taxReportColumns * @param taxDeclarationValues * @param simpleEmployees - * @param simpleUserInfos * @param extEmployees * @return */ @@ -66,7 +65,6 @@ public class TaxDeclarationValueList { List taxDeclarationValues, List employeeDeclares, List simpleEmployees, - List simpleUserInfos, List extEmployees, boolean cnKey) { if (CollectionUtils.isEmpty(simpleEmployees)) { return Collections.emptyList(); @@ -76,8 +74,6 @@ public class TaxDeclarationValueList { Map simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId); // 员工报送信息按照人员id聚合分类 Map employeeDeclareMap = SalaryEntityUtil.convert2Map(employeeDeclares, EmployeeDeclarePO::getEmployeeId); - // 员工个人信息按照人员id聚合分类 - Map simpleUserInfoMap = SalaryEntityUtil.convert2Map(simpleUserInfos, e -> e.getEmployeeId()); // 非系统员工按照人员id聚合分类 Map extEmployeeMap = SalaryEntityUtil.convert2Map(extEmployees, ExtEmpPO::getId); for (TaxDeclarationValuePO taxDeclarationValue : taxDeclarationValues) { @@ -90,23 +86,32 @@ public class TaxDeclarationValueList { } EmployeeDeclarePO employeeDeclare = employeeDeclareMap.get(taxDeclarationValue.getEmployeeId()); if (employeeDeclare != null) { + DataCollectionEmployee simpleUserInfo = simpleEmployeeMap.get(taxDeclarationValue.getEmployeeId()); dataMap.put(cnKey ? "工号" : "jobNum", employeeDeclare.getJobNum()); dataMap.put(cnKey ? "姓名" : "username", employeeDeclare.getEmployeeName()); dataMap.put(cnKey ? "证件类型" : "cardType",CardTypeEnum.getByValue(employeeDeclare.getCardType()).getDefaultLabel() ); dataMap.put(cnKey ? "证件号码" : "cardNum", employeeDeclare.getCardNum()); + dataMap.put(cnKey ? "部门" : "departmentName", simpleUserInfo == null ? "" : simpleUserInfo.getDepartmentName()); + dataMap.put(cnKey ? "手机号" : "mobile", simpleUserInfo == null ? "" : simpleUserInfo.getMobile()); + dataMap.put(cnKey ? "证件号码" : "idNo", simpleUserInfo == null ? "" : simpleUserInfo.getIdNo()); } else if (taxDeclarationValue.getEmployeeType() == null || Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())) { DataCollectionEmployee simpleEmployee = simpleEmployeeMap.get(taxDeclarationValue.getEmployeeId()); - DataCollectionEmployee simpleUserInfo = simpleUserInfoMap.get(taxDeclarationValue.getEmployeeId()); dataMap.put(cnKey ? "工号" : "jobNum", simpleEmployee.getWorkcode()); dataMap.put(cnKey ? "姓名" : "username", simpleEmployee.getUsername()); dataMap.put(cnKey ? "证件类型" : "cardType", SalaryI18nUtil.getI18nLabel(CardTypeEnum.RESIDENT_IDENTITY_CARDS.getLabelId(), CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel())); - dataMap.put(cnKey ? "证件号码" : "cardNum", simpleUserInfo == null ? "" : simpleUserInfo.getIdNo()); + dataMap.put(cnKey ? "证件号码" : "cardNum", simpleEmployee.getIdNo()); + dataMap.put(cnKey ? "部门" : "departmentName", simpleEmployee.getDepartmentName()); + dataMap.put(cnKey ? "手机号" : "mobile", simpleEmployee.getMobile()); + dataMap.put(cnKey ? "证件号码" : "idNo", simpleEmployee.getIdNo()); } else { ExtEmpPO extEmployee = extEmployeeMap.get(taxDeclarationValue.getEmployeeId()); dataMap.put(cnKey ? "工号" : "jobNum", extEmployee.getWorkcode()); dataMap.put(cnKey ? "姓名" : "username", extEmployee.getUsername()); dataMap.put(cnKey ? "证件类型" : "cardType", SalaryI18nUtil.getI18nLabel(CardTypeEnum.RESIDENT_IDENTITY_CARDS.getLabelId(), CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel())); dataMap.put(cnKey ? "证件号码" : "cardNum", extEmployee.getIdNo()); + dataMap.put(cnKey ? "部门" : "departmentName", extEmployee == null ? "" : extEmployee.getDepartmentName()); + dataMap.put(cnKey ? "手机号" : "mobile", extEmployee == null ? "" : extEmployee.getMobile()); + dataMap.put(cnKey ? "证件号码" : "idNo", extEmployee == null ? "" : extEmployee.getIdNo()); } tableDataList.add(dataMap); } diff --git a/src/com/engine/salary/entity/taxdeclaration/param/DownloadTemplateParam.java b/src/com/engine/salary/entity/taxdeclaration/param/DownloadTemplateParam.java index d9371b3fd..7037ae964 100644 --- a/src/com/engine/salary/entity/taxdeclaration/param/DownloadTemplateParam.java +++ b/src/com/engine/salary/entity/taxdeclaration/param/DownloadTemplateParam.java @@ -23,4 +23,8 @@ public class DownloadTemplateParam { * 导入文件id */ String imageId; + + + //下载模板时是否带出现有数据 + private boolean hasData; } diff --git a/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java index 63581da27..ebacaab1a 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationExcelServiceImpl.java @@ -225,6 +225,31 @@ public class TaxDeclarationExcelServiceImpl extends Service implements TaxDeclar List> rowList = new ArrayList<>(); rowList.add(heads); + + if(param.isHasData()){ + // 查询个税申报表明细 + List taxDeclarationValues = getTaxDeclarationValueService(user).listByTaxDeclarationIds(Collections.singleton(param.getTaxDeclarationId())); + // 转成个税申报表明细 + TaxDeclarationValueListDTO taxDeclarationValueListDTO = getTaxDeclarationValueService(user).convert2List(declarationPO, taxDeclarationValues); + + List dataIndexList = new ArrayList<>(); + dataIndexList.add("username"); + dataIndexList.add("departmentName"); + dataIndexList.add("mobile"); + dataIndexList.add("jobNum"); + dataIndexList.add("idNo"); + dataIndexList.addAll(SalaryEntityUtil.properties(taxReportColumnPOS, TaxReportColumnPO::getReportColumnDataIndex, Collectors.toList())); + + // 解析表中数据 + for (Map datum : taxDeclarationValueListDTO.getData()) { + List row = Lists.newArrayList(); + for (String dataIndex : dataIndexList) { + row.add(Util.null2String(datum.get(dataIndex))); + } + rowList.add(row); + } + } + XSSFWorkbook book = ExcelUtil.genWorkbookV2(rowList, incomeCategoryEnum.getDefaultLabel()); return book; } diff --git a/src/com/engine/salary/service/impl/TaxDeclarationValueServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationValueServiceImpl.java index f680c228c..59f1fcdcc 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationValueServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationValueServiceImpl.java @@ -146,9 +146,7 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar 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 simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(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); @@ -156,7 +154,7 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar // 列表表头 List weaTableColumns = TaxDeclarationValueList.buildTableColumns(taxReportColumns); // 列表数据 - List> data = TaxDeclarationValueList.buildTableData(incomeCategoryEnum, taxReportColumns, taxDeclarationValues, employeeDeclares, simpleEmployees, simpleUserInfos, extEmployees, false); + List> data = TaxDeclarationValueList.buildTableData(incomeCategoryEnum, taxReportColumns, taxDeclarationValues, employeeDeclares, simpleEmployees, extEmployees, false); return new TaxDeclarationValueListDTO().setColumns(weaTableColumns).setData(data); } @@ -382,15 +380,13 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar 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 simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(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> localList = TaxDeclarationValueList.buildTableData(incomeCategoryEnum, taxReportColumns, taxDeclarationValues, employeeDeclares, simpleEmployees, simpleUserInfos, extEmployees, true); + List> localList = TaxDeclarationValueList.buildTableData(incomeCategoryEnum, taxReportColumns, taxDeclarationValues, employeeDeclares, simpleEmployees, extEmployees, true); Map> localMap = new HashMap<>();