无关风月
2024-07-22 da26806f0fbc78b501d58976092cc681f786c35b
ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -278,6 +278,21 @@
                    .eq("studyId", one.getId())
                    .eq("week", week));
            if (studyId != null) {
                // 判断当前周目配置的题目数量
                List<String> subjectId = getSubjectId(week);
                List<String> newSubjectId = subjectId.stream().map(data -> {
                    if (data.startsWith(Constants.REDUCE)) {
                        data = data.replace(Constants.REDUCE, Constants.EMPTY_STR);
                    }
                    return data;
                }).distinct().collect(Collectors.toList());
                // 判断周目下题目是否足够
                if (newSubjectId.size() < game.getCount()) {
                    return R.fail("超级听力:当前周目下day1 - day5题目不足!");
                }
                if (newSubjectId.size() < game.getAnswerCount()) {
                    return R.fail("超级记忆:当前周目下day1 - day5题目不足!");
                }
                studyId.setWeek(dto.getWeek());
                studyId.setStudyId(one.getId());
                studyId.setCount(game.getCount());
@@ -290,6 +305,21 @@
                studyId.setAnswerRate(game.getAnswerRate());
                gameService.updateById(studyId);
            } else {
                // 判断当前周目配置的题目数量
                List<String> subjectId = getSubjectId(week);
                List<String> newSubjectId = subjectId.stream().map(data -> {
                    if (data.startsWith(Constants.REDUCE)) {
                        data = data.replace(Constants.REDUCE, Constants.EMPTY_STR);
                    }
                    return data;
                }).distinct().collect(Collectors.toList());
                // 判断周目下题目是否足够
                if (newSubjectId.size() < game.getCount()) {
                    return R.fail("超级听力:当前周目下day1 - day5题目不足!");
                }
                if (newSubjectId.size() < game.getAnswerCount()) {
                    return R.fail("超级记忆:当前周目下day1 - day5题目不足!");
                }
                TGame tGame = new TGame();
                tGame.setWeek(dto.getWeek());
                tGame.setAnswerRate(game.getAnswerRate());
@@ -1022,9 +1052,7 @@
                            item += studyListen.getSubject().split(",").length;
                        }
                        int i = (int) (((double) schedule / item) * 100);
                        if (i > userStudy.getListen()) {
                            userStudy.setListen(i);
                        }
                        userStudy.setListen(i);
                    }
                }
            } else if (Constants.TWO.equals(type)) {
@@ -1037,9 +1065,7 @@
                        if (!lookList.isEmpty()) {
                            int item = lookList.size();
                            int i = (int) (((double) schedule / item) * 100);
                            if (i > userStudy.getLook()) {
                                userStudy.setLook(i);
                            }
                            userStudy.setLook(i);
                        }
                    }
                }
@@ -1053,9 +1079,7 @@
                        if (!inductionList.isEmpty()) {
                            int item = inductionList.size();
                            int i = (int) (((double) schedule / item) * 100);
                            if (i > userStudy.getInduction()) {
                                userStudy.setInduction(i);
                            }
                            userStudy.setInduction(i);
                        }
                    }
                }
@@ -1068,9 +1092,7 @@
                        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()) {
                                userStudy.setAnswer(i);
                            }
                            userStudy.setAnswer(i);
                        }
                    }
                }
@@ -1084,9 +1106,7 @@
                        if (!pairList.isEmpty()) {
                            int item = pairList.size();
                            int i = (int) (((double) schedule / item) * 100);
                            if (i > userStudy.getPair()) {
                                userStudy.setPair(i);
                            }
                            userStudy.setPair(i);
                        }
                    }
                }