| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import kotlin.random.Random; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Autowired |
| | | private ICategoryService categoryService; |
| | | @PostMapping("/storyList") |
| | | // @ApiOperation(value = "配置学习类型选择故事", tags = {"题目管理"}) |
| | | public R<PageInfo<TStory>> storyList(@RequestBody ChoiceStory query) { |
| | |
| | | QueryWrapper<TStory> wrapper = new QueryWrapper<>(); |
| | | if (StringUtils.hasLength(query.getName())) { |
| | | wrapper.like("name", query.getName()); |
| | | } |
| | | if (StringUtils.hasLength(query.getCategoryName())){ |
| | | // 查询分类id包含的 |
| | | List<Integer> collect = categoryService.lambdaQuery().eq(TCategory::getState, 2) |
| | | .eq(TCategory::getType,1) |
| | | .like(TCategory::getName, query.getCategoryName()).list() |
| | | .stream().map(TCategory::getId).collect(Collectors.toList());// 查询分类id包含的 |
| | | List<Integer> collect2 = categoryService.lambdaQuery().eq(TCategory::getState, 2) |
| | | .eq(TCategory::getType,2) |
| | | .like(TCategory::getName, query.getCategoryName()).list() |
| | | .stream().map(TCategory::getParentId).collect(Collectors.toList()); |
| | | collect.addAll(collect2); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1); |
| | | } |
| | | wrapper.in("firstCategory", collect); |
| | | } |
| | | if (StringUtils.hasLength(query.getEnglish())) { |
| | | wrapper.like("english", query.getEnglish()); |
| | |
| | | switch (query.getStoryType()) { |
| | | case 2: |
| | | List<TStory> list = storyService.list(wrapper); |
| | | List<TStory> tSubjects = new ArrayList<>(list); |
| | | res.setRecords(tSubjects); |
| | | res.setTotal(tSubjects.size()); |
| | | for (TStory tSubject : list) { |
| | | TCategory first = categoryService.getById(tSubject.getFirstCategory()); |
| | | |
| | | TCategory second = categoryService.getById(tSubject.getSecondCategory()); |
| | | if (first!=null&& second!=null){ |
| | | tSubject.setCategoryName(first.getName()+"-"+second.getName()); |
| | | } |
| | | } |
| | | res.setRecords(list); |
| | | res.setTotal(list.size()); |
| | | return R.ok(res); |
| | | case 1: |
| | | // 查询出error字段不为空的数据 |
| | | wrapper.isNotNull("error"); |
| | | List<TStory> list1 = storyService.list(wrapper); |
| | | for (TStory tStory : list1) { |
| | | if (tStory.getError() != null && (!tStory.getError().isEmpty())) { |
| | | tStories.add(tStory); |
| | | TCategory first = categoryService.getById(tStory.getFirstCategory()); |
| | | TCategory second = categoryService.getById(tStory.getSecondCategory()); |
| | | if (first!=null&& second!=null){ |
| | | tStory.setCategoryName(first.getName()+"-"+second.getName()); |
| | | } |
| | | } |
| | | res.setRecords(tStories); |
| | | res.setTotal(tStories.size()); |
| | | res.setRecords(list1); |
| | | res.setTotal(list1.size()); |
| | | return R.ok(res); |
| | | |
| | | } |
| | |
| | | if (StringUtils.hasLength(query.getName())) { |
| | | wrapper.like("name", query.getName()); |
| | | } |
| | | if (StringUtils.hasLength(query.getCategoryName())){ |
| | | // 查询分类id包含的 |
| | | List<Integer> collect = categoryService.lambdaQuery().eq(TCategory::getState, 1) |
| | | .eq(TCategory::getType,1) |
| | | .like(TCategory::getName, query.getCategoryName()).list() |
| | | .stream().map(TCategory::getId).collect(Collectors.toList());// 查询分类id包含的 |
| | | List<Integer> collect2 = categoryService.lambdaQuery().eq(TCategory::getState, 1) |
| | | .eq(TCategory::getType,2) |
| | | .like(TCategory::getName, query.getCategoryName()).list() |
| | | .stream().map(TCategory::getParentId).collect(Collectors.toList()); |
| | | collect.addAll(collect2); |
| | | if (collect.isEmpty()){ |
| | | collect.add(-1); |
| | | } |
| | | wrapper.in("firstCategory", collect); |
| | | } |
| | | if (StringUtils.hasLength(query.getEnglish())) { |
| | | wrapper.like("english", query.getEnglish()); |
| | | } |
| | |
| | | switch (query.getStudyType()) { |
| | | case 1: |
| | | List<TSubject> list = subjectService.list(wrapper); |
| | | for (TSubject tSubject : list) { |
| | | TCategory first = categoryService.getById(tSubject.getFirstCategory()); |
| | | |
| | | TCategory second = categoryService.getById(tSubject.getSecondCategory()); |
| | | |
| | | if (first!=null&&second!=null){ |
| | | tSubject.setCategoryName(first.getName()+"-"+second.getName()); |
| | | } |
| | | } |
| | | res.setRecords(list); |
| | | res.setTotal(list.size()); |
| | | return R.ok(res); |
| | |
| | | List<TSubject> list1 = subjectService.list(wrapper); |
| | | List<TSubject> tSubjects = new ArrayList<>(); |
| | | for (TSubject tSubject : list1) { |
| | | TCategory first = categoryService.getById(tSubject.getFirstCategory()); |
| | | |
| | | TCategory second = categoryService.getById(tSubject.getSecondCategory()); |
| | | |
| | | if (first!=null&&second!=null){ |
| | | tSubject.setCategoryName(first.getName()+"-"+second.getName()); |
| | | } |
| | | if (!tSubject.getError().isEmpty()) { |
| | | tSubjects.add(tSubject); |
| | | } |
| | |
| | | return R.ok(res); |
| | | case 3: |
| | | List<TSubject> list2 = subjectService.list(wrapper); |
| | | for (TSubject tSubject : list2) { |
| | | TCategory first = categoryService.getById(tSubject.getFirstCategory()); |
| | | TCategory second = categoryService.getById(tSubject.getSecondCategory()); |
| | | |
| | | if (first!=null&&second!=null){ |
| | | tSubject.setCategoryName(first.getName()+"-"+second.getName()); |
| | | } |
| | | } |
| | | res.setRecords(list2); |
| | | res.setTotal(list2.size()); |
| | | return R.ok(res); |
| | |
| | | List<TSubject> list3 = subjectService.list(wrapper); |
| | | List<TSubject> tSubjects3 = new ArrayList<>(); |
| | | for (TSubject tSubject : list3) { |
| | | TCategory first = categoryService.getById(tSubject.getFirstCategory()); |
| | | |
| | | TCategory second = categoryService.getById(tSubject.getSecondCategory()); |
| | | if (first!=null&&second!=null){ |
| | | tSubject.setCategoryName(first.getName()+"-"+second.getName()); |
| | | } |
| | | if (!tSubject.getError().isEmpty()) { |
| | | tSubjects3.add(tSubject); |
| | | } |
| | |
| | | return R.ok(res); |
| | | case 5: |
| | | List<TSubject> list4 = subjectService.list(wrapper); |
| | | for (TSubject tSubject : list4) { |
| | | TCategory first = categoryService.getById(tSubject.getFirstCategory()); |
| | | |
| | | TCategory second = categoryService.getById(tSubject.getSecondCategory()); |
| | | if (first!=null&&second!=null){ |
| | | tSubject.setCategoryName(first.getName()+"-"+second.getName()); |
| | | } |
| | | } |
| | | res.setRecords(list4); |
| | | res.setTotal(list4.size()); |
| | | return R.ok(res); |
| | |
| | | .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()); |
| | |
| | | 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()); |
| | |
| | | tStudy.setQuarter(dto.getQuarter()); |
| | | studyService.saveOrUpdate(tStudy); |
| | | } |
| | | // 每次添加周目后需要根据季度来重新排序周目 |
| | | if (dto.getType() == 1){ |
| | | List<TStudy> list1 = studyService.lambdaQuery() |
| | | .eq(TStudy::getType, 1) |
| | | .orderByAsc(TStudy::getQuarter) |
| | | .orderByAsc(TStudy::getWeek) |
| | | .list(); |
| | | int i = 1; |
| | | for (TStudy tStudy : list1) { |
| | | tStudy.setWeek(i); |
| | | i++; |
| | | } |
| | | studyService.updateBatchById(list1); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | res.setWeeks(type); |
| | | List<TStudy> list8 = studyService.list(new QueryWrapper<TStudy>() |
| | | .eq("type", dto.getType()) |
| | | .eq("week", dto.getWeek())); |
| | | .eq("week", dto.getWeek()) |
| | | .orderByAsc("quarter")); |
| | | if (!list8.isEmpty()) { |
| | | res.setQuarter(list8.get(0).getQuarter()); |
| | | res.setTitle(list8.get(0).getTitle()); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | // 学习时长更新 |
| | |
| | | |
| | | private List<String> getData(TGame game, List<String> newSubjectId, int num) { |
| | | List<String> subjectData = new ArrayList<>(); |
| | | Random random = new Random(); |
| | | java.util.Random random = new java.util.Random(); |
| | | // 获取列表大小 |
| | | int dataSize = newSubjectId.size(); |
| | | // 生成随机索引并获取数据 |