| | |
| | | // 学习记录 |
| | | TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId) |
| | | .eq(TUserStudy::getDisabled, 0).one(); |
| | | // 查询剩余周目 |
| | | if (studyRecord != null) { |
| | | int size = studyService.list(new QueryWrapper<TStudy>() |
| | | .eq("type", 1)).size(); |
| | | studyRecord.setSurplus(size - studyRecord.getWeek()); |
| | | } else { |
| | | TUserStudy tUserStudy = new TUserStudy(); |
| | | tUserStudy.setSurplus(studyService.list(new QueryWrapper<TStudy>() |
| | | .eq("type", 1)).size()); |
| | | tUserStudy.setTodayStudy(Constants.ZERO); |
| | | tUserStudy.setTotalStudy(Constants.ZERO); |
| | | tUserStudy.setWeekStudy(Constants.ZERO); |
| | | tUserStudy.setMonthStudy(Constants.ZERO); |
| | | studyRecord = tUserStudy; |
| | | } |
| | | // 学习时长格式转换 |
| | | 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)); |
| | | List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery() |
| | | .eq(TGameRecord::getUserId, userId) |
| | | .eq(TGameRecord::getDisabled, 0) |
| | | .orderByDesc(TGameRecord::getCreateTime) |
| | | .list(); |
| | | 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)); |
| | | // 剩余周目 |
| | | List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0) |
| | | .eq(TStudy::getType, Constants.ONE) |
| | | .orderByAsc(TStudy::getWeek).list(); |
| | | int size = studyService.residueWeek(studyRecord, studyList); |
| | | studyRecord.setSurplus(size); |
| | | } |
| | | return R.ok(new StudyRecordResultVO(studyRecord, gameRecordList)); |
| | | } |
| | | |