|
@@ -9,12 +9,14 @@ import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.system.domain.*;
|
|
import org.dromara.system.domain.*;
|
|
|
import org.dromara.system.domain.bo.*;
|
|
import org.dromara.system.domain.bo.*;
|
|
|
import org.dromara.system.domain.constant.ProjectClassification;
|
|
import org.dromara.system.domain.constant.ProjectClassification;
|
|
|
|
|
+import org.dromara.system.domain.vo.ScorePreviewVo;
|
|
|
import org.dromara.system.domain.vo.ScoreSheetDetailVo;
|
|
import org.dromara.system.domain.vo.ScoreSheetDetailVo;
|
|
|
import org.dromara.system.domain.vo.ScoreSheetItemVo;
|
|
import org.dromara.system.domain.vo.ScoreSheetItemVo;
|
|
|
import org.dromara.system.domain.vo.ScoreSheetVo;
|
|
import org.dromara.system.domain.vo.ScoreSheetVo;
|
|
|
import org.dromara.system.mapper.GameAthleteMapper;
|
|
import org.dromara.system.mapper.GameAthleteMapper;
|
|
|
import org.dromara.system.mapper.GameEventMapper;
|
|
import org.dromara.system.mapper.GameEventMapper;
|
|
|
import org.dromara.system.mapper.GameEventProjectMapper;
|
|
import org.dromara.system.mapper.GameEventProjectMapper;
|
|
|
|
|
+import org.dromara.system.mapper.GameScoreMapper;
|
|
|
import org.dromara.system.mapper.app.ToClientMapper;
|
|
import org.dromara.system.mapper.app.ToClientMapper;
|
|
|
import org.dromara.system.service.IGameScoreService;
|
|
import org.dromara.system.service.IGameScoreService;
|
|
|
import org.dromara.system.service.IGameRankGroupService;
|
|
import org.dromara.system.service.IGameRankGroupService;
|
|
@@ -38,6 +40,7 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
private final IGameRankGroupService gameRankGroupService;
|
|
private final IGameRankGroupService gameRankGroupService;
|
|
|
private final ToClientMapper baseMapper;
|
|
private final ToClientMapper baseMapper;
|
|
|
private final IGameScoreService gameScoreService;
|
|
private final IGameScoreService gameScoreService;
|
|
|
|
|
+ private final GameScoreMapper gameScoreMapper;
|
|
|
private final GameAthleteMapper gameAthleteMapper;
|
|
private final GameAthleteMapper gameAthleteMapper;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -444,6 +447,130 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<ScorePreviewVo> getScorePreviewList(Long projectId) {
|
|
|
|
|
+ List<ScorePreviewVo> list = baseMapper.selectScorePreviewList(projectId);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ GameEventProject project = projectMapper.selectById(projectId);
|
|
|
|
|
+ if (project == null) {
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 1. 批量查询明细数据
|
|
|
|
|
+ List<GameScoreDetail> allDetails = Db.list(Wrappers.lambdaQuery(GameScoreDetail.class)
|
|
|
|
|
+ .eq(GameScoreDetail::getProjectId, projectId)
|
|
|
|
|
+ .eq(GameScoreDetail::getDelFlag, "0"));
|
|
|
|
|
+
|
|
|
|
|
+ if (!allDetails.isEmpty()) {
|
|
|
|
|
+ Map<Long, List<ScoreSheetDetailVo>> detailMap;
|
|
|
|
|
+ if (ProjectClassification.TEAM.getValue().equals(project.getClassification())) {
|
|
|
|
|
+ // 团体项目:按 teamId 分组
|
|
|
|
|
+ detailMap = allDetails.stream()
|
|
|
|
|
+ .filter(d -> d.getTeamId() != null)
|
|
|
|
|
+ .map(this::convertToDetailVo)
|
|
|
|
|
+ .collect(Collectors.groupingBy(ScoreSheetDetailVo::getTeamId));
|
|
|
|
|
+
|
|
|
|
|
+ list.forEach(item -> item.setDetails(detailMap.get(item.getTeamId())));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 个人项目:按 athleteId 分组
|
|
|
|
|
+ detailMap = allDetails.stream()
|
|
|
|
|
+ .filter(d -> d.getAthleteId() != null)
|
|
|
|
|
+ .map(this::convertToDetailVo)
|
|
|
|
|
+ .collect(Collectors.groupingBy(ScoreSheetDetailVo::getAthleteId));
|
|
|
|
|
+
|
|
|
|
|
+ list.forEach(item -> {
|
|
|
|
|
+ List<ScoreSheetDetailVo> details = detailMap.get(item.getAthleteId());
|
|
|
|
|
+ if (details == null && item.getScoreId() != null) {
|
|
|
|
|
+ // 兜底:按 scoreId 匹配
|
|
|
|
|
+ details = allDetails.stream()
|
|
|
|
|
+ .filter(d -> Objects.equals(d.getScoreId(), item.getScoreId()))
|
|
|
|
|
+ .map(this::convertToDetailVo)
|
|
|
|
|
+ .toList();
|
|
|
|
|
+ }
|
|
|
|
|
+ item.setDetails(details);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 处理时间格式转换
|
|
|
|
|
+ if (StringUtils.isNotBlank(project.getTimingFormat())) {
|
|
|
|
|
+ list.forEach(item -> {
|
|
|
|
|
+ if (StringUtils.isNotBlank(item.getScore())) {
|
|
|
|
|
+ item.setScore(convertDecimalToTimeScore(new BigDecimal(item.getScore()), project.getTimingFormat()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (item.getDetails() != null) {
|
|
|
|
|
+ item.getDetails().forEach(detail -> {
|
|
|
|
|
+ if (StringUtils.isNotBlank(detail.getPerformanceValue())) {
|
|
|
|
|
+ detail.setPerformanceValue(convertDecimalToTimeScore(
|
|
|
|
|
+ new BigDecimal(detail.getPerformanceValue()),
|
|
|
|
|
+ project.getTimingFormat()));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public void updateScorePreview(ScorePreviewUpdateBo bo) {
|
|
|
|
|
+ GameScore score = gameScoreMapper.selectById(bo.getScoreId());
|
|
|
|
|
+ if (score == null) {
|
|
|
|
|
+ throw new RuntimeException("成绩记录不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ GameEventProject project = projectMapper.selectById(score.getProjectId());
|
|
|
|
|
+
|
|
|
|
|
+ GameScoreBo scoreBo = new GameScoreBo();
|
|
|
|
|
+ scoreBo.setScoreId(score.getScoreId());
|
|
|
|
|
+ scoreBo.setEventId(score.getEventId());
|
|
|
|
|
+ scoreBo.setProjectId(score.getProjectId());
|
|
|
|
|
+ scoreBo.setAthleteId(score.getAthleteId());
|
|
|
|
|
+ scoreBo.setTeamId(score.getTeamId());
|
|
|
|
|
+
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(bo.getDetails())) {
|
|
|
|
|
+ // 如果提交了明细列表,则优先更新明细
|
|
|
|
|
+ List<GameScoreDetailBo> details = bo.getDetails().stream().map(d -> {
|
|
|
|
|
+ GameScoreDetailBo dbo = new GameScoreDetailBo();
|
|
|
|
|
+ dbo.setDetailId(d.getDetailId());
|
|
|
|
|
+ dbo.setAttemptIndex(d.getAttemptIndex());
|
|
|
|
|
+ dbo.setPerformanceValue(d.getPerformanceValue());
|
|
|
|
|
+ dbo.setFaultA(d.getFaultA());
|
|
|
|
|
+ dbo.setFaultB(d.getFaultB());
|
|
|
|
|
+ return dbo;
|
|
|
|
|
+ }).toList();
|
|
|
|
|
+ scoreBo.setDetails(details);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果没有明细,则更新单次成绩
|
|
|
|
|
+ BigDecimal performance = parsePerformanceValue(bo.getScore());
|
|
|
|
|
+ if (project != null && ProjectClassification.TEAM.getValue().equals(project.getClassification())) {
|
|
|
|
|
+ scoreBo.setTeamPerformance(performance);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ scoreBo.setIndividualPerformance(performance);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ gameScoreService.updateScoreAndRecalculate(scoreBo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public void removeScorePreview(Long scoreId) {
|
|
|
|
|
+ GameScore score = gameScoreMapper.selectById(scoreId);
|
|
|
|
|
+ if (score == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 删除成绩及明细
|
|
|
|
|
+ gameScoreService.deleteWithDetails(scoreId);
|
|
|
|
|
+
|
|
|
|
|
+ // 重新计算排名
|
|
|
|
|
+ gameScoreService.recalculateRankingsAndPoints(score.getEventId(), score.getProjectId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 批量保存配置信息
|
|
* 批量保存配置信息
|
|
|
*/
|
|
*/
|
|
@@ -528,4 +655,3 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|