添加产值汇总表专业所排序

This commit is contained in:
lpd
2026-05-26 15:52:19 +08:00
parent 6c6c02ae59
commit 2401a27fa7
3 changed files with 55 additions and 36 deletions

View File

@@ -15,12 +15,14 @@ public class EmployeeOutputSummaryExcelRespVO {
@ExcelProperty("序号")
private Integer serialNo;
@ExcelProperty("专业所")
private String officeName;
private Integer officeSortNo;
@ExcelProperty("姓名")
private String employeeName;
@ExcelProperty("所属专业所")
private String officeName;
@ExcelProperty("第一季度")
private BigDecimal quarterOneAmount;

View File

@@ -716,6 +716,7 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
.selectEnabledListByOutputYear(reqVO.getYear(), employeeIds)
.stream()
.collect(Collectors.toMap(EmployeeYearLeaderOutputDO::getEmployeeId, item -> item, (a, b) -> a));
Map<Long, OfficeDO> officeMap = getOfficeMap(employeeList);
List<EmployeeOutputSummaryExcelRespVO> rows = new ArrayList<>();
for (EmployeeDO employee : employeeList) {
@@ -737,8 +738,11 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
.setScale(2, RoundingMode.HALF_UP);
BigDecimal estimatedYearEndPerformanceAmount = remainingOutputAmount.multiply(kValue)
.setScale(2, RoundingMode.HALF_UP);
OfficeDO office = officeMap.get(employee.getOfficeId());
EmployeeOutputSummaryExcelRespVO row = new EmployeeOutputSummaryExcelRespVO();
row.setOfficeName(office == null ? "" : defaultString(office.getOfficeName()));
row.setOfficeSortNo(office == null ? null : office.getSortNo());
row.setEmployeeName(employee.getEmployeeName());
row.setQuarterOneAmount(amountToWan(accumulator.getQuarterOneAmount()));
row.setQuarterTwoAmount(amountToWan(accumulator.getQuarterTwoAmount()));
@@ -2420,19 +2424,30 @@ public class ProjectOutputReportServiceImpl implements ProjectOutputReportServic
private void sortEmployeeRows(List<EmployeeOutputSummaryExcelRespVO> rows, String sortType) {
Comparator<EmployeeOutputSummaryExcelRespVO> comparator;
if (Objects.equals(sortType, SORT_NAME_ASC)) {
comparator = Comparator.comparing(EmployeeOutputSummaryExcelRespVO::getEmployeeName,
String.CASE_INSENSITIVE_ORDER);
comparator = employeeOfficeComparator()
.thenComparing(EmployeeOutputSummaryExcelRespVO::getEmployeeName, String.CASE_INSENSITIVE_ORDER);
} else if (Objects.equals(sortType, SORT_ANNUAL_TOTAL_ASC)) {
comparator = Comparator.comparing(EmployeeOutputSummaryExcelRespVO::getAnnualTotalAmount, this::compareAmount)
comparator = employeeOfficeComparator()
.thenComparing(EmployeeOutputSummaryExcelRespVO::getAnnualTotalAmount, this::compareAmount)
.thenComparing(EmployeeOutputSummaryExcelRespVO::getEmployeeName, String.CASE_INSENSITIVE_ORDER);
} else {
comparator = Comparator.comparing(EmployeeOutputSummaryExcelRespVO::getAnnualTotalAmount, this::compareAmount)
.reversed()
Comparator<EmployeeOutputSummaryExcelRespVO> annualTotalDescComparator = Comparator
.comparing(EmployeeOutputSummaryExcelRespVO::getAnnualTotalAmount, this::compareAmount)
.reversed();
comparator = employeeOfficeComparator()
.thenComparing(annualTotalDescComparator)
.thenComparing(EmployeeOutputSummaryExcelRespVO::getEmployeeName, String.CASE_INSENSITIVE_ORDER);
}
rows.sort(comparator);
}
private Comparator<EmployeeOutputSummaryExcelRespVO> employeeOfficeComparator() {
return Comparator
.comparing((EmployeeOutputSummaryExcelRespVO row) -> row.getOfficeSortNo() == null
? Integer.MAX_VALUE : row.getOfficeSortNo())
.thenComparing(EmployeeOutputSummaryExcelRespVO::getOfficeName, String.CASE_INSENSITIVE_ORDER);
}
private int compareAmount(BigDecimal left, BigDecimal right) {
return amount(left).compareTo(amount(right));
}

View File

@@ -24,7 +24,7 @@ public class EmployeeOutputSummaryExcelBuilder extends AbstractProjectOutputExce
private static final String TITLE_PREFIX = "7.1.6 ";
private static final String TITLE_SUFFIX = " 年设计中心员工个人考核产值汇总,全公司产值人员汇总表";
private static final String SUBTITLE_SUFFIX = " 年设计中心员工个人考核产值汇总(单位:万元)";
private static final int LAST_COL = 12;
private static final int LAST_COL = 13;
private static final int DETAIL_START_ROW_NUM = 4;
public Workbook build(ExportData data) {
@@ -36,7 +36,7 @@ public class EmployeeOutputSummaryExcelBuilder extends AbstractProjectOutputExce
private void buildSheet(Workbook workbook, ExportData data) {
Sheet sheet = createSheet(workbook, SHEET_NAME, SHEET_NAME);
setColumnWidths(sheet, 8, 14, 12, 12, 12, 12, 12, 14, 14, 18, 14, 14, 14);
setColumnWidths(sheet, 8, 16, 14, 12, 12, 12, 12, 12, 14, 14, 18, 14, 14, 14);
CellStyle subtitleStyle = createDerivedStyle(workbook, createInfoStyle(workbook),
null, HorizontalAlignment.CENTER, true, (short) 11);
@@ -80,7 +80,7 @@ public class EmployeeOutputSummaryExcelBuilder extends AbstractProjectOutputExce
private int writeHeaderRow(Sheet sheet, int rowIndex, CellStyle style) {
writeRow(sheet, rowIndex, style,
"序号", "姓名", "第一季度", "第二季度", "第三季度", "第四季度", "年度合计",
"序号", "专业所", "姓名", "第一季度", "第二季度", "第三季度", "第四季度", "年度合计",
"所长 / BIM 考核产值", "年度考核产值合计", "1~12 月份预计发生成本(含预计精神文明奖)",
"基本考核产值", "剩余产值", "预估年底绩效");
return rowIndex + 1;
@@ -92,19 +92,20 @@ public class EmployeeOutputSummaryExcelBuilder extends AbstractProjectOutputExce
Row row = sheet.createRow(rowIndex);
int excelRowNum = rowIndex + 1;
setText(row, 0, rowData == null || rowData.getSerialNo() == null ? "" : rowData.getSerialNo(), cellStyle);
setText(row, 1, rowData == null ? "" : safeText(rowData.getEmployeeName()), leftCellStyle);
setNumericCell(row, 2, rowData == null ? null : rowData.getQuarterOneAmount(), amountStyle);
setNumericCell(row, 3, rowData == null ? null : rowData.getQuarterTwoAmount(), amountStyle);
setNumericCell(row, 4, rowData == null ? null : rowData.getQuarterThreeAmount(), amountStyle);
setNumericCell(row, 5, rowData == null ? null : rowData.getQuarterFourAmount(), amountStyle);
setNumericCell(row, 6, rowData == null ? null : rowData.getAnnualTotalAmount(), amountStyle);
setNumericCell(row, 7, rowData == null ? null : rowData.getOfficeLeaderOrBimAmount(), amountStyle);
setNumericCell(row, 8, rowData == null ? null : rowData.getTotalAssessmentOutputAmount(), amountStyle);
setNumericCell(row, 9, rowData == null ? null : rowData.getExpectedCostAmount(), amountStyle);
setText(row, 1, rowData == null ? "" : safeText(rowData.getOfficeName()), leftCellStyle);
setText(row, 2, rowData == null ? "" : safeText(rowData.getEmployeeName()), leftCellStyle);
setNumericCell(row, 3, rowData == null ? null : rowData.getQuarterOneAmount(), amountStyle);
setNumericCell(row, 4, rowData == null ? null : rowData.getQuarterTwoAmount(), amountStyle);
setNumericCell(row, 5, rowData == null ? null : rowData.getQuarterThreeAmount(), amountStyle);
setNumericCell(row, 6, rowData == null ? null : rowData.getQuarterFourAmount(), amountStyle);
setNumericCell(row, 7, rowData == null ? null : rowData.getAnnualTotalAmount(), amountStyle);
setNumericCell(row, 8, rowData == null ? null : rowData.getOfficeLeaderOrBimAmount(), amountStyle);
setNumericCell(row, 9, rowData == null ? null : rowData.getTotalAssessmentOutputAmount(), amountStyle);
setNumericCell(row, 10, rowData == null ? null : rowData.getExpectedCostAmount(), amountStyle);
setFormulaCell(row, 10, buildBasicAssessmentFormula(excelRowNum, data), formulaStyle);
setFormulaCell(row, 11, buildRemainingOutputFormula(excelRowNum), formulaStyle);
setFormulaCell(row, 12, buildPerformanceFormula(excelRowNum, data), formulaStyle);
setFormulaCell(row, 11, buildBasicAssessmentFormula(excelRowNum, data), formulaStyle);
setFormulaCell(row, 12, buildRemainingOutputFormula(excelRowNum), formulaStyle);
setFormulaCell(row, 13, buildPerformanceFormula(excelRowNum, data), formulaStyle);
}
private void writeTotalRow(Sheet sheet, int rowIndex, List<EmployeeOutputSummaryExcelRespVO> rows, ExportData data,
@@ -115,8 +116,9 @@ public class EmployeeOutputSummaryExcelBuilder extends AbstractProjectOutputExce
int detailEndRowNum = DETAIL_START_ROW_NUM + rows.size() - 1;
setText(row, 0, "", totalCellStyle);
setText(row, 1, "合计", totalLeftCellStyle);
for (int col = 2; col <= LAST_COL; col++) {
setText(row, 1, "", totalLeftCellStyle);
setText(row, 2, "合计", totalLeftCellStyle);
for (int col = 3; col <= LAST_COL; col++) {
if (rows.isEmpty()) {
setNumericCell(row, col, BigDecimal.ZERO, totalStyle);
continue;
@@ -126,9 +128,9 @@ public class EmployeeOutputSummaryExcelBuilder extends AbstractProjectOutputExce
}
// Ensure total-row formulas survive even if Excel recalculation is disabled.
if (!rows.isEmpty()) {
row.getCell(10).setCellFormula(buildTotalBasicAssessmentFormula(totalExcelRowNum));
row.getCell(11).setCellFormula(buildTotalRemainingOutputFormula(totalExcelRowNum));
row.getCell(12).setCellFormula(buildTotalPerformanceFormula(totalExcelRowNum, data));
row.getCell(11).setCellFormula(buildTotalBasicAssessmentFormula(totalExcelRowNum));
row.getCell(12).setCellFormula(buildTotalRemainingOutputFormula(totalExcelRowNum));
row.getCell(13).setCellFormula(buildTotalPerformanceFormula(totalExcelRowNum, data));
}
}
@@ -137,11 +139,11 @@ public class EmployeeOutputSummaryExcelBuilder extends AbstractProjectOutputExce
if (kValue.compareTo(BigDecimal.ZERO) <= 0) {
return "0";
}
return "ROUND(J" + excelRowNum + "/" + kValue.stripTrailingZeros().toPlainString() + ",2)";
return "ROUND(K" + excelRowNum + "/" + kValue.stripTrailingZeros().toPlainString() + ",2)";
}
private String buildRemainingOutputFormula(int excelRowNum) {
return "ROUND(I" + excelRowNum + "-K" + excelRowNum + ",2)";
return "ROUND(J" + excelRowNum + "-L" + excelRowNum + ",2)";
}
private String buildPerformanceFormula(int excelRowNum, ExportData data) {
@@ -149,21 +151,21 @@ public class EmployeeOutputSummaryExcelBuilder extends AbstractProjectOutputExce
if (kValue.compareTo(BigDecimal.ZERO) <= 0) {
return "0";
}
return "ROUND(L" + excelRowNum + "*" + kValue.stripTrailingZeros().toPlainString() + ",2)";
return "ROUND(M" + excelRowNum + "*" + kValue.stripTrailingZeros().toPlainString() + ",2)";
}
private String buildTotalBasicAssessmentFormula(int excelRowNum) {
return "SUM(K" + DETAIL_START_ROW_NUM + ":K" + (excelRowNum - 1) + ")";
}
private String buildTotalRemainingOutputFormula(int excelRowNum) {
return "SUM(L" + DETAIL_START_ROW_NUM + ":L" + (excelRowNum - 1) + ")";
}
private String buildTotalPerformanceFormula(int excelRowNum, ExportData data) {
private String buildTotalRemainingOutputFormula(int excelRowNum) {
return "SUM(M" + DETAIL_START_ROW_NUM + ":M" + (excelRowNum - 1) + ")";
}
private String buildTotalPerformanceFormula(int excelRowNum, ExportData data) {
return "SUM(N" + DETAIL_START_ROW_NUM + ":N" + (excelRowNum - 1) + ")";
}
private String safeYear(ExportData data) {
return data == null || data.getYear() == null ? "" : String.valueOf(data.getYear());
}