宁波精华报表

This commit is contained in:
Harryxzy 2024-06-25 15:23:02 +08:00
parent 0acd0187a9
commit f2ea1e983d
10 changed files with 1151 additions and 299 deletions

View File

@ -386,6 +386,7 @@ public class SalaryAcctResultBO {
map.put("id", e.getId());
//人员id
map.put("employeeId", e.getEmployeeId());
map.put("userName", fieldValueMap.get("username"));
// 个税扣缴义务人
String taxAgentName = taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY);
map.put("taxAgentName", taxAgentName);

View File

@ -38,6 +38,9 @@ public class NbjhSalaryReportParam extends BaseQueryParam {
// 是否是月按实际部分工资汇总表
private boolean yasjbfgzhzReport;
// 是否是当月汇总表
private boolean dyhzReport;
// 是否是合计
private boolean isSum;

View File

@ -848,10 +848,10 @@ public class SalaryArchiveExcelBO extends Service {
} else if (importHandleParam.isSalaryItemAdjust()) {
SalaryItemAdjustValidDTO salaryItemAdjustValid = SalaryArchiveItemBO.handleSalaryItemAdjustValid(effectiveSalaryItem, effectiveBeforeSalaryItem, ineffectiveSalaryItem, effectiveTime, importHandleParam.getToday(), cellVal, importHandleParam.getSalaryArchiveItemDelSalaryItemIds());
if (salaryItemAdjustValid.isBefore()) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowindex + key + salaryItemNoBeforeCurrentEffectiveTime);
excelComments.add(errorMessageMap);
isError = true;
// Map<String, String> errorMessageMap = Maps.newHashMap();
// errorMessageMap.put("message", rowindex + key + salaryItemNoBeforeCurrentEffectiveTime);
// excelComments.add(errorMessageMap);
// isError = true;
} else if (salaryItemAdjustValid.isSame()) {
// Map<String, String> errorMessageMap = Maps.newHashMap();
// errorMessageMap.put("message", rowindex + key + salaryItemAdjustNoSame);

View File

@ -251,14 +251,6 @@ public interface SalaryAcctResultService {
*/
Map<String, Object> ndjjReport(NbjhSalaryReportParam param);
/**
* 年度奖金报表合计行
*
* @param param
* @return
*/
Map<String, Object> ndjjReportSum(NbjhSalaryReportParam param);
/**
* 导出年度奖金报表
*
@ -269,8 +261,34 @@ public interface SalaryAcctResultService {
/**
* 年度奖金报批表
*
* @param param
* @return
*/
Map<String, Object> ndjjBpReport(NbjhSalaryReportParam param);
/**
* 导出年度奖金报批表
*
* @param param
* @return
*/
XSSFWorkbook exportNdjjBpReport(NbjhSalaryReportParam param);
/**
* 实际计提表
*
* @param param
* @return
*/
Map<String, Object> sjjtReport(NbjhSalaryReportParam param);
/**
* 导出实际计提表
*
* @param param
* @return
*/
XSSFWorkbook exportSjjtReport(NbjhSalaryReportParam param);
}

View File

@ -424,7 +424,7 @@ public class SalaryArchiveItemServiceImpl extends Service implements SalaryArchi
Date effectiveTime = effectiveSalaryItem.getEffectiveTime();
// 1.1 如果早于<当前已生效
if (saveEffectiveTime.before(effectiveTime)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期"));
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期"));
// 1.2 如果等于当前已生效 fixme 日期比较可能有bug
} else if (saveEffectiveTime.equals(effectiveTime)) {
if (effectiveBeforeSalaryItem != null && effectiveBeforeSalaryItem.getItemValue().equals(e.getAdjustValue())) {
@ -517,7 +517,7 @@ public class SalaryArchiveItemServiceImpl extends Service implements SalaryArchi
Date effectiveTime = effectiveSalaryItem.getEffectiveTime();
// 1.1 如果早于<当前已生效
if (saveEffectiveTime.before(effectiveTime)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期"));
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期"));
// 1.2 如果等于当前已生效 fixme 日期比较可能有bug
} else if (saveEffectiveTime.equals(effectiveTime)) {
if (effectiveBeforeSalaryItem != null && effectiveBeforeSalaryItem.getItemValue().equals(e.getAdjustValue())) {

View File

@ -123,7 +123,7 @@ public class SalaryArchiveTaxAgentServiceImpl extends Service implements SalaryA
Date effectiveTime = effectiveTaxAgent.getEffectiveTime();
// 1.1 如果早于<当前已生效
if (saveEffectiveTime.before(effectiveTime)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期"));
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100429, "生效日期不可早于当前已生效的调整日期"));
// 1.2 如果等于当前已生效
} else if (saveEffectiveTime.equals(effectiveTime)) {
if (CollectionUtils.isNotEmpty(salaryArchiveTaxAgents) && salaryArchiveTaxAgents.get(0).getTaxAgentId().equals(saveParam.getTaxAgentId())) {

View File

@ -6,6 +6,7 @@ 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.ss.util.RegionUtil;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.beans.BeanUtils;
@ -968,6 +969,215 @@ public class ExcelUtilPlus {
return workbook;
}
public static XSSFWorkbook genWorkbookWithChildTitleColumn4nbjh(List<List<Object>> rowList, String sheetName, boolean lastRowRed, String title, int titleCellNum, String xzyf) {
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 childTitleCellStyle = workbook.createCellStyle();
childTitleCellStyle.setFont(titleFont);
childTitleCellStyle.setAlignment(HorizontalAlignment.LEFT);
childTitleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
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);
// 设置header样式
XSSFCellStyle headerCellStyle = workbook.createCellStyle();
XSSFFont headerFont = workbook.createFont();
headerFont.setBold(true);
headerFont.setFontName("仿宋");
headerFont.setFontHeightInPoints((short) 18);
headerCellStyle.setFont(headerFont);
headerCellStyle.setAlignment(HorizontalAlignment.CENTER);
headerCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
headerCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
XSSFCellStyle subTitleCellStyle = workbook.createCellStyle();
XSSFFont subTitleFont = workbook.createFont();
subTitleFont.setBold(true);
subTitleFont.setFontName("仿宋");
subTitleFont.setFontHeightInPoints((short) 15);
subTitleCellStyle.setFont(subTitleFont);
subTitleCellStyle.setAlignment(HorizontalAlignment.CENTER);
subTitleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
subTitleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
subTitleCellStyle.setBorderLeft(BorderStyle.THIN);
subTitleCellStyle.setBorderRight(BorderStyle.THIN);
subTitleCellStyle.setBorderTop(BorderStyle.THIN);
subTitleCellStyle.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);
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);
XSSFSheet sheet = workbook.createSheet(sheetName);
//自适应宽度
sheet.autoSizeColumn(0, true);
//默认列宽
sheet.setDefaultColumnWidth(20);
//默认行高
sheet.setDefaultRowHeightInPoints(18);
// 表头
if (StringUtils.isNotBlank(title)) {
XSSFRow row = sheet.createRow(0);
XSSFCell cell = row.createCell(0);
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, titleCellNum-1));
cell.setCellStyle(headerCellStyle);
cell.setCellValue(title);
}
// 薪资月份
if (StringUtils.isNotBlank(xzyf)) {
XSSFRow row = sheet.createRow(1);
XSSFCell cell = row.createCell(0);
cell.setCellStyle(subTitleCellStyle);
cell.setCellValue("薪资月份");
XSSFCell cell2 = row.createCell(1);
cell2.setCellStyle(subTitleCellStyle);
cell2.setCellValue(xzyf);
}
//处理合并单元格
XSSFRow row0 = sheet.createRow(0 +2);
XSSFRow row1 = sheet.createRow(1 +2);
List<Object> header = rowList.get(0);
int startIndex = 0;
for (int i = 0; i < header.size(); i++) {
WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) header.get(i);
if (columnGroupItem.getChildren() == null) {
sheet.addMergedRegion(new CellRangeAddress(0 + 2, 1 + 2, startIndex, startIndex));
XSSFCell rowZeroCell = row0.createCell(startIndex, CellType.STRING);
rowZeroCell.setCellValue(columnGroupItem.getText().toString());
rowZeroCell.setCellStyle(titleCellStyle);
XSSFCell rowOneCell = row1.createCell(startIndex, CellType.STRING);
rowOneCell.setCellValue(columnGroupItem.getText().toString());
rowOneCell.setCellStyle(titleCellStyle);
//设置列宽
sheet.setColumnWidth(startIndex, Math.max(12, columnGroupItem.getText().length() * 4) * 256);
startIndex++;
} else {
List<WeaTableColumnGroup> childrenList = columnGroupItem.getChildren();
int endIndex = startIndex + childrenList.size() - 1;
CellRangeAddress range = null;
if (endIndex > startIndex) {
range = new CellRangeAddress(0 + 2, 0 + 2, startIndex, endIndex);
sheet.addMergedRegion(range);
RegionUtil.setBorderTop(BorderStyle.THIN, range,sheet);
}
XSSFCell cell = row0.createCell(startIndex, CellType.STRING);
cell.setCellValue(columnGroupItem.getText().toString());
cell.setCellStyle(childTitleCellStyle);
for (int j = 0; j < childrenList.size(); j++) {
WeaTableColumnGroup childrenItem = (WeaTableColumnGroup) childrenList.get(j);
XSSFCell subHeader = row1.createCell(startIndex + j, CellType.STRING);
subHeader.setCellValue(childrenItem.getText().toString());
subHeader.setCellStyle(titleCellStyle);
//设置列宽
sheet.setColumnWidth(startIndex + j, Math.max(12, childrenItem.getText().length() * 4) * 256);
}
startIndex += childrenList.size();
}
}
for (int rowIndex = 1; rowIndex < rowList.size(); rowIndex++) {
List<Object> infoList = rowList.get(rowIndex);
XSSFRow row = sheet.createRow(rowIndex + 3);
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 (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);
}
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

@ -1096,23 +1096,19 @@ public class SalaryAcctController {
public Response exportndjjReport(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
NbjhSalaryReportParam param = new NbjhSalaryReportParam();
String startDate = request.getParameter("startDate");
if (StringUtils.isNotBlank(startDate)) {
param.setStartDate(startDate);
String year = request.getParameter("year");
if (StringUtils.isNotBlank(year)) {
param.setYear(year);
}
String endDate = request.getParameter("endDate");
if (StringUtils.isNotBlank(endDate)) {
param.setEndDate(endDate);
}
String departmentIds = request.getParameter("departmentIds");
if (StringUtils.isNotBlank(departmentIds)) {
List<Long> departmentIdList = Arrays.stream(departmentIds.split(",")).filter(NumberUtils::isCreatable).map(Long::valueOf).collect(Collectors.toList());
param.setDepartmentIds(departmentIdList);
String zwcj = request.getParameter("zwcj");
if (StringUtils.isNotBlank(zwcj)) {
param.setZwcj(zwcj);
}
User user = HrmUserVarify.getUser(request, response);
XSSFWorkbook workbook = getSalaryAcctResultWrapper(user).exportNdjjReport(param);
String time = LocalDate.now().toString();
String fileName = "月按实际部分工资汇总表" + time;
String fileName = "年度奖金" + time;
try {
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
} catch (UnsupportedEncodingException e) {
@ -1125,7 +1121,7 @@ public class SalaryAcctController {
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);
log.error("年度奖金", e);
throw e;
}
}
@ -1139,5 +1135,110 @@ public class SalaryAcctController {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<NbjhSalaryReportParam, Map<String, Object>>(user).run(getSalaryAcctResultWrapper(user)::ndjjBpReport, param);
}
// 年度奖金报批表合计行
@POST
@Path("/acctresult/ndjjBpReportSum")
@Produces(MediaType.APPLICATION_JSON)
public String ndjjBpReportSum(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody NbjhSalaryReportParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<NbjhSalaryReportParam, Map<String, Object>>(user).run(getSalaryAcctResultWrapper(user)::ndjjBpReportSum, param);
}
/**
* 导出年度奖金表
*/
@GET
@Path("/acctresult/exportNdjjBpReport")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportNdjjBpReport(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
NbjhSalaryReportParam param = new NbjhSalaryReportParam();
String year = request.getParameter("year");
if (StringUtils.isNotBlank(year)) {
param.setYear(year);
}
String zwcj = request.getParameter("zwcj");
if (StringUtils.isNotBlank(zwcj)) {
param.setZwcj(zwcj);
}
User user = HrmUserVarify.getUser(request, response);
XSSFWorkbook workbook = getSalaryAcctResultWrapper(user).exportNdjjBpReport(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;
}
}
// 实际计提表
@POST
@Path("/acctresult/sjjtReport")
@Produces(MediaType.APPLICATION_JSON)
public String sjjtReport(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody NbjhSalaryReportParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<NbjhSalaryReportParam, Map<String, Object>>(user).run(getSalaryAcctResultWrapper(user)::sjjtReport, param);
}
// 实际计提表合计行
@POST
@Path("/acctresult/sjjtReportSum")
@Produces(MediaType.APPLICATION_JSON)
public String sjjtReportSum(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody NbjhSalaryReportParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<NbjhSalaryReportParam, Map<String, Object>>(user).run(getSalaryAcctResultWrapper(user)::sjjtReportSum, param);
}
/**
* 导出实际计提表
*/
@GET
@Path("/acctresult/exportSjjtReport")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportSjjtReport(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
NbjhSalaryReportParam param = new NbjhSalaryReportParam();
String dyhzReport = request.getParameter("dyhzReport");
if (StringUtils.isNotBlank(dyhzReport)) {
param.setDyhzReport(dyhzReport.equals("true"));
}
String startDate = request.getParameter("startDate");
if (StringUtils.isNotBlank(startDate)) {
param.setStartDate(startDate);
}
User user = HrmUserVarify.getUser(request, response);
XSSFWorkbook workbook = getSalaryAcctResultWrapper(user).exportSjjtReport(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*********************************/
}

View File

@ -357,7 +357,6 @@ public class SalaryAcctResultWrapper extends Service implements SalaryAcctResult
* @param param
*/
public Map<String, Object> ndjjReport(NbjhSalaryReportParam param) {
param.setYasjbfgzhzReport(true);
return getSalaryAcctResultService(user).ndjjReport(param);
}
@ -367,9 +366,8 @@ public class SalaryAcctResultWrapper extends Service implements SalaryAcctResult
* @param param
*/
public Map<String, Object> ndjjReportSum(NbjhSalaryReportParam param) {
param.setYasjbfgzhzReport(true);
param.setSum(true);
return getSalaryAcctResultService(user).ndjjReportSum(param);
return getSalaryAcctResultService(user).ndjjReport(param);
}
/**
@ -392,6 +390,57 @@ public class SalaryAcctResultWrapper extends Service implements SalaryAcctResult
return getSalaryAcctResultService(user).ndjjBpReport(param);
}
/**
* 年度奖金表报批合计行
*
* @param param
*/
public Map<String, Object> ndjjBpReportSum(NbjhSalaryReportParam param) {
param.setSum(true);
return getSalaryAcctResultService(user).ndjjBpReport(param);
}
/**
* 导出年度奖金表
* @param param
* @return
*/
public XSSFWorkbook exportNdjjBpReport(NbjhSalaryReportParam param) {
param.setExport(true);
return getSalaryAcctResultService(user).exportNdjjBpReport(param);
}
/**
* 实际计提表
*
* @param param
* @return
*/
public Map<String, Object> sjjtReport(NbjhSalaryReportParam param) {
return getSalaryAcctResultService(user).sjjtReport(param);
}
/**
* 实际计提表合计行
*
* @param param
*/
public Map<String, Object> sjjtReportSum(NbjhSalaryReportParam param) {
param.setSum(true);
return getSalaryAcctResultService(user).sjjtReport(param);
}
/**
* 导出实际计提表
* @param param
* @return
*/
public XSSFWorkbook exportSjjtReport(NbjhSalaryReportParam param) {
param.setExport(true);
return getSalaryAcctResultService(user).exportSjjtReport(param);
}
/**
* 薪资核算-校验