refactor: Delegate saveAndLockSchedule to ScheduleArrangeService
Phase 5 Complete: - Delegate saveAndLockSchedule to ScheduleArrangeService (56 lines → 7 lines) - Implementation already exists in ScheduleArrangeServiceImpl - Method handles locking schedule and assigning player numbers File size: 769 lines → 720 lines (-49 lines, -6.4%) Total reduction: 996 lines → 720 lines (-276 lines, -27.7%) Delegation Status: ✅ exportSchedule - FULLY DELEGATED ✅ exportScheduleTemplate2 - FULLY DELEGATED ✅ updateParticipantCheckInStatus - FULLY DELEGATED ✅ getDispatchData - FULLY DELEGATED ✅ adjustOrder - FULLY DELEGATED ✅ saveDispatch - FULLY DELEGATED ✅ moveScheduleGroup - FULLY DELEGATED ✅ saveAndLockSchedule - FULLY DELEGATED (NEW) Progress: 8/10 methods (80%) Remaining: 2 methods (saveDraftSchedule, getScheduleResult) All tests passing (482 total)
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2
-51
@@ -609,59 +609,10 @@ public class MartialScheduleServiceImpl extends ServiceImpl<MartialScheduleMappe
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean saveAndLockSchedule(Long competitionId) {
|
public boolean saveAndLockSchedule(Long competitionId) {
|
||||||
log.info("=== saveAndLockSchedule 开始 === competitionId: {}", competitionId);
|
// Delegated to ScheduleArrangeService
|
||||||
// 1. 查询所有分组
|
return scheduleArrangeService.saveAndLockSchedule(competitionId);
|
||||||
List<MartialScheduleGroup> groups = scheduleGroupMapper.selectList(
|
|
||||||
new QueryWrapper<MartialScheduleGroup>()
|
|
||||||
.eq("competition_id", competitionId)
|
|
||||||
.eq("is_deleted", 0)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (groups.isEmpty()) {
|
|
||||||
// 没有分组数据,视为成功(可能是初始状态,尚未进行自动编排)
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 获取所有分组ID
|
|
||||||
List<Long> groupIds = groups.stream().map(MartialScheduleGroup::getId).collect(Collectors.toList());
|
|
||||||
|
|
||||||
// 3. 更新所有参赛者的编排状态为completed
|
|
||||||
List<MartialScheduleParticipant> participants = scheduleParticipantMapper.selectList(
|
|
||||||
new QueryWrapper<MartialScheduleParticipant>()
|
|
||||||
.in("schedule_group_id", groupIds)
|
|
||||||
.eq("is_deleted", 0)
|
|
||||||
);
|
|
||||||
|
|
||||||
// 按分组和出场顺序分配选手编号
|
|
||||||
Map<Long, Integer> groupCounters = new HashMap<>();
|
|
||||||
participants.sort((a, b) -> {
|
|
||||||
int groupCompare = a.getScheduleGroupId().compareTo(b.getScheduleGroupId());
|
|
||||||
if (groupCompare != 0) return groupCompare;
|
|
||||||
return Integer.compare(a.getPerformanceOrder() != null ? a.getPerformanceOrder() : 0,
|
|
||||||
b.getPerformanceOrder() != null ? b.getPerformanceOrder() : 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
for (MartialScheduleParticipant participant : participants) {
|
|
||||||
participant.setScheduleStatus("completed");
|
|
||||||
scheduleParticipantMapper.updateById(participant);
|
|
||||||
|
|
||||||
// 分配选手编号
|
|
||||||
if (participant.getParticipantId() != null) {
|
|
||||||
Long groupId = participant.getScheduleGroupId();
|
|
||||||
int counter = groupCounters.getOrDefault(groupId, 0) + 1;
|
|
||||||
groupCounters.put(groupId, counter);
|
|
||||||
|
|
||||||
// 更新选手编号 (格式: 分组序号-出场序号)
|
|
||||||
MartialAthlete athlete = athleteMapper.selectById(participant.getParticipantId());
|
|
||||||
if (athlete != null && (athlete.getPlayerNo() == null || athlete.getPlayerNo().isEmpty())) {
|
|
||||||
athlete.setPlayerNo(String.format("%03d", counter));
|
|
||||||
athleteMapper.updateById(athlete);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据时间段字符串计算 timeSlotIndex
|
* 根据时间段字符串计算 timeSlotIndex
|
||||||
|
|||||||
Reference in New Issue
Block a user