| | |
| | | Long judgeId = ((Number) row.get("id")).longValue(); |
| | | String judgeName = (String) row.get("name"); |
| | | |
| | | // 查找该评委的评分 |
| | | Optional<ActivityPlayerRating> ratingOpt = activityPlayerRatingRepository |
| | | .findByActivityPlayerIdAndJudgeId(activityPlayerId, judgeId); |
| | | // 查找该评委的评分记录数量(从t_activity_player_rating表按activity_player_id和judge_id查询) |
| | | String ratingCountSql = "SELECT COUNT(*) FROM t_activity_player_rating WHERE activity_player_id = ? AND judge_id = ?"; |
| | | Integer ratingCount = jdbcTemplate.queryForObject(ratingCountSql, Integer.class, activityPlayerId, judgeId); |
| | | |
| | | Boolean hasRated = ratingCount != null && ratingCount > 0; // 评审次数>0表示已评审 |
| | | String ratingTime = null; |
| | | BigDecimal totalScore = null; |
| | | Integer status = 0; |
| | | |
| | | if (ratingOpt.isPresent()) { |
| | | ActivityPlayerRating rating = ratingOpt.get(); |
| | | totalScore = rating.getTotalScore(); |
| | | status = rating.getState(); |
| | | // 如果已评分,获取最新的评分记录 |
| | | if (hasRated) { |
| | | Optional<ActivityPlayerRating> ratingOpt = activityPlayerRatingRepository |
| | | .findByActivityPlayerIdAndJudgeId(activityPlayerId, judgeId); |
| | | |
| | | if (ratingOpt.isPresent()) { |
| | | ActivityPlayerRating rating = ratingOpt.get(); |
| | | totalScore = rating.getTotalScore(); |
| | | if (rating.getUpdateTime() != null) { |
| | | ratingTime = rating.getUpdateTime().toString(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Boolean isCurrentJudge = judgeId.equals(currentJudgeId); |
| | | |
| | | return new JudgeRatingStatusResponse(judgeId, judgeName, totalScore, status, isCurrentJudge); |
| | | return new JudgeRatingStatusResponse(judgeId, judgeName, hasRated, ratingTime, totalScore); |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | } |
| | | |