zouyu
2026-04-20 443b6fcdf3dd0a13cb2fc33500932f68744b4989
绩效模块调整2
已添加6个文件
353 ■■■■■ 文件已修改
performance-server/src/main/java/com/ruoyi/performance/excel/PerformanceShiftAnnotationTextExcelData.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/ruoyi/performance/excel/PerformanceShiftExcelData.java 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/ruoyi/performance/excel/handler/performance/CommentWriteHandler.java 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/java/com/ruoyi/performance/excel/handler/performance/PerformanceShiftHeaderWriteHandler.java 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/resources/static/performance_shift_month_template.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
performance-server/src/main/resources/static/performance_shift_year_template.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
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;
}
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;
}
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;
    }
}
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å¹´M月");
    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 "";
        }
    }
}
performance-server/src/main/resources/static/performance_shift_month_template.xlsx
Binary files differ
performance-server/src/main/resources/static/performance_shift_year_template.xlsx
Binary files differ