| | |
| | | // 获取评分项 |
| | | List<ActivityPlayerRatingItem> items = activityPlayerRatingItemRepository |
| | | .findByActivityPlayerRatingId(rating.getId()); |
| | | |
| | | List<CurrentJudgeRatingResponse.CurrentJudgeRatingItemResponse> itemResponses = items.stream() |
| | | .map(item -> new CurrentJudgeRatingResponse.CurrentJudgeRatingItemResponse( |
| | | item.getRatingItemId(), |
| | | "", // 评分项名称暂时为空 |
| | | item.getScore(), |
| | | item.getScore() // 使用得分作为加权得分 |
| | | )) |
| | | |
| | | List<Long> ratingItemIds = items.stream() |
| | | .map(ActivityPlayerRatingItem::getRatingItemId) |
| | | .filter(java.util.Objects::nonNull) |
| | | .distinct() |
| | | .collect(java.util.stream.Collectors.toList()); |
| | | |
| | | |
| | | java.util.Map<Long, RatingItem> ratingItemMap = ratingItemIds.isEmpty() |
| | | ? java.util.Collections.emptyMap() |
| | | : ratingItemRepository.findAllById(ratingItemIds).stream() |
| | | .collect(java.util.stream.Collectors.toMap(RatingItem::getId, java.util.function.Function.identity())); |
| | | |
| | | List<CurrentJudgeRatingResponse.CurrentJudgeRatingItemResponse> itemResponses = items.stream() |
| | | .map(item -> { |
| | | RatingItem ratingItem = ratingItemMap.get(item.getRatingItemId()); |
| | | String name = ratingItem != null ? ratingItem.getName() : ""; |
| | | BigDecimal maxScore = ratingItem != null && ratingItem.getMaxScore() != null |
| | | ? BigDecimal.valueOf(ratingItem.getMaxScore()) : null; |
| | | return new CurrentJudgeRatingResponse.CurrentJudgeRatingItemResponse( |
| | | item.getRatingItemId(), |
| | | name, |
| | | item.getScore(), |
| | | item.getScore(), |
| | | maxScore |
| | | ); |
| | | }) |
| | | .collect(java.util.stream.Collectors.toList()); |
| | | |
| | | response.setRatedAt(rating.getUpdateTime() != null ? rating.getUpdateTime().toString() : null); |
| | | response.setItems(itemResponses); |
| | | return response; |
| | | } |
| | |
| | | ((Number) row.get("rating_item_id")).longValue(), |
| | | (String) row.get("rating_item_name"), |
| | | (BigDecimal) row.get("score"), |
| | | (BigDecimal) row.get("score") // weightedScore 暂时使用相同值 |
| | | (BigDecimal) row.get("score"), |
| | | row.get("max_score") instanceof BigDecimal |
| | | ? (BigDecimal) row.get("max_score") |
| | | : row.get("max_score") instanceof Number |
| | | ? BigDecimal.valueOf(((Number) row.get("max_score")).doubleValue()) |
| | | : null |
| | | )) |
| | | .collect(java.util.stream.Collectors.toList()); |
| | | |
| | |
| | | response.setTotalScore(rating.getTotalScore()); |
| | | response.setStatus(rating.getState()); |
| | | response.setRemark(rating.getFeedback()); |
| | | response.setRatedAt(rating.getUpdateTime() != null ? rating.getUpdateTime().toString() : null); |
| | | response.setItems(items); |
| | | |
| | | return response; |
| | |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | | } |