无关风月
2024-07-19 9ee310626ef0f52dfb0f333783de679180092251
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -1,5 +1,4 @@
package com.ruoyi.study.controller;
import java.util.Date;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -22,7 +21,6 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.jetbrains.annotations.TestOnly;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@@ -86,7 +84,7 @@
    private ITUserPresentRecordService userPresentRecordService;
    @PostMapping("/testAddData")
        @ApiOperation(value = "测试分片", tags = {"测试分片"})
    @ApiOperation(value = "测试分片", tags = {"测试分片"})
    public R<Object> testAddData() {
        TIntegralRecord tIntegralRecord = new TIntegralRecord();
        tIntegralRecord.setIntegral("1");
@@ -146,6 +144,7 @@
        return R.ok();
    }
    @PostMapping("/storyList")
//    @ApiOperation(value = "配置学习类型选择故事", tags = {"题目管理"})
    public R<PageInfo<TStory>> storyList(@RequestBody ChoiceStory query) {
@@ -768,6 +767,22 @@
    }
    /**
     * 获取当前季度游戏难度
     */
    @GetMapping("/userGameDifficulty")
    @ApiOperation(value = "获取当前季度游戏难度", tags = {"学习端-首页"})
    public R<Integer> userGameDifficulty(@RequestParam Integer week) {
        LoginUserParent loginStudy = tokenService.getLoginUserStudy();
        if (null == loginStudy) {
            return R.tokenError("登录失效!");
        }
        Integer userid = loginStudy.getUserid();
        TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid)
                .eq(TUserStudy::getDisabled, 0).one();
        return R.ok(studyService.userGameDifficulty(studyRecord, week));
    }
    /**
     * 首次页面加载时调用,获取学习进度及学习时长等信息
     *
     * @param week 周目
@@ -996,76 +1011,75 @@
            Integer type = exitLearn.getType();
            // 更新用户学习完成率
            if (Constants.ONE.equals(type)) {
                if (1 == exitLearn.getSchedule()) {
                    userStudy.setListen(Constants.BURDEN_ONE);
                } else {
                    // 听音选图
                    List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day);
                    int item = 0;
                    for (TStudyListen studyListen : studyListens) {
                        item += studyListen.getSubject().split(",").length;
                    }
                    int i = (int) (((double) schedule / item) * 100);
                    if (i > userStudy.getListen()) {
                if (userStudy.getListen() != 100) {
                    if (1 == exitLearn.getSchedule()) {
                        userStudy.setListen(Constants.BURDEN_ONE);
                    } else {
                        // 听音选图
                        List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day);
                        int item = 0;
                        for (TStudyListen studyListen : studyListens) {
                            item += studyListen.getSubject().split(",").length;
                        }
                        int i = (int) (((double) schedule / item) * 100);
                        userStudy.setListen(i);
                    }
                }
            } else if (Constants.TWO.equals(type)) {
                if (1 == exitLearn.getSchedule()) {
                    userStudy.setLook(Constants.BURDEN_ONE);
                } else {
                    // 看图选音
                    List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day);
                    if (!lookList.isEmpty()) {
                        int item = lookList.size();
                        int i = (int) (((double) schedule / item) * 100);
                        if (i > userStudy.getLook()) {
                if (userStudy.getLook() != 100) {
                    if (1 == exitLearn.getSchedule()) {
                        userStudy.setLook(Constants.BURDEN_ONE);
                    } else {
                        // 看图选音
                        List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day);
                        if (!lookList.isEmpty()) {
                            int item = lookList.size();
                            int i = (int) (((double) schedule / item) * 100);
                            userStudy.setLook(i);
                        }
                    }
                }
            } else if (Constants.THREE.equals(type)) {
                if (1 == exitLearn.getSchedule()) {
                    userStudy.setInduction(Constants.BURDEN_ONE);
                } else {
                    // 归纳排除
                    List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day);
                    if (!inductionList.isEmpty()) {
                        int item = inductionList.size();
                        int i = (int) (((double) schedule / item) * 100);
                        if (i > userStudy.getInduction()) {
                if (userStudy.getInduction() != 100) {
                    if (1 == exitLearn.getSchedule()) {
                        userStudy.setInduction(Constants.BURDEN_ONE);
                    } else {
                        // 归纳排除
                        List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day);
                        if (!inductionList.isEmpty()) {
                            int item = inductionList.size();
                            int i = (int) (((double) schedule / item) * 100);
                            userStudy.setInduction(i);
                        }
                    }
                }
            } else if (Constants.FOUR.equals(type)) {
                if (1 == exitLearn.getSchedule()) {
                    userStudy.setAnswer(Constants.BURDEN_ONE);
                } else {
                    // 有问有答
                    List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day);
                    if (answerList.size() % Constants.TWO == Constants.ZERO) {
                        int i = (int) (((double) schedule / (answerList.size() / 2)) * 100);
                        if (i > userStudy.getAnswer()) {
                if (userStudy.getAnswer() != 100) {
                    if (1 == exitLearn.getSchedule()) {
                        userStudy.setAnswer(Constants.BURDEN_ONE);
                    } else {
                        // 有问有答
                        List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day);
                        if (answerList.size() % Constants.TWO == Constants.ZERO) {
                            int i = (int) (((double) schedule / (answerList.size() / 2)) * 100);
                            userStudy.setAnswer(i);
                        }
                    }
                }
            } else if (Constants.FIVE.equals(type)) {
                if (1 == exitLearn.getSchedule()) {
                    userStudy.setPair(Constants.BURDEN_ONE);
                } else {
                    // 音图相配
                    List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day);
                    if (!pairList.isEmpty()) {
                        int item = pairList.size();
                        int i = (int) (((double) schedule / item) * 100);
                        if (i > userStudy.getPair()) {
                if (userStudy.getPair() != 100) {
                    if (1 == exitLearn.getSchedule()) {
                        userStudy.setPair(Constants.BURDEN_ONE);
                    } else {
                        // 音图相配
                        List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day);
                        if (!pairList.isEmpty()) {
                            int item = pairList.size();
                            int i = (int) (((double) schedule / item) * 100);
                            userStudy.setPair(i);
                        }
                    }
                }
            }
        }
        // 学习时长更新
@@ -1794,6 +1808,7 @@
                .eq(TGameRecord::getDisabled, 0)
                .orderByDesc(TGameRecord::getCreateTime)
                .list();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm");
        if (null != studyRecord) {
            // 学习时长格式转换
            Integer todayStudy = studyRecord.getTodayStudy();
@@ -1806,6 +1821,9 @@
            int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum();
            Integer totalStudy = studyRecord.getTotalStudy();
            studyRecord.setTotalStudy(Math.round((float) (totalStudy) / 3600));
            for (TGameRecord tGameRecord : gameRecordList) {
                tGameRecord.setTime(simpleDateFormat.format(tGameRecord.getCreateTime()));
            }
            // 剩余周目
            List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0)
                    .eq(TStudy::getType, Constants.ONE)
@@ -1902,7 +1920,7 @@
    @GetMapping("/getIntegral")
    @ApiOperation(value = "获取剩余积分", tags = {"家长端-获取剩余积分"})
    public R<Integer> getIntegral() {
        if (tokenService.getLoginUser1() == null){
        if (tokenService.getLoginUser1() == null) {
            return R.tokenError("登录失效");
        }
        Integer userId = tokenService.getLoginUser1().getUserid();