From 770de42c8bbb10676663f33e2748c733c993d27b Mon Sep 17 00:00:00 2001 From: hjl <1657978663@qq.com> Date: 星期四, 20 六月 2024 15:28:42 +0800 Subject: [PATCH] fix: 学习端bug --- ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java | 97 ++++++++++++++++++++++++++++++++++-------------- 1 files changed, 68 insertions(+), 29 deletions(-) diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java index 57d48e6..d35dab6 100644 --- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java +++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java @@ -751,7 +751,11 @@ @ApiImplicitParam(value = "季度 首次进入季度quarter默认传1", name = "quarter", dataType = "Integer", required = true) }) public R<List<StudyWeekDTO>> weekList(@RequestParam(defaultValue = "1") Integer type, @RequestParam Integer quarter) { - List<StudyWeekDTO> result = studyService.weekList(type, quarter); + LoginUserParent loginUserStudy = tokenService.getLoginUserStudy(); + if (null == loginUserStudy) { + return R.tokenError("登录失效!"); + } + List<StudyWeekDTO> result = studyService.weekList(type, quarter,loginUserStudy.getUserid()); return R.ok(result); } @@ -850,28 +854,63 @@ 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; 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 = (int) ((double) (exitLearn.getTopicIds().split(",").length / item) * 100); + 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 = (int) ((double) (exitLearn.getSchedule() / item)) * 100; + 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 = (int) ((double) (exitLearn.getSchedule() / item)) * 100; + 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 = (int) ((double) (exitLearn.getSchedule() / (answerList.size() / 2))) * 100; + 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 = (int) ((double) (exitLearn.getSchedule() / item)) * 100; + if (i > userStudy.getPair()) { + userStudy.setPair(100 - i); + } } } // 学习时长更新 @@ -903,7 +942,7 @@ // 非会员只能查看非会员题目,会员可以查看所有题目 List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day); for (TStudyListen studyListen : studyListens) { - if (studyListen.getIsVip() == 1) { + if (studyListen.getIsVip() == 0) { // 需要会员查看 if (!isVip) { // 不是会员 @@ -934,7 +973,7 @@ // 非会员只能查看非会员题目,会员可以查看所有题目 List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day); for (TStudyLook studyListen : lookList) { - if (studyListen.getIsVip() == 1) { + if (studyListen.getIsVip() == 0) { // 需要会员查看 if (!isVip) { // 不是会员 @@ -965,7 +1004,7 @@ // 非会员只能查看非会员题目,会员可以查看所有题目 List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day); for (TStudyInduction studyListen : inductionList) { - if (studyListen.getIsVip() == 1) { + if (studyListen.getIsVip() == 0) { // 需要会员查看 if (!isVip) { // 不是会员 @@ -996,7 +1035,7 @@ // 非会员只能查看非会员题目,会员可以查看所有题目 List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day); for (TStudyAnswer studyListen : answerList) { - if (studyListen.getIsVip() == 1) { + if (studyListen.getIsVip() == 0) { // 需要会员查看 if (!isVip) { // 不是会员 @@ -1027,7 +1066,7 @@ // 非会员只能查看非会员题目,会员可以查看所有题目 List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day); for (TStudyPair pair : pairList) { - if (pair.getIsVip() == 1) { + if (pair.getIsVip() == 0) { // 需要会员查看 if (!isVip) { // 不是会员 @@ -1279,6 +1318,17 @@ user.setIntegral(user.getIntegral() + availableIntegral); add = add && userService.updateById(user); } + // 学习时长更新 + TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid) + .eq(TUserStudy::getDisabled, 0).one(); + 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); // 超级记忆逻辑 if (Constants.MEMORY.equals(completeStudy.getGameName())) { // 学习配置列表 @@ -1296,17 +1346,6 @@ String rate = game.getRate().split(",")[completeStudy.getDifficulty()]; add = add && completeStudy.getAccuracy() >= Integer.parseInt(rate); } - // 学习时长更新 - TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid) - .eq(TUserStudy::getDisabled, 0).one(); - 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); } -- Gitblit v1.7.1