|
|
@@ -519,7 +519,7 @@ public class GameScoreServiceImpl implements IGameScoreService {
|
|
|
|
|
|
Boolean result = false;
|
|
|
|
|
|
- if (project != null && "1".equals(project.getClassification())) {
|
|
|
+ if (project != null && ProjectClassification.TEAM.getValue().equals(project.getClassification())) {
|
|
|
// 团体项目:为队伍中的所有运动员创建或更新成绩记录
|
|
|
log.info("处理团体项目成绩更新");
|
|
|
result = handleTeamScoreUpdate(bo);
|
|
|
@@ -1339,18 +1339,47 @@ public class GameScoreServiceImpl implements IGameScoreService {
|
|
|
.eq(GameScore::getEventId, eventId)
|
|
|
);
|
|
|
|
|
|
- // 构建 teamId -> (projectId -> 积分累计和)
|
|
|
- Map<Long, Map<Long, Integer>> teamProjectPointSumMap = new HashMap<>();
|
|
|
+ // 创建项目ID到项目信息的映射
|
|
|
+ Map<Long, GameEventProjectVo> projectMap = projects.stream()
|
|
|
+ .collect(Collectors.toMap(GameEventProjectVo::getProjectId, p -> p));
|
|
|
+
|
|
|
+ // 构建 teamId -> (projectId -> 积分)
|
|
|
+ Map<Long, Map<Long, Integer>> teamProjectPointMap = new HashMap<>();
|
|
|
+
|
|
|
+ // 为每个队伍初始化积分映射
|
|
|
+ for (GameTeamVo team : teams) {
|
|
|
+ teamProjectPointMap.put(team.getTeamId(), new HashMap<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理积分计算
|
|
|
for (GameScoreVo score : allScores) {
|
|
|
Long teamId = score.getTeamId();
|
|
|
Long projectId = score.getProjectId();
|
|
|
if (teamId == null || projectId == null) {
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
int points = score.getScorePoint() != null ? score.getScorePoint() : 0;
|
|
|
|
|
|
- Map<Long, Integer> projectPointMap = teamProjectPointSumMap.computeIfAbsent(teamId, k -> new HashMap<>());
|
|
|
- projectPointMap.merge(projectId, points, Integer::sum);
|
|
|
+ // 获取项目信息
|
|
|
+ GameEventProjectVo project = projectMap.get(projectId);
|
|
|
+ if (project == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 为队伍初始化项目积分映射
|
|
|
+ Map<Long, Integer> projectPointMap = teamProjectPointMap.computeIfAbsent(teamId, k -> new HashMap<>());
|
|
|
+
|
|
|
+ // 区分项目类型处理积分
|
|
|
+ if (ProjectClassification.TEAM.getValue().equals(project.getClassification())) { // 团体项目
|
|
|
+ // 团体项目:一个队伍只需记录一次积分(取任意一个运动员的积分)
|
|
|
+ if (!projectPointMap.containsKey(projectId)) {
|
|
|
+ projectPointMap.put(projectId, points);
|
|
|
+ }
|
|
|
+ } else { // 个人项目
|
|
|
+ // 个人项目:累加计算所有运动员的积分
|
|
|
+ projectPointMap.merge(projectId, points, Integer::sum);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 构建导出/前端展示数据
|
|
|
@@ -1365,7 +1394,7 @@ public class GameScoreServiceImpl implements IGameScoreService {
|
|
|
Map<String, Integer> projectScores = new HashMap<>();
|
|
|
int totalScore = 0;
|
|
|
|
|
|
- Map<Long, Integer> projectPointMap = teamProjectPointSumMap.getOrDefault(team.getTeamId(), Collections.emptyMap());
|
|
|
+ Map<Long, Integer> projectPointMap = teamProjectPointMap.getOrDefault(team.getTeamId(), Collections.emptyMap());
|
|
|
|
|
|
for (GameEventProjectVo project : projects) {
|
|
|
int projectScore = projectPointMap.getOrDefault(project.getProjectId(), 0);
|
|
|
@@ -1793,7 +1822,7 @@ public class GameScoreServiceImpl implements IGameScoreService {
|
|
|
int colIndex = 0;
|
|
|
|
|
|
// 根据项目类型确定列标题
|
|
|
- if ("0".equals(project.getClassification())) {
|
|
|
+ if (ProjectClassification.SINGLE.getValue().equals(project.getClassification())) {
|
|
|
// 个人项目列标题
|
|
|
String[] headers = {
|
|
|
"序号", "队伍编号", "队伍名称", "姓名", "号码",
|
|
|
@@ -1836,7 +1865,7 @@ public class GameScoreServiceImpl implements IGameScoreService {
|
|
|
|
|
|
int colIndex = 0;
|
|
|
|
|
|
- if ("0".equals(project.getClassification())) {
|
|
|
+ if (ProjectClassification.SINGLE.getValue().equals(project.getClassification())) {
|
|
|
// 个人项目数据
|
|
|
createCellWithStyle(dataRow, colIndex++, i + 1, currentRowStyle); // 序号
|
|
|
createCellWithStyle(dataRow, colIndex++, data.get("teamCode"), currentRowStyle); // 队伍编号
|