| | |
| | | .collect(Collectors.toList()); |
| | | result = new SubjectRecordResultVO(teamIds, topicIds, subjectRecord.getAnswerNumber(), subjectRecord.getCorrectNumber()); |
| | | } else { |
| | | result = new SubjectRecordResultVO(); |
| | | result = null; |
| | | } |
| | | subjectRecordService.lambdaUpdate().set(TSubjectRecord::getDisabled, 0) |
| | | .eq(TSubjectRecord::getUserId, loginStudy.getUserid()).update(); |
| | |
| | | TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid) |
| | | .eq(TUserStudy::getDisabled, 0).one(); |
| | | if (null == userStudy) { |
| | | throw new GlobalException("登录用户学习记录不存在!"); |
| | | userStudy = createUserStudy(userid); |
| | | } |
| | | Integer quarter = exitLearn.getQuarter(); |
| | | Integer week = exitLearn.getWeek(); |
| | | Integer day = exitLearn.getDay(); |
| | | if (userStudy.getWeek().equals(exitLearn.getWeek()) && userStudy.getDay().equals(exitLearn.getDay())) { |
| | | // 计算完成率 |
| | | int completionRate = exitLearn.getTopicIds().split(",").length * 5; |
| | | List<String> teamList = Arrays.stream(exitLearn.getTeamIds().split(",")).collect(Collectors.toList()); |
| | | Integer type = exitLearn.getType(); |
| | | // 更新用户学习完成率 |
| | | if (Constants.ONE.equals(type) && userStudy.getListen() < completionRate) { |
| | | if (Constants.ONE.equals(type)) { |
| | | // 听音选图 |
| | | userStudy.setListen(completionRate); |
| | | } else if (Constants.TWO.equals(type) && userStudy.getLook() < completionRate) { |
| | | List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day); |
| | | int item = 0; |
| | | for (TStudyListen studyListen : studyListens) { |
| | | item += studyListen.getSubject().split(",").length; |
| | | } |
| | | int i = exitLearn.getTopicIds().split(",").length / item; |
| | | if (i > userStudy.getListen()) { |
| | | userStudy.setListen(100 - i); |
| | | } |
| | | } else if (Constants.TWO.equals(type)) { |
| | | // 看图选音 |
| | | userStudy.setLook(completionRate); |
| | | } else if (Constants.THREE.equals(type) && userStudy.getInduction() < completionRate) { |
| | | List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day); |
| | | if (!lookList.isEmpty()) { |
| | | int item = lookList.size(); |
| | | int i = exitLearn.getSchedule() / item; |
| | | if (i > userStudy.getLook()) { |
| | | userStudy.setLook(100 - i); |
| | | } |
| | | } |
| | | } else if (Constants.THREE.equals(type)) { |
| | | // 归纳排除 |
| | | userStudy.setInduction(completionRate); |
| | | } else if (Constants.FOUR.equals(type) && userStudy.getAnswer() < completionRate) { |
| | | List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day); |
| | | if (!inductionList.isEmpty()) { |
| | | int item = inductionList.size(); |
| | | int i = exitLearn.getSchedule() / item; |
| | | if (i > userStudy.getInduction()) { |
| | | userStudy.setInduction(100 - i); |
| | | } |
| | | } |
| | | } else if (Constants.FOUR.equals(type)) { |
| | | // 有问有答 |
| | | userStudy.setAnswer(completionRate); |
| | | } else if (Constants.FIVE.equals(type) && userStudy.getPair() < completionRate) { |
| | | List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day); |
| | | if (answerList.size() % Constants.TWO == Constants.ZERO) { |
| | | int i = exitLearn.getSchedule() / (answerList.size() / 2); |
| | | if (i > userStudy.getAnswer()) { |
| | | userStudy.setAnswer(100 - i); |
| | | } |
| | | } |
| | | } else if (Constants.FIVE.equals(type)) { |
| | | // 音图相配 |
| | | userStudy.setPair(completionRate); |
| | | List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day); |
| | | int item = pairList.size(); |
| | | int i = exitLearn.getSchedule() / item; |
| | | if (i > userStudy.getPair()) { |
| | | userStudy.setPair(100 - i); |
| | | } |
| | | } |
| | | } |
| | | // 学习时长更新 |
| | |
| | | record.setType(Constants.ZERO); |
| | | update = update && studyRecordService.save(record); |
| | | } |
| | | // 学习配置列表 |
| | | List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0) |
| | | .orderByAsc(TStudy::getWeek).list(); |
| | | if (studyList.isEmpty()) { |
| | | throw new GlobalException("学习配置列表未配置或数据失效!"); |
| | | } |
| | | // 更改学习记录 |
| | | Boolean updateStudyRecord = userStudyService.exchangeStudyRecord(studyList, userId, completeStudy); |
| | | TUserStudy userStudyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId) |
| | | .eq(TUserStudy::getDisabled, 0).one(); |
| | | if (null == userStudyRecord) { |
| | | userStudyRecord = createUserStudy(userId); |
| | | } |
| | | Boolean updateStudyRecord = userStudyService.exchangeStudyRecord(userStudyRecord, userId, completeStudy); |
| | | return R.ok(update && updateStudyRecord); |
| | | } |
| | | |
| | |
| | | // 学习时长更新 |
| | | TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid) |
| | | .eq(TUserStudy::getDisabled, 0).one(); |
| | | userStudy.setTotalStudy(userStudy.getTotalStudy() + completeStudy.getUseTime()); |
| | | userStudy.setTodayStudy(userStudy.getTodayStudy() + completeStudy.getUseTime()); |
| | | userStudy.setWeekStudy(userStudy.getWeekStudy() + completeStudy.getUseTime()); |
| | | userStudy.setMonthStudy(userStudy.getMonthStudy() + completeStudy.getUseTime()); |
| | | if (null == userStudy) { |
| | | userStudy = createUserStudy(userid); |
| | | userStudy.setTotalStudy(userStudy.getTotalStudy() + completeStudy.getUseTime()); |
| | | userStudy.setTodayStudy(userStudy.getTodayStudy() + completeStudy.getUseTime()); |
| | | userStudy.setWeekStudy(userStudy.getWeekStudy() + completeStudy.getUseTime()); |
| | | userStudy.setMonthStudy(userStudy.getMonthStudy() + completeStudy.getUseTime()); |
| | | } |
| | | boolean update = userStudyService.updateById(userStudy); |
| | | return R.ok(add && update); |
| | | } |
| | | |
| | | private TUserStudy createUserStudy(Integer userid) { |
| | | TUserStudy userStudy = new TUserStudy(); |
| | | userStudy.setUserId(userid); |
| | | // 学习周目 |
| | | TStudy tStudy = studyService.lambdaQuery().eq(TStudy::getQuarter, Constants.ONE) |
| | | .orderByAsc(TStudy::getWeek).last("limit 1").one(); |
| | | userStudy.setWeek(tStudy.getWeek()); |
| | | userStudy.setDay(Constants.ONE); |
| | | userStudy.setTotalStudy(Constants.ZERO); |
| | | userStudy.setTodayStudy(Constants.ZERO); |
| | | userStudy.setWeekStudy(Constants.ZERO); |
| | | userStudy.setMonthStudy(Constants.ZERO); |
| | | userStudy.setListen(Constants.BURDEN_ONE); |
| | | userStudy.setLook(Constants.BURDEN_ONE); |
| | | userStudy.setInduction(Constants.BURDEN_ONE); |
| | | userStudy.setAnswer(Constants.BURDEN_ONE); |
| | | userStudy.setPair(Constants.BURDEN_ONE); |
| | | userStudyService.save(userStudy); |
| | | return userStudy; |
| | | } |
| | | |
| | | private List<String> getSubjectId(Integer week) { |
| | |
| | | // 学习时长更新 |
| | | TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId) |
| | | .eq(TUserStudy::getDisabled, 0).one(); |
| | | userStudy.setTotalStudy(userStudy.getTotalStudy() + studyTime); |
| | | userStudy.setTodayStudy(userStudy.getTodayStudy() + studyTime); |
| | | userStudy.setWeekStudy(userStudy.getWeekStudy() + studyTime); |
| | | userStudy.setMonthStudy(userStudy.getMonthStudy() + studyTime); |
| | | if (null == userStudy) { |
| | | userStudy = createUserStudy(userId); |
| | | userStudy.setTotalStudy(userStudy.getTotalStudy() + studyTime); |
| | | userStudy.setTodayStudy(userStudy.getTodayStudy() + studyTime); |
| | | userStudy.setWeekStudy(userStudy.getWeekStudy() + studyTime); |
| | | userStudy.setMonthStudy(userStudy.getMonthStudy() + studyTime); |
| | | } |
| | | boolean update = userStudyService.updateById(userStudy); |
| | | if (!update) { |
| | | throw new GlobalException("学习时长更新失败!"); |
| | |
| | | // 学习记录 |
| | | TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId) |
| | | .eq(TUserStudy::getDisabled, 0).one(); |
| | | // 学习时长格式转换 |
| | | Integer todayStudy = studyRecord.getTodayStudy(); |
| | | studyRecord.setTodayStudy(Math.round((float) todayStudy / 3600)); |
| | | Integer weekStudy = studyRecord.getWeekStudy(); |
| | | studyRecord.setWeekStudy(Math.round((float) weekStudy / 3600)); |
| | | Integer monthStudy = studyRecord.getMonthStudy(); |
| | | studyRecord.setMonthStudy(Math.round((float) monthStudy / 3600)); |
| | | // 总时长还需计算上游戏测试成绩时长 |
| | | List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId) |
| | | .eq(TGameRecord::getDisabled, 0).list(); |
| | | int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum(); |
| | | Integer totalStudy = studyRecord.getTotalStudy(); |
| | | studyRecord.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600)); |
| | | // 剩余周目 |
| | | int size = studyService.list(new QueryWrapper<TStudy>() |
| | | .eq("type", 1)).size(); |
| | | studyRecord.setSurplus(size - studyRecord.getWeek()); |
| | | if (null != studyRecord) { |
| | | // 学习时长格式转换 |
| | | Integer todayStudy = studyRecord.getTodayStudy(); |
| | | studyRecord.setTodayStudy(Math.round((float) todayStudy / 3600)); |
| | | Integer weekStudy = studyRecord.getWeekStudy(); |
| | | studyRecord.setWeekStudy(Math.round((float) weekStudy / 3600)); |
| | | Integer monthStudy = studyRecord.getMonthStudy(); |
| | | studyRecord.setMonthStudy(Math.round((float) monthStudy / 3600)); |
| | | // 游戏总时长 |
| | | int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum(); |
| | | Integer totalStudy = studyRecord.getTotalStudy(); |
| | | studyRecord.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600)); |
| | | // 剩余周目 |
| | | int size = studyService.list(new QueryWrapper<TStudy>() |
| | | .eq("type", 1)).size(); |
| | | studyRecord.setSurplus(size - studyRecord.getWeek()); |
| | | } |
| | | return R.ok(new StudyRecordResultVO(studyRecord, gameRecordList)); |
| | | } |
| | | |
| | |
| | | integralRecord.setUpdateTime(new Date()); |
| | | return R.ok(integralRecordService.save(integralRecord)); |
| | | } |
| | | |
| | | @GetMapping("/addIntegralDetailParent") |
| | | // @ApiOperation(value = "添加-积分明细", tags = {"添加-积分明细"}) |
| | | @ApiImplicitParams({ |
| | |
| | | } |
| | | return R.ok(userService.updateById(user)); |
| | | } |
| | | |
| | | @GetMapping("/exchangeIntegralParent") |
| | | // @ApiOperation(value = "用户积分变动", tags = {"用户积分变动"}) |
| | | public R<Boolean> exchangeIntegralParent(@RequestParam("integral") Integer integral, @RequestParam("method") String method) { |
| | | if (tokenService.getLoginUser1()==null){ |
| | | if (tokenService.getLoginUser1() == null) { |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | TUser user = userService.getById(tokenService.getLoginUser1().getUserid()); |