Skip to content

Commit 8c7e804

Browse files
committed
适应最新的前端传递格式
1 parent d24d8f3 commit 8c7e804

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/main/java/club/boyuan/official/service/impl/InterviewAssignmentServiceImpl.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,12 @@ private List<LocalDateTime> generateTimeSlotsForSpecificDays(LocalDate day1, Loc
362362
LocalDate[] dates = {day1, day2};
363363
for (LocalDate date : dates) {
364364
// 生成上午时间段 (9:00-11:00)
365-
for (LocalTime time = MORNING_START; !time.equals(MORNING_END); time = time.plusMinutes(INTERVIEW_DURATION)) {
365+
for (LocalTime time = MORNING_START; time.isBefore(MORNING_END); time = time.plusMinutes(INTERVIEW_DURATION)) {
366366
timeSlots.add(LocalDateTime.of(date, time));
367367
}
368368

369369
// 生成下午时间段 (13:00-17:00)
370-
for (LocalTime time = AFTERNOON_START; !time.equals(AFTERNOON_END); time = time.plusMinutes(INTERVIEW_DURATION)) {
370+
for (LocalTime time = AFTERNOON_START; time.isBefore(AFTERNOON_END); time = time.plusMinutes(INTERVIEW_DURATION)) {
371371
timeSlots.add(LocalDateTime.of(date, time));
372372
}
373373
}
@@ -386,12 +386,12 @@ private List<LocalDateTime> generateTimeSlots(LocalDate startDate, LocalDate end
386386
LocalDate date = startDate.plusDays(dayOffset);
387387

388388
// 生成上午时间段 (9:00-11:00)
389-
for (LocalTime time = MORNING_START; !time.equals(MORNING_END); time = time.plusMinutes(INTERVIEW_DURATION)) {
389+
for (LocalTime time = MORNING_START; time.isBefore(MORNING_END); time = time.plusMinutes(INTERVIEW_DURATION)) {
390390
timeSlots.add(LocalDateTime.of(date, time));
391391
}
392392

393393
// 生成下午时间段 (13:00-17:00)
394-
for (LocalTime time = AFTERNOON_START; !time.equals(AFTERNOON_END); time = time.plusMinutes(INTERVIEW_DURATION)) {
394+
for (LocalTime time = AFTERNOON_START; time.isBefore(AFTERNOON_END); time = time.plusMinutes(INTERVIEW_DURATION)) {
395395
timeSlots.add(LocalDateTime.of(date, time));
396396
}
397397
}
@@ -568,8 +568,10 @@ private LocalDateTime findAnyAvailableSlot(String department,
568568
* 严格按照用户选择的具体日期和时间段进行匹配
569569
*/
570570
private boolean isSlotMatchPreference(LocalDateTime slotTime, String preferredTime) {
571+
// 处理格式如 "Day 1 上午" 或 "Day 1 下午"
571572
String[] parts = preferredTime.split(" ");
572-
if (parts.length != 3 || !"Day".equals(parts[0])) {
573+
if (parts.length < 3 || !"Day".equals(parts[0])) {
574+
logger.warn("无效的期望时间格式: {}", preferredTime);
573575
return false;
574576
}
575577

@@ -598,8 +600,11 @@ private boolean isSlotMatchPreference(LocalDateTime slotTime, String preferredTi
598600
} else if ("下午".equals(period)) {
599601
return !time.isBefore(AFTERNOON_START) && time.isBefore(AFTERNOON_END);
600602
}
603+
} else {
604+
logger.debug("时间槽 {} 与期望时间 {} 不匹配: 日期不匹配", slotTime, preferredTime);
601605
}
602606
} catch (NumberFormatException e) {
607+
logger.warn("解析期望时间失败: {}", preferredTime, e);
603608
return false;
604609
}
605610

0 commit comments

Comments
 (0)