From 443b6fcdf3dd0a13cb2fc33500932f68744b4989 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期一, 20 四月 2026 16:35:18 +0800
Subject: [PATCH] 绩效模块调整2

---
 performance-server/src/main/resources/static/performance_shift_month_template.xlsx                                       |    0 
 performance-server/src/main/java/com/ruoyi/performance/excel/PerformanceShiftAnnotationTextExcelData.java                |   34 +++++
 performance-server/src/main/java/com/ruoyi/performance/excel/PerformanceShiftExcelData.java                              |  107 +++++++++++++++++
 performance-server/src/main/resources/static/performance_shift_year_template.xlsx                                        |    0 
 performance-server/src/main/java/com/ruoyi/performance/excel/handler/performance/PerformanceShiftHeaderWriteHandler.java |  105 +++++++++++++++++
 performance-server/src/main/java/com/ruoyi/performance/excel/handler/performance/CommentWriteHandler.java                |  107 +++++++++++++++++
 6 files changed, 353 insertions(+), 0 deletions(-)

diff --git a/performance-server/src/main/java/com/ruoyi/performance/excel/PerformanceShiftAnnotationTextExcelData.java b/performance-server/src/main/java/com/ruoyi/performance/excel/PerformanceShiftAnnotationTextExcelData.java
new file mode 100644
index 0000000..e2addf4
--- /dev/null
+++ b/performance-server/src/main/java/com/ruoyi/performance/excel/PerformanceShiftAnnotationTextExcelData.java
@@ -0,0 +1,34 @@
+package com.ruoyi.performance.excel;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 鐝瀵煎嚭锛屾壒娉ㄤ笅鏍囧璞�
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class PerformanceShiftAnnotationTextExcelData {
+
+    /**
+     * 鍒椾笅鏍�
+     */
+    @ApiModelProperty("鍒椾笅鏍�")
+    private int rowIndex;
+
+    /**
+     * 鍒椾笅鏍�
+     */
+    @ApiModelProperty("鍒椾笅鏍�")
+    private int cellIndex;
+
+    /**
+     * 鎵规敞鏂囨湰
+     */
+    @ApiModelProperty("鎵规敞鏂囨湰")
+    private String annotationText;
+
+}
diff --git a/performance-server/src/main/java/com/ruoyi/performance/excel/PerformanceShiftExcelData.java b/performance-server/src/main/java/com/ruoyi/performance/excel/PerformanceShiftExcelData.java
new file mode 100644
index 0000000..82468cd
--- /dev/null
+++ b/performance-server/src/main/java/com/ruoyi/performance/excel/PerformanceShiftExcelData.java
@@ -0,0 +1,107 @@
+package com.ruoyi.performance.excel;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class PerformanceShiftExcelData {
+
+    /**
+     * 瀵煎嚭搴忓彿
+     */
+    @ApiModelProperty("瀵煎嚭搴忓彿")
+    private Integer excelIndex;
+
+    /**
+     * 濮撳悕
+     */
+    @ApiModelProperty("濮撳悕")
+    private String personName;
+
+    /**
+     * 鐝鍒楄〃
+     */
+    @ApiModelProperty("鐝鍒楄〃")
+    private List<String> shiftNameList;
+
+    /**
+     * 鏃╃彮澶╂暟
+     */
+    @ApiModelProperty("鏃╃彮澶╂暟")
+    private Integer morningShiftCount;
+
+    /**
+     * 涓彮澶╂暟
+     */
+    @ApiModelProperty("涓彮澶╂暟")
+    private Integer dayShiftCount;
+
+    /**
+     * 澶滅彮澶╂暟
+     */
+    @ApiModelProperty("澶滅彮澶╂暟")
+    private Integer nightShiftCount;
+
+    /**
+     * 浼戞伅澶╂暟
+     */
+    @ApiModelProperty("浼戞伅澶╂暟")
+    private Integer holidayLeaveCount;
+
+    /**
+     * 鍏樊澶╂暟
+     */
+    @ApiModelProperty("鍏樊澶╂暟")
+    private Integer officialTripCount;
+
+    /**
+     * 浜嬪亣澶╂暟
+     */
+    @ApiModelProperty("浜嬪亣澶╂暟")
+    private Integer personalLeaveCount;
+
+    /**
+     * 鐥呭亣澶╂暟
+     */
+    @ApiModelProperty("鐥呭亣澶╂暟")
+    private Integer sickLeaveCount;
+
+    /**
+     * 骞村亣澶╂暟
+     */
+    @ApiModelProperty("骞村亣澶╂暟")
+    private Integer annualLeaveCount;
+
+    /**
+     * 濠氬亣澶╂暟
+     */
+    @ApiModelProperty("濠氬亣澶╂暟")
+    private Integer marriageLeaveCount;
+
+    /**
+     * 浜у亣澶╂暟
+     */
+    @ApiModelProperty("浜у亣澶╂暟")
+    private Integer maternityLeaveCount;
+
+    /**
+     * 涓у亣澶╂暟
+     */
+    @ApiModelProperty("涓у亣澶╂暟")
+    private Integer bereavementLeaveCount;
+
+    /**
+     * 鍑哄嫟鎬诲ぉ鏁�
+     */
+    @ApiModelProperty("鍑哄嫟鎬诲ぉ鏁�")
+    private Integer totalCount;
+
+    /**
+     * 鍑哄嫟鎬绘椂闂�
+     */
+    @ApiModelProperty("鍑哄嫟鎬绘椂闂�")
+    private Double totalWorkHourCount;
+
+}
diff --git a/performance-server/src/main/java/com/ruoyi/performance/excel/handler/performance/CommentWriteHandler.java b/performance-server/src/main/java/com/ruoyi/performance/excel/handler/performance/CommentWriteHandler.java
new file mode 100644
index 0000000..6a4f54f
--- /dev/null
+++ b/performance-server/src/main/java/com/ruoyi/performance/excel/handler/performance/CommentWriteHandler.java
@@ -0,0 +1,107 @@
+package com.ruoyi.performance.excel.handler.performance;
+
+import com.alibaba.excel.util.BooleanUtils;
+import com.alibaba.excel.write.handler.RowWriteHandler;
+import com.alibaba.excel.write.handler.context.RowWriteHandlerContext;
+import com.ruoyi.performance.excel.PerformanceShiftAnnotationTextExcelData;
+import com.ruoyi.performance.excel.PerformanceShiftExcelData;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 鐝瀵煎嚭鍐欏叆澶勭悊鍣�
+ * 1. 琛ラ綈妯℃澘涓笉瀛樺湪鐨勭彮娆℃槑缁嗗崟鍏冩牸
+ * 2. 鍦ㄥ搴斿崟鍏冩牸涓婂啓鍏ユ壒娉�
+ */
+public class CommentWriteHandler implements RowWriteHandler {
+
+    /**
+     * 妯℃澘鏁版嵁璧峰琛屼负绗� 5 琛�
+     */
+    private static final int DATA_START_ROW_INDEX = 4;
+
+    /**
+     * 妯℃澘鐝璧峰鍒椾负 C 鍒�
+     */
+    private static final int DATA_START_COLUMN_INDEX = 2;
+
+    private final List<PerformanceShiftExcelData> excelDataList;
+
+    private final Map<String, String> annotationTextMap = new HashMap<>();
+
+    public CommentWriteHandler(List<PerformanceShiftExcelData> excelDataList,
+            List<PerformanceShiftAnnotationTextExcelData> annotationTextList) {
+        this.excelDataList = excelDataList == null ? Collections.emptyList() : excelDataList;
+        if (annotationTextList == null) {
+            return;
+        }
+        annotationTextList.stream()
+                .filter(item -> item != null && StringUtils.isNotBlank(item.getAnnotationText()))
+                .forEach(item -> annotationTextMap.put(buildKey(item.getRowIndex(), item.getCellIndex()),
+                        item.getAnnotationText()));
+    }
+
+    @Override
+    public void afterRowDispose(RowWriteHandlerContext context) {
+        if (BooleanUtils.isTrue(context.getHead())) {
+            return;
+        }
+        Row row = context.getRow();
+        if (row == null || row.getRowNum() < DATA_START_ROW_INDEX) {
+            return;
+        }
+        int dataIndex = row.getRowNum() - DATA_START_ROW_INDEX;
+        if (dataIndex < 0 || dataIndex >= excelDataList.size()) {
+            return;
+        }
+        PerformanceShiftExcelData excelData = excelDataList.get(dataIndex);
+        if (excelData == null || excelData.getShiftNameList() == null) {
+            return;
+        }
+
+        Sheet sheet = row.getSheet();
+        CellStyle cellStyle = sheet.getColumnStyle(DATA_START_COLUMN_INDEX);
+        Drawing<?> drawingPatriarch = null;
+        List<String> shiftList = excelData.getShiftNameList();
+        for (int i = 0; i < shiftList.size(); i++) {
+            int cellIndex = DATA_START_COLUMN_INDEX + i;
+            Cell cell = row.getCell(cellIndex);
+            if (cell == null) {
+                cell = row.createCell(cellIndex);
+            }
+            if (cellStyle != null) {
+                cell.setCellStyle(cellStyle);
+            }
+            String cellValue = shiftList.get(i);
+            if (StringUtils.isNotBlank(cellValue)) {
+                cell.setCellValue(cellValue);
+            }
+
+            String annotationText = annotationTextMap.get(buildKey(dataIndex, i));
+            if (StringUtils.isBlank(annotationText) || cell.getCellComment() != null) {
+                continue;
+            }
+            if (drawingPatriarch == null) {
+                drawingPatriarch = sheet.createDrawingPatriarch();
+            }
+            Comment comment = drawingPatriarch.createCellComment(new XSSFClientAnchor(
+                    0, 0, 0, 0,
+                    cellIndex, row.getRowNum(),
+                    cellIndex + 2, row.getRowNum() + 3));
+            comment.setString(new XSSFRichTextString(annotationText));
+            comment.setAuthor("NS-LIMS");
+            cell.setCellComment(comment);
+        }
+    }
+
+    private String buildKey(int rowIndex, int cellIndex) {
+        return rowIndex + "_" + cellIndex;
+    }
+}
diff --git a/performance-server/src/main/java/com/ruoyi/performance/excel/handler/performance/PerformanceShiftHeaderWriteHandler.java b/performance-server/src/main/java/com/ruoyi/performance/excel/handler/performance/PerformanceShiftHeaderWriteHandler.java
new file mode 100644
index 0000000..edbd446
--- /dev/null
+++ b/performance-server/src/main/java/com/ruoyi/performance/excel/handler/performance/PerformanceShiftHeaderWriteHandler.java
@@ -0,0 +1,105 @@
+package com.ruoyi.performance.excel.handler.performance;
+
+import com.alibaba.excel.write.handler.SheetWriteHandler;
+import com.alibaba.excel.write.handler.context.SheetWriteHandlerContext;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 鐝瀵煎嚭鍔ㄦ�佽〃澶村鐞嗗櫒
+ */
+public class PerformanceShiftHeaderWriteHandler implements SheetWriteHandler {
+
+    private static final int TITLE_ROW_INDEX = 1;
+
+    private static final int WEEK_ROW_INDEX = 2;
+
+    private static final int DAY_ROW_INDEX = 3;
+
+    private static final int START_COLUMN_INDEX = 2;
+
+    private static final int MAX_DATE_COLUMN_COUNT = 31;
+
+    private static final DateTimeFormatter TITLE_FORMATTER = DateTimeFormatter.ofPattern("yyyy骞碝鏈�");
+
+    private final List<LocalDate> attendanceDateList;
+
+    public PerformanceShiftHeaderWriteHandler(List<LocalDate> attendanceDateList) {
+        this.attendanceDateList = attendanceDateList == null ? Collections.emptyList() : attendanceDateList;
+    }
+
+    @Override
+    public void afterSheetCreate(SheetWriteHandlerContext context) {
+        Sheet sheet = context.getWriteSheetHolder().getSheet();
+        if (sheet == null || attendanceDateList.isEmpty()) {
+            return;
+        }
+
+        Row titleRow = sheet.getRow(TITLE_ROW_INDEX);
+        if (titleRow != null) {
+            Cell titleCell = titleRow.getCell(0);
+            if (titleCell != null) {
+                titleCell.setCellValue(attendanceDateList.get(attendanceDateList.size() - 1).format(TITLE_FORMATTER));
+            }
+        }
+
+        Row weekRow = sheet.getRow(WEEK_ROW_INDEX);
+        Row dayRow = sheet.getRow(DAY_ROW_INDEX);
+        if (weekRow == null || dayRow == null) {
+            return;
+        }
+
+        for (int i = 0; i < MAX_DATE_COLUMN_COUNT; i++) {
+            Cell weekCell = getOrCreateCell(weekRow, START_COLUMN_INDEX + i);
+            Cell dayCell = getOrCreateCell(dayRow, START_COLUMN_INDEX + i);
+            if (i < attendanceDateList.size()) {
+                LocalDate currentDate = attendanceDateList.get(i);
+                weekCell.setCellValue(resolveWeekOfYear(currentDate));
+                dayCell.setCellValue(currentDate.getDayOfMonth());
+            } else {
+                weekCell.setBlank();
+                dayCell.setBlank();
+            }
+        }
+    }
+
+    private Cell getOrCreateCell(Row row, int cellIndex) {
+        Cell cell = row.getCell(cellIndex);
+        if (cell != null) {
+            return cell;
+        }
+        Cell templateCell = row.getCell(START_COLUMN_INDEX);
+        cell = row.createCell(cellIndex);
+        if (templateCell != null && templateCell.getCellStyle() != null) {
+            cell.setCellStyle(templateCell.getCellStyle());
+        }
+        return cell;
+    }
+
+    private String resolveWeekOfYear(LocalDate date) {
+        switch (date.getDayOfWeek()) {
+            case MONDAY:
+                return "涓�";
+            case TUESDAY:
+                return "浜�";
+            case WEDNESDAY:
+                return "涓�";
+            case THURSDAY:
+                return "鍥�";
+            case FRIDAY:
+                return "浜�";
+            case SATURDAY:
+                return "鍏�";
+            case SUNDAY:
+                return "鏃�";
+            default:
+                return "";
+        }
+    }
+}
diff --git a/performance-server/src/main/resources/static/performance_shift_month_template.xlsx b/performance-server/src/main/resources/static/performance_shift_month_template.xlsx
new file mode 100644
index 0000000..35677e2
--- /dev/null
+++ b/performance-server/src/main/resources/static/performance_shift_month_template.xlsx
Binary files differ
diff --git a/performance-server/src/main/resources/static/performance_shift_year_template.xlsx b/performance-server/src/main/resources/static/performance_shift_year_template.xlsx
new file mode 100644
index 0000000..2499d38
--- /dev/null
+++ b/performance-server/src/main/resources/static/performance_shift_year_template.xlsx
Binary files differ

--
Gitblit v1.9.3