|
@@ -191,8 +191,10 @@ public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, Attenda
|
|
|
// 2. 获取自定义休息日列表
|
|
|
List<LocalDate> customHolidays = getCustomHolidays(yearMonth);
|
|
|
|
|
|
- // 2.1 获取自定义休息日列表
|
|
|
+ // 2.1 获取自定义工作日列表
|
|
|
List<LocalDate> workdays = getWorkDays(yearMonth);
|
|
|
+ // 2.2 获取自定义工作日列表
|
|
|
+ List<LocalDate> freeDays = getFreeDays(yearMonth);
|
|
|
|
|
|
// 3. 生成该月所有日期的信息
|
|
|
List<DayInfo> calendar = new ArrayList<>();
|
|
@@ -204,17 +206,18 @@ public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, Attenda
|
|
|
dayInfo.setDate(date.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
|
|
dayInfo.setDayOfWeek(date.getDayOfWeek().getValue()); // 1-7 (Monday-Sunday)
|
|
|
|
|
|
+ dayInfo.setType(2);//工作日
|
|
|
// 判断是否为休息日(周末或自定义假日)
|
|
|
if (date.getDayOfWeek() == DayOfWeek.SATURDAY
|
|
|
|| date.getDayOfWeek() == DayOfWeek.SUNDAY
|
|
|
|| customHolidays.contains(date)) {
|
|
|
dayInfo.setType(0); // 休息日
|
|
|
- }else {
|
|
|
- dayInfo.setType(1);//工作日
|
|
|
}
|
|
|
-
|
|
|
+ if (freeDays.contains(date)) {
|
|
|
+ dayInfo.setType(1);//调休
|
|
|
+ }
|
|
|
if (workdays.contains(date)){
|
|
|
- dayInfo.setType(1);//工作日
|
|
|
+ dayInfo.setType(2);//工作日
|
|
|
}
|
|
|
|
|
|
calendar.add(dayInfo);
|
|
@@ -258,20 +261,9 @@ public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, Attenda
|
|
|
return workDays;
|
|
|
}
|
|
|
|
|
|
- // 辅助方法:获取自定义休息日列表(示例)
|
|
|
- private List<LocalDate> getCustomHolidays(YearMonth yearMonth) {
|
|
|
+ private List<LocalDate> getFreeDays(YearMonth yearMonth) {
|
|
|
List<LocalDate> holidays = new ArrayList<>();
|
|
|
-
|
|
|
- // 2025年中国法定节假日列表
|
|
|
- String[] holidayDates = {
|
|
|
- "2025-01-01", // 元旦
|
|
|
- "2025-01-28", "2025-01-29", "2025-01-30", "2025-01-31", "2025-02-03", "2025-02-04", // 春节
|
|
|
- "2025-04-04", // 清明节
|
|
|
- "2025-05-01", "2025-05-02", "2025-05-05", // 劳动节
|
|
|
- "2025-06-02", // 端午节
|
|
|
- "2025-10-01", "2025-10-02", "2025-10-03", "2025-10-06", "2025-10-07", "2025-10-08" // 国庆节
|
|
|
- };
|
|
|
- List<String> collect2 = Arrays.stream(holidayDates).collect(Collectors.toList());
|
|
|
+ List<String> collect2 = new ArrayList<>();
|
|
|
|
|
|
LocalDate endOfMonth = yearMonth.atEndOfMonth();
|
|
|
LocalDate startOfMonth = yearMonth.atDay(1);
|
|
@@ -296,4 +288,29 @@ public class AttendanceServiceImpl extends ServiceImpl<AttendanceMapper, Attenda
|
|
|
}
|
|
|
return holidays;
|
|
|
}
|
|
|
+
|
|
|
+ // 辅助方法:获取自定义休息日列表(示例)
|
|
|
+ private List<LocalDate> getCustomHolidays(YearMonth yearMonth) {
|
|
|
+ List<LocalDate> holidays = new ArrayList<>();
|
|
|
+
|
|
|
+ // 2025年中国法定节假日列表
|
|
|
+ String[] holidayDates = {
|
|
|
+ "2025-01-01", // 元旦
|
|
|
+ "2025-01-28", "2025-01-29", "2025-01-30", "2025-01-31", "2025-02-03", "2025-02-04", // 春节
|
|
|
+ "2025-04-04", // 清明节
|
|
|
+ "2025-05-01", "2025-05-02", "2025-05-05", // 劳动节
|
|
|
+ "2025-06-02", // 端午节
|
|
|
+ "2025-10-01", "2025-10-02", "2025-10-03", "2025-10-06", "2025-10-07", "2025-10-08" // 国庆节
|
|
|
+ };
|
|
|
+ // 将字符串日期转换为LocalDate并添加到列表中
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
|
|
+ for (String dateStr : holidayDates) {
|
|
|
+ LocalDate holiday = LocalDate.parse(dateStr, formatter);
|
|
|
+ if (holiday.getYear() == yearMonth.getYear() &&
|
|
|
+ holiday.getMonth() == yearMonth.getMonth()) {
|
|
|
+ holidays.add(holiday);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return holidays;
|
|
|
+ }
|
|
|
}
|