|  |  |  | 
|---|
|  |  |  | package com.ruoyi.study.controller; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.ruoyi.common.core.constant.Constants; | 
|---|
|  |  |  | import com.ruoyi.common.core.domain.R; | 
|---|
|  |  |  | import com.ruoyi.common.core.exception.GlobalException; | 
|---|
|  |  |  | import com.ruoyi.common.core.web.domain.BaseModel; | 
|---|
|  |  |  | import com.ruoyi.common.core.web.page.PageInfo; | 
|---|
|  |  |  | import com.ruoyi.common.security.service.TokenService; | 
|---|
|  |  |  | import com.ruoyi.goods.api.feignClient.GoodsClient; | 
|---|
|  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import org.jetbrains.annotations.TestOnly; | 
|---|
|  |  |  | import kotlin.random.Random; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.util.StringUtils; | 
|---|
|  |  |  | import org.springframework.validation.annotation.Validated; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import javax.sound.sampled.*; | 
|---|
|  |  |  | import java.io.BufferedInputStream; | 
|---|
|  |  |  | import java.io.File; | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.io.InputStream; | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.math.RoundingMode; | 
|---|
|  |  |  | import java.net.MalformedURLException; | 
|---|
|  |  |  | import java.net.URL; | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  | 
|---|
|  |  |  | private ManagementClient managementClient; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ITUserPresentRecordService userPresentRecordService; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ITSubjectRecordDetailService subjectRecordDetailService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/testAddData") | 
|---|
|  |  |  | @ApiOperation(value = "测试分片", tags = {"测试分片"}) | 
|---|
|  |  |  | @ApiOperation(value = "测试分片", tags = {"测试分片"}) | 
|---|
|  |  |  | public R<Object> testAddData() { | 
|---|
|  |  |  | TIntegralRecord tIntegralRecord = new TIntegralRecord(); | 
|---|
|  |  |  | tIntegralRecord.setIntegral("1"); | 
|---|
|  |  |  | tIntegralRecord.setMethod("1"); | 
|---|
|  |  |  | tIntegralRecord.setUserId(23); | 
|---|
|  |  |  | tIntegralRecord.setGameId(1); | 
|---|
|  |  |  | tIntegralRecord.setGameDifficulty(1); | 
|---|
|  |  |  | tIntegralRecord.setStoryId(1); | 
|---|
|  |  |  | tIntegralRecord.setStoryType(1); | 
|---|
|  |  |  | integralRecordService.save(tIntegralRecord); | 
|---|
|  |  |  | TGameRecord tGameRecord = new TGameRecord(); | 
|---|
|  |  |  | tGameRecord.setUserId(33); | 
|---|
|  |  |  | tGameRecord.setAccuracy(0); | 
|---|
|  |  |  | tGameRecord.setGameName(""); | 
|---|
|  |  |  | tGameRecord.setUseTime(0); | 
|---|
|  |  |  | tGameRecord.setUseTime1(""); | 
|---|
|  |  |  | tGameRecord.setGameId(0); | 
|---|
|  |  |  | tGameRecord.setGameDifficulty(0); | 
|---|
|  |  |  | tGameRecord.setTime(""); | 
|---|
|  |  |  | tGameRecord.setDisabled(false); | 
|---|
|  |  |  | tGameRecord.setCreateBy(""); | 
|---|
|  |  |  | tGameRecord.setCreateTime(new Date()); | 
|---|
|  |  |  | tGameRecord.setUpdateBy(""); | 
|---|
|  |  |  | tGameRecord.setUpdateTime(new Date()); | 
|---|
|  |  |  | gameRecordService.save(tGameRecord); | 
|---|
|  |  |  | TSubjectRecord tSubjectRecord = new TSubjectRecord(); | 
|---|
|  |  |  | tSubjectRecord.setUserId(22); | 
|---|
|  |  |  | tSubjectRecord.setWeek(0); | 
|---|
|  |  |  | tSubjectRecord.setDay(0); | 
|---|
|  |  |  | tSubjectRecord.setBeforeSubject(""); | 
|---|
|  |  |  | tSubjectRecord.setType(0); | 
|---|
|  |  |  | tSubjectRecord.setCompleteSubject(""); | 
|---|
|  |  |  | tSubjectRecord.setAnswerNumber(0); | 
|---|
|  |  |  | tSubjectRecord.setCorrectNumber(0); | 
|---|
|  |  |  | tSubjectRecord.setDisabled(false); | 
|---|
|  |  |  | tSubjectRecord.setCreateBy(""); | 
|---|
|  |  |  | tSubjectRecord.setCreateTime(new Date()); | 
|---|
|  |  |  | tSubjectRecord.setUpdateBy(""); | 
|---|
|  |  |  | tSubjectRecord.setUpdateTime(new Date()); | 
|---|
|  |  |  | subjectRecordService.save(tSubjectRecord); | 
|---|
|  |  |  | TUserPresentRecord tUserPresentRecord = new TUserPresentRecord(); | 
|---|
|  |  |  | tUserPresentRecord.setUserId(44); | 
|---|
|  |  |  | tUserPresentRecord.setPresentTime(new Date()); | 
|---|
|  |  |  | tUserPresentRecord.setIsDelete(0); | 
|---|
|  |  |  | userPresentRecordService.save(tUserPresentRecord); | 
|---|
|  |  |  | TSubjectRecordDetail tSubjectRecordDetail = new TSubjectRecordDetail(); | 
|---|
|  |  |  | tSubjectRecordDetail.setUserId(12); | 
|---|
|  |  |  | subjectRecordDetailService.save(tSubjectRecordDetail); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TUserStudyRecord tUserStudyRecord = new TUserStudyRecord(); | 
|---|
|  |  |  | tUserStudyRecord.setUserId(17); | 
|---|
|  |  |  | tUserStudyRecord.setQuarter(0); | 
|---|
|  |  |  | tUserStudyRecord.setWeek(0); | 
|---|
|  |  |  | tUserStudyRecord.setDay(0); | 
|---|
|  |  |  | tUserStudyRecord.setObtainedIntegral(0); | 
|---|
|  |  |  | tUserStudyRecord.setType(0); | 
|---|
|  |  |  | tUserStudyRecord.setStudyType(0); | 
|---|
|  |  |  | tUserStudyRecord.setStoryId(0); | 
|---|
|  |  |  | studyRecordService.save(tUserStudyRecord); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/subjectList") | 
|---|
|  |  |  | //    @ApiOperation(value = "配置学习类型选择题目", tags = {"题目管理"}) | 
|---|
|  |  |  | public R<PageInfo<TSubject>> subjectList(@RequestBody ChoiceSubject query) { | 
|---|
|  |  |  | PageInfo<TSubject> res = new PageInfo<>(query.getPageNumber(), query.getPageSize()); | 
|---|
|  |  |  | QueryWrapper<TSubject> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | public R<IPage<TSubject>> subjectList(@RequestBody ChoiceSubject query) { | 
|---|
|  |  |  | // 创建分页对象,传入当前页和每页显示条数 | 
|---|
|  |  |  | IPage<TSubject> page = new Page<>(query.getPageNumber(), query.getPageSize());        QueryWrapper<TSubject> 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, 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::getId).collect(Collectors.toList()); | 
|---|
|  |  |  | collect.addAll(collect2); | 
|---|
|  |  |  | if (collect2.isEmpty()) { | 
|---|
|  |  |  | if (collect.isEmpty()) { | 
|---|
|  |  |  | collect.add(-1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | wrapper.in("firstCategory", collect); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | wrapper.in("secondCategory", collect2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (StringUtils.hasLength(query.getEnglish())) { | 
|---|
|  |  |  | wrapper.like("english", query.getEnglish()); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (StringUtils.hasLength(query.getType())) { | 
|---|
|  |  |  | wrapper.like("type", query.getType()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TCategory> list5 = categoryService.list(); | 
|---|
|  |  |  | wrapper.eq("state", 1); | 
|---|
|  |  |  | // 执行分页查询 | 
|---|
|  |  |  | IPage<TSubject> res = subjectService.page(page, wrapper); | 
|---|
|  |  |  | List<TSubject> list = res.getRecords(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | switch (query.getStudyType()) { | 
|---|
|  |  |  | case 1: | 
|---|
|  |  |  | List<TSubject> list = subjectService.list(wrapper); | 
|---|
|  |  |  | for (TSubject tSubject : list) { | 
|---|
|  |  |  | TCategory first = list5.stream().filter(e->e.getId().equals(tSubject.getFirstCategory())).findFirst().orElse(null); | 
|---|
|  |  |  | TCategory second = list5.stream().filter(e->e.getId().equals(tSubject.getSecondCategory())).findFirst().orElse(null); | 
|---|
|  |  |  | if (first != null && second != null) { | 
|---|
|  |  |  | tSubject.setCategoryName(first.getName() + "-" + second.getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setRecords(list); | 
|---|
|  |  |  | res.setTotal(list.size()); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | case 2: | 
|---|
|  |  |  | // 查询出error字段不为空的数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | List<TSubject> list1 = subjectService.list(wrapper); | 
|---|
|  |  |  | List<TSubject> tSubjects = new ArrayList<>(); | 
|---|
|  |  |  | for (TSubject tSubject : list1) { | 
|---|
|  |  |  | TCategory first = list5.stream().filter(e->e.getId().equals(tSubject.getFirstCategory())).findFirst().orElse(null); | 
|---|
|  |  |  | TCategory second = list5.stream().filter(e->e.getId().equals(tSubject.getSecondCategory())).findFirst().orElse(null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (first != null && second != null) { | 
|---|
|  |  |  | tSubject.setCategoryName(first.getName() + "-" + second.getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!tSubject.getError().isEmpty()) { | 
|---|
|  |  |  | tSubjects.add(tSubject); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setRecords(tSubjects); | 
|---|
|  |  |  | res.setTotal(tSubjects.size()); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | case 3: | 
|---|
|  |  |  | List<TSubject> list2 = subjectService.list(wrapper); | 
|---|
|  |  |  | for (TSubject tSubject : list2) { | 
|---|
|  |  |  | TCategory first = list5.stream().filter(e->e.getId().equals(tSubject.getFirstCategory())).findFirst().orElse(null); | 
|---|
|  |  |  | TCategory second = list5.stream().filter(e->e.getId().equals(tSubject.getSecondCategory())).findFirst().orElse(null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (first != null && second != null) { | 
|---|
|  |  |  | tSubject.setCategoryName(first.getName() + "-" + second.getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setRecords(list2); | 
|---|
|  |  |  | res.setTotal(list2.size()); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | case 4: | 
|---|
|  |  |  | // 查询出error字段不为空的数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | List<TSubject> list3 = subjectService.list(wrapper); | 
|---|
|  |  |  | List<TSubject> tSubjects3 = new ArrayList<>(); | 
|---|
|  |  |  | for (TSubject tSubject : list3) { | 
|---|
|  |  |  | TCategory first = list5.stream().filter(e->e.getId().equals(tSubject.getFirstCategory())).findFirst().orElse(null); | 
|---|
|  |  |  | TCategory second = list5.stream().filter(e->e.getId().equals(tSubject.getSecondCategory())).findFirst().orElse(null); | 
|---|
|  |  |  | if (first != null && second != null) { | 
|---|
|  |  |  | tSubject.setCategoryName(first.getName() + "-" + second.getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!tSubject.getError().isEmpty()) { | 
|---|
|  |  |  | tSubjects3.add(tSubject); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setRecords(tSubjects3); | 
|---|
|  |  |  | res.setTotal(tSubjects3.size()); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | case 5: | 
|---|
|  |  |  | List<TSubject> list4 = subjectService.list(wrapper); | 
|---|
|  |  |  | for (TSubject tSubject : list4) { | 
|---|
|  |  |  | TCategory first = list5.stream().filter(e->e.getId().equals(tSubject.getFirstCategory())).findFirst().orElse(null); | 
|---|
|  |  |  | TCategory second = list5.stream().filter(e->e.getId().equals(tSubject.getSecondCategory())).findFirst().orElse(null); | 
|---|
|  |  |  | if (first != null && second != null) { | 
|---|
|  |  |  | tSubject.setCategoryName(first.getName() + "-" + second.getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setRecords(list4); | 
|---|
|  |  |  | res.setTotal(list4.size()); | 
|---|
|  |  |  | return R.ok(res); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TSubject> objects = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq("week", week) | 
|---|
|  |  |  | .eq("type", type)); | 
|---|
|  |  |  | one.setQuarter(dto.getQuarter()); | 
|---|
|  |  |  | one.setQuarterRate(dto.getQuarterRate()); | 
|---|
|  |  |  | one.setTitle(dto.getTitle()); | 
|---|
|  |  |  | studyService.updateById(one); | 
|---|
|  |  |  | GameDTO game = dto.getGame(); | 
|---|
|  |  |  | StoryListenDTO storyListen = dto.getStoryListen(); | 
|---|
|  |  |  | System.err.println("学习配置"+dto); | 
|---|
|  |  |  | if (day == 6) { | 
|---|
|  |  |  | // 先判断有没有配置 | 
|---|
|  |  |  | TGame studyId = gameService.getOne(new QueryWrapper<TGame>() | 
|---|
|  |  |  | .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.setAnswerCount(game.getAnswerCount()); | 
|---|
|  |  |  | studyId.setRate(game.getRate()); | 
|---|
|  |  |  | studyId.setAnswerRate(game.getAnswerRate()); | 
|---|
|  |  |  | studyId.setSubjectIds(game.getSubjectIds()); | 
|---|
|  |  |  | studyId.setSubjectIdsOne(game.getSubjectIdsOne()); | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | 
|---|
|  |  |  | tGame.setAnswerTime(game.getAnswerTime()); | 
|---|
|  |  |  | tGame.setAnswerIntegral(game.getAnswerIntegral()); | 
|---|
|  |  |  | tGame.setAnswerCount(game.getAnswerCount()); | 
|---|
|  |  |  | tGame.setSubjectIds(game.getSubjectIds()); | 
|---|
|  |  |  | tGame.setSubjectIdsOne(game.getSubjectIdsOne()); | 
|---|
|  |  |  | gameService.save(tGame); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | storyListenService.save(tStoryListen); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | List<Integer> ids = studyListenService.lambdaQuery().eq(TStudyListen::getId, one.getId()) | 
|---|
|  |  |  | .eq(TStudyListen::getWeek, week) | 
|---|
|  |  |  | .eq(TStudyListen::getDay, day).list().stream().map(TStudyListen::getId).collect(Collectors.toList()); | 
|---|
|  |  |  | for (Integer id : ids) { | 
|---|
|  |  |  | subjectRecordDetailService.remove(new LambdaQueryWrapper<TSubjectRecordDetail>() | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getObjectId, id) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getWeek, week) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getType, 1)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 删除原有数据 | 
|---|
|  |  |  | studyListenService.remove(new QueryWrapper<TStudyListen>() | 
|---|
|  |  |  | .eq("studyId", one.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | tStudyListen.setIntegral(studyListenDTO.getIntegral()); | 
|---|
|  |  |  | tStudyListen.setWeek(week); | 
|---|
|  |  |  | tStudyListen.setIsVip(studyListenDTO.getIsVip()); | 
|---|
|  |  |  | tStudyListen.setRate(dto.getListenRate()); | 
|---|
|  |  |  | studyListenService.save(tStudyListen); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Integer> ids1 = studyLookService.lambdaQuery().eq(TStudyLook::getId, one.getId()) | 
|---|
|  |  |  | .eq(TStudyLook::getWeek, week) | 
|---|
|  |  |  | .eq(TStudyLook::getDay, day).list().stream().map(TStudyLook::getId).collect(Collectors.toList()); | 
|---|
|  |  |  | for (Integer id : ids1) { | 
|---|
|  |  |  | subjectRecordDetailService.remove(new LambdaQueryWrapper<TSubjectRecordDetail>() | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getObjectId, id) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getWeek, week) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getType, 2)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | studyLookService.remove(new QueryWrapper<TStudyLook>() | 
|---|
|  |  |  | .eq("studyId", one.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | tStudyLook.setIntegral(studyLookDTO.getIntegral()); | 
|---|
|  |  |  | tStudyLook.setWeek(week); | 
|---|
|  |  |  | tStudyLook.setIsVip(studyLookDTO.getIsVip()); | 
|---|
|  |  |  | tStudyLook.setRate(dto.getLookRate()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | studyLookService.save(tStudyLook); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Integer> ids2 = studyInductionService.lambdaQuery().eq(TStudyInduction::getId, one.getId()) | 
|---|
|  |  |  | .eq(TStudyInduction::getWeek, week) | 
|---|
|  |  |  | .eq(TStudyInduction::getDay, day).list().stream().map(TStudyInduction::getId).collect(Collectors.toList()); | 
|---|
|  |  |  | for (Integer id : ids2) { | 
|---|
|  |  |  | subjectRecordDetailService.remove(new LambdaQueryWrapper<TSubjectRecordDetail>() | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getObjectId, id) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getWeek, week) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getType, 3)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | studyInductionService.remove(new QueryWrapper<TStudyInduction>() | 
|---|
|  |  |  | .eq("studyId", one.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | tStudyInduction.setSubject(studyInductionDTO.getSubject()); | 
|---|
|  |  |  | tStudyInduction.setIntegral(studyInductionDTO.getIntegral()); | 
|---|
|  |  |  | tStudyInduction.setWeek(week); | 
|---|
|  |  |  | tStudyInduction.setRate(dto.getInductionRate()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | tStudyInduction.setIsVip(studyInductionDTO.getIsVip()); | 
|---|
|  |  |  | studyInductionService.save(tStudyInduction); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Integer> ids3 = studyAnswerService.lambdaQuery().eq(TStudyAnswer::getId, one.getId()) | 
|---|
|  |  |  | .eq(TStudyAnswer::getWeek, week) | 
|---|
|  |  |  | .eq(TStudyAnswer::getDay, day).list().stream().map(TStudyAnswer::getId).collect(Collectors.toList()); | 
|---|
|  |  |  | for (Integer id : ids3) { | 
|---|
|  |  |  | subjectRecordDetailService.remove(new LambdaQueryWrapper<TSubjectRecordDetail>() | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getObjectId, id) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getWeek, week) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getType, 4)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | studyAnswerService.remove(new QueryWrapper<TStudyAnswer>() | 
|---|
|  |  |  | .eq("studyId", one.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | tStudyAnswer.setAnswerSubject(studyAnswerDTO.getAnswerSubject()); | 
|---|
|  |  |  | tStudyAnswer.setIntegral(studyAnswerDTO.getIntegral()); | 
|---|
|  |  |  | tStudyAnswer.setWeek(week); | 
|---|
|  |  |  | tStudyAnswer.setRate(dto.getAnswerRate()); | 
|---|
|  |  |  | tStudyAnswer.setIsVip(studyAnswerDTO.getIsVip()); | 
|---|
|  |  |  | studyAnswerService.save(tStudyAnswer); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<Integer> ids4 = studyPairService.lambdaQuery().eq(TStudyPair::getId, one.getId()) | 
|---|
|  |  |  | .eq(TStudyPair::getWeek, week) | 
|---|
|  |  |  | .eq(TStudyPair::getDay, day).list().stream().map(TStudyPair::getId).collect(Collectors.toList()); | 
|---|
|  |  |  | for (Integer id : ids4) { | 
|---|
|  |  |  | subjectRecordDetailService.remove(new LambdaQueryWrapper<TSubjectRecordDetail>() | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getObjectId, id) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getWeek, week) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getType, 5)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | studyPairService.remove(new QueryWrapper<TStudyPair>() | 
|---|
|  |  |  | .eq("studyId", one.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | tStudyPair.setSubject(studyPairDTO.getSubject()); | 
|---|
|  |  |  | tStudyPair.setIntegral(studyPairDTO.getIntegral()); | 
|---|
|  |  |  | tStudyPair.setWeek(week); | 
|---|
|  |  |  | tStudyPair.setRate(dto.getPairRate()); | 
|---|
|  |  |  | tStudyPair.setIsVip(studyPairDTO.getIsVip()); | 
|---|
|  |  |  | studyPairService.save(tStudyPair); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void main(String[] args) throws Exception { | 
|---|
|  |  |  | double temp = 1.687; | 
|---|
|  |  |  | System.err.println((int) temp); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq("week", dto.getWeek()) | 
|---|
|  |  |  | .eq("type", dto.getType())); | 
|---|
|  |  |  | if (one != null) { | 
|---|
|  |  |  | one.setType(dto.getType()); | 
|---|
|  |  |  | one.setWeek(dto.getWeek()); | 
|---|
|  |  |  | one.setTitle(dto.getTitle()); | 
|---|
|  |  |  | one.setQuarter(dto.getQuarter()); | 
|---|
|  |  |  | studyService.saveOrUpdate(one); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | TStudy tStudy = new TStudy(); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | List<TGame> games = gameService.list(new QueryWrapper<TGame>()); | 
|---|
|  |  |  | List<TStoryListen> storyListens = storyListenService.list(new QueryWrapper<TStoryListen>()); | 
|---|
|  |  |  | List<TStudyListen> studyListens = studyListenService.list(); | 
|---|
|  |  |  | List<TStudyLook> studyLooks = studyLookService.list(); | 
|---|
|  |  |  | List<TStudyInduction> studyInductions = studyInductionService.list(); | 
|---|
|  |  |  | List<TStudyAnswer> studyAnswers = studyAnswerService.list(); | 
|---|
|  |  |  | List<TStudyPair> studyPairs = studyPairService.list(); | 
|---|
|  |  |  | for (TStudy tStudy : list1) { | 
|---|
|  |  |  | System.err.println("进入修改"); | 
|---|
|  |  |  | tStudy.setWeek(i); | 
|---|
|  |  |  | // 将对应的题目配置修改week | 
|---|
|  |  |  | List<TGame> games1 = games.stream().filter(e -> e.getWeek().equals(tStudy.getWeek())).collect(Collectors.toList()); | 
|---|
|  |  |  | for (TGame tGame : games1) { | 
|---|
|  |  |  | tGame.setWeek(i); | 
|---|
|  |  |  | tGame.setStudyId(tStudy.getId()); | 
|---|
|  |  |  | gameService.updateById(tGame); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 听故事 | 
|---|
|  |  |  | List<TStoryListen> storyListens1 = storyListens.stream().filter(e -> e.getWeek().equals(tStudy.getWeek())).collect(Collectors.toList()); | 
|---|
|  |  |  | for (TStoryListen tStoryListen : storyListens1) { | 
|---|
|  |  |  | tStoryListen.setWeek(i); | 
|---|
|  |  |  | tStoryListen.setStudyId(tStudy.getId()); | 
|---|
|  |  |  | storyListenService.updateById(tStoryListen); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 听音选图 | 
|---|
|  |  |  | List<TStudyListen> studyListens1 = studyListens.stream().filter(e -> e.getWeek().equals(tStudy.getWeek())).collect(Collectors.toList()); | 
|---|
|  |  |  | for (TStudyListen tStudyListen : studyListens1) { | 
|---|
|  |  |  | tStudyListen.setWeek(i); | 
|---|
|  |  |  | tStudyListen.setStudyId(tStudy.getId()); | 
|---|
|  |  |  | studyListenService.updateById(tStudyListen); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 看图选音 | 
|---|
|  |  |  | List<TStudyLook> studyLooks1 = studyLooks.stream().filter(e -> e.getWeek().equals(tStudy.getWeek())).collect(Collectors.toList()); | 
|---|
|  |  |  | for (TStudyLook tStudyLook : studyLooks1) { | 
|---|
|  |  |  | tStudyLook.setWeek(i); | 
|---|
|  |  |  | tStudyLook.setStudyId(tStudy.getId()); | 
|---|
|  |  |  | studyLookService.updateById(tStudyLook); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 归纳判断 | 
|---|
|  |  |  | List<TStudyInduction> studyInductions1 = studyInductions.stream().filter(e -> e.getWeek().equals(tStudy.getWeek())).collect(Collectors.toList()); | 
|---|
|  |  |  | for (TStudyInduction tStudyInduction : studyInductions1) { | 
|---|
|  |  |  | tStudyInduction.setWeek(i); | 
|---|
|  |  |  | tStudyInduction.setStudyId(tStudy.getId()); | 
|---|
|  |  |  | System.err.println("归纳判断" + tStudy.getId()); | 
|---|
|  |  |  | studyInductionService.updateById(tStudyInduction); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TStudyAnswer> studyAnswers1 = studyAnswers.stream().filter(e -> e.getWeek().equals(tStudy.getWeek())).collect(Collectors.toList()); | 
|---|
|  |  |  | for (TStudyAnswer tStudyAnswer : studyAnswers1) { | 
|---|
|  |  |  | tStudyAnswer.setStudyId(tStudy.getId()); | 
|---|
|  |  |  | tStudyAnswer.setWeek(i); | 
|---|
|  |  |  | studyAnswerService.updateById(tStudyAnswer); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TStudyPair> studyPairs1 = studyPairs.stream().filter(e -> e.getWeek().equals(tStudy.getWeek())).collect(Collectors.toList()); | 
|---|
|  |  |  | for (TStudyPair tStudyPair : studyPairs1) { | 
|---|
|  |  |  | tStudyPair.setWeek(i); | 
|---|
|  |  |  | tStudyPair.setStudyId(tStudy.getId()); | 
|---|
|  |  |  | studyPairService.updateById(tStudyPair); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | res.setQuarterRate(list8.get(0).getQuarterRate()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<StudyListenVO> listenVOS = new ArrayList<>(); | 
|---|
|  |  |  | List<GameVO> gameVOS = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | List<TStudyListen> list = studyListenService.list(new QueryWrapper<TStudyListen>() | 
|---|
|  |  |  | .eq("week", week) | 
|---|
|  |  |  | .eq("day", day)); | 
|---|
|  |  |  | List<TSubject> list9 = subjectService.list(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (TStudyListen tStudyListen : list) { | 
|---|
|  |  |  | StringBuilder temp = new StringBuilder(); | 
|---|
|  |  |  | StudyListenVO studyListenVO = new StudyListenVO(); | 
|---|
|  |  |  | if (StringUtils.hasLength(tStudyListen.getSubject())) { | 
|---|
|  |  |  | for (String s : tStudyListen.getSubject().split(",")) { | 
|---|
|  |  |  | TSubject byId = subjectService.getById(s); | 
|---|
|  |  |  | temp.append(byId.getName()).append(","); | 
|---|
|  |  |  | TSubject byId = list9.stream().filter(e -> e.getId().equals(Integer.valueOf(s))).findFirst().orElse(null); | 
|---|
|  |  |  | if (byId != null) { | 
|---|
|  |  |  | temp.append(byId.getName()).append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String string = temp.toString(); | 
|---|
|  |  |  | studyListenVO.setName(string.substring(0, string.length() - 1)); | 
|---|
|  |  |  | 
|---|
|  |  |  | studyListenVO.setIsVip(tStudyListen.getIsVip()); | 
|---|
|  |  |  | listenVOS.add(studyListenVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setListenRate(tStudyListen.getRate()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 看音选图 | 
|---|
|  |  |  | 
|---|
|  |  |  | StudyLookVO studyLookVO1 = new StudyLookVO(); | 
|---|
|  |  |  | if (StringUtils.hasLength(tStudyLook.getSubject())) { | 
|---|
|  |  |  | for (String s : tStudyLook.getSubject().split(",")) { | 
|---|
|  |  |  | TSubject byId = subjectService.getById(s); | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  | TSubject byId = list9.stream().filter(e -> e.getId().equals(Integer.valueOf(s))).findFirst().orElse(null); | 
|---|
|  |  |  | if (byId != null) { | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String[] split = tStudyLook.getSort().split(","); | 
|---|
|  |  |  | String s1 = split[index]; | 
|---|
|  |  |  | sorts.append(s1).append(","); | 
|---|
|  |  |  | 
|---|
|  |  |  | studyLookVO1.setIsVip(tStudyLook.getIsVip()); | 
|---|
|  |  |  | lookVOS.add(studyLookVO1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setLookRate(tStudyLook.getRate()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 归纳排除 | 
|---|
|  |  |  | 
|---|
|  |  |  | if (StringUtils.hasLength(tStudyInduction.getSubject())) { | 
|---|
|  |  |  | for (String s : tStudyInduction.getSubject().split(",")) { | 
|---|
|  |  |  | String replace = s.replace("-", ""); | 
|---|
|  |  |  | TSubject byId = subjectService.getById(replace); | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  | TSubject byId = list9.stream().filter(e -> e.getId().equals(Integer.valueOf(replace))).findFirst().orElse(null); | 
|---|
|  |  |  | if (byId != null) { | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String string = names.toString(); | 
|---|
|  |  |  | studyInductionVO.setName(string.substring(0, string.length() - 1)); | 
|---|
|  |  |  | 
|---|
|  |  |  | studyInductionVO.setIsVip(tStudyInduction.getIsVip()); | 
|---|
|  |  |  | inductionVOS.add(studyInductionVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setInductionRate(tStudyInduction.getRate()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 有问有答 | 
|---|
|  |  |  | 
|---|
|  |  |  | if (tStudyAnswer.getIsAnswer() != null) { | 
|---|
|  |  |  | if (tStudyAnswer.getIsAnswer() == 1) { | 
|---|
|  |  |  | if (tStudyAnswer.getSubject() != null) { | 
|---|
|  |  |  | TSubject byId = subjectService.getById(tStudyAnswer.getSubject()); | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TSubject byId = list9.stream().filter(e -> e.getId().equals(tStudyAnswer.getSubject())).findFirst().orElse(null); | 
|---|
|  |  |  | if (byId != null) { | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (tStudyAnswer.getAnswerSubject() != null) { | 
|---|
|  |  |  | TSubject byId1 = subjectService.getById(tStudyAnswer.getAnswerSubject()); | 
|---|
|  |  |  | names.append(byId1.getName()).append(","); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TSubject byId1 = list9.stream().filter(e -> e.getId().equals(tStudyAnswer.getAnswerSubject())).findFirst().orElse(null); | 
|---|
|  |  |  | if (byId1 != null) { | 
|---|
|  |  |  | names.append(byId1.getName()).append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (tStudyAnswer.getSubject() != null) { | 
|---|
|  |  |  | TSubject byId = subjectService.getById(tStudyAnswer.getSubject()); | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  | TSubject byId = list9.stream().filter(e -> e.getId().equals(tStudyAnswer.getSubject())).findFirst().orElse(null); | 
|---|
|  |  |  | if (byId != null) { | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (tStudyAnswer.getAnswerSubject() != null) { | 
|---|
|  |  |  | TSubject byId1 = subjectService.getById(tStudyAnswer.getAnswerSubject()); | 
|---|
|  |  |  | names.append(byId1.getName()).append(","); | 
|---|
|  |  |  | TSubject byId1 = list9.stream().filter(e -> e.getId().equals(tStudyAnswer.getAnswerSubject())).findFirst().orElse(null); | 
|---|
|  |  |  | if (byId1 != null) { | 
|---|
|  |  |  | names.append(byId1.getName()).append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | studyAnswerVO.setIsAnswer(tStudyAnswer.getIsAnswer()); | 
|---|
|  |  |  | studyAnswerVO.setSubject(tStudyAnswer.getSubject() + "," + tStudyAnswer.getAnswerSubject()); | 
|---|
|  |  |  | answerVOS.add(studyAnswerVO); | 
|---|
|  |  |  | res.setAnswerRate(tStudyAnswer.getRate()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | StudyPairVO studyPairVO = new StudyPairVO(); | 
|---|
|  |  |  | if (StringUtils.hasLength(tStudyPair.getSubject())) { | 
|---|
|  |  |  | for (String s : tStudyPair.getSubject().split(",")) { | 
|---|
|  |  |  | TSubject byId = subjectService.getById(s); | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TSubject byId = list9.stream().filter(e -> e.getId().equals(Integer.valueOf(s))).findFirst().orElse(null); | 
|---|
|  |  |  | if (byId != null) { | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String string = names.toString(); | 
|---|
|  |  |  | studyPairVO.setName(string.substring(0, string.length() - 1)); | 
|---|
|  |  |  | 
|---|
|  |  |  | studyPairVO.setIsVip(tStudyPair.getIsVip()); | 
|---|
|  |  |  | pairVOS.add(studyPairVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | res.setPairRate(tStudyPair.getRate()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TGame> list5 = gameService.list(new QueryWrapper<TGame>() | 
|---|
|  |  |  | .eq("week", week)); | 
|---|
|  |  |  | 
|---|
|  |  |  | gameVO.setAnswerCount(tGame.getAnswerCount()); | 
|---|
|  |  |  | gameVO.setRate(tGame.getRate()); | 
|---|
|  |  |  | gameVO.setAnswerRate(tGame.getAnswerRate()); | 
|---|
|  |  |  | String subjectIds = tGame.getSubjectIds(); | 
|---|
|  |  |  | if(subjectIds!=null && subjectIds.length()>0){ | 
|---|
|  |  |  | gameVO.setSubjects(subjectService.list(new QueryWrapper<TSubject>() | 
|---|
|  |  |  | .in("id", subjectIds.split(",")))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String subjectIdsOne = tGame.getSubjectIdsOne(); | 
|---|
|  |  |  | if(subjectIdsOne!=null && subjectIdsOne.length()>0){ | 
|---|
|  |  |  | gameVO.setSubjectsOne(subjectService.list(new QueryWrapper<TSubject>() | 
|---|
|  |  |  | .in("id", subjectIdsOne.split(",")))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | gameVOS.add(gameVO); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TStoryListen> list6 = storyListenService.list(new QueryWrapper<TStoryListen>() | 
|---|
|  |  |  | .eq("week", week)); | 
|---|
|  |  |  | List<TStory> list10 = storyService.list(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (TStoryListen tStory : list6) { | 
|---|
|  |  |  | StoryVO storyVO = new StoryVO(); | 
|---|
|  |  |  | storyVO.setStory(tStory.getStory()); | 
|---|
|  |  |  | 
|---|
|  |  |  | StringBuilder sort1 = new StringBuilder(); | 
|---|
|  |  |  | if (StringUtils.hasLength(tStory.getStory())) { | 
|---|
|  |  |  | for (String s : tStory.getStory().split(",")) { | 
|---|
|  |  |  | TStory byId = storyService.getById(s); | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  | TStory byId = list10.stream().filter(e -> e.getId().equals(Integer.valueOf(s))).findFirst().orElse(null); | 
|---|
|  |  |  | if (byId != null) { | 
|---|
|  |  |  | names.append(byId.getName()).append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (StringUtils.hasLength(tStory.getLookStory())) { | 
|---|
|  |  |  | for (String s : tStory.getLookStory().split(",")) { | 
|---|
|  |  |  | TStory byId = storyService.getById(s); | 
|---|
|  |  |  | names1.append(byId.getName()).append(","); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | TStory byId = list10.stream().filter(e -> e.getId().equals(Integer.valueOf(s))).findFirst().orElse(null); | 
|---|
|  |  |  | if (byId != null) { | 
|---|
|  |  |  | names1.append(byId.getName()).append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (StringUtils.hasLength(tStory.getSort())) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取当前季度游戏难度 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @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 周目 | 
|---|
|  |  |  | 
|---|
|  |  |  | @GetMapping("/studySchedule") | 
|---|
|  |  |  | @ApiOperation(value = "获取用户学习进度", tags = {"学习端-首页"}) | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true) | 
|---|
|  |  |  | @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public R<TUserStudy> studySchedule(@RequestParam Integer week) { | 
|---|
|  |  |  | LoginUserParent loginStudy = tokenService.getLoginUserStudy(); | 
|---|
|  |  |  | 
|---|
|  |  |  | Integer userid = loginStudy.getUserid(); | 
|---|
|  |  |  | TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, loginStudy.getUserid()) | 
|---|
|  |  |  | .eq(TUserStudy::getDisabled, 0).one(); | 
|---|
|  |  |  | TStudy study = studyService.lambdaQuery().eq(TStudy::getWeek, week).one(); | 
|---|
|  |  |  | if (study.getQuarter()!=1){ | 
|---|
|  |  |  | // 判断上季度 通关率 | 
|---|
|  |  |  | String quarterRate = study.getQuarterRate(); | 
|---|
|  |  |  | BigDecimal bigDecimal = new BigDecimal(quarterRate); | 
|---|
|  |  |  | // 查询五个自主学习通关率 | 
|---|
|  |  |  | List<TSubjectRecordDetail> list = subjectRecordDetailService.lambdaQuery().eq(TSubjectRecordDetail::getWeek, week) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getUserId, userid).list(); | 
|---|
|  |  |  | List<TSubjectRecordDetail> pass = list.stream().filter(e -> e.getStatus() == 2).collect(Collectors.toList()); | 
|---|
|  |  |  | if (list.isEmpty()){ | 
|---|
|  |  |  | return R.fail("上季度未达到通关率"+quarterRate+"%,当前通关率0%"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BigDecimal divide = new BigDecimal(pass.size()).divide(new BigDecimal(list.size()), 2, RoundingMode.HALF_UP); | 
|---|
|  |  |  | if (divide.compareTo(bigDecimal)<1){ | 
|---|
|  |  |  | return R.fail("上季度未达到通关率"+quarterRate+"%,当前通关率"+divide.multiply(new BigDecimal(100))+"%"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (null != studyRecord) { | 
|---|
|  |  |  | // 计算当前周 day 1-5的总进度 | 
|---|
|  |  |  | int computeSchedule = studyService.computeSchedule(studyRecord, week); | 
|---|
|  |  |  | 
|---|
|  |  |  | List<StudyWeekDTO> result = studyService.weekList(type, quarter, loginUserStudy.getUserid()); | 
|---|
|  |  |  | return R.ok(result); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取在线时间赠送积分信息 | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 学习时长更新 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(studyService.listenSelectPicture(week, day, studyListens)); | 
|---|
|  |  |  | return R.ok(studyService.listenSelectPicture(week, day, studyListens, tokenService.getLoginUserStudy().getUserid())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(studyService.pictureSelectVoice(week, day, lookList)); | 
|---|
|  |  |  | return studyService.pictureSelectVoice(week, day, lookList, tokenService.getLoginUserStudy().getUserid()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(studyService.induceExclude(week, day, inductionList)); | 
|---|
|  |  |  | return studyService.induceExclude(week, day, inductionList, tokenService.getLoginUserStudy().getUserid()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(studyService.questionsAndAnswers(week, day, answerList)); | 
|---|
|  |  |  | return studyService.questionsAndAnswers(week, day, answerList, tokenService.getLoginUserStudy().getUserid()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(studyService.pictureMateVoice(week, day, pairList)); | 
|---|
|  |  |  | return studyService.pictureMateVoice(week, day, pairList, tokenService.getLoginUserStudy().getUserid()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 2.0新增-记录答题状态 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/answerQuestion") | 
|---|
|  |  |  | @ApiOperation(value = "2.0新增-记录答题状态", tags = {"学习端-听-自主学习"}) | 
|---|
|  |  |  | public R answerQuestion(@RequestBody @Validated AnswerQuestionDTO answerQuestionDTO) { | 
|---|
|  |  |  | LoginUserParent userStudy = tokenService.getLoginUserStudy(); | 
|---|
|  |  |  | if (null == userStudy) { | 
|---|
|  |  |  | return R.tokenError("登录失效!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | System.err.println("答题DTO"+answerQuestionDTO); | 
|---|
|  |  |  | TSubjectRecordDetail byId = subjectRecordDetailService.getById(answerQuestionDTO.getId()); | 
|---|
|  |  |  | byId.setUserId(null); | 
|---|
|  |  |  | byId.setStatus(answerQuestionDTO.getStatus()); | 
|---|
|  |  |  | subjectRecordDetailService.updateById(byId); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 2.0新增-重新开始 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/restart") | 
|---|
|  |  |  | @ApiOperation(value = "2.0新增-重新开始", tags = {"学习端-听-自主学习"}) | 
|---|
|  |  |  | public R restart(@RequestBody RestartDTO restartDTO) { | 
|---|
|  |  |  | LoginUserParent userStudy = tokenService.getLoginUserStudy(); | 
|---|
|  |  |  | if (null == userStudy) { | 
|---|
|  |  |  | return R.tokenError("登录失效!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TSubjectRecordDetail> list = subjectRecordDetailService.lambdaQuery() | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getUserId, userStudy.getUserid()) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getWeek, restartDTO.getWeek()) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getDay, restartDTO.getDay()) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getType, restartDTO.getType()) | 
|---|
|  |  |  | .list(); | 
|---|
|  |  |  | for (TSubjectRecordDetail tSubjectRecordDetail : list) { | 
|---|
|  |  |  | tSubjectRecordDetail.setStatus(1); | 
|---|
|  |  |  | tSubjectRecordDetail.setUserId(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | subjectRecordDetailService.updateBatchById(list); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 学习完成,生成学习记录,积分明细记录 | 
|---|
|  |  |  | 
|---|
|  |  |  | if (null == userStudy) { | 
|---|
|  |  |  | return R.tokenError("登录失效!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TSubjectRecordDetail> subjectRecordDetails = subjectRecordDetailService.lambdaQuery().eq(TSubjectRecordDetail::getUserId, userStudy.getUserid()) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getWeek, week).eq(BaseModel::getDisabled, 0).list(); | 
|---|
|  |  |  | List<TSubjectRecordDetail> listenList = subjectRecordDetails.stream().filter(e -> e.getType() == 5).collect(Collectors.toList()); | 
|---|
|  |  |  | int listenPass = (int) listenList.stream().filter(e -> e.getStatus() == 2).count(); | 
|---|
|  |  |  | int listenSize = listenList.size(); | 
|---|
|  |  |  | if (listenSize!=0){ | 
|---|
|  |  |  | // 先计算上一天的通关率 设置为两位小数 | 
|---|
|  |  |  | double listenRate = (double) listenPass /listenSize; | 
|---|
|  |  |  | BigDecimal divide = new BigDecimal(listenPass).divide(new BigDecimal(listenSize), 2, RoundingMode.HALF_UP); | 
|---|
|  |  |  | TStudyPair one = studyPairService.lambdaQuery().eq(TStudyPair::getWeek, week) | 
|---|
|  |  |  | .eq(TStudyPair::getDay, 5).last("limit 1").one(); | 
|---|
|  |  |  | if (one!=null){ | 
|---|
|  |  |  | if (listenRate<(Double.parseDouble(one.getRate())/100)){ | 
|---|
|  |  |  | return R.fail("音图相配未达到通关率"+one.getRate()+"%,"+"当前通关率:"+divide.multiply(new BigDecimal(100))+"%"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Integer[] array = {0, 1, 2}; | 
|---|
|  |  |  | if (!Arrays.stream(array).collect(Collectors.toList()).contains(difficulty)) { | 
|---|
|  |  |  | throw new GlobalException("请选择符合规则的游戏难度!"); | 
|---|
|  |  |  | 
|---|
|  |  |  | game.setTime(game.getTime().split(",")[difficulty]); | 
|---|
|  |  |  | // 检验是否完成难度 | 
|---|
|  |  |  | studyService.checkDifficulty(difficulty, week, game, userStudy.getUserid()); | 
|---|
|  |  |  | List<String> subjectId = getSubjectId(week); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        List<String> subjectId = getSubjectId(week); | 
|---|
|  |  |  | List<String> subjectId = new ArrayList<>(); | 
|---|
|  |  |  | String subjectIds = game.getSubjectIds(); | 
|---|
|  |  |  | if(subjectIds!=null){ | 
|---|
|  |  |  | String[] split = subjectIds.split(","); | 
|---|
|  |  |  | for (String s : split) { | 
|---|
|  |  |  | subjectId.add(s); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<String> newSubjectId = subjectId.stream().map(data -> { | 
|---|
|  |  |  | if (data.startsWith(Constants.REDUCE)) { | 
|---|
|  |  |  | data = data.replace(Constants.REDUCE, Constants.EMPTY_STR); | 
|---|
|  |  |  | 
|---|
|  |  |  | if (null == userStudy) { | 
|---|
|  |  |  | return R.tokenError("登录失效!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TSubjectRecordDetail> subjectRecordDetails = subjectRecordDetailService.lambdaQuery().eq(TSubjectRecordDetail::getUserId, userStudy.getUserid()) | 
|---|
|  |  |  | .eq(TSubjectRecordDetail::getWeek, week).eq(BaseModel::getDisabled, 0).list(); | 
|---|
|  |  |  | List<TSubjectRecordDetail> listenList = subjectRecordDetails.stream().filter(e -> e.getType() == 5).collect(Collectors.toList()); | 
|---|
|  |  |  | int listenPass = (int) listenList.stream().filter(e -> e.getStatus() == 2).count(); | 
|---|
|  |  |  | int listenSize = listenList.size(); | 
|---|
|  |  |  | if (listenSize!=0){ | 
|---|
|  |  |  | // 先计算上一天的通关率 设置为两位小数 | 
|---|
|  |  |  | double listenRate = (double) listenPass /listenSize; | 
|---|
|  |  |  | BigDecimal divide = new BigDecimal(listenPass).divide(new BigDecimal(listenSize), 2, RoundingMode.HALF_UP); | 
|---|
|  |  |  | TStudyPair one = studyPairService.lambdaQuery().eq(TStudyPair::getWeek, week) | 
|---|
|  |  |  | .eq(TStudyPair::getDay, 5).last("limit 1").one(); | 
|---|
|  |  |  | if (one!=null){ | 
|---|
|  |  |  | if (listenRate<(Double.parseDouble(one.getRate())/100)){ | 
|---|
|  |  |  | return R.fail("音图相配未达到通关率"+one.getRate()+"%,"+"当前通关率:"+divide.multiply(new BigDecimal(100))+"%"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | TGame game = gameService.gameHearing(quarter, week); | 
|---|
|  |  |  | if (null == game) { | 
|---|
|  |  |  | throw new GlobalException("当前季度该周目暂无配置游戏数据!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<String> subjectId = getSubjectId(week); | 
|---|
|  |  |  | //        List<String> subjectId = getSubjectId(week); | 
|---|
|  |  |  | List<String> subjectId = new ArrayList<>(); | 
|---|
|  |  |  | String subjectIds = game.getSubjectIdsOne(); | 
|---|
|  |  |  | if(subjectIds!=null){ | 
|---|
|  |  |  | String[] split = subjectIds.split(","); | 
|---|
|  |  |  | for (String s : split) { | 
|---|
|  |  |  | subjectId.add(s); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<String> subjectData = getSubjectData(game, subjectId); | 
|---|
|  |  |  | List<TSubject> subjectList = getSubjectList(subjectData); | 
|---|
|  |  |  | // 返回数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | photoList.add(new GameMemoryPhotoVO(tSubject.getId(), tSubject.getImg())); | 
|---|
|  |  |  | voiceList.add(new GameMemoryVoiceVO(tSubject.getId(), tSubject.getCorrect())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | photoList = photoList.stream().distinct().collect(Collectors.toList()); | 
|---|
|  |  |  | voiceList = voiceList.stream().distinct().collect(Collectors.toList()); | 
|---|
|  |  |  | // 校验超级听力是否通过 | 
|---|
|  |  |  | // studyService.checkClearance(game,userStudy.getUserid()); | 
|---|
|  |  |  | // 框架记忆数量翻倍,前端需要根据数量画格子 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | // 生成随机索引并获取数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | public R<StudyStoryListenResultVO> lookPictureDbu(@RequestParam Integer quarter, @RequestParam Integer week) { | 
|---|
|  |  |  | // 看图配音信息 | 
|---|
|  |  |  | TStoryListen storyListen = storyListenService.storyDetail(quarter, week); | 
|---|
|  |  |  | if (storyListen==null){ | 
|---|
|  |  |  | return R.fail("当前未配置看图配音信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 题组信息 | 
|---|
|  |  |  | StudyStoryVO studyStory = new StudyStoryVO(); | 
|---|
|  |  |  | studyStory.setId(storyListen.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | public R<StudyStoryListenResultVO> frameworkMemory(@RequestParam Integer quarter, @RequestParam Integer week) { | 
|---|
|  |  |  | // 看图配音信息 | 
|---|
|  |  |  | TStoryListen storyListen = storyListenService.storyDetail(quarter, week); | 
|---|
|  |  |  | if (storyListen==null){ | 
|---|
|  |  |  | return R.fail("当前未配置框架记忆信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 题组信息 | 
|---|
|  |  |  | StudyStoryVO studyStory = new StudyStoryVO(); | 
|---|
|  |  |  | studyStory.setId(storyListen.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(TGameRecord::getDisabled, 0) | 
|---|
|  |  |  | .orderByDesc(TGameRecord::getCreateTime) | 
|---|
|  |  |  | .list(); | 
|---|
|  |  |  | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm"); | 
|---|
|  |  |  | if (null != studyRecord) { | 
|---|
|  |  |  | // 学习时长格式转换 | 
|---|
|  |  |  | Integer todayStudy = studyRecord.getTodayStudy(); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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) | 
|---|
|  |  |  | 
|---|
|  |  |  | @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(); | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(userService.updateById(user)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/lookVideo") | 
|---|
|  |  |  | //    @ApiOperation(value = "用户积分变动", tags = {"用户积分变动"}) | 
|---|
|  |  |  | public R<Boolean> lookVideo() { | 
|---|
|  |  |  | boolean update = userService.update(new LambdaUpdateWrapper<TUser>().set(TUser::getLookVideo, 0)); | 
|---|
|  |  |  | return R.ok(update); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|