| | |
| | | // 删除已有的评分项 |
| | | activityPlayerRatingItemRepository.deleteByActivityPlayerRatingId(rating.getId()); |
| | | } else { |
| | | // 创建新的评分记录 |
| | | rating = new ActivityPlayerRating(activityId, activityPlayerId, playerId, currentJudgeId, ratingSchemeId); |
| | | // 创建新的评分记录,暂时使用1作为stageId的默认值 |
| | | rating = new ActivityPlayerRating(activityId, activityPlayerId, 1L, playerId, currentJudgeId, ratingSchemeId); |
| | | rating = activityPlayerRatingRepository.save(rating); |
| | | log.info("创建新的评分记录,ID: {}", rating.getId()); |
| | | } |
| | |
| | | |
| | | // 创建评分项记录 |
| | | ActivityPlayerRatingItem ratingItemEntity = new ActivityPlayerRatingItem( |
| | | activityId, |
| | | activityPlayerId, |
| | | rating.getId(), |
| | | 1L, // stageId,暂时使用1 |
| | | playerId, |
| | | currentJudgeId, |
| | | ratingSchemeId, |
| | | itemId, |
| | | ratingItem.getName(), |
| | | BigDecimal.ONE, // 默认权重为1 |
| | | BigDecimal.valueOf(ratingItem.getMaxScore()), |
| | | score |
| | | ); |
| | | ratingItemEntity.setRemark(input.getComment()); |
| | | |
| | | activityPlayerRatingItemRepository.save(ratingItemEntity); |
| | | |
| | | // 累加加权得分 |
| | | if (ratingItemEntity.getWeightedScore() != null) { |
| | | totalScore = totalScore.add(ratingItemEntity.getWeightedScore()); |
| | | // 累加得分 |
| | | if (score != null) { |
| | | totalScore = totalScore.add(score); |
| | | } |
| | | |
| | | log.info("保存评分项目: itemId={}, score={}, weightedScore={}", |
| | | itemId, score, ratingItemEntity.getWeightedScore()); |
| | | log.info("保存评分项目: itemId={}, score={}", |
| | | itemId, score); |
| | | } |
| | | |
| | | // 更新总分和状态 |
| | | rating.setTotalScore(totalScore); |
| | | rating.setStatus(1); // 已评分 |
| | | rating.setRemark(input.getComment()); |
| | | rating.setState(1); // 已评分 |
| | | rating.setFeedback(input.getComment()); |
| | | activityPlayerRatingRepository.save(rating); |
| | | |
| | | log.info("评分保存完成,总分: {}", totalScore); |
| | |
| | | CurrentJudgeRatingResponse response = new CurrentJudgeRatingResponse(); |
| | | response.setId(rating.getId()); |
| | | response.setTotalScore(rating.getTotalScore()); |
| | | response.setStatus(rating.getStatus()); |
| | | response.setRemark(rating.getRemark()); |
| | | response.setStatus(rating.getState()); |
| | | response.setRemark(rating.getFeedback()); |
| | | |
| | | // 获取评分项 |
| | | List<ActivityPlayerRatingItem> items = activityPlayerRatingItemRepository |
| | |
| | | List<CurrentJudgeRatingResponse.CurrentJudgeRatingItemResponse> itemResponses = items.stream() |
| | | .map(item -> new CurrentJudgeRatingResponse.CurrentJudgeRatingItemResponse( |
| | | item.getRatingItemId(), |
| | | item.getRatingItemName(), |
| | | "", // 评分项名称暂时为空 |
| | | item.getScore(), |
| | | item.getWeightedScore() |
| | | item.getScore() // 使用得分作为加权得分 |
| | | )) |
| | | .collect(java.util.stream.Collectors.toList()); |
| | | |
| | |
| | | if (ratingOpt.isPresent()) { |
| | | ActivityPlayerRating rating = ratingOpt.get(); |
| | | totalScore = rating.getTotalScore(); |
| | | status = rating.getStatus(); |
| | | status = rating.getState(); |
| | | } |
| | | |
| | | Boolean isCurrentJudge = judgeId.equals(currentJudgeId); |