From 770de42c8bbb10676663f33e2748c733c993d27b Mon Sep 17 00:00:00 2001
From: hjl <1657978663@qq.com>
Date: 星期四, 20 六月 2024 15:28:42 +0800
Subject: [PATCH] fix: 学习端bug

---
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java     |   72 ++++++++++--------
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyService.java             |   12 --
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java        |   49 ++++++-----
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java |   46 ++++++++---
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TSubject.java                    |    5 +
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/StudyWeekDTO.java                   |    6 +
 ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/TGoodsServiceImpl.java     |   13 ++-
 7 files changed, 119 insertions(+), 84 deletions(-)

diff --git a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/TGoodsServiceImpl.java b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/TGoodsServiceImpl.java
index a238c85..cfc617e 100644
--- a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/TGoodsServiceImpl.java
+++ b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/TGoodsServiceImpl.java
@@ -153,8 +153,10 @@
         // 扣除用户积分
         result = result && studyClient.exchangeIntegral(needIntegral, Constants.BURDEN).getData();
         return result;
-    }private Boolean exchangeGoodParent(GoodExchangeDTO goodExchange, Recipient recipient, Integer number,
-                                 Integer goodId, int needIntegral) {
+    }
+
+    private Boolean exchangeGoodParent(GoodExchangeDTO goodExchange, Recipient recipient, Integer number,
+                                       Integer goodId, int needIntegral) {
         // 兑换成功,生成订单信息、生成积分明细(积分明细需要远程调用rouyi-study服务)
         TOrder order = orderInfoParent(goodExchange, recipient, number, goodId, needIntegral);
         boolean result = orderService.save(order);
@@ -175,7 +177,7 @@
             return R.exchangeError("商品不存在,请稍后重试!");
         }
         LoginUserParent loginUser1 = tokenService.getLoginUser1();
-        if (null == loginUser1){
+        if (null == loginUser1) {
             return R.tokenError("登录失效");
         }
         // 校验用户积分是否足够兑换
@@ -240,10 +242,11 @@
         order.setIntegral(needIntegral);
         order.setConsigneeName(recipient.getRecipient());
         order.setConsigneePhone(recipient.getRecipientPhone());
-        order.setConsigneeAddress(recipient.getAddress());
+        order.setConsigneeAddress(recipient.getProvince() + recipient.getCity() + recipient.getAddress());
         order.setDisabled(Boolean.FALSE);
         return order;
     }
+
     private TOrder orderInfoParent(GoodExchangeDTO goodExchange, Recipient recipient, Integer number, Integer goodId, int needIntegral) {
         TOrder order = new TOrder();
         order.setOrderNumber(goodExchange.getOrderNumber());
@@ -255,7 +258,7 @@
         order.setIntegral(needIntegral);
         order.setConsigneeName(recipient.getRecipient());
         order.setConsigneePhone(recipient.getRecipientPhone());
-        order.setConsigneeAddress(recipient.getAddress());
+        order.setConsigneeAddress(recipient.getProvince() + recipient.getCity() + recipient.getAddress());
         order.setDisabled(Boolean.FALSE);
         return order;
     }
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 3ce58ac..d35dab6 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
@@ -751,7 +751,11 @@
             @ApiImplicitParam(value = "季度 首次进入季度quarter默认传1", name = "quarter", dataType = "Integer", required = true)
     })
     public R<List<StudyWeekDTO>> weekList(@RequestParam(defaultValue = "1") Integer type, @RequestParam Integer quarter) {
-        List<StudyWeekDTO> result = studyService.weekList(type, quarter);
+        LoginUserParent loginUserStudy = tokenService.getLoginUserStudy();
+        if (null == loginUserStudy) {
+            return R.tokenError("登录失效!");
+        }
+        List<StudyWeekDTO> result = studyService.weekList(type, quarter,loginUserStudy.getUserid());
         return R.ok(result);
     }
 
@@ -857,7 +861,6 @@
         Integer day = exitLearn.getDay();
         if (userStudy.getWeek().equals(exitLearn.getWeek()) && userStudy.getDay().equals(exitLearn.getDay())) {
             // 计算完成率
-            List<String> teamList = Arrays.stream(exitLearn.getTeamIds().split(",")).collect(Collectors.toList());
             Integer type = exitLearn.getType();
             // 更新用户学习完成率
             if (Constants.ONE.equals(type)) {
@@ -867,7 +870,7 @@
                 for (TStudyListen studyListen : studyListens) {
                     item += studyListen.getSubject().split(",").length;
                 }
-                int i = exitLearn.getTopicIds().split(",").length / item;
+                int i = (int) ((double) (exitLearn.getTopicIds().split(",").length / item) * 100);
                 if (i > userStudy.getListen()) {
                     userStudy.setListen(100 - i);
                 }
@@ -876,7 +879,7 @@
                 List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day);
                 if (!lookList.isEmpty()) {
                     int item = lookList.size();
-                    int i = exitLearn.getSchedule() / item;
+                    int i = (int) ((double) (exitLearn.getSchedule() / item)) * 100;
                     if (i > userStudy.getLook()) {
                         userStudy.setLook(100 - i);
                     }
@@ -886,7 +889,7 @@
                 List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day);
                 if (!inductionList.isEmpty()) {
                     int item = inductionList.size();
-                    int i = exitLearn.getSchedule() / item;
+                    int i = (int) ((double) (exitLearn.getSchedule() / item)) * 100;
                     if (i > userStudy.getInduction()) {
                         userStudy.setInduction(100 - i);
                     }
@@ -895,7 +898,7 @@
                 // 有问有答
                 List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day);
                 if (answerList.size() % Constants.TWO == Constants.ZERO) {
-                    int i = exitLearn.getSchedule() / (answerList.size() / 2);
+                    int i = (int) ((double) (exitLearn.getSchedule() / (answerList.size() / 2))) * 100;
                     if (i > userStudy.getAnswer()) {
                         userStudy.setAnswer(100 - i);
                     }
@@ -904,7 +907,7 @@
                 // 音图相配
                 List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day);
                 int item = pairList.size();
-                int i = exitLearn.getSchedule() / item;
+                int i = (int) ((double) (exitLearn.getSchedule() / item)) * 100;
                 if (i > userStudy.getPair()) {
                     userStudy.setPair(100 - i);
                 }
@@ -939,7 +942,7 @@
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day);
         for (TStudyListen studyListen : studyListens) {
-            if (studyListen.getIsVip() == 1) {
+            if (studyListen.getIsVip() == 0) {
                 // 需要会员查看
                 if (!isVip) {
                     // 不是会员
@@ -970,7 +973,7 @@
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day);
         for (TStudyLook studyListen : lookList) {
-            if (studyListen.getIsVip() == 1) {
+            if (studyListen.getIsVip() == 0) {
                 // 需要会员查看
                 if (!isVip) {
                     // 不是会员
@@ -1001,7 +1004,7 @@
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day);
         for (TStudyInduction studyListen : inductionList) {
-            if (studyListen.getIsVip() == 1) {
+            if (studyListen.getIsVip() == 0) {
                 // 需要会员查看
                 if (!isVip) {
                     // 不是会员
@@ -1032,7 +1035,7 @@
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day);
         for (TStudyAnswer studyListen : answerList) {
-            if (studyListen.getIsVip() == 1) {
+            if (studyListen.getIsVip() == 0) {
                 // 需要会员查看
                 if (!isVip) {
                     // 不是会员
@@ -1063,7 +1066,7 @@
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day);
         for (TStudyPair pair : pairList) {
-            if (pair.getIsVip() == 1) {
+            if (pair.getIsVip() == 0) {
                 // 需要会员查看
                 if (!isVip) {
                     // 不是会员
@@ -1315,6 +1318,17 @@
             user.setIntegral(user.getIntegral() + availableIntegral);
             add = add && userService.updateById(user);
         }
+        // 学习时长更新
+        TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid)
+                .eq(TUserStudy::getDisabled, 0).one();
+        if (null == userStudy) {
+            userStudy = createUserStudy(userid);
+            userStudy.setTotalStudy(userStudy.getTotalStudy() + completeStudy.getUseTime());
+            userStudy.setTodayStudy(userStudy.getTodayStudy() + completeStudy.getUseTime());
+            userStudy.setWeekStudy(userStudy.getWeekStudy() + completeStudy.getUseTime());
+            userStudy.setMonthStudy(userStudy.getMonthStudy() + completeStudy.getUseTime());
+        }
+        boolean update = userStudyService.updateById(userStudy);
         // 超级记忆逻辑
         if (Constants.MEMORY.equals(completeStudy.getGameName())) {
             // 学习配置列表
@@ -1332,17 +1346,6 @@
             String rate = game.getRate().split(",")[completeStudy.getDifficulty()];
             add = add && completeStudy.getAccuracy() >= Integer.parseInt(rate);
         }
-        // 学习时长更新
-        TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid)
-                .eq(TUserStudy::getDisabled, 0).one();
-        if (null == userStudy) {
-            userStudy = createUserStudy(userid);
-            userStudy.setTotalStudy(userStudy.getTotalStudy() + completeStudy.getUseTime());
-            userStudy.setTodayStudy(userStudy.getTodayStudy() + completeStudy.getUseTime());
-            userStudy.setWeekStudy(userStudy.getWeekStudy() + completeStudy.getUseTime());
-            userStudy.setMonthStudy(userStudy.getMonthStudy() + completeStudy.getUseTime());
-        }
-        boolean update = userStudyService.updateById(userStudy);
         return R.ok(add && update);
     }
 
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TSubject.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TSubject.java
index 47e586f..10655aa 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TSubject.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TSubject.java
@@ -1,6 +1,7 @@
 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.ruoyi.common.core.web.domain.BaseModel;
@@ -62,4 +63,8 @@
     @ApiModelProperty(value = "错误语音 多个逗号拼接")
     private String error;
 
+    @ApiModelProperty(value = "排序")
+    @TableField(exist = false)
+    private Integer sort;
+
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/StudyWeekDTO.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/StudyWeekDTO.java
index 34c6d56..cf6b5a0 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/StudyWeekDTO.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/StudyWeekDTO.java
@@ -25,11 +25,15 @@
     @ApiModelProperty("study表Id")
     private String id;
 
-    public StudyWeekDTO(Integer week, Integer type, Integer quarter, String title, Integer total) {
+    @ApiModelProperty("能否进入周目学习")
+    private Boolean canStudy;
+
+    public StudyWeekDTO(Integer week, Integer type, Integer quarter, String title, Integer total,Boolean canStudy) {
         super.setWeek(week);
         super.setType(type);
         this.quarter = quarter;
         this.title = title;
         this.totalIntegral = total;
+        this.canStudy = canStudy;
     }
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyService.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyService.java
index 4b6653e..3b93e3c 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyService.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyService.java
@@ -2,7 +2,6 @@
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.study.domain.*;
-import com.ruoyi.study.dto.CompleteGameDTO;
 import com.ruoyi.study.dto.StudyWeekDTO;
 import com.ruoyi.study.vo.*;
 
@@ -23,9 +22,10 @@
      *
      * @param type    所属类型
      * @param quarter 季度
+     * @param userId  用户id
      * @return 列表
      */
-    List<StudyWeekDTO> weekList(Integer type, Integer quarter);
+    List<StudyWeekDTO> weekList(Integer type, Integer quarter, Integer userId);
 
     /**
      * 获取学习进度及学习时长等信息
@@ -114,12 +114,4 @@
      */
     int computeTotalIntegral(List<String> studyIds, Integer type, Integer accuracy);
 
-    /**
-     * 超级记忆正确率达到通关率标准,才能进入下一周目学习
-     *
-     * @param game          游戏信息
-     * @param userid        用户id
-     * @param completeStudy 游戏完成信息
-     */
-    void checkRate(TGame game, Integer userid, CompleteGameDTO completeStudy);
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
index 1f7d72f..68186aa 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
@@ -5,7 +5,6 @@
 import com.ruoyi.common.core.exception.GlobalException;
 import com.ruoyi.common.core.utils.bean.BeanUtils;
 import com.ruoyi.study.domain.*;
-import com.ruoyi.study.dto.CompleteGameDTO;
 import com.ruoyi.study.dto.StudyWeekDTO;
 import com.ruoyi.study.mapper.TStudyMapper;
 import com.ruoyi.study.service.*;
@@ -56,7 +55,7 @@
     }
 
     @Override
-    public List<StudyWeekDTO> weekList(Integer type, Integer quarter) {
+    public List<StudyWeekDTO> weekList(Integer type, Integer quarter, Integer userId) {
         List<StudyWeekDTO> result = new ArrayList<>();
         // 根据季度和type查询学习配置
         List<TStudy> study = lambdaQuery().eq(TStudy::getQuarter, quarter).eq(TStudy::getType, type)
@@ -125,9 +124,41 @@
             total += storyListenList.stream().map(TStoryListen::getIntegral).mapToInt(Integer::intValue).sum();
             // 自主故事 - 看图配音
             total += storyListenList.stream().map(TStoryListen::getLookIntegral).mapToInt(Integer::intValue).sum();
-            result.add(new StudyWeekDTO(week, type, quarter, title, total));
+            // 判断周目是否可以进入学习
+            Boolean canStudy = checkWeekCanStudy(userId, item);
+            result.add(new StudyWeekDTO(week, type, quarter, title, total, canStudy));
         }
         return result;
+    }
+
+    /**
+     * @param userId 用户id
+     * @return 当前周目是否学习
+     */
+    private Boolean checkWeekCanStudy(Integer userId, TStudy study) {
+        TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId)
+                .eq(TUserStudy::getDisabled, 0).one();
+        if (null == userStudy) {
+            userStudy = new TUserStudy();
+            userStudy.setUserId(userId);
+            // 学习周目
+            TStudy tStudy = this.lambdaQuery().eq(TStudy::getQuarter, Constants.ONE)
+                    .orderByAsc(TStudy::getWeek).last("limit 1").one();
+            userStudy.setWeek(tStudy.getWeek());
+            userStudy.setDay(Constants.ONE);
+            userStudy.setTotalStudy(Constants.ZERO);
+            userStudy.setTodayStudy(Constants.ZERO);
+            userStudy.setWeekStudy(Constants.ZERO);
+            userStudy.setMonthStudy(Constants.ZERO);
+            userStudy.setListen(Constants.BURDEN_ONE);
+            userStudy.setLook(Constants.BURDEN_ONE);
+            userStudy.setInduction(Constants.BURDEN_ONE);
+            userStudy.setAnswer(Constants.BURDEN_ONE);
+            userStudy.setPair(Constants.BURDEN_ONE);
+            userStudyService.save(userStudy);
+        }
+        // 学习记录所属周目大于当前学习周目,判断为已学习
+        return userStudy.getWeek() >= study.getWeek();
     }
 
     @Override
@@ -209,14 +240,18 @@
         // 语音及图片
         List<List<TSubject>> subjectList = new ArrayList<>();
         for (TStudyLook studyLook : lookList) {
+            List<String> sortList = Arrays.stream(studyLook.getSort().split(",")).collect(Collectors.toList());
             List<String> subjectIds = Arrays.stream(studyLook.getSubject().split(",")).collect(Collectors.toList());
             List<TSubject> list = new ArrayList<>();
             // 图片及语音集合
-            for (String id : subjectIds) {
-                TSubject data = subjectService.lambdaQuery().eq(TSubject::getId, id)
+            for (int i = 0; i < subjectIds.size(); i++) {
+                TSubject data = subjectService.lambdaQuery().eq(TSubject::getId, subjectIds.get(i))
                         .eq(TSubject::getDisabled, 0).one();
+                data.setSort(Integer.parseInt(sortList.get(i)));
                 list.add(data);
             }
+            // 根据顺序排序
+            list.sort(Comparator.comparingInt(TSubject::getSort));
             subjectList.add(list);
         }
         return new StudyLookResultVO(learnStudy, subjectList);
@@ -348,11 +383,6 @@
     @Override
     public int computeSchedule(TUserStudy result, Integer week) {
         // 基础学习进度
-        Integer listen = result.getListen();
-        Integer look = result.getLook();
-        Integer induction = result.getInduction();
-        Integer answer = result.getAnswer();
-        Integer pair = result.getPair();
         Integer day = result.getDay();
         // 默认进度为 0
         int defaultSchedule;
@@ -374,23 +404,6 @@
             } else {
                 defaultSchedule = 0;
             }
-            // 进度学习完成度计算总学习进度
-            // todo 不确定是否需要累计计算 中途退出的进度
-            /*if (!Constants.ZERO.equals(listen) && !Constants.BURDEN_ONE.equals(listen)) {
-                defaultSchedule += 4 * (100 / listen);
-            }
-            if (!Constants.ZERO.equals(look) && !Constants.BURDEN_ONE.equals(look)) {
-                defaultSchedule += 4 * (100 / look);
-            }
-            if (!Constants.ZERO.equals(induction) && !Constants.BURDEN_ONE.equals(induction)) {
-                defaultSchedule += 4 * (100 / induction);
-            }
-            if (!Constants.ZERO.equals(answer) && !Constants.BURDEN_ONE.equals(answer)) {
-                defaultSchedule += 4 * (100 / answer);
-            }
-            if (!Constants.ZERO.equals(pair) && !Constants.BURDEN_ONE.equals(pair)) {
-                defaultSchedule += 4 * (100 / pair);
-            }*/
         }
         return defaultSchedule;
     }
@@ -437,11 +450,6 @@
             throw new GlobalException("题目信息异常!");
         }
         return (int) (sum * ((double) accuracy / 100));
-    }
-
-    @Override
-    public void checkRate(TGame game, Integer userid, CompleteGameDTO completeStudy) {
-
     }
 
 }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java
index 7a0beef..0170754 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java
@@ -13,6 +13,7 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -134,25 +135,44 @@
     @Override
     public void checkRate(TGame game, Integer userid, CompleteGameDTO completeStudy, List<TStudy> studyList) {
         String answerRate = game.getAnswerRate();
+        // 下一周目逻辑
+        int quarterItem = 1;
+        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);
+            // 记录学习季度
+            if (study.getId().equals(game.getStudyId())) {
+                quarterItem = quarter;
+            }
+        }
+        // 获取当前季度所有周目
+        List<TStudy> studyList1 = studyMap.get(quarterItem);
         // 正确率达到通关率
         if (completeStudy.getAccuracy() >= Integer.parseInt(answerRate)) {
             // 获取用户超级记忆游戏记录
             TUserStudy userStudy = this.lambdaQuery().eq(TUserStudy::getUserId, userid).one();
-            Integer nextDay = DAY_MAP.get(String.valueOf(userStudy.getDay()));
-            userStudy.setDay(nextDay);
-            if (Constants.ONE.equals(nextDay)) {
-                // 获取下一周目信息
-                int index = -1;
-                for (int i = 0; i < studyList.size(); i++) {
-                    if (studyList.get(i).getWeek().equals(userStudy.getWeek())) {
-                        index = i;
-                        break;
+            for (int i = 0; i < studyList1.size(); i++) {
+                TStudy tStudy = studyList1.get(i);
+                if (tStudy.getWeek().equals(userStudy.getWeek())) {
+                    // 是否为当前季度最后一周目
+                    if (i + 1 == studyList1.size() - 1) {
+                        List<TStudy> studyList2 = studyMap.get(quarterItem + 1);
+                        // 下一季度数据为空
+                        if (null != studyList2 && !studyList2.isEmpty()) {
+                            TStudy tStudy1 = studyList2.get(Constants.ZERO);
+                            tStudy.setWeek(tStudy1.getWeek());
+                        }
+                    } else {
+                        TStudy tStudy1 = studyList1.get(i + 1);
+                        userStudy.setWeek(tStudy1.getWeek());
                     }
                 }
-                int nextIndex = (index + 1) % studyList.size();
-                TStudy nextStudy = studyList.get(nextIndex);
-                // 更新学习进度及学习时长
-                userStudy.setWeek(nextStudy.getWeek());
             }
             this.updateById(userStudy);
         }

--
Gitblit v1.7.1