From 2401a27fa7383f1ecd6c786bef64a47f814160ee Mon Sep 17 00:00:00 2001 From: lpd <1337706942@qq.com> Date: Tue, 26 May 2026 15:52:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=A7=E5=80=BC=E6=B1=87?= =?UTF-8?q?=E6=80=BB=E8=A1=A8=E4=B8=93=E4=B8=9A=E6=89=80=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/EmployeeOutputSummaryExcelRespVO.java | 8 ++- .../ProjectOutputReportServiceImpl.java | 25 ++++++-- .../EmployeeOutputSummaryExcelBuilder.java | 58 ++++++++++--------- 3 files changed, 55 insertions(+), 36 deletions(-) diff --git a/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/controller/admin/report/vo/EmployeeOutputSummaryExcelRespVO.java b/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/controller/admin/report/vo/EmployeeOutputSummaryExcelRespVO.java index 867888c..6919a1f 100644 --- a/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/controller/admin/report/vo/EmployeeOutputSummaryExcelRespVO.java +++ b/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/controller/admin/report/vo/EmployeeOutputSummaryExcelRespVO.java @@ -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; diff --git a/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/service/report/ProjectOutputReportServiceImpl.java b/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/service/report/ProjectOutputReportServiceImpl.java index 7a444e9..1da2bad 100644 --- a/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/service/report/ProjectOutputReportServiceImpl.java +++ b/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/service/report/ProjectOutputReportServiceImpl.java @@ -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 officeMap = getOfficeMap(employeeList); List 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 rows, String sortType) { Comparator 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 annualTotalDescComparator = Comparator + .comparing(EmployeeOutputSummaryExcelRespVO::getAnnualTotalAmount, this::compareAmount) + .reversed(); + comparator = employeeOfficeComparator() + .thenComparing(annualTotalDescComparator) .thenComparing(EmployeeOutputSummaryExcelRespVO::getEmployeeName, String.CASE_INSENSITIVE_ORDER); } rows.sort(comparator); } + private Comparator 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)); } diff --git a/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/service/report/builder/EmployeeOutputSummaryExcelBuilder.java b/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/service/report/builder/EmployeeOutputSummaryExcelBuilder.java index e329e9a..84501ca 100644 --- a/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/service/report/builder/EmployeeOutputSummaryExcelBuilder.java +++ b/lyzsys-module-tjt/src/main/java/cn/iocoder/lyzsys/module/tjt/service/report/builder/EmployeeOutputSummaryExcelBuilder.java @@ -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 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()); }