From 402aba359adb4b10cfa98ad7fcb424eb55641129 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期四, 04 七月 2024 15:54:52 +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 | 87 ++++++++++++++++++++++++------------------- 1 files changed, 48 insertions(+), 39 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 a1774c5..23cf42d 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; @@ -111,7 +112,7 @@ wrapper.isNotNull("error"); List<TStory> list1 = storyService.list(wrapper); for (TStory tStory : list1) { - if (tStory.getError()!=null && (!tStory.equals(""))){ + if (tStory.getError() != null && (!tStory.getError().isEmpty())) { tStories.add(tStory); } } @@ -738,7 +739,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 = studyService.studySchedule(studyRecord,week); + studyRecord = studyService.studySchedule(studyRecord, week); } return R.ok(studyRecord); } @@ -873,8 +874,6 @@ } else { result = null; } - subjectRecordService.lambdaUpdate().set(TSubjectRecord::getDisabled, 0) - .eq(TSubjectRecord::getUserId, loginStudy.getUserid()).update(); return R.ok(result); } @@ -967,7 +966,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("登录失效!"); @@ -1656,8 +1655,11 @@ TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId) .eq(TUserStudy::getDisabled, 0).one(); // 总时长还需计算上游戏测试成绩时长 - List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId) - .eq(TGameRecord::getDisabled, 0).list(); + List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery() + .eq(TGameRecord::getUserId, userId) + .eq(TGameRecord::getDisabled, 0) + .orderByDesc(TGameRecord::getCreateTime) + .list(); if (null != studyRecord) { // 学习时长格式转换 Integer todayStudy = studyRecord.getTodayStudy(); @@ -1669,7 +1671,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) @@ -1693,39 +1695,41 @@ // 学习记录 TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId) .eq(TUserStudy::getDisabled, 0).one(); - // 查询剩余周目 - if (studyRecord != null) { - int size = studyService.list(new QueryWrapper<TStudy>() - .eq("type", 1)).size(); - studyRecord.setSurplus(size - studyRecord.getWeek()); - } else { - TUserStudy tUserStudy = new TUserStudy(); - tUserStudy.setSurplus(studyService.list(new QueryWrapper<TStudy>() - .eq("type", 1)).size()); - tUserStudy.setTodayStudy(Constants.ZERO); - tUserStudy.setTotalStudy(Constants.ZERO); - tUserStudy.setWeekStudy(Constants.ZERO); - tUserStudy.setMonthStudy(Constants.ZERO); - studyRecord = tUserStudy; - } - // 学习时长格式转换 - Integer todayStudy = studyRecord.getTodayStudy(); - studyRecord.setTodayStudy(Math.round((float) todayStudy / 3600)); - Integer weekStudy = studyRecord.getWeekStudy(); - studyRecord.setWeekStudy(Math.round((float) weekStudy / 3600)); - Integer monthStudy = studyRecord.getMonthStudy(); - studyRecord.setMonthStudy(Math.round((float) monthStudy / 3600)); // 总时长还需计算上游戏测试成绩时长 - List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId) - .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)); + List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery() + .eq(TGameRecord::getUserId, userId) + .eq(TGameRecord::getDisabled, 0) + .orderByDesc(TGameRecord::getCreateTime) + .list(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm"); + if (null != studyRecord) { + // 学习时长格式转换 + Integer todayStudy = studyRecord.getTodayStudy(); + studyRecord.setTodayStudy(Math.round((float) todayStudy / 3600)); + Integer weekStudy = studyRecord.getWeekStudy(); + studyRecord.setWeekStudy(Math.round((float) weekStudy / 3600)); + Integer monthStudy = studyRecord.getMonthStudy(); + 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)); + // 剩余周目 + 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)); } + @PostMapping("/recordManagement/{id}") @ApiOperation(value = "游戏测试成绩", tags = {"管理后台-查看用户详情"}) - public R<StudyRecordResultVO> recordManagement(@PathVariable("id")Integer id) { + public R<StudyRecordResultVO> recordManagement(@PathVariable("id") Integer id) { // 学习记录 TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, id) .eq(TUserStudy::getDisabled, 0).one(); @@ -1808,12 +1812,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