|
@@ -27,11 +27,12 @@ import com.yonge.cooleshow.biz.dal.vo.ActivityMusicVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.ActivityRankingVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.MusicSheetVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.activity.ActivityTeacherWrapper;
|
|
|
+import com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper;
|
|
|
import com.yonge.cooleshow.common.enums.ActivityResourceEnum;
|
|
|
import com.yonge.cooleshow.common.enums.ActivityTypeEnum;
|
|
|
import com.yonge.cooleshow.common.enums.EStatus;
|
|
|
+import com.yonge.cooleshow.common.enums.YesOrNoEnum;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -39,7 +40,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -204,17 +204,56 @@ public class ActivityEvaluationServiceImpl extends ServiceImpl<ActivityEvaluatio
|
|
|
|
|
|
@Override
|
|
|
public List<ActivityMusicVo> getActivityMusic(Long activityPlanId, Long userId) {
|
|
|
+
|
|
|
+ // 活动曲目信息
|
|
|
List<ActivityMusicVo> result = baseMapper.selectActivityMusic(activityPlanId, userId);
|
|
|
- for (ActivityMusicVo activityMusicVo : result) {
|
|
|
- List<ActivityRankingVo> rankingList = activityEvaluationRecordService.queryRankingList(activityPlanId, activityMusicVo.getEvaluationId(), 1);
|
|
|
- if (rankingList != null && rankingList.size() > 0) {
|
|
|
- activityMusicVo.setUserSubject(rankingList.get(0).getUserSubject());
|
|
|
- activityMusicVo.setScore(rankingList.get(0).getScore());
|
|
|
- activityMusicVo.setUserAvatar(rankingList.get(0).getUserAvatar());
|
|
|
- activityMusicVo.setUsername(rankingList.get(0).getUsername());
|
|
|
- activityMusicVo.setUserId(rankingList.get(0).getUserId());
|
|
|
+
|
|
|
+ // 活动信息
|
|
|
+ ActivityPlan activity = activityPlanService.getById(activityPlanId);
|
|
|
+ if (Objects.isNull(activity)) {
|
|
|
+ throw new BizException("无效的活动ID");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 评测活动
|
|
|
+ if (ActivityTypeEnum.EVALUATION == activity.getActivityType()) {
|
|
|
+
|
|
|
+
|
|
|
+ // 单曲排名,计算每一个曲目的最高分
|
|
|
+ if (ActivityRankingMethodEnum.MUSIC_RANKING == activity.getRankingMethod()) {
|
|
|
+
|
|
|
+ result.parallelStream().forEach(item -> {
|
|
|
+
|
|
|
+ List<ActivityRankingVo> rankingList = activityEvaluationRecordService.queryRankingList(activityPlanId, item.getEvaluationId(), 1);
|
|
|
+ if (rankingList != null && rankingList.size() > 0) {
|
|
|
+ item.setUserSubject(rankingList.get(0).getUserSubject());
|
|
|
+ item.setScore(rankingList.get(0).getScore());
|
|
|
+ item.setUserAvatar(rankingList.get(0).getUserAvatar());
|
|
|
+ item.setUsername(rankingList.get(0).getUsername());
|
|
|
+ item.setUserId(rankingList.get(0).getUserId());
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 总分排名
|
|
|
+ if (ActivityRankingMethodEnum.TOTAL_SCORE == activity.getRankingMethod()) {
|
|
|
+
|
|
|
+ Map<Long, Double> collect = Maps.newHashMap();
|
|
|
+ if (result.stream().anyMatch(x -> x.getJoin() == YesOrNoEnum.YES)) {
|
|
|
+
|
|
|
+ collect = getBaseMapper().selectSubjectMusicHighestScoreStat(activity.getId(), userId).stream()
|
|
|
+ .collect(Collectors.toMap(StatGroupWrapper::getId, StatGroupWrapper::getNumber, (o, n) -> n));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ActivityMusicVo item : result) {
|
|
|
+
|
|
|
+ item.setScore(collect.getOrDefault(item.getEvaluationId(), 0D));
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|