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:
2026-01-18 13:15:33 +08:00
parent eef5fa4471
commit 1f97d842a0
9 changed files with 3 additions and 52 deletions
Binary file not shown.
@@ -609,60 +609,11 @@ public class MartialScheduleServiceImpl extends ServiceImpl<MartialScheduleMappe
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveAndLockSchedule(Long competitionId) {
log.info("=== saveAndLockSchedule 开始 === competitionId: {}", competitionId);
// 1. 查询所有分组
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;
// Delegated to ScheduleArrangeService
return scheduleArrangeService.saveAndLockSchedule(competitionId);
}
/**
* 根据时间段字符串计算 timeSlotIndex
* 按照时间从早到晚分配索引: 08:30=0, 13:30=1, 其他时间按字符串顺序排序