添加导出Excel组别字段、isMe标记、小程序出场顺序优化

- ScheduleGroupData添加category字段
- 编排保存时写入组别(男子/女子/混合)
- LineupParticipantVO添加isMe字段标记当前用户选手
- 修复SQL participant_id映射

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
2026-01-15 15:56:28 +08:00
co-authored by factory-droid[bot]
parent 15837dff9d
commit 42b25a7cf2
4 changed files with 88 additions and 18 deletions
@@ -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<Map<String, Object>> getLineup(
@RequestParam Long competitionId,
@RequestParam(required = false) Long projectId
@RequestParam(required = false) Long projectId,
@RequestParam(required = false) Long orderId
) {
Map<String, Object> 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<MartialRegistrationOrder> orderWrapper = new LambdaQueryWrapper<>();
orderWrapper.eq(MartialRegistrationOrder::getCompetitionId, competitionId)
.eq(orderId != null, MartialRegistrationOrder::getId, orderId)
.eq(MartialRegistrationOrder::getUserId, user.getUserId())
.eq(MartialRegistrationOrder::getIsDeleted, 0);
List<MartialRegistrationOrder> 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<Long> myOrderIds = myOrders.stream()
.map(MartialRegistrationOrder::getId)
.collect(Collectors.toSet());
// 查询当前用户在该赛事的运动员记录(通过订单ID关联)
LambdaQueryWrapper<MartialAthlete> athleteWrapper = new LambdaQueryWrapper<>();
athleteWrapper.eq(MartialAthlete::getCompetitionId, competitionId)
.in(MartialAthlete::getOrderId, myOrderIds)
.eq(MartialAthlete::getIsDeleted, 0);
List<MartialAthlete> 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<Long> myAthleteIds = myAthletes.stream()
.map(MartialAthlete::getId)
.collect(Collectors.toSet());
// 使用现有mapper查询编排详情
List<ScheduleGroupDetailVO> 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();
// 过滤出包含当前用户的分组
Set<Long> myGroupIds = details.stream()
.filter(d -> d.getParticipantId() != null && myAthleteIds.contains(d.getParticipantId()))
.map(ScheduleGroupDetailVO::getGroupId)
.collect(Collectors.toSet());
// 只保留用户参与的分组数据
details = details.stream()
.filter(d -> d.getGroupName() != null && d.getGroupName().contains(projectName))
.filter(d -> myGroupIds.contains(d.getGroupId()))
.collect(Collectors.toList());
}
}
// 转换为LineupGroupVO格式
Map<Long, LineupGroupVO> groupMap = new HashMap<>();
Map<Long, LineupGroupVO> 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;
@@ -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,
@@ -15,4 +15,5 @@ public class LineupParticipantVO implements Serializable {
private String playerName;
private String organization;
private String status;
private Boolean isMe; // 是否为当前用户
}
@@ -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<MartialAthlete> 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<MartialAthlete> getAthletes() {
return athletes;
}