|
|
@@ -28,6 +28,7 @@ import org.dromara.system.domain.constant.GameEventConstant;
|
|
|
import org.dromara.system.domain.constant.ProjectClassification;
|
|
|
import org.dromara.system.domain.constant.SortType;
|
|
|
import org.dromara.system.domain.vo.*;
|
|
|
+import org.dromara.system.domain.vo.app.ExGameScoreVo;
|
|
|
import org.dromara.system.mapper.*;
|
|
|
import org.dromara.system.service.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -212,9 +213,9 @@ public class GameScoreServiceImpl implements IGameScoreService {
|
|
|
List<RankingBoardVO> list = baseMapper.selectRankingBoardData(eventId, projectId, classification, rgId);
|
|
|
|
|
|
// 3. 处理成绩显示格式(针对计时类进行转换)
|
|
|
- if (isTiming && list != null) {
|
|
|
+ if (list != null) {
|
|
|
for (RankingBoardVO item : list) {
|
|
|
- if (StringUtils.isNotBlank(item.getScore())) {
|
|
|
+ if (isTiming && StringUtils.isNotBlank(item.getScore())) {
|
|
|
try {
|
|
|
BigDecimal decimalScore = new BigDecimal(item.getScore());
|
|
|
String timeFormat = convertDecimalToTimeScore(decimalScore);
|
|
|
@@ -224,12 +225,104 @@ public class GameScoreServiceImpl implements IGameScoreService {
|
|
|
} catch (Exception e) {
|
|
|
log.warn("看板排名数据成绩转换失败: {}, score: {}", item.getName(), item.getScore());
|
|
|
}
|
|
|
+ }else {
|
|
|
+ BigDecimal decimalScore = new BigDecimal(item.getScore());
|
|
|
+ // 去除尾随零
|
|
|
+ String scoreStr = decimalScore.stripTrailingZeros().toPlainString();
|
|
|
+ item.setScore(scoreStr);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<ExGameScoreVo> getExRankingBoardData(Long eventId, Long projectId, String classification) {
|
|
|
+ // 1. 调用 Mapper 获取原始排名数据
|
|
|
+ List<ExGameScoreVo> list = baseMapper.selectExRankingBoardData(eventId, projectId, classification);
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 数据格式化等加工操作
|
|
|
+ for (ExGameScoreVo item : list) {
|
|
|
+ if (StringUtils.isNotBlank(item.getScore())) {
|
|
|
+ try {
|
|
|
+ BigDecimal decimalScore = new BigDecimal(item.getScore());
|
|
|
+ // 去除尾随零
|
|
|
+ String scoreStr = decimalScore.stripTrailingZeros().toPlainString();
|
|
|
+ String rule = item.getScoreRule();
|
|
|
+
|
|
|
+ if ("1".equals(rule)) {
|
|
|
+ // 计时类根据 timingFormat 计时格式进行格式化
|
|
|
+ String format = item.getTimingFormat();
|
|
|
+ if ("1".equals(format)) {
|
|
|
+ // 1---00:00.00 分:秒.毫秒 (保留两位毫秒/百分秒)
|
|
|
+ long totalSeconds = decimalScore.longValue();
|
|
|
+ BigDecimal fraction = decimalScore.subtract(BigDecimal.valueOf(totalSeconds));
|
|
|
+ long hundredths = fraction.multiply(BigDecimal.valueOf(100))
|
|
|
+ .setScale(0, java.math.RoundingMode.HALF_UP)
|
|
|
+ .longValue();
|
|
|
+ long minutes = totalSeconds / 60;
|
|
|
+ long seconds = totalSeconds % 60;
|
|
|
+ if (hundredths >= 100) {
|
|
|
+ seconds += hundredths / 100;
|
|
|
+ hundredths = hundredths % 100;
|
|
|
+ }
|
|
|
+ if (seconds >= 60) {
|
|
|
+ minutes += seconds / 60;
|
|
|
+ seconds = seconds % 60;
|
|
|
+ }
|
|
|
+ item.setScore(String.format("%02d:%02d.%02d", minutes, seconds, hundredths));
|
|
|
+ } else {
|
|
|
+ // 默认计时格式或 0---00:00:00.000 时:分:秒.毫秒
|
|
|
+ long totalSeconds = decimalScore.longValue();
|
|
|
+ BigDecimal fraction = decimalScore.subtract(BigDecimal.valueOf(totalSeconds));
|
|
|
+ long millis = fraction.multiply(BigDecimal.valueOf(1000))
|
|
|
+ .setScale(0, java.math.RoundingMode.HALF_UP)
|
|
|
+ .longValue();
|
|
|
+ long hours = totalSeconds / 3600;
|
|
|
+ long minutes = (totalSeconds % 3600) / 60;
|
|
|
+ long seconds = totalSeconds % 60;
|
|
|
+ if (millis >= 1000) {
|
|
|
+ seconds += millis / 1000;
|
|
|
+ millis = millis % 1000;
|
|
|
+ }
|
|
|
+ if (seconds >= 60) {
|
|
|
+ minutes += seconds / 60;
|
|
|
+ seconds = seconds % 60;
|
|
|
+ }
|
|
|
+ if (minutes >= 60) {
|
|
|
+ hours += minutes / 60;
|
|
|
+ minutes = minutes % 60;
|
|
|
+ }
|
|
|
+ item.setScore(String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, millis));
|
|
|
+ }
|
|
|
+ } else if ("2".equals(rule) || "6".equals(rule) || "7".equals(rule)) {
|
|
|
+ // 距离类、远度距离类、高度距离类附加 m
|
|
|
+ item.setScore(scoreStr + "m");
|
|
|
+ } else if ("3".equals(rule) || "4".equals(rule)) {
|
|
|
+ // 计数类附加项目配置的计数单位
|
|
|
+ String unit = item.getCountUnit();
|
|
|
+ if (StringUtils.isNotBlank(unit)) {
|
|
|
+ item.setScore(scoreStr + unit);
|
|
|
+ } else {
|
|
|
+ item.setScore(scoreStr);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 其他类型直接设置
|
|
|
+ item.setScore(scoreStr);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("体验端排名数据成绩转换失败: {}, score: {}", item.getName(), item.getScore());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ item.setScore("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 校验并批量删除成绩信息
|
|
|
*
|
|
|
@@ -599,8 +692,9 @@ public class GameScoreServiceImpl implements IGameScoreService {
|
|
|
String rule = project.getScoreRule();
|
|
|
|
|
|
// 1. 汇总失误次数 (通常是所有轮次的累加)
|
|
|
-// int totalFault = details.stream().mapToInt(d -> d.getFaultA() != null ? d.getFaultA() : 0).sum();
|
|
|
-// bo.setFaultA(totalFault);
|
|
|
+ // int totalFault = details.stream().mapToInt(d -> d.getFaultA() != null ?
|
|
|
+ // d.getFaultA() : 0).sum();
|
|
|
+ // bo.setFaultA(totalFault);
|
|
|
|
|
|
// 2. 汇总主成绩
|
|
|
List<BigDecimal> values = details.stream()
|