zouyu
2026-05-07 25ca0715b47090fc79527910cbb4cf7ea9b3e1f2
performance-server/src/main/java/com/ruoyi/performance/service/impl/StaffAttendanceTrackingRecordServiceImpl.java
@@ -50,10 +50,7 @@
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
@@ -412,10 +409,37 @@
        return this.saveOrUpdateBatch(records);
    }
    /**
     * 根据导出日期格式化导出时间范围
     * @param staffAttendanceDTO
     */
    private static void formatExportDateRange(StaffAttendanceDTO staffAttendanceDTO){
        if(StringUtils.isNoneBlank(staffAttendanceDTO.getReportDate())){
            LocalTime startTime = LocalTime.of(0,0,0);
            LocalTime endTime = LocalTime.of(23,59,59);
            YearMonth yearMonth;
            if(StringUtils.equals(staffAttendanceDTO.getAttendanceReportType(),CalendarType.MONTH.name())){
                yearMonth = YearMonth.parse(staffAttendanceDTO.getReportDate(),DateTimeFormatter.ofPattern("yyyy-MM"));
                LocalDateTime startDateTime = LocalDateTime.of(yearMonth.minusMonths(1L).atDay(26),startTime);
                LocalDateTime endDateTime = LocalDateTime.of(yearMonth.atDay(25),endTime);
                staffAttendanceDTO.setStartDate(startDateTime);
                staffAttendanceDTO.setEndDate(endDateTime);
            }else if(StringUtils.equals(staffAttendanceDTO.getAttendanceReportType(),CalendarType.YEAR.name())){
                Year year = Year.parse(staffAttendanceDTO.getReportDate(),DateTimeFormatter.ofPattern("yyyy"));
                yearMonth = year.atMonth(1);
                LocalDateTime startDateTime = LocalDateTime.of(yearMonth.minusMonths(1L).atDay(26),startTime);
                LocalDateTime endDateTime = LocalDateTime.of(yearMonth.withMonth(12).atDay(25),endTime);
                staffAttendanceDTO.setStartDate(startDateTime);
                staffAttendanceDTO.setEndDate(endDateTime);
            }
        }
    }
    @Override
    public void exportStaffAttendanceRecords(HttpServletResponse response, StaffAttendanceDTO staffAttendanceDTO) {
        response.reset();
        try{
            formatExportDateRange(staffAttendanceDTO);
            //查询人员架构
            List<User> userList = userMapper.selectUserListByPerformance(false);
            List<Integer> userIdList = userList.stream().map(User::getId).collect(Collectors.toList());
@@ -423,6 +447,7 @@
            //批注信息坐标信息
            List<StaffAttendanceAnnotationTextExcelData> annotationTextList = new ArrayList<>();
            // 查询班次
            List<PerformanceShiftMapDto> performanceShifts = performanceShiftMapper.selectListByWorkTime(
                    staffAttendanceDTO.getStartDate(), staffAttendanceDTO.getEndDate(), staffAttendanceDTO.getKeyword());
            //获取考勤数据