diff --git a/minio_data/.minio.sys/buckets/.bloomcycle.bin/xl.meta b/minio_data/.minio.sys/buckets/.bloomcycle.bin/xl.meta index eb4341d..1d18627 100644 Binary files a/minio_data/.minio.sys/buckets/.bloomcycle.bin/xl.meta and b/minio_data/.minio.sys/buckets/.bloomcycle.bin/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/.usage-cache.bin.bkp/xl.meta b/minio_data/.minio.sys/buckets/.usage-cache.bin.bkp/xl.meta index 56a7627..de9fb94 100644 Binary files a/minio_data/.minio.sys/buckets/.usage-cache.bin.bkp/xl.meta and b/minio_data/.minio.sys/buckets/.usage-cache.bin.bkp/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/.usage-cache.bin/xl.meta b/minio_data/.minio.sys/buckets/.usage-cache.bin/xl.meta index 43e5dbf..f158d42 100644 Binary files a/minio_data/.minio.sys/buckets/.usage-cache.bin/xl.meta and b/minio_data/.minio.sys/buckets/.usage-cache.bin/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/.usage.json/xl.meta b/minio_data/.minio.sys/buckets/.usage.json/xl.meta index efc0698..0883c76 100644 Binary files a/minio_data/.minio.sys/buckets/.usage.json/xl.meta and b/minio_data/.minio.sys/buckets/.usage.json/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin.bkp/xl.meta b/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin.bkp/xl.meta index 18e091a..f749a1c 100644 Binary files a/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin.bkp/xl.meta and b/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin.bkp/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin/xl.meta b/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin/xl.meta index 0c049ae..c2d65f3 100644 Binary files a/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin/xl.meta and b/minio_data/.minio.sys/buckets/000000-assets/.usage-cache.bin/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/assets/.usage-cache.bin.bkp/xl.meta b/minio_data/.minio.sys/buckets/assets/.usage-cache.bin.bkp/xl.meta index 5bf6433..e485b1b 100644 Binary files a/minio_data/.minio.sys/buckets/assets/.usage-cache.bin.bkp/xl.meta and b/minio_data/.minio.sys/buckets/assets/.usage-cache.bin.bkp/xl.meta differ diff --git a/minio_data/.minio.sys/buckets/assets/.usage-cache.bin/xl.meta b/minio_data/.minio.sys/buckets/assets/.usage-cache.bin/xl.meta index e054dca..37c6668 100644 Binary files a/minio_data/.minio.sys/buckets/assets/.usage-cache.bin/xl.meta and b/minio_data/.minio.sys/buckets/assets/.usage-cache.bin/xl.meta differ diff --git a/src/main/java/org/springblade/modules/martial/service/IScheduleDispatchService.java b/src/main/java/org/springblade/modules/martial/service/IScheduleDispatchService.java index 4dbf925..bdba769 100644 --- a/src/main/java/org/springblade/modules/martial/service/IScheduleDispatchService.java +++ b/src/main/java/org/springblade/modules/martial/service/IScheduleDispatchService.java @@ -1,6 +1,7 @@ package org.springblade.modules.martial.service; import org.springblade.modules.martial.pojo.dto.AdjustOrderDTO; +import org.springblade.modules.martial.pojo.dto.MoveScheduleGroupDTO; import org.springblade.modules.martial.pojo.dto.SaveDispatchDTO; import org.springblade.modules.martial.pojo.vo.DispatchDataVO; @@ -35,4 +36,12 @@ public interface IScheduleDispatchService { * @return Success flag */ boolean saveDispatch(SaveDispatchDTO dto); + + /** + * Move schedule group to different venue and time slot + * + * @param dto Move schedule group data + * @return Success flag + */ + boolean moveScheduleGroup(MoveScheduleGroupDTO dto); } diff --git a/src/main/java/org/springblade/modules/martial/service/impl/MartialScheduleServiceImpl.java b/src/main/java/org/springblade/modules/martial/service/impl/MartialScheduleServiceImpl.java index aabfc03..42f67b4 100644 --- a/src/main/java/org/springblade/modules/martial/service/impl/MartialScheduleServiceImpl.java +++ b/src/main/java/org/springblade/modules/martial/service/impl/MartialScheduleServiceImpl.java @@ -706,65 +706,11 @@ public class MartialScheduleServiceImpl extends ServiceImpl details = scheduleDetailMapper.selectList( - new QueryWrapper() - .eq("schedule_group_id", dto.getGroupId()) - .eq("is_deleted", 0) - ); - - if (details.isEmpty()) { - throw new RuntimeException("分组详情不存在"); - } - - // 3. 查询目标场地信息 - MartialVenue targetVenue = venueService.getById(dto.getTargetVenueId()); - if (targetVenue == null) { - throw new RuntimeException("目标场地不存在"); - } - - // 4. 根据时间段索引计算日期和时间 - // 假设: 0=第1天上午, 1=第1天下午, 2=第2天上午, 3=第2天下午... - // 需要从赛事信息中获取起始日期 - int dayOffset = dto.getTargetTimeSlotIndex() / 2; // 每天2个时段 - boolean isAfternoon = dto.getTargetTimeSlotIndex() % 2 == 1; - String timeSlot = isAfternoon ? "13:30" : "08:30"; - - // 获取赛事起始日期(从第一个detail中获取) - LocalDate baseDate = details.get(0).getScheduleDate(); - if (baseDate == null) { - throw new RuntimeException("无法确定赛事起始日期"); - } - - // 计算目标日期(从起始日期开始,加上dayOffset天的偏移) - // 如果当前detail的日期早于base date,需要调整 - LocalDate minDate = details.stream() - .map(MartialScheduleDetail::getScheduleDate) - .filter(Objects::nonNull) - .min(LocalDate::compareTo) - .orElse(baseDate); - - LocalDate targetDate = minDate.plusDays(dayOffset); - - // 5. 更新所有detail记录 - for (MartialScheduleDetail detail : details) { - detail.setVenueId(dto.getTargetVenueId()); - detail.setVenueName(targetVenue.getVenueName()); - detail.setScheduleDate(targetDate); - detail.setTimeSlot(timeSlot); - detail.setTimeSlotIndex(dto.getTargetTimeSlotIndex()); - scheduleDetailMapper.updateById(detail); - } - - return true; + // Delegated to ScheduleDispatchService + return scheduleDispatchService.moveScheduleGroup(dto); } + @Override public org.springblade.modules.martial.pojo.vo.DispatchDataVO getDispatchData(Long competitionId, Long venueId, Integer timeSlotIndex) { // Delegated to ScheduleDispatchService diff --git a/src/main/java/org/springblade/modules/martial/service/impl/ScheduleDispatchServiceImpl.java b/src/main/java/org/springblade/modules/martial/service/impl/ScheduleDispatchServiceImpl.java index 8b0cf16..9c50668 100644 --- a/src/main/java/org/springblade/modules/martial/service/impl/ScheduleDispatchServiceImpl.java +++ b/src/main/java/org/springblade/modules/martial/service/impl/ScheduleDispatchServiceImpl.java @@ -7,15 +7,19 @@ import org.springblade.modules.martial.mapper.*; import org.springblade.modules.martial.pojo.entity.MartialScheduleDetail; import org.springblade.modules.martial.pojo.entity.MartialScheduleGroup; import org.springblade.modules.martial.pojo.entity.MartialScheduleParticipant; +import org.springblade.modules.martial.pojo.entity.MartialVenue; import org.springblade.modules.martial.pojo.dto.*; import org.springblade.modules.martial.pojo.vo.*; import org.springblade.modules.martial.service.IScheduleDispatchService; +import org.springblade.modules.martial.service.IMartialVenueService; import org.springframework.stereotype.Service; import org.springframework.cache.annotation.CacheEvict; import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; +import java.time.LocalDate; +import java.util.Objects; @Slf4j @Service @@ -25,6 +29,7 @@ public class ScheduleDispatchServiceImpl implements IScheduleDispatchService { private final MartialScheduleGroupMapper scheduleGroupMapper; private final MartialScheduleParticipantMapper scheduleParticipantMapper; private final MartialScheduleDetailMapper scheduleDetailMapper; + private final IMartialVenueService venueService; @Override public org.springblade.modules.martial.pojo.vo.DispatchDataVO getDispatchData(Long competitionId, Long venueId, Integer timeSlotIndex) { @@ -181,4 +186,65 @@ public class ScheduleDispatchServiceImpl implements IScheduleDispatchService { return true; } + @Override + @CacheEvict(value = "scheduleResult", allEntries = true) + @Transactional(rollbackFor = Exception.class) + public boolean moveScheduleGroup(MoveScheduleGroupDTO dto) { + // 1. Query group information + MartialScheduleGroup group = scheduleGroupMapper.selectById(dto.getGroupId()); + if (group == null) { + throw new RuntimeException("分组不存在"); + } + + // 2. Query detail records for this group + List details = scheduleDetailMapper.selectList( + new QueryWrapper() + .eq("schedule_group_id", dto.getGroupId()) + .eq("is_deleted", 0) + ); + + if (details.isEmpty()) { + throw new RuntimeException("分组详情不存在"); + } + + // 3. Query target venue information + MartialVenue targetVenue = venueService.getById(dto.getTargetVenueId()); + if (targetVenue == null) { + throw new RuntimeException("目标场地不存在"); + } + + // 4. Calculate date and time based on time slot index + // Assumption: 0=Day1 AM, 1=Day1 PM, 2=Day2 AM, 3=Day2 PM... + int dayOffset = dto.getTargetTimeSlotIndex() / 2; // 2 slots per day + boolean isAfternoon = dto.getTargetTimeSlotIndex() % 2 == 1; + String timeSlot = isAfternoon ? "13:30" : "08:30"; + + // Get base date from first detail + LocalDate baseDate = details.get(0).getScheduleDate(); + if (baseDate == null) { + throw new RuntimeException("无法确定赛事起始日期"); + } + + // Calculate target date + LocalDate minDate = details.stream() + .map(MartialScheduleDetail::getScheduleDate) + .filter(Objects::nonNull) + .min(LocalDate::compareTo) + .orElse(baseDate); + + LocalDate targetDate = minDate.plusDays(dayOffset); + + // 5. Update all detail records + for (MartialScheduleDetail detail : details) { + detail.setVenueId(dto.getTargetVenueId()); + detail.setVenueName(targetVenue.getVenueName()); + detail.setScheduleDate(targetDate); + detail.setTimeSlot(timeSlot); + detail.setTimeSlotIndex(dto.getTargetTimeSlotIndex()); + scheduleDetailMapper.updateById(detail); + } + + return true; + } + }