薪酬系统-福利台账,线下对比结果列表导出v1
This commit is contained in:
parent
5f9d929865
commit
1e476e06a5
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Object> headerList = Lists.newArrayList();
|
||||
|
||||
Set<String> employeeInfo = employeeInfo();
|
||||
Set<String> 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<Map<String, Object>> resultMapList = insuranceComparisonResultListDTO.getData().getList();
|
||||
// excel导出的数据
|
||||
List<List<Object>> rows = new ArrayList<>();
|
||||
rows.add(headerList);
|
||||
for (Map<String, Object> map : resultMapList) {
|
||||
List<Object> 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<AccountExportPO> 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<String> welfareInfo() {
|
||||
|
||||
Set<String> info = new HashSet<>();
|
||||
|
||||
List<ICategoryPO> listAll = MapperProxyFactory.getProxy(ICategoryMapper.class).listAll();
|
||||
List<ICategoryPO> socialWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 1).collect(Collectors.toList());
|
||||
List<ICategoryPO> fundWelfareList = listAll.stream().filter(e -> e.getWelfareType() == 2).collect(Collectors.toList());
|
||||
List<ICategoryPO> 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<String> employeeInfo() {
|
||||
Set<String> info = new HashSet<>();
|
||||
|
||||
info.add("userName");
|
||||
info.add("department");
|
||||
info.add("mobile");
|
||||
info.add("workcode");
|
||||
info.add("socialPayOrg");
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<InsuranceComparisonResultQueryParam, PageInfo<Map<String, Object>>>(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*********************************/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue