| | |
| | | |
| | | @Override |
| | | public int computeSchedule(TUserStudy result, Integer week) { |
| | | List<TStudy> studyList = this.lambdaQuery().eq(TStudy::getDisabled, 0) |
| | | .eq(TStudy::getType, 1) |
| | | .orderByAsc(TStudy::getWeek).list(); |
| | | // 基础学习进度 |
| | | Integer day = result.getDay(); |
| | | Integer studyWeek = result.getWeek(); |
| | | Map<Integer, List<TStudy>> studyMap = new HashMap<>(8); |
| | | for (TStudy study : studyList) { |
| | | Integer quarter = study.getQuarter(); |
| | | List<TStudy> itemList = studyMap.get(quarter); |
| | | if (null == itemList) { |
| | | itemList = new ArrayList<>(); |
| | | } |
| | | itemList.add(study); |
| | | studyMap.put(quarter, itemList); |
| | | } |
| | | // 临时判断参数 |
| | | boolean itemBool = false; |
| | | for (Map.Entry<Integer, List<TStudy>> map : studyMap.entrySet()) { |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | // 默认进度为 0 |
| | | int defaultSchedule; |
| | | // week以超过当前week,进度为 100% |
| | | if (result.getWeek() > week) { |
| | | if (itemBool) { |
| | | defaultSchedule = 100; |
| | | } else { |
| | | // 根据day初始化学习进度 |
| | |
| | | } 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); |
| | | } |
| | | |
| | | } |
| | | 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("超级听力暂未通关!"); |
| | | } |
| | | } |
| | | |
| | | } |