修复预约排班规则可约判断

This commit is contained in:
2026-07-01 19:54:53 +08:00
parent 3709c86310
commit 2e41aaef70
4 changed files with 109 additions and 4 deletions
@@ -152,11 +152,11 @@ public class AppointmentCapacityServiceImpl implements AppointmentCapacityServic
startTime.toLocalTime(),
endTime.toLocalTime()
);
if (schedule != null) {
if (schedule != null && isManualScheduleOverride(schedule)) {
return resolveExplicitScheduleCapacity(schedule);
}
ArtistScheduleDO daySchedule = scheduleMapper.selectDayScheduleForUpdate(shopId, artistId, startTime.toLocalDate());
if (daySchedule != null) {
if (daySchedule != null && isManualScheduleOverride(daySchedule)) {
throw new RuntimeException(UNAVAILABLE_MESSAGE);
}
return resolveRuleCapacity(shopId, artistId, startTime, endTime);
@@ -206,4 +206,12 @@ public class AppointmentCapacityServiceImpl implements AppointmentCapacityServic
}
return !appointmentStartTime.isBefore(scheduleStartTime) && !appointmentEndTime.isAfter(scheduleEndTime);
}
private boolean isManualScheduleOverride(ArtistScheduleDO schedule) {
if (schedule == null || schedule.getRemark() == null || schedule.getRemark().isBlank()) {
return false;
}
String remark = schedule.getRemark().trim();
return !"规则生成排班".equals(remark) && !remark.startsWith("例外排班:");
}
}
@@ -380,10 +380,13 @@ public class PlanningServiceImpl implements PlanningService {
}
Map<String, ArtistScheduleExceptionDO> exceptionByArtistDate = loadArtistScheduleExceptions(shopId, artistIds, start, end);
Set<String> explicitDayKeys = explicitSchedules.stream()
.filter(this::isManualScheduleOverride)
.filter(schedule -> schedule.getArtistId() != null && schedule.getWorkDate() != null)
.map(this::scheduleKey)
.collect(Collectors.toCollection(HashSet::new));
List<ArtistScheduleDO> schedules = new ArrayList<>(explicitSchedules);
List<ArtistScheduleDO> schedules = explicitSchedules.stream()
.filter(this::isManualScheduleOverride)
.collect(Collectors.toCollection(ArrayList::new));
LocalDate cursor = start;
while (!cursor.isAfter(end)) {
for (PlanningArtistVO artist : artists) {
@@ -448,6 +451,14 @@ public class PlanningServiceImpl implements PlanningService {
return artistId + ":" + workDate;
}
private boolean isManualScheduleOverride(ArtistScheduleDO schedule) {
if (schedule == null || schedule.getRemark() == null || schedule.getRemark().isBlank()) {
return false;
}
String remark = schedule.getRemark().trim();
return !"规则生成排班".equals(remark) && !remark.startsWith("例外排班:");
}
private PlanningScheduleVO toScheduleVO(ArtistScheduleDO schedule, List<PlanningArtistVO> artists) {
Map<Long, String> artistNames = artists.stream()
.collect(Collectors.toMap(PlanningArtistVO::getId, PlanningArtistVO::getName, (a, b) -> a));
@@ -689,7 +700,7 @@ public class PlanningServiceImpl implements PlanningService {
if (schedule != null && !Integer.valueOf(1).equals(schedule.getStatus())) {
return "rest";
}
if (schedule == null || Integer.valueOf(0).equals(artist.getStatus())) {
if (schedule == null) {
return "rest";
}
if (hasContinuousFreeWindow(schedule, appointments, MONTH_AVAILABLE_MINUTES)) {