ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -1589,9 +1589,11 @@ Integer totalStudy = studyRecord.getTotalStudy(); studyRecord.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600)); // 剩余周目 int size = studyService.list(new QueryWrapper<TStudy>() .eq("type", 1)).size(); studyRecord.setSurplus(size - studyRecord.getWeek()); List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0) .eq(TStudy::getType, Constants.ONE) .orderByAsc(TStudy::getWeek).list(); int size = studyService.residueWeek(studyRecord,studyList); studyRecord.setSurplus(size); } return R.ok(new StudyRecordResultVO(studyRecord, gameRecordList)); } @@ -1667,7 +1669,14 @@ if (tokenService.getLoginUserStudy() == null) { return R.tokenError("登录失效"); } return R.ok(integralRecordService.integralDetail(new Page<>(pageNum, pageSize), tokenService.getLoginUserStudy().getUserid(), time)); IPage<TIntegralRecord> page = integralRecordService.integralDetail(new Page<>(pageNum, pageSize), tokenService.getLoginUserStudy().getUserid(), time); for (TIntegralRecord record : page.getRecords()) { if (!record.getIntegral().startsWith("-")) { record.setIntegral("+" + record.getIntegral()); } } return R.ok(page); } @GetMapping("/integralDetailParent") ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TIntegralRecord.java
@@ -1,11 +1,15 @@ package com.ruoyi.study.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.web.domain.BaseModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; /** * <p> @@ -54,6 +58,11 @@ @ApiModelProperty("故事id 对应t_story_listen") private Integer storyId; @ApiModelProperty("积分变动时间") @TableField(exist = false) @JsonFormat(pattern = "yyyy-MM-dd HH:mm") private Date time; /** * 前端用,返回积分变动类型 * @@ -62,4 +71,8 @@ public String getType() { return integral.startsWith("-") ? "减少" : "增加"; } public Date getTime() { return super.getCreateTime(); } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyService.java
@@ -114,4 +114,12 @@ */ int computeTotalIntegral(List<String> studyIds, Integer type, Integer accuracy); /** * 计算剩余学习周目 * * @param studyRecord 学习进度信息 * @param studyList 学习配置列表 * @return 剩余周目 */ int residueWeek(TUserStudy studyRecord, List<TStudy> studyList); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
@@ -288,7 +288,7 @@ for (int i = 0; i < Constants.THREE; i++) { String id = subjectIds.get(i); if (id.startsWith("-")) { id = id.replace("-",""); id = id.replace("-", ""); subjectLists.add(subjectService.getById(id)); } } @@ -302,11 +302,11 @@ for (int i = Constants.THREE; i < Constants.FIVE; i++) { String id = subjectIds.get(i); if (id.startsWith("-")) { id = id.replace("-",""); id = id.replace("-", ""); subjectLists.add(subjectService.getById(id)); } } subjectLists.add(subjectService.getById(subjectIds.get(subjectIds.size() - 1).replace("-",""))); subjectLists.add(subjectService.getById(subjectIds.get(subjectIds.size() - 1).replace("-", ""))); subjectList.add(subjectLists); } return new StudyInductionResultVO(learnStudy, subjectList); @@ -359,11 +359,11 @@ copyProperties(two1, twoVO); // 判断第一组题目的问题题目及回答题目,哪个是答案 if (Constants.ZERO.equals(one.getIsAnswer())) { oneVO.setIsQuestion(0); twoVO.setIsQuestion(1); } else { oneVO.setIsQuestion(1); twoVO.setIsQuestion(0); } else { oneVO.setIsQuestion(0); twoVO.setIsQuestion(1); } voList.add(oneVO); voList.add(twoVO); @@ -486,4 +486,66 @@ return (int) (sum * ((double) accuracy / 100)); } @Override public int residueWeek(TUserStudy studyRecord, List<TStudy> studyList) { // 已学习周目 int residueWeek = 0; // 已学习到的周目 Integer studyWeek = studyRecord.getWeek(); // 根据季度分组封装 Map<Integer, List<TStudy>> studyMap = new HashMap<>(8); for (TStudy study : studyList) { Integer quarter = study.getQuarter(); List<TStudy> itemList = studyMap.get(quarter); if (null == itemList) { itemList = new ArrayList<>(); } itemList.add(study); studyMap.put(quarter, itemList); } // 顺序排序 Map<Integer, List<TStudy>> itemMap = new HashMap<>(8); List<Integer> keyList = new ArrayList<>(); for (Map.Entry<Integer, List<TStudy>> map : studyMap.entrySet()) { Integer key = map.getKey(); keyList.add(key); } Collections.sort(keyList); for (Integer key : keyList) { List<TStudy> itemList = studyMap.get(key); itemMap.put(key, itemList); } // 计算已学习周目 boolean v = false; for (Map.Entry<Integer, List<TStudy>> map : itemMap.entrySet()) { List<TStudy> list = map.getValue(); for (int i = 0; i < list.size(); i++) { TStudy item = list.get(i); if (item.getWeek().equals(studyWeek)) { Integer listen = studyRecord.getListen(); Integer answer = studyRecord.getAnswer(); Integer look = studyRecord.getLook(); Integer induction = studyRecord.getInduction(); Integer pair = studyRecord.getPair(); Integer gameDifficulty = studyRecord.getGameDifficulty(); // 听音选图、看图选音、音图相配、有问有答、归纳排除的进度是否 100%,并且超级听力的游戏难度是否为2 boolean isStudy = Constants.ONE_HUNDRED.equals(listen) && Constants.ONE_HUNDRED.equals(look) && Constants.ONE_HUNDRED.equals(induction) && Constants.ONE_HUNDRED.equals(pair) && Constants.ONE_HUNDRED.equals(answer) && Constants.TWO.equals(gameDifficulty); if (isStudy) { residueWeek++; } v = true; break; } else { residueWeek++; } } if (v) { break; } } return studyList.size() - residueWeek; } } ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TIntegralRecordMapper.xml
@@ -13,5 +13,6 @@ and userId = #{userId} </if> </where> order by createTime desc </select> </mapper>