From 42b25a7cf249120b171964020121ec60abb2e18a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=85=E6=88=BF?= Date: Fri, 9 Jan 2026 20:11:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=BC=E5=87=BAExcel?= =?UTF-8?q?=E7=BB=84=E5=88=AB=E5=AD=97=E6=AE=B5=E3=80=81isMe=E6=A0=87?= =?UTF-8?q?=E8=AE=B0=E3=80=81=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=87=BA=E5=9C=BA?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ScheduleGroupData添加category字段 - 编排保存时写入组别(男子/女子/混合) - LineupParticipantVO添加isMe字段标记当前用户选手 - 修复SQL participant_id映射 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .../controller/MartialMiniController.java | 90 +++++++++++++++---- .../mapper/MartialScheduleGroupMapper.xml | 2 +- .../martial/pojo/vo/LineupParticipantVO.java | 1 + .../MartialScheduleArrangeServiceImpl.java | 13 +++ 4 files changed, 88 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/springblade/modules/martial/controller/MartialMiniController.java b/src/main/java/org/springblade/modules/martial/controller/MartialMiniController.java index 83a7e81..ee78def 100644 --- a/src/main/java/org/springblade/modules/martial/controller/MartialMiniController.java +++ b/src/main/java/org/springblade/modules/martial/controller/MartialMiniController.java @@ -10,6 +10,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.secure.BladeUser; import org.springblade.core.tool.utils.Func; import org.springblade.modules.martial.pojo.dto.MiniAthleteScoreDTO; import org.springblade.modules.martial.pojo.dto.MiniLoginDTO; @@ -40,6 +42,8 @@ import java.time.LocalDateTime; import java.time.Duration; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Set; import java.util.Map; import java.util.List; import java.util.Objects; @@ -67,6 +71,7 @@ public class MartialMiniController extends BladeController { private final IMartialScoreService scoreService; private final BladeRedis bladeRedis; private final IMartialResultService resultService; + private final IMartialRegistrationOrderService registrationOrderService; private final MartialScheduleStatusMapper scheduleStatusMapper; private final MartialScheduleGroupMapper scheduleGroupMapper; @@ -363,6 +368,7 @@ public class MartialMiniController extends BladeController { @RequestParam Long judgeId, @RequestParam Integer refereeType, @RequestParam(required = false) Long projectId, + @RequestParam(required = false) Long orderId, @RequestParam(required = false) Long venueId, @RequestParam(required = false) Long competitionId, @RequestParam(defaultValue = "1") Integer current, @@ -872,37 +878,89 @@ public class MartialMiniController extends BladeController { /** * 获取出场顺序 + /** + * 获取出场顺序(只返回当前用户报名的项目) */ @GetMapping("/schedule/lineup") - @Operation(summary = "获取出场顺序", description = "获取已编排的出场顺序列表") + @Operation(summary = "获取出场顺序", description = "获取当前用户报名项目的出场顺序") public R> getLineup( @RequestParam Long competitionId, - @RequestParam(required = false) Long projectId + @RequestParam(required = false) Long projectId, + @RequestParam(required = false) Long orderId ) { Map result = new HashMap<>(); + // 获取当前登录用户 + BladeUser user = AuthUtil.getUser(); + System.out.println("user: " + (user != null ? user.getUserId() : "null")); + if (user == null) { + result.put("groups", new ArrayList<>()); + return R.data(result); + } + + // 查询当前用户在该赛事的订单 + LambdaQueryWrapper orderWrapper = new LambdaQueryWrapper<>(); + orderWrapper.eq(MartialRegistrationOrder::getCompetitionId, competitionId) + .eq(orderId != null, MartialRegistrationOrder::getId, orderId) + .eq(MartialRegistrationOrder::getUserId, user.getUserId()) + .eq(MartialRegistrationOrder::getIsDeleted, 0); + List myOrders = registrationOrderService.list(orderWrapper); + + System.out.println("myOrders count: " + myOrders.size()); + if (myOrders.isEmpty()) { + result.put("groups", new ArrayList<>()); + return R.data(result); + } + + // 获取用户的所有订单ID + Set myOrderIds = myOrders.stream() + .map(MartialRegistrationOrder::getId) + .collect(Collectors.toSet()); + + // 查询当前用户在该赛事的运动员记录(通过订单ID关联) + LambdaQueryWrapper athleteWrapper = new LambdaQueryWrapper<>(); + athleteWrapper.eq(MartialAthlete::getCompetitionId, competitionId) + .in(MartialAthlete::getOrderId, myOrderIds) + .eq(MartialAthlete::getIsDeleted, 0); + List myAthletes = athleteService.list(athleteWrapper); + + if (myAthletes.isEmpty()) { + result.put("groups", new ArrayList<>()); + return R.data(result); + } + + // 获取用户的所有athlete ID + System.out.println("myAthletes count: " + myAthletes.size()); + System.out.println("myAthletes: " + myAthletes.stream().map(a -> a.getId() + ":" + a.getPlayerName()).collect(Collectors.joining(", "))); + Set myAthleteIds = myAthletes.stream() + .map(MartialAthlete::getId) + .collect(Collectors.toSet()); + // 使用现有mapper查询编排详情 List details = scheduleGroupMapper.selectScheduleGroupDetails(competitionId); + System.out.println("details count: " + (details != null ? details.size() : 0)); + if (details != null && !details.isEmpty()) { + System.out.println("first detail participantId: " + details.get(0).getParticipantId()); + } if (details == null || details.isEmpty()) { result.put("groups", new ArrayList<>()); return R.data(result); } - // 按项目过滤 - if (projectId != null) { - // 需要通过groupName或其他字段判断项目,这里先获取项目名 - MartialProject project = projectService.getById(projectId); - if (project != null) { - String projectName = project.getProjectName(); - details = details.stream() - .filter(d -> d.getGroupName() != null && d.getGroupName().contains(projectName)) - .collect(Collectors.toList()); - } - } + // 过滤出包含当前用户的分组 + Set myGroupIds = details.stream() + .filter(d -> d.getParticipantId() != null && myAthleteIds.contains(d.getParticipantId())) + .map(ScheduleGroupDetailVO::getGroupId) + .collect(Collectors.toSet()); + + // 只保留用户参与的分组数据 + details = details.stream() + .filter(d -> myGroupIds.contains(d.getGroupId())) + .collect(Collectors.toList()); // 转换为LineupGroupVO格式 - Map groupMap = new HashMap<>(); + Map groupMap = new LinkedHashMap<>(); for (ScheduleGroupDetailVO detail : details) { Long groupId = detail.getGroupId(); LineupGroupVO group = groupMap.get(groupId); @@ -925,6 +983,7 @@ public class MartialMiniController extends BladeController { participant.setOrder(detail.getPerformanceOrder() != null ? detail.getPerformanceOrder() : group.getParticipants().size() + 1); participant.setPlayerName(detail.getPlayerName()); participant.setOrganization(detail.getOrganization()); + participant.setIsMe(myAthleteIds.contains(detail.getParticipantId())); participant.setStatus(detail.getScheduleStatus() != null ? detail.getScheduleStatus() : "waiting"); group.getParticipants().add(participant); } @@ -934,9 +993,6 @@ public class MartialMiniController extends BladeController { return R.data(result); } - /** - * 生成表号: 场地(1位) + 时段(1位) + 序号(2位) - */ private String generateTableNo(ScheduleGroupDetailVO detail) { // 场地编号(简单取第一个数字或默认1) int venueNo = 1; diff --git a/src/main/java/org/springblade/modules/martial/mapper/MartialScheduleGroupMapper.xml b/src/main/java/org/springblade/modules/martial/mapper/MartialScheduleGroupMapper.xml index 8bb0b99..71d239b 100644 --- a/src/main/java/org/springblade/modules/martial/mapper/MartialScheduleGroupMapper.xml +++ b/src/main/java/org/springblade/modules/martial/mapper/MartialScheduleGroupMapper.xml @@ -19,7 +19,7 @@ d.time_slot AS timeSlot, d.time_slot_index AS timeSlotIndex, d.schedule_date AS scheduleDate, - p.id AS participantId, + p.participant_id AS participantId, p.organization AS organization, p.check_in_status AS checkInStatus, p.schedule_status AS scheduleStatus, diff --git a/src/main/java/org/springblade/modules/martial/pojo/vo/LineupParticipantVO.java b/src/main/java/org/springblade/modules/martial/pojo/vo/LineupParticipantVO.java index 7ae5a98..5c26ae6 100644 --- a/src/main/java/org/springblade/modules/martial/pojo/vo/LineupParticipantVO.java +++ b/src/main/java/org/springblade/modules/martial/pojo/vo/LineupParticipantVO.java @@ -15,4 +15,5 @@ public class LineupParticipantVO implements Serializable { private String playerName; private String organization; private String status; + private Boolean isMe; // 是否为当前用户 } diff --git a/src/main/java/org/springblade/modules/martial/service/impl/MartialScheduleArrangeServiceImpl.java b/src/main/java/org/springblade/modules/martial/service/impl/MartialScheduleArrangeServiceImpl.java index 8e1eb11..26c5119 100644 --- a/src/main/java/org/springblade/modules/martial/service/impl/MartialScheduleArrangeServiceImpl.java +++ b/src/main/java/org/springblade/modules/martial/service/impl/MartialScheduleArrangeServiceImpl.java @@ -477,6 +477,7 @@ public class MartialScheduleArrangeServiceImpl implements IMartialScheduleArrang group.setProjectId(first.getProjectId()); group.setProjectType((project.getType() == 2 || project.getType() == 3) ? 2 : 1); // type=2(双人)或type=3(集体)映射为projectType=2(集体) group.setMaxParticipants(project.getMaxParticipants()); // 设置项目单位容纳人数 + group.setCategory(categoryName); // 设置组别 group.setDisplayOrder(displayOrder++); group.setTotalParticipants(members.size()); group.setTotalTeams((int) teamCount); @@ -558,6 +559,7 @@ public class MartialScheduleArrangeServiceImpl implements IMartialScheduleArrang group.setProjectType(1); group.setMaxParticipants(maxPeoplePerGroup); // 设置项目单位容纳人数 group.setDisplayOrder(displayOrder++); + group.setCategory(categoryName); // 设置组别 group.setTotalParticipants(members.size()); group.setAthletes(members); @@ -587,6 +589,7 @@ public class MartialScheduleArrangeServiceImpl implements IMartialScheduleArrang group.setProjectType(1); group.setMaxParticipants(maxPeoplePerGroup); // 设置项目单位容纳人数 group.setDisplayOrder(displayOrder++); + group.setCategory(categoryName); // 设置组别 group.setTotalParticipants(subGroupMembers.size()); group.setAthletes(new ArrayList<>(subGroupMembers)); @@ -862,6 +865,7 @@ public class MartialScheduleArrangeServiceImpl implements IMartialScheduleArrang group.setTotalParticipants(groupData.getTotalParticipants()); group.setTotalTeams(groupData.getTotalTeams()); group.setEstimatedDuration(groupData.getEstimatedDuration()); + group.setCategory(groupData.getCategory()); // 保存组别 group.setCreateTime(new Date()); scheduleGroupMapper.insert(group); @@ -956,6 +960,7 @@ public class MartialScheduleArrangeServiceImpl implements IMartialScheduleArrang private Integer totalTeams; private Integer estimatedDuration; private Integer maxParticipants; // 项目单位容纳人数 + private String category; // 组别(男子/女子/混合) private List athletes; // 分配结果 @@ -1031,6 +1036,14 @@ public class MartialScheduleArrangeServiceImpl implements IMartialScheduleArrang this.maxParticipants = maxParticipants; } + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + public List getAthletes() { return athletes; }