|
@@ -35,6 +35,7 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -220,21 +221,13 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
.in(GameEventProject::getProjectId, projectIds)
|
|
.in(GameEventProject::getProjectId, projectIds)
|
|
|
.select(GameEventProject::getProjectId, GameEventProject::getProjectType,
|
|
.select(GameEventProject::getProjectId, GameEventProject::getProjectType,
|
|
|
GameEventProject::getClassification, GameEventProject::getProjectName,
|
|
GameEventProject::getClassification, GameEventProject::getProjectName,
|
|
|
- GameEventProject::getStatus));
|
|
|
|
|
|
|
+ GameEventProject::getStatus, GameEventProject::getScoreCount));
|
|
|
return res.isEmpty() ? new ArrayList<>() : res.stream().map(p -> {
|
|
return res.isEmpty() ? new ArrayList<>() : res.stream().map(p -> {
|
|
|
GameAppProject appProject = BeanUtil.copyProperties(p, GameAppProject.class);
|
|
GameAppProject appProject = BeanUtil.copyProperties(p, GameAppProject.class);
|
|
|
appProject.setId(p.getEventId());
|
|
appProject.setId(p.getEventId());
|
|
|
appProject.setState(p.getStatus());
|
|
appProject.setState(p.getStatus());
|
|
|
- appProject.setSex(p.getGender());
|
|
|
|
|
appProject.setType(typeMaps.get(p.getProjectType()));
|
|
appProject.setType(typeMaps.get(p.getProjectType()));
|
|
|
- appProject.setPmnum(p.getRoundType());
|
|
|
|
|
- appProject.setPaiMing(p.getOrderType());
|
|
|
|
|
appProject.setChengJiNum(p.getScoreCount());
|
|
appProject.setChengJiNum(p.getScoreCount());
|
|
|
- appProject.setJifen(p.getScoreValue());
|
|
|
|
|
- appProject.setGuize(p.getTimingFormat());
|
|
|
|
|
- appProject.setLunci(p.getGameRound());
|
|
|
|
|
- appProject.setJieduan(p.getGameStage());
|
|
|
|
|
- appProject.setZu(p.getRgName());
|
|
|
|
|
return appProject;
|
|
return appProject;
|
|
|
}).toList();
|
|
}).toList();
|
|
|
}
|
|
}
|
|
@@ -246,6 +239,8 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
if (vo == null) {
|
|
if (vo == null) {
|
|
|
throw new RuntimeException("该赛事下不存在此项目");
|
|
throw new RuntimeException("该赛事下不存在此项目");
|
|
|
}
|
|
}
|
|
|
|
|
+ // 暂存原始成绩类型,用于后续判断是否是计数/排名类
|
|
|
|
|
+ String rawScoreRule = vo.getChengjiType();
|
|
|
|
|
|
|
|
// 批量查询字典数据,避免多次调用 Redis/MySQL 交互
|
|
// 批量查询字典数据,避免多次调用 Redis/MySQL 交互
|
|
|
Map<String, List<SysDictDataVo>> dictMap = dictService.selectDictDataByTypes(List.of(
|
|
Map<String, List<SysDictDataVo>> dictMap = dictService.selectDictDataByTypes(List.of(
|
|
@@ -322,6 +317,23 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 5. 处理计数和排名类的成绩,转换为整数
|
|
|
|
|
+ String rule = rawScoreRule != null ? rawScoreRule.trim() : "";
|
|
|
|
|
+ if ("3".equals(rule) || "4".equals(rule) || "5".equals(rule)) {
|
|
|
|
|
+ items.forEach(item -> {
|
|
|
|
|
+ if (StringUtils.isNotBlank(item.getScore())) {
|
|
|
|
|
+ item.setScore(convertToIntegerScore(item.getScore()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(item.getChengji())) {
|
|
|
|
|
+ item.getChengji().forEach(detail -> {
|
|
|
|
|
+ if (StringUtils.isNotBlank(detail.getNum())) {
|
|
|
|
|
+ detail.setNum(convertToIntegerScore(detail.getNum()));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
vo.setUser(items);
|
|
vo.setUser(items);
|
|
|
return vo;
|
|
return vo;
|
|
|
}
|
|
}
|
|
@@ -348,9 +360,7 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
ScoreSheetDetailVo dvo = new ScoreSheetDetailVo();
|
|
ScoreSheetDetailVo dvo = new ScoreSheetDetailVo();
|
|
|
dvo.setDetailId(d.getDetailId());
|
|
dvo.setDetailId(d.getDetailId());
|
|
|
dvo.setScoreId(d.getScoreId());
|
|
dvo.setScoreId(d.getScoreId());
|
|
|
- dvo.setAttemptIndex(d.getAttemptIndex());
|
|
|
|
|
dvo.setNum(d.getPerformanceValue() != null ? d.getPerformanceValue().toString() : null);
|
|
dvo.setNum(d.getPerformanceValue() != null ? d.getPerformanceValue().toString() : null);
|
|
|
- dvo.setShiwu(d.getFaultA());
|
|
|
|
|
// 传递关联 ID 供分组使用
|
|
// 传递关联 ID 供分组使用
|
|
|
dvo.setId(d.getAthleteId());
|
|
dvo.setId(d.getAthleteId());
|
|
|
dvo.setTeamId(d.getTeamId());
|
|
dvo.setTeamId(d.getTeamId());
|
|
@@ -402,6 +412,25 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 将计数或排名类成绩转换为整数,去除小数点后面的部分
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param scoreStr 成绩字符串
|
|
|
|
|
+ * @return 整数成绩字符串
|
|
|
|
|
+ */
|
|
|
|
|
+ private String convertToIntegerScore(String scoreStr) {
|
|
|
|
|
+ if (StringUtils.isBlank(scoreStr)) {
|
|
|
|
|
+ return scoreStr;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ BigDecimal decimal = new BigDecimal(scoreStr.trim());
|
|
|
|
|
+ return decimal.setScale(0, RoundingMode.HALF_UP).toPlainString();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ // 解析失败(例如DNF等非数值特殊状态),保留原样
|
|
|
|
|
+ return scoreStr;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void submitScoreSheet(ScoreSubmitBo bo) {
|
|
public void submitScoreSheet(ScoreSubmitBo bo) {
|
|
@@ -426,9 +455,7 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
if (CollectionUtils.isNotEmpty(item.getChengji())) {
|
|
if (CollectionUtils.isNotEmpty(item.getChengji())) {
|
|
|
for (ScoreSubmitDetailBo detail : item.getChengji()) {
|
|
for (ScoreSubmitDetailBo detail : item.getChengji()) {
|
|
|
if (detail.getNum() == null) {
|
|
if (detail.getNum() == null) {
|
|
|
- String attemptStr = detail.getAttemptIndex() != null ? "第 " + detail.getAttemptIndex() + " 轮"
|
|
|
|
|
- : "明细";
|
|
|
|
|
- throw new RuntimeException("提交失败:" + displayName + " 的" + attemptStr + "成绩不能为空");
|
|
|
|
|
|
|
+ throw new RuntimeException("提交失败:" + displayName + " 的" + "明细成绩不能为空");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
@@ -540,12 +567,12 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
|
|
|
|
|
// 统一模式:优先处理明细列表
|
|
// 统一模式:优先处理明细列表
|
|
|
if (CollectionUtils.isNotEmpty(item.getChengji())) {
|
|
if (CollectionUtils.isNotEmpty(item.getChengji())) {
|
|
|
|
|
+ AtomicInteger attemptIndex = new AtomicInteger(1);
|
|
|
List<GameScoreDetailBo> details = item.getChengji().stream().map(d -> {
|
|
List<GameScoreDetailBo> details = item.getChengji().stream().map(d -> {
|
|
|
GameScoreDetailBo dbo = new GameScoreDetailBo();
|
|
GameScoreDetailBo dbo = new GameScoreDetailBo();
|
|
|
dbo.setDetailId(d.getDetailId());
|
|
dbo.setDetailId(d.getDetailId());
|
|
|
- dbo.setAttemptIndex(d.getAttemptIndex());
|
|
|
|
|
|
|
+ dbo.setAttemptIndex(attemptIndex.getAndIncrement());
|
|
|
dbo.setPerformanceValue(d.getNum());
|
|
dbo.setPerformanceValue(d.getNum());
|
|
|
- dbo.setFaultA(d.getShiwu());
|
|
|
|
|
return dbo;
|
|
return dbo;
|
|
|
}).toList();
|
|
}).toList();
|
|
|
scoreBo.setDetails(details);
|
|
scoreBo.setDetails(details);
|
|
@@ -657,6 +684,24 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 处理计数和排名类的成绩,转换为整数
|
|
|
|
|
+ String rawScoreRule = project.getScoreRule();
|
|
|
|
|
+ String rule = rawScoreRule != null ? rawScoreRule.trim() : "";
|
|
|
|
|
+ if ("3".equals(rule) || "4".equals(rule) || "5".equals(rule)) {
|
|
|
|
|
+ list.forEach(item -> {
|
|
|
|
|
+ if (StringUtils.isNotBlank(item.getScore())) {
|
|
|
|
|
+ item.setScore(convertToIntegerScore(item.getScore()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (item.getChengji() != null) {
|
|
|
|
|
+ item.getChengji().forEach(detail -> {
|
|
|
|
|
+ if (StringUtils.isNotBlank(detail.getNum())) {
|
|
|
|
|
+ detail.setNum(convertToIntegerScore(detail.getNum()));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -676,15 +721,17 @@ public class ToClientServiceImpl implements IToClientService {
|
|
|
scoreBo.setProjectId(score.getProjectId());
|
|
scoreBo.setProjectId(score.getProjectId());
|
|
|
scoreBo.setAthleteId(score.getAthleteId());
|
|
scoreBo.setAthleteId(score.getAthleteId());
|
|
|
scoreBo.setTeamId(score.getTeamId());
|
|
scoreBo.setTeamId(score.getTeamId());
|
|
|
|
|
+ scoreBo.setFaultA(bo.getShiwu());
|
|
|
|
|
+ scoreBo.setCompleteTime(parsePerformanceValue(bo.getYongshi()));
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(bo.getChengji())) {
|
|
if (CollectionUtils.isNotEmpty(bo.getChengji())) {
|
|
|
// 如果提交了明细列表,则优先更新明细
|
|
// 如果提交了明细列表,则优先更新明细
|
|
|
|
|
+ AtomicInteger index = new AtomicInteger(1);
|
|
|
List<GameScoreDetailBo> details = bo.getChengji().stream().map(d -> {
|
|
List<GameScoreDetailBo> details = bo.getChengji().stream().map(d -> {
|
|
|
GameScoreDetailBo dbo = new GameScoreDetailBo();
|
|
GameScoreDetailBo dbo = new GameScoreDetailBo();
|
|
|
dbo.setDetailId(d.getDetailId());
|
|
dbo.setDetailId(d.getDetailId());
|
|
|
- dbo.setAttemptIndex(d.getAttemptIndex());
|
|
|
|
|
|
|
+ dbo.setAttemptIndex(index.getAndIncrement());
|
|
|
dbo.setPerformanceValue(d.getNum());
|
|
dbo.setPerformanceValue(d.getNum());
|
|
|
- dbo.setFaultA(d.getShiwu());
|
|
|
|
|
return dbo;
|
|
return dbo;
|
|
|
}).toList();
|
|
}).toList();
|
|
|
scoreBo.setDetails(details);
|
|
scoreBo.setDetails(details);
|