|
|
@@ -72,8 +72,9 @@ public class ElectrometerServiceImpl implements IElectrometerService {
|
|
|
LambdaQueryWrapper<GameAthleteCompetitionGroup> groupWrapper = Wrappers.lambdaQuery(GameAthleteCompetitionGroup.class)
|
|
|
.in(GameAthleteCompetitionGroup::getAthleteId, athleteIds);
|
|
|
List<GameAthleteCompetitionGroup> competitionGroups = gameAthleteCompetitionGroupMapper.selectList(groupWrapper);
|
|
|
- Map<Long, GameAthleteCompetitionGroup> groupMap = competitionGroups.stream()
|
|
|
- .collect(Collectors.toMap(GameAthleteCompetitionGroup::getAthleteId, g -> g));
|
|
|
+ // 支持一个运动员对应多个分组
|
|
|
+ Map<Long, List<GameAthleteCompetitionGroup>> groupMap = competitionGroups.stream()
|
|
|
+ .collect(Collectors.groupingBy(GameAthleteCompetitionGroup::getAthleteId));
|
|
|
|
|
|
// 4. 查询分组信息
|
|
|
List<Long> groupIds = competitionGroups.stream().map(GameAthleteCompetitionGroup::getGroupId).collect(Collectors.toList());
|
|
|
@@ -91,52 +92,60 @@ public class ElectrometerServiceImpl implements IElectrometerService {
|
|
|
// 5. 组装数据
|
|
|
List<SysDictDataVo> data = dictTypeService.selectDictDataByType("game_stage");
|
|
|
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
- return athletes.stream().map(athlete -> {
|
|
|
- ElectrometerDataItemVo item = new ElectrometerDataItemVo();
|
|
|
-
|
|
|
- // 基本信息
|
|
|
- item.setHm(athlete.getAthleteCode());
|
|
|
- item.setXm(athlete.getName());
|
|
|
- item.setXb(athlete.getGender());
|
|
|
- item.setDw(athlete.getUnit());
|
|
|
-
|
|
|
- // 获取比赛分组信息
|
|
|
- GameAthleteCompetitionGroup competitionGroup = groupMap.get(athlete.getAthleteId());
|
|
|
- if (competitionGroup != null) {
|
|
|
- item.setCcDm(String.valueOf(competitionGroup.getGroupId()));
|
|
|
- item.setZc(String.valueOf(competitionGroup.getGroupIndex()));
|
|
|
- item.setDc(String.valueOf(competitionGroup.getTrackIndex()));
|
|
|
-
|
|
|
- // 组别信息
|
|
|
- if (!eventGroupMap.isEmpty()) {
|
|
|
- GameEventGroup eventGroup = eventGroupMap.get(competitionGroup.getGroupId());
|
|
|
- if (eventGroup != null) {
|
|
|
- item.setZbMc(eventGroup.getGroupName());
|
|
|
- if (eventGroup.getBeginTime() != null) {
|
|
|
- item.setTm(eventGroup.getBeginTime());
|
|
|
+ List<ElectrometerDataItemVo> result = new ArrayList<>();
|
|
|
+
|
|
|
+ for (GameAthlete athlete : athletes) {
|
|
|
+ // 获取该运动员的所有分组
|
|
|
+ List<GameAthleteCompetitionGroup> athleteGroups = groupMap.get(athlete.getAthleteId());
|
|
|
+ if (athleteGroups != null && !athleteGroups.isEmpty()) {
|
|
|
+ // 为每个分组创建一条记录
|
|
|
+ for (GameAthleteCompetitionGroup competitionGroup : athleteGroups) {
|
|
|
+ ElectrometerDataItemVo item = new ElectrometerDataItemVo();
|
|
|
+
|
|
|
+ // 基本信息
|
|
|
+ item.setHm(athlete.getAthleteCode());
|
|
|
+ item.setXm(athlete.getName());
|
|
|
+ item.setXb(athlete.getGender());
|
|
|
+ item.setDw(athlete.getUnit());
|
|
|
+
|
|
|
+ // 比赛分组信息
|
|
|
+ item.setCcDm(String.valueOf(competitionGroup.getGroupId()));
|
|
|
+ item.setZc(String.valueOf(competitionGroup.getGroupIndex()));
|
|
|
+ item.setDc(String.valueOf(competitionGroup.getTrackIndex()));
|
|
|
+
|
|
|
+ // 组别信息
|
|
|
+ if (!eventGroupMap.isEmpty()) {
|
|
|
+ GameEventGroup eventGroup = eventGroupMap.get(competitionGroup.getGroupId());
|
|
|
+ if (eventGroup != null) {
|
|
|
+ item.setZbMc(eventGroup.getGroupName());
|
|
|
+ if (eventGroup.getBeginTime() != null) {
|
|
|
+ item.setTm(eventGroup.getBeginTime());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 项目信息 - 根据比赛分组中的项目ID查找对应项目
|
|
|
- GameEventProject project = projectMap.get(competitionGroup.getProjectId());
|
|
|
- if (project != null) {
|
|
|
- item.setXmMc(project.getProjectName());
|
|
|
- item.setTjsDm(project.getProjectType());
|
|
|
- item.setSx(project.getScoreRule()); // 计算规则-项目属性
|
|
|
- Optional<String> label = data.stream()
|
|
|
- .filter(d -> d.getDictValue().equals(project.getGameStage()))
|
|
|
- .map(SysDictDataVo::getDictLabel)
|
|
|
- .findFirst();
|
|
|
- item.setScMc(label.orElse("")); //比赛阶段
|
|
|
- if (project.getStartTime() != null) {
|
|
|
- item.setTm(project.getStartTime());
|
|
|
+ // 项目信息 - 根据比赛分组中的项目ID查找对应项目
|
|
|
+ GameEventProject project = projectMap.get(competitionGroup.getProjectId());
|
|
|
+ if (project != null) {
|
|
|
+ item.setXmMc(project.getProjectName());
|
|
|
+ item.setTjsDm(project.getProjectType());
|
|
|
+ item.setSx(project.getScoreRule()); // 计算规则-项目属性
|
|
|
+ Optional<String> label = data.stream()
|
|
|
+ .filter(d -> d.getDictValue().equals(project.getGameStage()))
|
|
|
+ .map(SysDictDataVo::getDictLabel)
|
|
|
+ .findFirst();
|
|
|
+ item.setScMc(label.orElse("")); //比赛阶段
|
|
|
+ if (project.getStartTime() != null) {
|
|
|
+ item.setTm(project.getStartTime());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ result.add(item);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- return item;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|