增加申报表导入时导出现有数据选项

This commit is contained in:
钱涛 2025-01-06 16:55:52 +08:00
parent 483c368732
commit 8a49ea89f8
4 changed files with 44 additions and 14 deletions

View File

@ -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<TaxDeclarationValuePO> taxDeclarationValues,
List<EmployeeDeclarePO> employeeDeclares,
List<DataCollectionEmployee> simpleEmployees,
List<DataCollectionEmployee> simpleUserInfos,
List<ExtEmpPO> extEmployees, boolean cnKey) {
if (CollectionUtils.isEmpty(simpleEmployees)) {
return Collections.emptyList();
@ -76,8 +74,6 @@ public class TaxDeclarationValueList {
Map<Long, DataCollectionEmployee> simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId);
// 员工报送信息按照人员id聚合分类
Map<Long, EmployeeDeclarePO> employeeDeclareMap = SalaryEntityUtil.convert2Map(employeeDeclares, EmployeeDeclarePO::getEmployeeId);
// 员工个人信息按照人员id聚合分类
Map<Long, DataCollectionEmployee> simpleUserInfoMap = SalaryEntityUtil.convert2Map(simpleUserInfos, e -> e.getEmployeeId());
// 非系统员工按照人员id聚合分类
Map<Long, ExtEmpPO> 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);
}

View File

@ -23,4 +23,8 @@ public class DownloadTemplateParam {
* 导入文件id
*/
String imageId;
//下载模板时是否带出现有数据
private boolean hasData;
}

View File

@ -225,6 +225,31 @@ public class TaxDeclarationExcelServiceImpl extends Service implements TaxDeclar
List<List<Object>> rowList = new ArrayList<>();
rowList.add(heads);
if(param.isHasData()){
// 查询个税申报表明细
List<TaxDeclarationValuePO> taxDeclarationValues = getTaxDeclarationValueService(user).listByTaxDeclarationIds(Collections.singleton(param.getTaxDeclarationId()));
// 转成个税申报表明细
TaxDeclarationValueListDTO taxDeclarationValueListDTO = getTaxDeclarationValueService(user).convert2List(declarationPO, taxDeclarationValues);
List<String> 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<String, Object> datum : taxDeclarationValueListDTO.getData()) {
List<Object> 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;
}

View File

@ -146,9 +146,7 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar
List<EmployeeDeclarePO> employeeDeclares = getEmployeeDeclareService(user).listByTaxCycleAndTaxAgentIdAndEmployeeIds(taxDeclaration.getTaxCycle(), taxDeclaration.getTaxAgentId(), employeeIds);
// 查询人员信息
List<Long> simpleEmployeeIds = taxDeclarationValues.stream().filter(taxDeclarationValue -> taxDeclarationValue.getEmployeeType() == null || Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())).map(TaxDeclarationValuePO::getEmployeeId).distinct().collect(Collectors.toList());
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds);
// 查询人员薪资身份证号码等
List<DataCollectionEmployee> simpleUserInfos = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds);
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(simpleEmployeeIds);
// 查询外部人员
List<Long> extEmployeeIds = taxDeclarationValues.stream().filter(taxDeclarationValue -> Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue())).map(TaxDeclarationValuePO::getEmployeeId).collect(Collectors.toList());
List<ExtEmpPO> extEmployees = getExtEmpService(user).getExtEmpByIds(extEmployeeIds);
@ -156,7 +154,7 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar
// 列表表头
List<WeaTableColumn> weaTableColumns = TaxDeclarationValueList.buildTableColumns(taxReportColumns);
// 列表数据
List<Map<String, Object>> data = TaxDeclarationValueList.buildTableData(incomeCategoryEnum, taxReportColumns, taxDeclarationValues, employeeDeclares, simpleEmployees, simpleUserInfos, extEmployees, false);
List<Map<String, Object>> 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<EmployeeDeclarePO> employeeDeclares = getEmployeeDeclareService(user).listByTaxCycleAndTaxAgentIdAndEmployeeIds(taxDeclaration.getTaxCycle(), taxDeclaration.getTaxAgentId(), employeeIds);
// 查询人员信息
List<Long> simpleEmployeeIds = taxDeclarationValues.stream().filter(taxDeclarationValue -> taxDeclarationValue.getEmployeeType() == null || Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())).map(TaxDeclarationValuePO::getEmployeeId).distinct().collect(Collectors.toList());
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds);
// 查询人员薪资身份证号码等
List<DataCollectionEmployee> simpleUserInfos = getSalaryEmployeeService(user).getEmployeeByIds(simpleEmployeeIds);
List<DataCollectionEmployee> simpleEmployees = getSalaryEmployeeService(user).getEmployeeByIdsAll(simpleEmployeeIds);
// 查询外部人员
List<Long> extEmployeeIds = taxDeclarationValues.stream().filter(taxDeclarationValue -> Objects.equals(taxDeclarationValue.getEmployeeType(), EmployeeTypeEnum.EXT_EMPLOYEE.getValue())).map(TaxDeclarationValuePO::getEmployeeId).collect(Collectors.toList());
List<ExtEmpPO> extEmployees = getExtEmpService(user).getExtEmpByIds(extEmployeeIds);
// 列表数据
List<Map<String, Object>> localList = TaxDeclarationValueList.buildTableData(incomeCategoryEnum, taxReportColumns, taxDeclarationValues, employeeDeclares, simpleEmployees, simpleUserInfos, extEmployees, true);
List<Map<String, Object>> localList = TaxDeclarationValueList.buildTableData(incomeCategoryEnum, taxReportColumns, taxDeclarationValues, employeeDeclares, simpleEmployees, extEmployees, true);
Map<String, Map<String, Object>> localMap = new HashMap<>();