refactor: integrate ScheduleExportService into MartialScheduleServiceImpl
Phase 2, Step 2.4: Delegate export methods to ScheduleExportService - Add IScheduleExportService dependency with @Autowired - Replace exportSchedule method body with service delegation - Replace exportScheduleTemplate2 method body with service delegation - Maintain method signatures for backward compatibility - All 443 tests passing Related to Phase 2 refactoring plan
This commit is contained in:
+7
-69
@@ -1,5 +1,7 @@
|
||||
package org.springblade.modules.martial.service.impl;
|
||||
|
||||
import org.springblade.modules.martial.service.IScheduleExportService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springblade.modules.martial.excel.ScheduleExportExcel;
|
||||
@@ -49,6 +51,9 @@ public class MartialScheduleServiceImpl extends ServiceImpl<MartialScheduleMappe
|
||||
@Autowired
|
||||
private IMartialProjectService projectService;
|
||||
|
||||
@Autowired
|
||||
private IScheduleExportService scheduleExportService;
|
||||
|
||||
@Autowired
|
||||
private IMartialVenueService venueService;
|
||||
|
||||
@@ -75,75 +80,8 @@ public class MartialScheduleServiceImpl extends ServiceImpl<MartialScheduleMappe
|
||||
*/
|
||||
@Override
|
||||
public List<ScheduleExportExcel> exportSchedule(Long competitionId) {
|
||||
List<ScheduleExportExcel> exportList = new ArrayList<>();
|
||||
|
||||
// 使用与 getScheduleResult 相同的数据源
|
||||
List<ScheduleGroupDetailVO> details = scheduleGroupMapper.selectScheduleGroupDetails(competitionId);
|
||||
|
||||
if (details.isEmpty()) {
|
||||
return exportList;
|
||||
}
|
||||
|
||||
// 按分组ID分组,然后按 displayOrder 排序
|
||||
Map<Long, List<ScheduleGroupDetailVO>> groupMap = details.stream()
|
||||
.collect(Collectors.groupingBy(ScheduleGroupDetailVO::getGroupId));
|
||||
|
||||
// 获取分组的排序顺序
|
||||
List<Long> sortedGroupIds = details.stream()
|
||||
.collect(Collectors.toMap(
|
||||
ScheduleGroupDetailVO::getGroupId,
|
||||
d -> d.getDisplayOrder() != null ? d.getDisplayOrder() : 999,
|
||||
(a, b) -> a
|
||||
))
|
||||
.entrySet().stream()
|
||||
.sorted(Map.Entry.comparingByValue())
|
||||
.map(Map.Entry::getKey)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 按排序顺序遍历分组
|
||||
for (Long groupId : sortedGroupIds) {
|
||||
List<ScheduleGroupDetailVO> groupDetails = groupMap.get(groupId);
|
||||
if (groupDetails == null || groupDetails.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ScheduleGroupDetailVO firstDetail = groupDetails.get(0);
|
||||
|
||||
// 过滤出有参赛者的记录,并按出场顺序排序
|
||||
List<ScheduleGroupDetailVO> participants = groupDetails.stream()
|
||||
.filter(d -> d.getParticipantId() != null)
|
||||
.sorted(Comparator.comparing(d -> d.getPerformanceOrder() != null ? d.getPerformanceOrder() : 999))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (participants.isEmpty()) {
|
||||
// 没有参赛者,创建一条基础记录
|
||||
ScheduleExportExcel excel = new ScheduleExportExcel();
|
||||
excel.setScheduleDate(firstDetail.getScheduleDate() != null ? firstDetail.getScheduleDate() : "");
|
||||
excel.setTimeSlot(firstDetail.getTimeSlot());
|
||||
excel.setVenueName(firstDetail.getVenueName());
|
||||
excel.setProjectName(firstDetail.getGroupName());
|
||||
excel.setCategory(firstDetail.getCategory());
|
||||
excel.setStatus("completed".equals(firstDetail.getScheduleStatus()) ? "已完成" : "草稿");
|
||||
exportList.add(excel);
|
||||
} else {
|
||||
// 为每个参赛者创建导出记录
|
||||
for (ScheduleGroupDetailVO detail : participants) {
|
||||
ScheduleExportExcel excel = new ScheduleExportExcel();
|
||||
excel.setScheduleDate(detail.getScheduleDate() != null ? detail.getScheduleDate() : "");
|
||||
excel.setTimeSlot(detail.getTimeSlot());
|
||||
excel.setVenueName(detail.getVenueName());
|
||||
excel.setProjectName(detail.getGroupName());
|
||||
excel.setCategory(detail.getCategory());
|
||||
excel.setAthleteName(detail.getPlayerName());
|
||||
excel.setTeamName(detail.getOrganization());
|
||||
excel.setSortOrder(detail.getPerformanceOrder());
|
||||
excel.setStatus(detail.getCheckInStatus() != null ? detail.getCheckInStatus() : "未签到");
|
||||
exportList.add(excel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return exportList;
|
||||
// Delegated to ScheduleExportService
|
||||
return scheduleExportService.exportSchedule(competitionId);
|
||||
}
|
||||
@Override
|
||||
public List<ScheduleExportExcel2> exportScheduleTemplate2(Long competitionId, Long venueId) {
|
||||
|
||||
Reference in New Issue
Block a user