package com.engine.salary.service.impl; import com.engine.core.impl.Service; import com.engine.salary.biz.AddUpDeductionBiz; import com.engine.salary.biz.EmployBiz; import com.engine.salary.cmd.datacollection.*; import com.engine.salary.entity.datacollection.AddUpDeduction; import com.engine.salary.entity.datacollection.DataCollectionEmployee; import com.engine.salary.entity.datacollection.dto.AddUpDeductionDTO; import com.engine.salary.entity.datacollection.dto.AddUpDeductionRecordDTO; import com.engine.salary.entity.datacollection.param.AddUpDeductionQueryParam; import com.engine.salary.entity.taxagent.bo.TaxAgentBO; import com.engine.salary.entity.taxagent.dto.TaxAgentEmployeeDTO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.datacollection.AddUpDeductionMapper; import com.engine.salary.service.*; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.excel.ExcelComment; import com.engine.salary.util.excel.ExcelUtil; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; import com.google.common.collect.Lists; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.general.Util; import javax.annotation.Resource; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.YearMonth; import java.util.*; import java.util.stream.Collectors; public class AddUpDeductionServiceImpl extends Service implements AddUpDeductionService { private AddUpDeductionMapper getAddUpDeductionMapper() { return MapperProxyFactory.getProxy(AddUpDeductionMapper.class); } private TaxAgentV2Service taxAgentService; private SalaryAcctRecordService salaryAcctRecordService; private SalaryAcctEmployeeService salaryAcctEmployeeService; private SalaryEmployeeService salaryEmployeeService; @Override public Map list(Map params) { return commandExecutor.execute(new AddUpDeductionListCmd(params, user)); } @Override public XSSFWorkbook export(Map params) { Boolean chief = taxAgentService.isChief((long) user.getUID()); AddUpDeductionQueryParam addUpDeductionQueryParam = (AddUpDeductionQueryParam) params.get("addUpDeductionQueryParam"); AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); XSSFWorkbook workbook = addUpDeductionBiz.export(addUpDeductionQueryParam); return workbook; // return commandExecutor.execute(new AddUpDeductionExportCmd(params, user)); } @Override public Map getSearchCondition(Map params) { return commandExecutor.execute(new AddUpDeductionGetSearchConditionCmd(params, user)); } @Override public Map importAddUpDeduction(Map params) { return commandExecutor.execute(new AddUpDeductionImportCmd(params, user)); } @Override public Map getDetailList(Map params) { return commandExecutor.execute(new AddUpDeductionGetDetailListCmd(params, user)); } @Override public Map preview(Map params) { return commandExecutor.execute(new AddUpDeductionPreviewCmd(params, user)); } @Override public XSSFWorkbook exportDetail(Map params) { AddUpDeductionQueryParam queryParam = (AddUpDeductionQueryParam) params.get("addUpDeductionQueryParam"); EmployBiz employBiz = new EmployBiz(); AddUpDeductionBiz biz = new AddUpDeductionBiz(); Long id = queryParam.getAccumulatedSpecialAdditionalDeductionId(); if (id == null) { throw new SalaryRunTimeException("id不能为空"); } AddUpDeduction po = biz.getById(id); if (po == null) { throw new SalaryRunTimeException(String.format("累计专项附加扣除不存在" + "[id:%s]", id)); } List employeeList = employBiz.getEmployeeByIds(Collections.singletonList(po.getEmployeeId())); if (CollectionUtils.isEmpty(employeeList)) { throw new SalaryRunTimeException("员工信息不存在"); } //查询参数 queryParam.setEmployeeId(po.getEmployeeId()); //申报月份 List declareMonth = queryParam.getDeclareMonth(); if (CollectionUtils.isNotEmpty(declareMonth)) { queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); } XSSFWorkbook workbook = biz.exportDetail(queryParam); return workbook; // return commandExecutor.execute(new AddUpDeductionExportDetailCmd(params, user)); } @Override public List getAddUpDeductionList(YearMonth declareMonth, List employeeIds) { AddUpDeductionBiz addUpDeductionBiz = new AddUpDeductionBiz(); if (declareMonth == null) { throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100342, "参数有误:申报月份、租户key必传")); } return addUpDeductionBiz.listSome(AddUpDeduction.builder().declareMonth(SalaryDateUtil.toDateStartOfMonth(declareMonth)).employeeIds(employeeIds).build()); } @Override public XSSFWorkbook downloadTemplate(AddUpDeductionQueryParam queryParam) { String sheetName = SalaryI18nUtil.getI18nLabel(101603, "累计专项附加扣除导入模板"); String[] header = { SalaryI18nUtil.getI18nLabel(85429, "姓名"), SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), SalaryI18nUtil.getI18nLabel(86185, "部门"), SalaryI18nUtil.getI18nLabel(86186, "手机号"), SalaryI18nUtil.getI18nLabel(86317, "工号"), SalaryI18nUtil.getI18nLabel(86318, "证件号码"), SalaryI18nUtil.getI18nLabel(86319, "入职日期"), SalaryI18nUtil.getI18nLabel(86321, "累计子女教育"), SalaryI18nUtil.getI18nLabel(86323, "累计继续教育"), SalaryI18nUtil.getI18nLabel(86324, "累计住房贷款利息"), SalaryI18nUtil.getI18nLabel(86325, "累计住房租金"), SalaryI18nUtil.getI18nLabel(86326, "累计赡养老人"), SalaryI18nUtil.getI18nLabel(105142, "累计大病医疗"), SalaryI18nUtil.getI18nLabel(105142, "累计婴幼儿照护") }; List headerList = Arrays.asList(header); // 2.表头 if (queryParam.getDeclareMonth() != null) { queryParam.setDeclareMonth(queryParam.getDeclareMonth().stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList())); } // 获取累计专项附加扣除 List list = getAddUpDeductionMapper().list(queryParam); // 人员信息赋值 list.forEach(m -> { // todo 身份证号 m.setIdNo(""); }); List> rows = new ArrayList<>(); rows.add(headerList); for (AddUpDeductionDTO dto : list) { List row = new ArrayList<>(); row.add(Util.null2String(dto.getUsername())); row.add(Util.null2String(dto.getTaxAgentName())); row.add(Util.null2String(dto.getDepartmentName())); row.add(Util.null2String(dto.getMobile())); row.add(Util.null2String(dto.getJobNum())); row.add(Util.null2String(dto.getIdNo())); row.add(Util.null2String(dto.getHiredate())); row.add(Util.null2String(dto.getAddUpChildEducation())); row.add(Util.null2String(dto.getAddUpContinuingEducation())); row.add(Util.null2String(dto.getAddUpHousingLoanInterest())); row.add(Util.null2String(dto.getAddUpHousingRent())); row.add(Util.null2String(dto.getAddUpSupportElderly())); row.add(Util.null2String(dto.getAddUpIllnessMedical())); row.add(Util.null2String(dto.getAddUpInfantCare())); rows.add(row); } // 4.注释 List excelComments = Lists.newArrayList(); excelComments.add(new ExcelComment(0, 0, 3, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); excelComments.add(new ExcelComment(1, 0, 4, 2, SalaryI18nUtil.getI18nLabel(100344, "必填"))); excelComments.add(new ExcelComment(7, 0, 10, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); excelComments.add(new ExcelComment(8, 0, 11, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); excelComments.add(new ExcelComment(9, 0, 12, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); excelComments.add(new ExcelComment(10, 0, 13, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); excelComments.add(new ExcelComment(11, 0, 14, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); excelComments.add(new ExcelComment(12, 0, 15, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); excelComments.add(new ExcelComment(13, 0, 16, 2, SalaryI18nUtil.getI18nLabel(100344, "输入数字"))); XSSFWorkbook book = ExcelUtil.genWorkbookV2(rows, sheetName, excelComments); return book; } @Override public AddUpDeduction getById(Long id) { return getAddUpDeductionMapper().getById(id); } // /** // * 获取作为修改者的最新记录 // * 说明:以人员id和个税口角义务人id去重 // * // * @param currentEmployeeId // * @return // */ // private List getLastListByModifier(Long currentEmployeeId) { // List list = new LambdaQueryChainWrapper<>(getAddUpDeductionMapper()) // .eq(AddUpDeductionPO::getDeleteType, 0) // .eq(AddUpDeductionPO::getTenantKey) // .eq(AddUpDeductionPO::getModifier, currentEmployeeId) // .orderByDesc(AddUpDeductionPO::getDeclareMonth) // .list(); // return list.stream() // .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getEmployeeId() + "-" + f.getTaxAgentId()))), ArrayList::new)); // } @Override public PageInfo listPage(AddUpDeductionQueryParam queryParam, Long employeeId) { // 未开启分权或是薪酬模块总管理员 if (!taxAgentService.isOpenDevolution() || taxAgentService.isChief(employeeId)) { SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); List list = getAddUpDeductionMapper().list(queryParam); return new PageInfo<>(list, AddUpDeductionDTO.class); } else { List taxAgentEmployees = taxAgentService.listTaxAgentAndEmployee(employeeId); List taxAgentIdsAsAdmin = taxAgentService.listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); // List lastList = getLastListByModifier(employeeId); List list = getAddUpDeductionMapper().list(queryParam); list = list.stream().filter(f -> // 作为管理员 taxAgentIdsAsAdmin.contains(f.getTaxAgentId()) // 作为分管理员 || TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId()) // 自己最后修改过的,则可以看到最新和其历史 // || lastList.stream().anyMatch(l -> l.getEmployeeId().equals(f.getEmployeeId()) && l.getTaxAgentId().equals(f.getTaxAgentId()) && !l.getDeclareMonth().isBefore(f.getDeclareMonth())) ).collect(Collectors.toList()); // 填充总数和当页数据 // 分页参数 PageInfo dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), AddUpDeductionDTO.class); dtoPage.setTotal(list.size()); dtoPage.setList(SalaryPageUtil.subList(dtoPage.getPageNum(), dtoPage.getSize(), list)); return dtoPage; } } @Override public PageInfo recordListPage(AddUpDeductionQueryParam queryParam, Long employeeId) { // 未开启分权或是薪酬模块总管理员 if (!taxAgentService.isOpenDevolution() || taxAgentService.isChief(employeeId)) { SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); List list = getAddUpDeductionMapper().recordList(queryParam); return new PageInfo<>(list, AddUpDeductionRecordDTO.class); } else { List taxAgentEmployees = taxAgentService.listTaxAgentAndEmployee(employeeId); List taxAgentIdsAsAdmin = taxAgentService.listAllTaxAgentsAsAdmin(employeeId).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); // List lastList = getLastListByModifier(employeeId, tenantKey); List list = getAddUpDeductionMapper().recordList(queryParam); list = list.stream().filter(f -> // 作为管理员 taxAgentIdsAsAdmin.contains(f.getTaxAgentId()) // 作为分管理员 || TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId()) // 自己最后修改过的,则可以看到最新和其历史 // || lastList.stream().anyMatch(l -> l.getEmployeeId().equals(f.getEmployeeId()) && l.getTaxAgentId().equals(f.getTaxAgentId()) && !l.getDeclareMonth().isBefore(f.getDeclareMonth())) ).collect(Collectors.toList()); // 分页参数 // 填充总数和当页数据 PageInfo dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), AddUpDeductionRecordDTO.class); dtoPage.setTotal(list.size()); dtoPage.setList(SalaryPageUtil.subList(dtoPage.getPageNum(), dtoPage.getSize(), list)); return dtoPage; } } @Override public void export(Map map, String username, String eteamsId, boolean isChief, AddUpDeductionQueryParam queryParam, Long employeeId, String tenantKey) { List sheetList = new ArrayList<>(); ExcelSheetData excelSheetData = new ExcelSheetData(); String nameI18n = SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85380, "累计专项附加扣除"); // 1.工作簿名称 excelSheetData.setSheetName(nameI18n); String[] header = { SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85429, "姓名"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86184, "个税扣缴义务人"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86185, "部门"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86186, "手机号"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86317, "工号"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86318, "证件号码"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86319, "入职日期"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86321, "累计子女教育"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86323, "累计继续教育"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86324, "累计住房贷款利息"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86325, "累计住房租金"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86326, "累计赡养老人"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 105142, "累计大病医疗"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 117732, "累计婴幼儿照护") }; // 2.表头 excelSheetData.setHeaders(Collections.singletonList(header)); queryParam.setDeclareMonthDate(CollectionUtils.emptyIfNull(queryParam.getDeclareMonth()).stream().map(e-> LocalDate.of(e.getYear(),e.getMonthValue(),1)).collect(Collectors.toList())); // 获取累计专项附加扣除 List list = addUpDeductionMapper.list(queryParam, tenantKey); // 开启分权并且不是薪酬模块总管理员 if (taxAgentService.isOpenDevolution(tenantKey) && !isChief) { List taxAgentEmployees = taxAgentService.listTaxAgentAndEmployee(employeeId, tenantKey); List taxAgentIdsAsAdmin = taxAgentService.listAllTaxAgentsAsAdmin(employeeId, tenantKey).stream().map(TaxAgentPO::getId).collect(Collectors.toList()); List lastList = getLastListByModifier(employeeId, tenantKey); list = list.stream().filter(f -> // 作为管理员 taxAgentIdsAsAdmin.contains(f.getTaxAgentId()) // 作为分管理员 || TaxAgentBO.checkTaxAgentAndEmployee(taxAgentEmployees, f.getTaxAgentId(), f.getEmployeeId()) // 自己最后修改过的,则可以看到最新和其历史 || lastList.stream().anyMatch(l->l.getEmployeeId().equals(f.getEmployeeId()) && l.getTaxAgentId().equals(f.getTaxAgentId()) && !l.getDeclareMonth().isBefore(f.getDeclareMonth())) ).collect(Collectors.toList()); } List simpleUserInfos = salaryEmployeeService.listByEmployeeIds(list.stream().map(AddUpDeductionListDTO::getEmployeeId).collect(Collectors.toList()), tenantKey); List> rows = new ArrayList<>(); for (AddUpDeductionListDTO dto : list) { List row = new ArrayList<>(); row.add(dto.getUsername()); row.add(dto.getTaxAgentName()); row.add(dto.getDepartmentName()); row.add(dto.getMobile()); row.add(dto.getJobNum()); row.add(DataCollectionBO.getIdNo(dto.getEmployeeId(), simpleUserInfos)); row.add(dto.getHiredate()+""); row.add(dto.getAddUpChildEducation()); row.add(dto.getAddUpContinuingEducation()); row.add(dto.getAddUpHousingLoanInterest()); row.add(dto.getAddUpHousingRent()); row.add(dto.getAddUpSupportElderly()); row.add(dto.getAddUpIllnessMedical()); row.add(dto.getAddUpInfantCare()); rows.add(row); } // 3.表数据 excelSheetData.setRows(rows); sheetList.add(excelSheetData); salaryBatchService.simpleExportExcel(ExportExcelInfo.builder() .bizId(map.get("biz").toString()) .flag(true) .userId(employeeId) .eteamsId(eteamsId) .tenantKey(tenantKey) .operator(username) .module(map.get("module").toString()) .fileName(nameI18n + SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now())) .handlerName(map.get("function").toString()) .dataType(nameI18n) .function(map.get("function").toString()).build(), sheetList); } @Override public void downloadTemplate(Map map, String username, String eteamsId, boolean isChief, AddUpDeductionQueryParam queryParam, Long employeeId, String tenantKey) { List sheetList = new ArrayList<>(); ExcelSheetData excelSheetData = new ExcelSheetData(); String nameI18n = SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 101603, "累计专项附加扣除导入模板"); // 1.工作簿名称 excelSheetData.setSheetName(nameI18n); String[] header = { SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 85429, "姓名"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86184, "个税扣缴义务人"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86185, "部门"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86186, "手机号"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86317, "工号"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86318, "证件号码"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86319, "入职日期"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86321, "累计子女教育"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86323, "累计继续教育"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86324, "累计住房贷款利息"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86325, "累计住房租金"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 86326, "累计赡养老人"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 105142, "累计大病医疗"), SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 117732, "累计婴幼儿照护") }; // 2.表头 excelSheetData.setHeaders(Collections.singletonList(header)); queryParam.setDeclareMonthDate(CollectionUtils.emptyIfNull(queryParam.getDeclareMonth()).stream().map(e-> LocalDate.of(e.getYear(),e.getMonthValue(),1)).collect(Collectors.toList())); // 获取累计专项附加扣除 List list = addUpDeductionMapper.list(queryParam, tenantKey); List simpleUserInfos = salaryEmployeeService.listByEmployeeIds(list.stream().map(AddUpDeductionListDTO::getEmployeeId).collect(Collectors.toList()), tenantKey); List> rows = new ArrayList<>(); for (AddUpDeductionListDTO dto : list) { List row = new ArrayList<>(); row.add(dto.getUsername()); row.add(dto.getTaxAgentName()); row.add(dto.getDepartmentName()); row.add(dto.getMobile()); row.add(dto.getJobNum()); row.add(DataCollectionBO.getIdNo(dto.getEmployeeId(), simpleUserInfos)); row.add(dto.getHiredate()+""); row.add(dto.getAddUpChildEducation()); row.add(dto.getAddUpContinuingEducation()); row.add(dto.getAddUpHousingLoanInterest()); row.add(dto.getAddUpHousingRent()); row.add(dto.getAddUpSupportElderly()); row.add(dto.getAddUpIllnessMedical()); row.add(dto.getAddUpInfantCare()); rows.add(row); } // 3.表数据 excelSheetData.setRows(rows); // 4.注释 List excelComments = Lists.newArrayList(); salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100344, "必填"), 0, 0, 0, 0); salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100344, "必填"), 0, 0, 1, 1); salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 7, 7); salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 8, 8); salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 9, 9); salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 10, 10); salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 11, 11); salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 12, 12); salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, employeeId, 100343, "输入数字"), 0, 0, 13, 13); excelSheetData.setExcelComment(excelComments); sheetList.add(excelSheetData); salaryBatchService.simpleExportExcel(ExportExcelInfo.builder() .bizId(map.get("biz").toString()) .flag(true) .userId(employeeId) .eteamsId(eteamsId) .tenantKey(tenantKey) .operator(username) .module(map.get("module").toString()) .fileName(nameI18n + SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now())) .handlerName(map.get("function").toString()) .dataType(nameI18n) .function(map.get("function").toString()).build(), sheetList); } /** * 导出 * * @param param * @return */ private XSSFWorkbook export(AddUpDeductionQueryParam param) { //获取操作按钮资源 List> rowList = getExcelRowList(param); //获取excel return ExcelUtil.genWorkbook(rowList, "累计专项附加扣除"); } /** * 获取excel数据行 * * @return 导出数据行集合 */ private List> getExcelRowList(AddUpDeductionQueryParam param) { //excel标题 List title = Arrays.asList("姓名", "个税扣缴义务人", "部门", "手机号", "工号", "证件号码", "入职日期", "累计子女教育", "累计继续教育", "累计住房贷款利息", "累计住房租金", "累计赡养老人", "累计大病医疗", "累计婴幼儿照护"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); List list = list(param); final List> dataRowList = Optional.ofNullable(list) .map(List::stream) .map(operatorStream -> operatorStream.map(dto -> { List cellList = new ArrayList<>(); cellList.add(Util.null2String(dto.getUsername())); cellList.add(Util.null2String(dto.getTaxAgentName())); cellList.add(Util.null2String(dto.getDepartmentName())); cellList.add(Util.null2String(dto.getMobile())); cellList.add(Util.null2String(dto.getJobNum())); cellList.add(Util.null2String(dto.getIdNo())); cellList.add(Util.null2String(dto.getHiredate())); cellList.add(Util.null2String(dto.getAddUpChildEducation())); cellList.add(Util.null2String(dto.getAddUpContinuingEducation())); cellList.add(Util.null2String(dto.getAddUpHousingLoanInterest())); cellList.add(Util.null2String(dto.getAddUpHousingRent())); cellList.add(Util.null2String(dto.getAddUpSupportElderly())); cellList.add(Util.null2String(dto.getAddUpIllnessMedical())); cellList.add(Util.null2String(dto.getAddUpInfantCare())); return cellList; }).collect(Collectors.toList())) .orElse(Collections.emptyList()); List> rowList = new ArrayList<>(); rowList.add(title); rowList.addAll(dataRowList); return rowList; } }