万众财务报表

This commit is contained in:
Harryxzy 2025-02-26 14:48:35 +08:00
parent 7588a024ca
commit 9a528d4eef
8 changed files with 432 additions and 8 deletions

View File

@ -0,0 +1,33 @@
package com.engine.salary.entity.salaryacct.po;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author Harryxzy
* @ClassName WzDhReportSetPO
* @date 2025/02/25 17:41
* @description
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WzDhReportSetPO {
// 人员类型
private String rylx;
// 统计项目名称
private String tjxmmc;
// 统计薪资项
private List<Long> tjxzx;
// 排序
private Integer px;
}

View File

@ -155,6 +155,7 @@ public interface SalaryAcctExcelService {
*/
Map<String, Object> exportTemplateList(SalaryAcctResultTemplateSaveParam param);
//
// /**
// * 薪资核算结果校验异常导出

View File

@ -7,8 +7,10 @@ import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultListColumnDTO;
import com.engine.salary.entity.salaryacct.param.*;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import com.engine.salary.util.page.PageInfo;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -230,4 +232,8 @@ public interface SalaryAcctResultService {
String handleWzResult();
String handleWzResult2();
Map<String, Object> dhSalaryReportList(Date salaryMonth);
XSSFWorkbook exportDhSalaryReport(Date salaryMonth);
}

View File

@ -7,16 +7,14 @@ import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.common.LocalDateRange;
import com.engine.salary.component.WeaTableColumnGroup;
import com.engine.salary.config.SalaryElogConfig;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.constant.SalaryItemConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.report.po.SalaryAcctResultReportPO;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctConfig;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultLogBO;
import com.engine.salary.entity.salaryacct.bo.*;
import com.engine.salary.entity.salaryacct.dto.SalaryAccEmployeeListDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctImportFieldDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultTemplateDTO;
@ -35,6 +33,7 @@ import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.OperateTypeEnum;
import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.enums.salaryaccounting.LockStatusEnum;
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
import com.engine.salary.enums.salaryaccounting.SalaryAcctResultDataSourceEnum;
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
import com.engine.salary.exception.SalaryRunTimeException;
@ -72,7 +71,9 @@ import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StopWatch;
import weaver.conn.RecordSet;
import weaver.file.ImageFileManager;
import weaver.general.BaseBean;
import weaver.hrm.User;
import java.io.InputStream;

View File

@ -6,6 +6,7 @@ import com.engine.core.impl.Service;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.cache.SalaryCacheKey;
import com.engine.salary.common.LocalDateRange;
import com.engine.salary.component.WeaTableColumnGroup;
import com.engine.salary.config.SalaryElogConfig;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.encrypt.AESEncryptUtil;
@ -56,6 +57,7 @@ import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.IdGenerator;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.excel.ExcelUtilPlus;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.engine.salary.util.valid.ValidUtil;
@ -70,10 +72,13 @@ import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.util.StopWatch;
import weaver.conn.RecordSet;
import weaver.conn.mybatis.MyBatisFactory;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import java.math.BigDecimal;
@ -1469,4 +1474,190 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
}
return "success";
}
@Override
public Map<String, Object> dhSalaryReportList(Date salaryMonth) {
Map<String, Object> resultMap = new HashMap<>();
if (salaryMonth == null) {
return null;
}
BaseBean baseBean = new BaseBean();
List<Long> salarySobIds = Arrays.stream(baseBean.getPropValue("sxwzDhSalaryReport", "dh_report_salary_sob_id").split(","))
.filter(NumberUtils::isCreatable)
.map(Long::valueOf)
.collect(Collectors.toList());
// 查询薪资核算记录
LocalDateRange salaryMonthRange = LocalDateRange.builder().fromDate(salaryMonth).endDate(salaryMonth).build();
List<SalaryAcctRecordPO> salaryAcctRecordList = getSalaryAcctRecordService(user).listBySalarySobIdsAndSalaryMonth(salarySobIds, salaryMonthRange);
// 过滤未归档数据
salaryAcctRecordList = salaryAcctRecordList.stream().filter(record -> record.getStatus() > SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()).collect(Collectors.toList());
List<Long> salaryAcctRecordIds = salaryAcctRecordList.stream().map(SalaryAcctRecordPO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(salaryAcctRecordIds)) {
return resultMap;
}
// 查询薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeePOList = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(salaryAcctRecordIds);
if (CollectionUtils.isEmpty(salaryAcctEmployeePOList)) {
return resultMap;
}
// 获取员工信息
List<Long> salaryAcctEmpIds = salaryAcctEmployeePOList.stream().map(SalaryAcctEmployeePO::getId).distinct().collect(Collectors.toList());
// 获取需要统计的项目信息
List<WzDhReportSetPO> cwReportMappingList = listAllCwReportMappingInfo();
Long rylxItemId = NumberUtils.isCreatable(baseBean.getPropValue("sxwzDhSalaryReport", "rylx_salary_item_id")) ? Long.valueOf(baseBean.getPropValue("sxwzDhSalaryReport", "rylx_salary_item_id")) : 0L;
// 获取需要统计的薪资项目
List<Long> salaryItemIds = cwReportMappingList.stream().map(setPO -> setPO.getTjxzx()).flatMap(Collection::stream).collect(Collectors.toList());
salaryItemIds.add(rylxItemId);
List<SalaryItemPO> salaryItemList = getSalaryItemService(user).listByIds(salaryItemIds);
List<SalaryItemPO> numberItems = salaryItemList.stream().filter(item -> item.getDataType().equals(SalaryDataTypeEnum.NUMBER.getValue())).collect(Collectors.toList());
// 查询薪资核算结果
List<SalaryAcctResultPO> acctResultList = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, salaryItemIds);
List<Map<String, Object>> acctResultMap = buildData4WZ(salaryItemList, salaryAcctEmployeePOList, acctResultList);
// 根据人员类型分组
Map<String, List<Map<String, Object>>> acctResultGroupMap = SalaryEntityUtil.group2Map(acctResultMap, map -> Util.null2String(map.getOrDefault(rylxItemId.toString(), "")));
LinkedHashMap<String, LinkedHashMap<String, Object>> sumResultByGroup = getSumResultByGroup(acctResultGroupMap, Collections.emptyList(), numberItems, cwReportMappingList);
// 构建表头
List<WeaTableColumnGroup> columns = new ArrayList<>();
columns.add(new WeaTableColumnGroup("150px", "人员类型", "rylx"));
columns.add(new WeaTableColumnGroup("150px", "明细", "mx"));
columns.add(new WeaTableColumnGroup("150px", "金额", "je"));
List<LinkedHashMap<String, Object>> resultList = new ArrayList<>();
for (Map.Entry<String, LinkedHashMap<String, Object>> entry : sumResultByGroup.entrySet()) {
String rylx = entry.getKey();
entry.getValue().forEach((key, value) -> {
LinkedHashMap<String, Object> singleRowMap = new LinkedHashMap<>();
singleRowMap.put("rylx", rylx);
singleRowMap.put("mx", key);
singleRowMap.put("je", value);
resultList.add(singleRowMap);
});
}
Map<String, Object> map = new HashMap<>();
map.put("column", columns);
map.put("data", resultList);
return map;
}
@Override
public XSSFWorkbook exportDhSalaryReport(Date salaryMonth) {
Map<String, Object> resultMap = dhSalaryReportList(salaryMonth);
List<WeaTableColumnGroup> columns = resultMap.get("column") == null ? new ArrayList<WeaTableColumnGroup>() : (List<WeaTableColumnGroup>)resultMap.get("column");
List<LinkedHashMap<String, Object>> data = resultMap.get("data") == null ? new ArrayList<LinkedHashMap<String, Object>>() : (List<LinkedHashMap<String, Object>>) resultMap.get("data");
if (CollectionUtils.isNotEmpty(columns) && CollectionUtils.isNotEmpty(data)) {
List<List<Object>> rows = new ArrayList<>();
rows.add(columns.stream().map(WeaTableColumnGroup::getText).collect(Collectors.toList()));
for (LinkedHashMap<String, Object> rowMap : data) {
List<Object> rowList = new ArrayList<>();
for (WeaTableColumnGroup column : columns) {
if (column.getColumn().equals("je") && NumberUtils.isCreatable(Util.null2String(rowMap.getOrDefault(column.getColumn(), "")))) {
rowList.add(new BigDecimal(Util.null2String(rowMap.getOrDefault(column.getColumn(), ""))));
} else {
rowList.add(Util.null2String(rowMap.getOrDefault(column.getColumn(), "")));
}
}
rows.add(rowList);
}
return ExcelUtilPlus.genWorkbook4Wz(rows, "薪酬报表", false);
}
return null;
}
/**
* 获取德闳薪酬财务报表映射配置信息
* @return
*/
private List<WzDhReportSetPO> listAllCwReportMappingInfo() {
List<WzDhReportSetPO> resultList = new ArrayList<>();
RecordSet rs = new RecordSet();
rs.execute("select rylx,tjxmmc,tjxzx,px from uf_dhcwbbyspz");
while (rs.next()) {
String rylx = rs.getString("rylx");
String tjxmmc = rs.getString("tjxmmc");
String tjxzx = rs.getString("tjxzx");
List<Long> tjxzxIds = Arrays.stream(tjxzx.split(",")).filter(NumberUtils::isCreatable).map(Long::valueOf).collect(Collectors.toList());
int px = rs.getInt("px");
resultList.add(WzDhReportSetPO.builder()
.rylx(rylx)
.tjxmmc(tjxmmc)
.tjxzx(tjxzxIds)
.px(px)
.build());
}
return resultList;
}
public List<Map<String, Object>> buildData4WZ(List<SalaryItemPO> salaryItems,
List<SalaryAcctEmployeePO> salaryAcctEmployees,
List<SalaryAcctResultPO> salaryAccountingResults) {
if (CollectionUtils.isEmpty(salaryAcctEmployees)) {
return Collections.emptyList();
}
SalaryI18nUtil.i18nList(salaryAcctEmployees);
Map<Long, List<SalaryAcctResultPO>> acctResultMap = SalaryEntityUtil.group2Map(salaryAccountingResults, SalaryAcctResultPO::getSalaryAcctEmpId);
return salaryAcctEmployees.stream().map(e -> {
Map<Long, Object> resultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(e.getId(), Collections.emptyList()),
SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue);
// 薪资项目的值
Map<String, Object> map = SalaryEntityUtil.convert2Map(salaryItems, o -> "" + o.getId(), o -> resultValueMap.getOrDefault(o.getId(), StringUtils.EMPTY));
// 主键id
map.put("id", e.getId());
//人员id
map.put("employeeId", e.getEmployeeId());
return map;
}).collect(Collectors.toList());
}
private LinkedHashMap<String, LinkedHashMap<String, Object>> getSumResultByGroup(Map<String, List<Map<String, Object>>> groupBy,
List<SalarySobItemPO> salarySobItemPOS,
List<SalaryItemPO> numberItems,
List<WzDhReportSetPO> cwReportMappingList) {
LinkedHashMap<String, List<Map<String, Object>>> sortedGroupBy = new LinkedHashMap<>();
groupBy.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.forEachOrdered(x -> sortedGroupBy.put(x.getKey(), x.getValue()));
// 本次薪资核算所用的薪资账套下的薪资项目
Map<String, List<WzDhReportSetPO>> tjxmMappingGroup = SalaryEntityUtil.group2Map(cwReportMappingList, WzDhReportSetPO::getRylx);
LinkedHashMap<String, LinkedHashMap<String, Object>> resultMap = new LinkedHashMap<>();
for(Map.Entry<String, List<Map<String, Object>>> entrySet : sortedGroupBy.entrySet()){
List<Map<String, Object>> value = entrySet.getValue();
// 获取该分组有哪些统计项
List<WzDhReportSetPO> wzDhReportSetList = tjxmMappingGroup.get(entrySet.getKey());
if (CollectionUtils.isEmpty(wzDhReportSetList)) {
continue;
}
wzDhReportSetList = wzDhReportSetList.stream().sorted(Comparator.comparing(WzDhReportSetPO::getPx)).collect(Collectors.toList());
Map<String, Object> sumMap = new HashMap<>();
for (WzDhReportSetPO setPO : wzDhReportSetList) {
// 某个统计项
if (CollectionUtils.isEmpty(setPO.getTjxzx())) {
continue;
}
// 一个统计项的合计
BigDecimal itemSumValue = new BigDecimal("0");
for (Map<String, Object> valueMap : value) {
// 一个统计项可能由多个薪资项加起来
BigDecimal personSumValue = setPO.getTjxzx().stream().filter(itemId -> valueMap.get(itemId.toString()) != null)
.map(itemId -> (String) valueMap.get(itemId.toString()))
.filter(NumberUtils::isCreatable)
.map(BigDecimal::new)
.reduce(BigDecimal.ZERO, BigDecimal::add);
itemSumValue = itemSumValue.add(personSumValue);
}
sumMap.put(setPO.getTjxmmc(), itemSumValue);
}
LinkedHashMap<String, Object> sortedSumMap = new LinkedHashMap<>();
sumMap.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.forEachOrdered(x -> sortedSumMap.put(x.getKey(), x.getValue()));
resultMap.put(entrySet.getKey(), sortedSumMap);
}
return resultMap;
}
}

View File

@ -3,9 +3,11 @@ package com.engine.salary.util.excel;
import com.engine.salary.component.WeaTableColumnGroup;
import com.engine.salary.util.SalaryDateUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import weaver.wechat.util.Utils;
import java.awt.Color;
import java.math.BigDecimal;
@ -864,6 +866,150 @@ public class ExcelUtilPlus {
return workbook;
}
public static XSSFWorkbook genWorkbook4Wz(List<List<Object>> rowList, String sheetName, boolean lastRowRed) {
XSSFWorkbook workbook = new XSSFWorkbook();
// 设置title样式
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
XSSFFont titleFont = workbook.createFont();
titleFont.setBold(true);
titleFont.setFontName("仿宋");
titleFont.setFontHeightInPoints((short) 15);
titleCellStyle.setFont(titleFont);
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
titleCellStyle.setBorderLeft(BorderStyle.THIN);
titleCellStyle.setBorderRight(BorderStyle.THIN);
titleCellStyle.setBorderTop(BorderStyle.THIN);
titleCellStyle.setBorderBottom(BorderStyle.THIN);
// 设置主体样式
XSSFCellStyle cellStyle = workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setFontName("宋体");
font.setFontHeightInPoints((short) 10);// 设置字体大小
cellStyle.setFont(font);// 选择需要用到的字体格式
cellStyle.setWrapText(true);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setFillPattern(FillPatternType.NO_FILL);
XSSFCellStyle redCellStyle = workbook.createCellStyle();
XSSFFont redFont = workbook.createFont();
redFont.setFontName("宋体");
redFont.setFontHeightInPoints((short) 10);// 设置字体大小
redFont.setColor(new XSSFColor(new Color(0xFF3333), null));
redFont.setBold(true);
redCellStyle.setWrapText(true);
redCellStyle.setFont(redFont);// 选择需要用到的字体格式
redCellStyle.setBorderLeft(BorderStyle.THIN);
redCellStyle.setBorderRight(BorderStyle.THIN);
redCellStyle.setBorderTop(BorderStyle.THIN);
redCellStyle.setBorderBottom(BorderStyle.THIN);
XSSFCellStyle childTitleCellStyle = workbook.createCellStyle();
childTitleCellStyle.setFont(font);
childTitleCellStyle.setAlignment(HorizontalAlignment.CENTER);
childTitleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
childTitleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
childTitleCellStyle.setBorderLeft(BorderStyle.THIN);
childTitleCellStyle.setBorderRight(BorderStyle.THIN);
childTitleCellStyle.setBorderTop(BorderStyle.THIN);
childTitleCellStyle.setBorderBottom(BorderStyle.THIN);
XSSFSheet sheet = workbook.createSheet(sheetName);
//自适应宽度
sheet.autoSizeColumn(0, true);
//默认列宽
sheet.setDefaultColumnWidth(20);
//默认行高
sheet.setDefaultRowHeightInPoints(18);
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
List<Object> infoList = rowList.get(rowIndex);
XSSFRow row = sheet.createRow(rowIndex);
float height = 18;
float finalHeight = 18;
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
XSSFCell cell = row.createCell(cellIndex);
if (rowIndex == 0) {
cell.setCellStyle(titleCellStyle);
} else {
if (cellIndex == 0) {
cell.setCellStyle(childTitleCellStyle);
} else {
if (lastRowRed && rowIndex == rowList.size() - 1) {
cell.setCellStyle(redCellStyle);
} else {
cell.setCellStyle(cellStyle);
}
}
}
Object o = infoList.get(cellIndex);
if (o instanceof String) {
cell.setCellType(CellType.STRING);
cell.setCellValue(String.valueOf(o));
} else if (o instanceof BigDecimal) {
cell.setCellType(CellType.NUMERIC);
cell.setCellValue(o == null ? 0 : ((BigDecimal) o).doubleValue());
} else if (o instanceof Boolean) {
cell.setCellType(CellType.BOOLEAN);
cell.setCellValue(String.valueOf(o));
} else if (o instanceof Date) {
cell.setCellType(CellType.STRING);
cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o));
} else {
cell.setCellType(CellType.STRING);
cell.setCellValue(o == null ? "" : o.toString());
}
//判断是否要调整高度
int width = sheet.getColumnWidth(cellIndex) / 256;
finalHeight = getFinalHeight(o, width, finalHeight, height);
}
row.setHeightInPoints(finalHeight);
}
//处理合并单元格
int startIndex = 1;
String oldRylx = "";
for (int i = 1; i < rowList.size(); i++) {
List<Object> infoList = rowList.get(i);
String rylx = Utils.null2String(infoList.get(0));
if (StringUtils.isBlank(oldRylx) || !oldRylx.equals(rylx)) {
// 查询有几个相同的人员类型
int mergeCol = 1;
for (int j = i+1;j < rowList.size(); j++) {
String nextRylx = Utils.null2String(rowList.get(j).get(0));
if (nextRylx.equals(rylx)) {
mergeCol++;
} else {
break;
}
}
int endIndex = startIndex + mergeCol - 1;
if (endIndex > startIndex) {
sheet.addMergedRegion(new CellRangeAddress(startIndex, endIndex, 0, 0));
}
startIndex += mergeCol;
oldRylx = rylx;
}
}
return workbook;
}
public static float getFinalHeight(Object o, int width, float finalHeight, float height) {
if (o != null && getStrlength(o.toString()) > width) {
float remainder = getStrlength(o.toString()) % width;

View File

@ -31,10 +31,7 @@ import javax.ws.rs.core.StreamingOutput;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -1051,4 +1048,44 @@ public class SalaryAcctController {
}
/**********************************线下对比 end*********************************/
@POST
@Path("/dhSalaryReport/list")
@Produces(MediaType.APPLICATION_JSON)
public String dhSalaryReportList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctRecordQueryParam param) {
User user = HrmUserVarify.getUser(request, response);
Date salaryMonth = SalaryDateUtil.dateStrToLocalYearMonth(param.getStartMonthStr());
return new ResponseResult<Date, Map<String, Object>>(user).run(getSalaryAcctResultWrapper(user)::dhSalaryReportList, salaryMonth);
}
@GET
@Path("/dhSalaryReport/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportDhSalaryReport(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User user = HrmUserVarify.getUser(request, response);
String startMonthStr = request.getParameter("startMonthStr");
Date salaryMonth = null;
if (StringUtils.isNotBlank(startMonthStr)) {
salaryMonth = SalaryDateUtil.dateStrToLocalYearMonth(startMonthStr);
}
XSSFWorkbook workbook = getSalaryAcctResultWrapper(user).exportDhSalaryReport(salaryMonth);
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;
}
}
}

View File

@ -30,6 +30,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import weaver.hrm.User;
import java.math.BigDecimal;
@ -415,6 +416,14 @@ public class SalaryAcctResultWrapper extends Service implements SalaryAcctResult
return getSalaryAcctResultService(user).handleWzResult2();
}
public Map<String, Object> dhSalaryReportList(Date salaryMonth) {
return getSalaryAcctResultService(user).dhSalaryReportList(salaryMonth);
}
public XSSFWorkbook exportDhSalaryReport(Date salaryMonth) {
return getSalaryAcctResultService(user).exportDhSalaryReport(salaryMonth);
}
/**
* 薪资核算-校验
*