| | |
| | | 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 = false; |
| | | Boolean hasRated = ratingCount != null && ratingCount > 0; // 评审次数>0表示已评审 |
| | | String ratingTime = null; |
| | | BigDecimal totalScore = null; |
| | | |
| | | // 如果已评分,获取最新的评分记录 |
| | | if (hasRated) { |
| | | Optional<ActivityPlayerRating> ratingOpt = activityPlayerRatingRepository |
| | | .findByActivityPlayerIdAndJudgeId(activityPlayerId, judgeId); |
| | | |
| | | if (ratingOpt.isPresent()) { |
| | | ActivityPlayerRating rating = ratingOpt.get(); |
| | | hasRated = rating.getState() != null && rating.getState() == 1; // 使用state判断是否已评分 |
| | | totalScore = rating.getTotalScore(); |
| | | if (rating.getUpdateTime() != null) { |
| | | ratingTime = rating.getUpdateTime().toString(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return new JudgeRatingStatusResponse(judgeId, judgeName, hasRated, ratingTime, totalScore); |
| | | }).collect(java.util.stream.Collectors.toList()); |