feat: 裁判端选手列表按编排出场顺序显示
优先从martial_schedule_participant表查询,按performance_order排序 如果没有编排数据则回退到原始martial_athlete表查询 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
factory-droid[bot]
parent
c799eb194f
commit
1002fc0945
+93
-14
@@ -34,6 +34,8 @@ import org.springblade.modules.martial.pojo.entity.MartialResult;
|
|||||||
import org.springblade.core.redis.cache.BladeRedis;
|
import org.springblade.core.redis.cache.BladeRedis;
|
||||||
import org.springblade.modules.martial.mapper.MartialScheduleStatusMapper;
|
import org.springblade.modules.martial.mapper.MartialScheduleStatusMapper;
|
||||||
import org.springblade.modules.martial.mapper.MartialScheduleGroupMapper;
|
import org.springblade.modules.martial.mapper.MartialScheduleGroupMapper;
|
||||||
|
import org.springblade.modules.martial.mapper.MartialScheduleParticipantMapper;
|
||||||
|
import org.springblade.modules.martial.mapper.MartialScheduleDetailMapper;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -76,6 +78,8 @@ public class MartialMiniController extends BladeController {
|
|||||||
private final IMartialRegistrationOrderService registrationOrderService;
|
private final IMartialRegistrationOrderService registrationOrderService;
|
||||||
private final MartialScheduleStatusMapper scheduleStatusMapper;
|
private final MartialScheduleStatusMapper scheduleStatusMapper;
|
||||||
private final MartialScheduleGroupMapper scheduleGroupMapper;
|
private final MartialScheduleGroupMapper scheduleGroupMapper;
|
||||||
|
private final MartialScheduleParticipantMapper scheduleParticipantMapper;
|
||||||
|
private final MartialScheduleDetailMapper scheduleDetailMapper;
|
||||||
|
|
||||||
// Redis缓存key前缀
|
// Redis缓存key前缀
|
||||||
private static final String MINI_LOGIN_CACHE_PREFIX = "mini:login:";
|
private static final String MINI_LOGIN_CACHE_PREFIX = "mini:login:";
|
||||||
@@ -244,23 +248,23 @@ public class MartialMiniController extends BladeController {
|
|||||||
@RequestParam(defaultValue = "1") Integer current,
|
@RequestParam(defaultValue = "1") Integer current,
|
||||||
@RequestParam(defaultValue = "10") Integer size
|
@RequestParam(defaultValue = "10") Integer size
|
||||||
) {
|
) {
|
||||||
// 1. 构建选手查询条件
|
// 1. 优先从编排表查询选手(按出场顺序)
|
||||||
LambdaQueryWrapper<MartialAthlete> athleteQuery = new LambdaQueryWrapper<>();
|
List<MartialAthlete> athletes = getAthletesFromSchedule(competitionId, projectId, venueId);
|
||||||
athleteQuery.eq(MartialAthlete::getIsDeleted, 0);
|
|
||||||
|
|
||||||
// 按比赛ID过滤(重要:确保只显示当前比赛的选手)
|
// 如果编排表没有数据,回退到原始选手表查询
|
||||||
if (competitionId != null) {
|
if (athletes.isEmpty()) {
|
||||||
athleteQuery.eq(MartialAthlete::getCompetitionId, competitionId);
|
LambdaQueryWrapper<MartialAthlete> athleteQuery = new LambdaQueryWrapper<>();
|
||||||
|
athleteQuery.eq(MartialAthlete::getIsDeleted, 0);
|
||||||
|
if (competitionId != null) {
|
||||||
|
athleteQuery.eq(MartialAthlete::getCompetitionId, competitionId);
|
||||||
|
}
|
||||||
|
if (projectId != null) {
|
||||||
|
athleteQuery.eq(MartialAthlete::getProjectId, projectId);
|
||||||
|
}
|
||||||
|
athleteQuery.orderByAsc(MartialAthlete::getOrderNum);
|
||||||
|
athletes = athleteService.list(athleteQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectId != null) {
|
|
||||||
athleteQuery.eq(MartialAthlete::getProjectId, projectId);
|
|
||||||
}
|
|
||||||
|
|
||||||
athleteQuery.orderByAsc(MartialAthlete::getOrderNum);
|
|
||||||
|
|
||||||
List<MartialAthlete> athletes = athleteService.list(athleteQuery);
|
|
||||||
|
|
||||||
// 2. 获取该场地所有主裁判的judge_id列表
|
// 2. 获取该场地所有主裁判的judge_id列表
|
||||||
List<Long> chiefJudgeIds = getChiefJudgeIds(venueId);
|
List<Long> chiefJudgeIds = getChiefJudgeIds(venueId);
|
||||||
|
|
||||||
@@ -321,6 +325,81 @@ public class MartialMiniController extends BladeController {
|
|||||||
return R.data(page);
|
return R.data(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从编排表查询选手列表(按出场顺序)
|
||||||
|
*/
|
||||||
|
private List<MartialAthlete> getAthletesFromSchedule(Long competitionId, Long projectId, Long venueId) {
|
||||||
|
if (competitionId == null) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询编排分组
|
||||||
|
LambdaQueryWrapper<MartialScheduleGroup> groupQuery = new LambdaQueryWrapper<>();
|
||||||
|
groupQuery.eq(MartialScheduleGroup::getCompetitionId, competitionId);
|
||||||
|
groupQuery.eq(MartialScheduleGroup::getIsDeleted, 0);
|
||||||
|
if (projectId != null) {
|
||||||
|
groupQuery.eq(MartialScheduleGroup::getProjectId, projectId);
|
||||||
|
}
|
||||||
|
List<MartialScheduleGroup> groups = scheduleGroupMapper.selectList(groupQuery);
|
||||||
|
|
||||||
|
if (groups.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Long> groupIds = groups.stream().map(MartialScheduleGroup::getId).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 如果指定了场地,过滤出该场地的分组
|
||||||
|
if (venueId != null) {
|
||||||
|
LambdaQueryWrapper<MartialScheduleDetail> detailQuery = new LambdaQueryWrapper<>();
|
||||||
|
detailQuery.in(MartialScheduleDetail::getScheduleGroupId, groupIds);
|
||||||
|
detailQuery.eq(MartialScheduleDetail::getVenueId, venueId);
|
||||||
|
detailQuery.eq(MartialScheduleDetail::getIsDeleted, 0);
|
||||||
|
List<MartialScheduleDetail> details = scheduleDetailMapper.selectList(detailQuery);
|
||||||
|
groupIds = details.stream().map(MartialScheduleDetail::getScheduleGroupId).collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (groupIds.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询编排参赛者(按出场顺序)
|
||||||
|
LambdaQueryWrapper<MartialScheduleParticipant> participantQuery = new LambdaQueryWrapper<>();
|
||||||
|
participantQuery.in(MartialScheduleParticipant::getScheduleGroupId, groupIds);
|
||||||
|
participantQuery.eq(MartialScheduleParticipant::getIsDeleted, 0);
|
||||||
|
participantQuery.orderByAsc(MartialScheduleParticipant::getPerformanceOrder);
|
||||||
|
List<MartialScheduleParticipant> participants = scheduleParticipantMapper.selectList(participantQuery);
|
||||||
|
|
||||||
|
if (participants.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取选手ID列表
|
||||||
|
List<Long> athleteIds = participants.stream()
|
||||||
|
.map(MartialScheduleParticipant::getParticipantId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (athleteIds.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询选手详情
|
||||||
|
LambdaQueryWrapper<MartialAthlete> athleteQuery = new LambdaQueryWrapper<>();
|
||||||
|
athleteQuery.in(MartialAthlete::getId, athleteIds);
|
||||||
|
athleteQuery.eq(MartialAthlete::getIsDeleted, 0);
|
||||||
|
List<MartialAthlete> athleteList = athleteService.list(athleteQuery);
|
||||||
|
|
||||||
|
// 按编排顺序排序
|
||||||
|
Map<Long, MartialAthlete> athleteMap = athleteList.stream()
|
||||||
|
.collect(Collectors.toMap(MartialAthlete::getId, a -> a));
|
||||||
|
|
||||||
|
return participants.stream()
|
||||||
|
.map(p -> athleteMap.get(p.getParticipantId()))
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取场地所有主裁判的judge_id列表
|
* 获取场地所有主裁判的judge_id列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user