From 1e476e06a591b8071aacbccecec24b1bc5b1376c Mon Sep 17 00:00:00 2001 From: sy Date: Thu, 29 Sep 2022 17:32:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=96=AA=E9=85=AC=E7=B3=BB=E7=BB=9F-=E7=A6=8F?= =?UTF-8?q?=E5=88=A9=E5=8F=B0=E8=B4=A6=EF=BC=8C=E7=BA=BF=E4=B8=8B=E5=AF=B9?= =?UTF-8?q?=E6=AF=94=E7=BB=93=E6=9E=9C=E5=88=97=E8=A1=A8=E5=AF=BC=E5=87=BA?= =?UTF-8?q?v1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/SIAComparisonResultService.java | 6 +- .../impl/SIAComparisonResultServiceImpl.java | 136 +++++++++++++++++- .../salary/web/SIAccountController.java | 42 +++++- .../wrapper/SIAComparisonResultWrapper.java | 11 ++ 4 files changed, 192 insertions(+), 3 deletions(-) diff --git a/src/com/engine/salary/service/SIAComparisonResultService.java b/src/com/engine/salary/service/SIAComparisonResultService.java index b3be1af62..73e6d3b9c 100644 --- a/src/com/engine/salary/service/SIAComparisonResultService.java +++ b/src/com/engine/salary/service/SIAComparisonResultService.java @@ -3,6 +3,7 @@ package com.engine.salary.service; import com.engine.salary.entity.salaryacct.param.SalaryComparisonResultQueryParam; import com.engine.salary.entity.siaccount.dto.InsuranceComparisonResultListDTO; import com.engine.salary.entity.siaccount.param.InsuranceComparisonResultQueryParam; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * @Author: sy @@ -22,5 +23,8 @@ public interface SIAComparisonResultService { */ InsuranceComparisonResultListDTO listByParam(InsuranceComparisonResultQueryParam queryParam); - + /** + * 导出福利核算线下对比结果 + */ + XSSFWorkbook exportComparisonResult(InsuranceComparisonResultQueryParam queryParam); } diff --git a/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java b/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java index 6d4f71df2..6ea78761a 100644 --- a/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java +++ b/src/com/engine/salary/service/impl/SIAComparisonResultServiceImpl.java @@ -23,23 +23,29 @@ import com.engine.salary.entity.salarysob.po.SalarySobPO; import com.engine.salary.entity.siaccount.bo.InsuranceComparisonResultBO; import com.engine.salary.entity.siaccount.dto.InsuranceComparisonResultListDTO; import com.engine.salary.entity.siaccount.param.InsuranceComparisonResultQueryParam; +import com.engine.salary.entity.sicategory.po.ICategoryPO; import com.engine.salary.entity.siexport.param.InsuranceExportParam; import com.engine.salary.entity.siexport.po.AccountExportPO; import com.engine.salary.entity.siexport.po.ExcelAccountExportPO; import com.engine.salary.entity.taxagent.po.TaxAgentPO; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.InsuranceExportMapper; +import com.engine.salary.mapper.sicategory.ICategoryMapper; import com.engine.salary.service.SIAComparisonResultService; import com.engine.salary.util.SalaryEntityUtil; import com.engine.salary.util.SalaryI18nUtil; import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.excel.ExcelUtil; import com.engine.salary.util.page.Column; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; +import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.util.*; import java.util.stream.Collectors; @@ -71,6 +77,55 @@ public class SIAComparisonResultServiceImpl extends Service implements SIACompar return listByParam(false, queryParam); } + @Override + public XSSFWorkbook exportComparisonResult(InsuranceComparisonResultQueryParam queryParam) { + ValidUtil.doValidator(queryParam); + + // 查询线下对比结果 + InsuranceComparisonResultListDTO insuranceComparisonResultListDTO = listByParam(queryParam); + // 薪资核算线下对比结果列表表头 + List headerList = Lists.newArrayList(); + + Set employeeInfo = employeeInfo(); + Set welfareInfo = welfareInfo(); + for (Column weaTableColumn : insuranceComparisonResultListDTO.getWeaTableColumns()) { + // 员工信息字段 + if (employeeInfo.contains(weaTableColumn.getKey())) { + headerList.add(weaTableColumn.getTitle()); + } + // 薪资项目的表头 + if (welfareInfo.contains(weaTableColumn.getKey())) { + headerList.add(weaTableColumn.getTitle() + " (线上值)"); + headerList.add(weaTableColumn.getTitle() + " (线下值)"); + } + } + + List> resultMapList = insuranceComparisonResultListDTO.getData().getList(); + // excel导出的数据 + List> rows = new ArrayList<>(); + rows.add(headerList); + for (Map map : resultMapList) { + List row = Lists.newArrayList(); + for (Column weaTableColumn : insuranceComparisonResultListDTO.getWeaTableColumns()) { + // 员工信息字段的值 + if (employeeInfo.contains(weaTableColumn.getKey())) { + row.add(map.get(weaTableColumn.getKey())); + } + // 福利项目的值 + if (welfareInfo.contains(weaTableColumn.getKey())) { + Map tempMap = (Map) map.getOrDefault(weaTableColumn.getKey(), Collections.emptyMap()); + row.add(tempMap.get("acctResultValue")); + row.add(tempMap.get("excelResultValue")); + } + } + rows.add(row); + } + + String sheetName = "线下对比结果"; + + return ExcelUtil.genWorkbookV2(rows, sheetName); + } + /** * 根据福利核算人员查询福利核算线下对比结果 @@ -84,7 +139,7 @@ public class SIAComparisonResultServiceImpl extends Service implements SIACompar List accountExportPOS = getInsuranceExportMapper().exportAccount(queryParam.getPaymentStatus(), insuranceExportParam); //如果入参包含姓名信息 if (queryParam.getUserName() != null) { - accountExportPOS.stream().filter(v -> v.getUserName().contains(queryParam.getUserName())).collect(Collectors.toList()); + accountExportPOS = accountExportPOS.stream().filter(v -> v.getUserName().contains(queryParam.getUserName())).collect(Collectors.toList()); } AccountExportPOEncrypt.decryptAccountExportPOList(accountExportPOS); @@ -118,4 +173,83 @@ public class SIAComparisonResultServiceImpl extends Service implements SIACompar // 返回结果 return new InsuranceComparisonResultListDTO().setWeaTableColumns(weaTableColumns).setData(dtoPage); } + + private Set welfareInfo() { + + Set info = new HashSet<>(); + + List listAll = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll(); + List socialWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 1).collect(Collectors.toList()); + List fundWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 2).collect(Collectors.toList()); + List otherWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 3).collect(Collectors.toList()); + + //组装社保基数 + for (ICategoryPO po : socialWelfareList) { + info.add(po.getId() + "socialBase"); + } + //组装公积金基数 + for (ICategoryPO po : fundWelfareList) { + info.add(po.getId() + "fundBase"); + } + //组装其他福利基数 + for (ICategoryPO po : otherWelfareList) { + info.add(po.getId() + "otherBase"); + } + //社保个人(生育保险个人、工伤保险个人、失业保险个人、养老保险个人、医疗保险个人) + for (ICategoryPO po : socialWelfareList) { + info.add(po.getId() + "socialPer"); + } + info.add("socialPerSum"); + + //住房公积金个人、补充住房公积金个人 + for (ICategoryPO po : fundWelfareList) { + info.add(po.getId() + "fundPer"); + } + info.add("fundPerSum"); + + //其他个人(比如企业年金个人) + for (ICategoryPO po : otherWelfareList) { + info.add(po.getId() + "otherPer"); + } + info.add("otherPerSum"); + info.add("perSum"); + + //社保单位(生育保险单位、工伤保险单位、失业保险单位、养老保险单位、医疗保险单位) + for (ICategoryPO po : socialWelfareList) { + info.add(po.getId() + "socialCom"); + } + info.add("socialComSum"); + + //住房公积金单位、补充住房公积金单位 + for (ICategoryPO po : fundWelfareList) { + info.add(po.getId() + "fundCom"); + } + info.add("fundComSum"); + + //其他单位(比如企业年金单位) + for (ICategoryPO po : otherWelfareList) { + info.add(po.getId() + "otherCom"); + } + info.add("otherComSum"); + info.add("comSum"); + + info.add("socialSum"); + info.add("fundSum"); + info.add("otherSum"); + info.add("total"); + + return info; + } + + private Set employeeInfo() { + Set info = new HashSet<>(); + + info.add("userName"); + info.add("department"); + info.add("mobile"); + info.add("workcode"); + info.add("socialPayOrg"); + + return info; + } } diff --git a/src/com/engine/salary/web/SIAccountController.java b/src/com/engine/salary/web/SIAccountController.java index ed5d921d2..32236d4b6 100644 --- a/src/com/engine/salary/web/SIAccountController.java +++ b/src/com/engine/salary/web/SIAccountController.java @@ -2,7 +2,6 @@ package com.engine.salary.web; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; -import com.engine.salary.entity.salaryacct.param.SalaryComparisonResultQueryParam; import com.engine.salary.entity.siaccount.dto.InsuranceAccountTabDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO; import com.engine.salary.entity.siaccount.dto.InsuranceAcctDetailImportFieldDTO; @@ -62,6 +61,7 @@ public class SIAccountController { private SIAComparisonResultWrapper getSIAComparisonResultWrapper(User user) { return (SIAComparisonResultWrapper) ServiceUtil.getService(SIAComparisonResultWrapper.class, user); } + /** * 获取台账列表页 * @@ -568,6 +568,46 @@ public class SIAccountController { return new ResponseResult>>(user).run(getSIAComparisonResultWrapper(user)::listPage, param); } + //导出福利核算-线上线下对比结果 + @GET + @Path("/comparisonresult/export") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public Response exportComparisonResult(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + InsuranceComparisonResultQueryParam param = new InsuranceComparisonResultQueryParam(); + + param.setPaymentStatus(Integer.valueOf(request.getParameter("paymentStatus"))); + param.setBillMonth(request.getParameter("billMonth")); + param.setPaymentOrganization(request.getParameter("paymentOrganization")); + String onlyDiffEmployee = request.getParameter("onlyDiffEmployee"); + if (StringUtils.isNotBlank(onlyDiffEmployee)) { + param.setOnlyDiffEmployee(Boolean.parseBoolean(onlyDiffEmployee)); + } + String userName = request.getParameter("userName"); + if (StringUtils.isNotBlank(userName)) { + param.setUserName(userName); + } + + User user = HrmUserVarify.getUser(request, response); + XSSFWorkbook workbook = getSIAComparisonResultWrapper(user).exportComparisonResult(param); + String time = LocalDate.now().toString(); + String fileName = "福利核算-线下对比结果" + time; + try { + fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + StreamingOutput output = outputStream -> { + workbook.write(outputStream); + outputStream.flush(); + }; + response.setContentType("application/octet-stream"); + return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build(); + } catch (Exception e) { + log.error("福利核算-线下对比结果导出异常", e); + throw e; + } + } // **********************************线下对比 end*********************************/ } diff --git a/src/com/engine/salary/wrapper/SIAComparisonResultWrapper.java b/src/com/engine/salary/wrapper/SIAComparisonResultWrapper.java index 794762189..2e4fc0d37 100644 --- a/src/com/engine/salary/wrapper/SIAComparisonResultWrapper.java +++ b/src/com/engine/salary/wrapper/SIAComparisonResultWrapper.java @@ -11,6 +11,7 @@ import com.engine.salary.service.SalaryComparisonResultService; import com.engine.salary.service.impl.SIAComparisonResultServiceImpl; import com.engine.salary.service.impl.SalaryComparisonResultServiceImpl; import com.engine.salary.util.page.PageInfo; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import weaver.hrm.User; import java.util.Map; @@ -41,4 +42,14 @@ public class SIAComparisonResultWrapper extends Service { return pageInfo; } + + /** + * 导出福利核算线下对比结果 + * + * @param queryParam 列表查询条件 + * @return + */ + public XSSFWorkbook exportComparisonResult(InsuranceComparisonResultQueryParam queryParam) { + return getSIAComparisonResultService(user).exportComparisonResult( queryParam); + } }