| | |
| | | Integer id = item.getId(); |
| | | // 计算总积分 |
| | | int total = 0; |
| | | List<Integer> dayList = new ArrayList<>(); |
| | | // 有问有答 |
| | | List<TStudyAnswer> answerList = studyAnswerService.lambdaQuery().eq(TStudyAnswer::getStudyId, id) |
| | | .eq(TStudyAnswer::getDisabled, 0).list(); |
| | | Optional<TStudyAnswer> answerOptional = answerList.stream().findAny(); |
| | | if (answerOptional.isPresent()) { |
| | | total += answerOptional.get().getIntegral(); |
| | | for (TStudyAnswer data : answerList) { |
| | | Integer day = data.getDay(); |
| | | if (!dayList.contains(day)) { |
| | | total += data.getIntegral(); |
| | | dayList.add(day); |
| | | } |
| | | } |
| | | dayList.clear(); |
| | | // 归纳判断 |
| | | List<TStudyInduction> inductionList = studyInductionService.lambdaQuery().eq(TStudyInduction::getStudyId, id) |
| | | .eq(TStudyInduction::getDisabled, 0).list(); |
| | | Optional<TStudyInduction> inductionOptional = inductionList.stream().findAny(); |
| | | if (inductionOptional.isPresent()) { |
| | | total += inductionOptional.get().getIntegral(); |
| | | for (TStudyInduction data : inductionList) { |
| | | Integer day = data.getDay(); |
| | | if (!dayList.contains(day)) { |
| | | total += data.getIntegral(); |
| | | dayList.add(day); |
| | | } |
| | | } |
| | | dayList.clear(); |
| | | // 看图选音 |
| | | List<TStudyLook> lookList = studyLookService.lambdaQuery().eq(TStudyLook::getStudyId, id) |
| | | .eq(TStudyLook::getDisabled, 0).list(); |
| | | Optional<TStudyLook> lookOptional = lookList.stream().findAny(); |
| | | if (lookOptional.isPresent()) { |
| | | total += lookOptional.get().getIntegral(); |
| | | for (TStudyLook data : lookList) { |
| | | Integer day = data.getDay(); |
| | | if (!dayList.contains(day)) { |
| | | total += data.getIntegral(); |
| | | dayList.add(day); |
| | | } |
| | | } |
| | | dayList.clear(); |
| | | // 听音选图 |
| | | List<TStudyListen> listenList = studyListenService.lambdaQuery().eq(TStudyListen::getStudyId, id) |
| | | .eq(TStudyListen::getDisabled, 0).list(); |
| | | Optional<TStudyListen> listenOptional = listenList.stream().findAny(); |
| | | if (listenOptional.isPresent()) { |
| | | total += listenOptional.get().getIntegral(); |
| | | for (TStudyListen data : listenList) { |
| | | Integer day = data.getDay(); |
| | | if (!dayList.contains(day)) { |
| | | total += data.getIntegral(); |
| | | dayList.add(day); |
| | | } |
| | | } |
| | | dayList.clear(); |
| | | // 音图相配 |
| | | List<TStudyPair> pairList = studyPairService.lambdaQuery().eq(TStudyPair::getStudyId, id) |
| | | .eq(TStudyPair::getDisabled, 0).list(); |
| | | Optional<TStudyPair> pairOptional = pairList.stream().findAny(); |
| | | if (pairOptional.isPresent()) { |
| | | total += pairOptional.get().getIntegral(); |
| | | for (TStudyPair data : pairList) { |
| | | Integer day = data.getDay(); |
| | | if (!dayList.contains(day)) { |
| | | total += data.getIntegral(); |
| | | dayList.add(day); |
| | | } |
| | | } |
| | | dayList.clear(); |
| | | // 自主游戏 |
| | | List<TGame> gameList = gameService.lambdaQuery().eq(TGame::getStudyId, id) |
| | | .eq(TGame::getDisabled, 0).list(); |
| | |
| | | } |
| | | // 临时判断参数 |
| | | boolean itemBool = false; |
| | | // 学习进度所属季度 |
| | | int studyQuarter = 1; |
| | | // 当前进入周目所属季度 |
| | | int thisQuarter = 1; |
| | | for (Map.Entry<Integer, List<TStudy>> map : studyMap.entrySet()) { |
| | | Integer key = map.getKey(); |
| | | List<TStudy> list = map.getValue(); |
| | | List<Integer> collect = list.stream().map(TStudy::getWeek).collect(Collectors.toList()); |
| | | if (collect.contains(studyWeek)) { |
| | | int i = collect.indexOf(studyWeek); |
| | | if (collect.contains(week)) { |
| | | int x = collect.indexOf(week); |
| | | itemBool = i > x; |
| | | } |
| | | studyQuarter = key; |
| | | } |
| | | if (collect.contains(week)) { |
| | | thisQuarter = key; |
| | | } |
| | | } |
| | | // 默认进度为 0 |
| | | int defaultSchedule; |
| | | // 季度判断 |
| | | if (studyQuarter > thisQuarter) { |
| | | defaultSchedule = 100; |
| | | } else if (studyQuarter < thisQuarter) { |
| | | defaultSchedule = 0; |
| | | } else { |
| | | List<TStudy> tStudies = studyMap.get(studyQuarter); |
| | | List<Integer> weekList = tStudies.stream().map(TStudy::getWeek).collect(Collectors.toList()); |
| | | int studyIndex = weekList.indexOf(studyWeek); |
| | | int weekIndex = weekList.indexOf(week); |
| | | if (studyIndex > weekIndex) { |
| | | defaultSchedule = 100; |
| | | } else if (studyIndex < weekIndex) { |
| | | defaultSchedule = 0; |
| | | } else { |
| | | // 根据day初始化学习进度 |
| | | if (Constants.ONE.equals(day)) { |
| | | defaultSchedule = 0; |
| | | } else if (Constants.TWO.equals(day)) { |
| | | defaultSchedule = 20; |
| | | } else if (Constants.THREE.equals(day)) { |
| | | defaultSchedule = 40; |
| | | } else if (Constants.FOUR.equals(day)) { |
| | | defaultSchedule = 60; |
| | | } else if (Constants.FIVE.equals(day)) { |
| | | defaultSchedule = 80; |
| | | } else { |
| | | defaultSchedule = 0; |
| | | } |
| | | // 根据五种学习计算进度 |
| | | Integer listen = result.getListen(); |
| | | if (!Constants.BURDEN_ONE.equals(listen)) { |
| | | defaultSchedule += (int) (((double) listen / 100) * 4); |
| | | } |
| | | Integer look = result.getLook(); |
| | | if (!Constants.BURDEN_ONE.equals(look)) { |
| | | defaultSchedule += (int) (((double) look / 100) * 4); |
| | | } |
| | | Integer induction = result.getInduction(); |
| | | if (!Constants.BURDEN_ONE.equals(induction)) { |
| | | defaultSchedule += (int) (((double) induction / 100) * 4); |
| | | } |
| | | Integer answer = result.getAnswer(); |
| | | if (!Constants.BURDEN_ONE.equals(answer)) { |
| | | defaultSchedule += (int) (((double) answer / 100) * 4); |
| | | } |
| | | Integer pair = result.getPair(); |
| | | if (!Constants.BURDEN_ONE.equals(pair)) { |
| | | defaultSchedule += (int) (((double) pair / 100) * 4); |
| | | } |
| | | } |
| | | } |
| | | // week以超过当前week,进度为 100% |
| | | if (itemBool) { |
| | | /*if (itemBool) { |
| | | defaultSchedule = 100; |
| | | } else { |
| | | // 根据day初始化学习进度 |
| | |
| | | // 根据五种学习计算进度 |
| | | Integer listen = result.getListen(); |
| | | if (!Constants.BURDEN_ONE.equals(listen)) { |
| | | defaultSchedule += (int)(((double)listen / 100) * 4); |
| | | defaultSchedule += (int) (((double) listen / 100) * 4); |
| | | } |
| | | Integer look = result.getLook(); |
| | | if (!Constants.BURDEN_ONE.equals(look)) { |
| | | defaultSchedule += (int)(((double)look / 100) * 4); |
| | | defaultSchedule += (int) (((double) look / 100) * 4); |
| | | } |
| | | Integer induction = result.getInduction(); |
| | | if (!Constants.BURDEN_ONE.equals(induction)) { |
| | | defaultSchedule += (int)(((double)induction / 100) * 4); |
| | | defaultSchedule += (int) (((double) induction / 100) * 4); |
| | | } |
| | | Integer answer = result.getAnswer(); |
| | | if (!Constants.BURDEN_ONE.equals(answer)) { |
| | | defaultSchedule += (int)(((double)answer / 100) * 4); |
| | | defaultSchedule += (int) (((double) answer / 100) * 4); |
| | | } |
| | | Integer pair = result.getPair(); |
| | | if (!Constants.BURDEN_ONE.equals(pair)) { |
| | | defaultSchedule += (int)(((double)pair / 100) * 4); |
| | | defaultSchedule += (int) (((double) pair / 100) * 4); |
| | | } |
| | | |
| | | } |
| | | }*/ |
| | | return defaultSchedule; |
| | | } |
| | | |
| | |
| | | return studyList.size() - residueWeek; |
| | | } |
| | | |
| | | @Override |
| | | public void checkClearance(TGame game, Integer userid) { |
| | | String rate = game.getRate().split(",")[Constants.TWO]; |
| | | // 获取用户游戏进度 |
| | | List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userid) |
| | | .eq(TGameRecord::getGameId, game.getId()) |
| | | .ge(TGameRecord::getAccuracy, rate) |
| | | .eq(TGameRecord::getGameDifficulty, Constants.TWO).list(); |
| | | if (list.isEmpty()) { |
| | | throw new GlobalException("超级听力暂未通关!"); |
| | | } |
| | | } |
| | | |
| | | } |