From 2862c59d0be4f603a89778f9f2635cfaf8518a2b Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期四, 04 七月 2024 18:03:40 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/DolphinEnglish --- ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java | 55 ++++++++++++++++++++++++++++++++----------------------- 1 files changed, 32 insertions(+), 23 deletions(-) diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java index ce72700..b2385ee 100644 --- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java +++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java @@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -873,8 +874,6 @@ } else { result = null; } - subjectRecordService.lambdaUpdate().set(TSubjectRecord::getDisabled, 0) - .eq(TSubjectRecord::getUserId, loginStudy.getUserid()).update(); return R.ok(result); } @@ -910,46 +909,47 @@ for (TStudyListen studyListen : studyListens) { item += studyListen.getSubject().split(",").length; } - int i = (int) ((double) (exitLearn.getTopicIds().split(",").length / item) * 100); + int i = (int) (((double) schedule / item) * 100); if (i > userStudy.getListen()) { - userStudy.setListen(100 - i); + userStudy.setListen(i); } } else if (Constants.TWO.equals(type)) { // 看图选音 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()) { - userStudy.setLook(100 - i); - } + int item = 0; + for (TStudyLook studyLook : lookList) { + item += studyLook.getSubject().split(",").length; + } + int i = (int) (((double) schedule / item) * 100); + if (i > userStudy.getLook()) { + userStudy.setLook(i); } } else if (Constants.THREE.equals(type)) { // 归纳排除 List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day); if (!inductionList.isEmpty()) { int item = inductionList.size(); - int i = (int) ((double) (schedule / item)) * 100; + int i = (int) (((double) schedule / item) * 100); if (i > userStudy.getInduction()) { - userStudy.setInduction(100 - i); + userStudy.setInduction(i); } } } else if (Constants.FOUR.equals(type)) { // 有问有答 List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day); if (answerList.size() % Constants.TWO == Constants.ZERO) { - int i = (int) ((double) (schedule / (answerList.size() / 2))) * 100; + int i = (int) (((double) schedule / (answerList.size() / 2)) * 100); if (i > userStudy.getAnswer()) { - userStudy.setAnswer(100 - i); + userStudy.setAnswer(i); } } } else if (Constants.FIVE.equals(type)) { // 音图相配 List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day); int item = pairList.size(); - int i = (int) ((double) (schedule / item)) * 100; + int i = (int) (((double) schedule / item) * 100); if (i > userStudy.getPair()) { - userStudy.setPair(100 - i); + userStudy.setPair(i); } } } @@ -967,7 +967,7 @@ */ @GetMapping("/exitGameOrStory") @ApiOperation(value = "退出游戏/故事学习", tags = {"学习端-题目"}) - public R<Boolean> exitGameOrStory(@RequestParam Integer studyTime) { + public R<Boolean> exitGameOrStory(@RequestParam("studyTime") Integer studyTime) { LoginUserParent loginStudy = tokenService.getLoginUserStudy(); if (null == loginStudy) { return R.tokenError("登录失效!"); @@ -1672,7 +1672,7 @@ // 游戏总时长 int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum(); Integer totalStudy = studyRecord.getTotalStudy(); - studyRecord.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600)); + studyRecord.setTotalStudy(Math.round((float) (totalStudy) / 3600)); // 剩余周目 List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0) .eq(TStudy::getType, Constants.ONE) @@ -1702,6 +1702,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(); @@ -1712,8 +1713,11 @@ studyRecord.setMonthStudy(Math.round((float) monthStudy / 3600)); // 游戏总时长 int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum(); + for (TGameRecord tGameRecord : gameRecordList) { + tGameRecord.setTime(simpleDateFormat.format(tGameRecord.getCreateTime())); + } Integer totalStudy = studyRecord.getTotalStudy(); - studyRecord.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600)); + studyRecord.setTotalStudy(Math.round((float) (totalStudy) / 3600)); // 剩余周目 List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0) .eq(TStudy::getType, Constants.ONE) @@ -1757,7 +1761,7 @@ .eq(TGameRecord::getDisabled, 0).list(); int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum(); Integer totalStudy = studyRecord.getTotalStudy(); - studyRecord.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600)); + studyRecord.setTotalStudy(Math.round((float) (totalStudy) / 3600)); StudyRecordResultVO studyRecordResultVO = new StudyRecordResultVO(studyRecord, gameRecordList); return R.ok(studyRecordResultVO); } @@ -1809,12 +1813,17 @@ public R<IPage<TIntegralRecord>> integralDetailParent(String time, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) { - System.err.println("页码" + pageNum); - System.err.println("页数" + pageSize); if (tokenService.getLoginUser1() == null) { return R.tokenError("登录失效"); } - return R.ok(integralRecordService.integralDetail(new Page<>(pageNum, pageSize), tokenService.getLoginUser1().getUserid(), time)); + IPage<TIntegralRecord> page = integralRecordService.integralDetail(new Page<>(pageNum, pageSize), + tokenService.getLoginUser1().getUserid(), time); + for (TIntegralRecord record : page.getRecords()) { + if (!record.getIntegral().startsWith("-")) { + record.setIntegral("+" + record.getIntegral()); + } + } + return R.ok(page); } /** -- Gitblit v1.7.1