From 5b6664153c815494604c357ec631605e03ad8ddc Mon Sep 17 00:00:00 2001
From: zjk <852185829@qq.com>
Date: 星期二, 13 十月 2026 10:05:42 +0800
Subject: [PATCH] Revert "fix(ruoyi-study): 修复学习进度推进异常及前端展示错误"

---
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java |  101 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 83 insertions(+), 18 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 6f3f1f6..e3c7e21 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
@@ -449,6 +449,8 @@
                 tStudyListen.setIsVip(studyListenDTO.getIsVip());
                 tStudyListen.setRate(dto.getListenRate());
                 tStudyListen.setStudySort(studyListenDTO.getStudySort());
+                tStudyListen.setType(studyListenDTO.getType());
+                tStudyListen.setSort(studyListenDTO.getSort());
                 studyListenService.save(tStudyListen);
             }
             List<Integer> ids1 = studyLookService.lambdaQuery().eq(TStudyLook::getId, one.getId())
@@ -559,6 +561,7 @@
                 tStudyPair.setRate(dto.getPairRate());
                 tStudyPair.setIsVip(studyPairDTO.getIsVip());
                 tStudyPair.setStudySort(studyPairDTO.getStudySort());
+                tStudyPair.setSort(studyPairDTO.getSort());
                 studyPairService.save(tStudyPair);
             }
         }
@@ -761,7 +764,8 @@
         // 听音选图
         List<TStudyListen> list = studyListenService.list(new QueryWrapper<TStudyListen>()
                 .eq("week", week)
-                .eq("day", day).orderByAsc("studySort"));
+                // studySort 会有重复值,追加 id 升序作为二级排序,保证与提交数组顺序一致
+                .eq("day", day).orderByAsc("studySort").orderByAsc("id"));
         List<TSubject> list9 = subjectService.list();
 
         for (TStudyListen tStudyListen : list) {
@@ -771,7 +775,7 @@
                 for (String s : tStudyListen.getSubject().split(",")) {
                     TSubject byId = list9.stream().filter(e -> e.getId().equals(Integer.valueOf(s))).findFirst().orElse(null);
                     if (byId != null) {
-                        temp.append(byId.getName()).append(",");
+                        temp.append(byId.getName()).append("#");
                     }
                 }
                 String string = temp.toString();
@@ -781,6 +785,7 @@
                 studyListenVO.setIsVip(tStudyListen.getIsVip());
                 studyListenVO.setId(tStudyListen.getId());
                 studyListenVO.setType(tStudyListen.getType());
+                studyListenVO.setSort(tStudyListen.getSort());
                 listenVOS.add(studyListenVO);
             }
             res.setListenRate(tStudyListen.getRate());
@@ -789,7 +794,7 @@
         // 看音选图
         List<TStudyLook> list1 = studyLookService.list(new QueryWrapper<TStudyLook>()
                 .eq("week", week)
-                .eq("day", day).orderByAsc("studySort")
+                .eq("day", day).orderByAsc("studySort").orderByAsc("id")
         );
         for (TStudyLook tStudyLook : list1) {
             int index = 0;
@@ -800,7 +805,7 @@
                 for (String s : tStudyLook.getSubject().split(",")) {
                     TSubject byId = list9.stream().filter(e -> e.getId().equals(Integer.valueOf(s))).findFirst().orElse(null);
                     if (byId != null) {
-                        names.append(byId.getName()).append(",");
+                        names.append(byId.getName()).append("#");
                     }
                     String[] split = tStudyLook.getSort().split(",");
                     String s1 = split[index];
@@ -824,7 +829,7 @@
         // 归纳排除
         List<TStudyInduction> list2 = studyInductionService.list(new QueryWrapper<TStudyInduction>()
                 .eq("week", week)
-                .eq("day", day).orderByAsc("studySort")
+                .eq("day", day).orderByAsc("studySort").orderByAsc("id")
         );
         for (TStudyInduction tStudyInduction : list2) {
             StringBuilder names = new StringBuilder();
@@ -834,7 +839,7 @@
                     String replace = s.replace("-", "");
                     TSubject byId = list9.stream().filter(e -> e.getId().equals(Integer.valueOf(replace))).findFirst().orElse(null);
                     if (byId != null) {
-                        names.append(byId.getName()).append(",");
+                        names.append(byId.getName()).append("#");
                     }
                 }
                 String string = names.toString();
@@ -852,7 +857,7 @@
         // 有问有答
         List<TStudyAnswer> list3 = studyAnswerService.list(new QueryWrapper<TStudyAnswer>()
                 .eq("week", week)
-                .eq("day", day).orderByAsc("studySort"));
+                .eq("day", day).orderByAsc("studySort").orderByAsc("id"));
         for (TStudyAnswer tStudyAnswer : list3) {
             StringBuilder names = new StringBuilder();
             StudyAnswerVO studyAnswerVO = new StudyAnswerVO();
@@ -862,27 +867,27 @@
 
                         TSubject byId = list9.stream().filter(e -> e.getId().equals(tStudyAnswer.getSubject())).findFirst().orElse(null);
                         if (byId != null) {
-                            names.append(byId.getName()).append(",");
+                            names.append(byId.getName()).append("#");
                         }
                     }
                     if (tStudyAnswer.getAnswerSubject() != null) {
 
                         TSubject byId1 = list9.stream().filter(e -> e.getId().equals(tStudyAnswer.getAnswerSubject())).findFirst().orElse(null);
                         if (byId1 != null) {
-                            names.append(byId1.getName()).append(",");
+                            names.append(byId1.getName()).append("#");
                         }
                     }
                 } else {
                     if (tStudyAnswer.getSubject() != null) {
                         TSubject byId = list9.stream().filter(e -> e.getId().equals(tStudyAnswer.getSubject())).findFirst().orElse(null);
                         if (byId != null) {
-                            names.append(byId.getName()).append(",");
+                            names.append(byId.getName()).append("#");
                         }
                     }
                     if (tStudyAnswer.getAnswerSubject() != null) {
                         TSubject byId1 = list9.stream().filter(e -> e.getId().equals(tStudyAnswer.getAnswerSubject())).findFirst().orElse(null);
                         if (byId1 != null) {
-                            names.append(byId1.getName()).append(",");
+                            names.append(byId1.getName()).append("#");
                         }
                     }
                 }
@@ -905,7 +910,7 @@
         // 音图相配
         List<TStudyPair> list4 = studyPairService.list(new QueryWrapper<TStudyPair>()
                 .eq("week", week)
-                .eq("day", day).orderByAsc("studySort")
+                .eq("day", day).orderByAsc("studySort").orderByAsc("id")
         );
         for (TStudyPair tStudyPair : list4) {
             StringBuilder names = new StringBuilder();
@@ -915,7 +920,7 @@
 
                     TSubject byId = list9.stream().filter(e -> e.getId().equals(Integer.valueOf(s))).findFirst().orElse(null);
                     if (byId != null) {
-                        names.append(byId.getName()).append(",");
+                        names.append(byId.getName()).append("#");
                     }
                 }
                 String string = names.toString();
@@ -924,6 +929,7 @@
                 studyPairVO.setSubject(tStudyPair.getSubject());
                 studyPairVO.setIsVip(tStudyPair.getIsVip());
                 studyPairVO.setId(tStudyPair.getId());
+                studyPairVO.setSort(tStudyPair.getSort());
                 pairVOS.add(studyPairVO);
             }
             res.setPairRate(tStudyPair.getRate());
@@ -970,7 +976,7 @@
                 for (String s : tStory.getStory().split(",")) {
                     TStory byId = list10.stream().filter(e -> e.getId().equals(Integer.valueOf(s))).findFirst().orElse(null);
                     if (byId != null) {
-                        names.append(byId.getName()).append(",");
+                        names.append(byId.getName()).append("#");
                     }
                 }
             }
@@ -979,7 +985,7 @@
 
                     TStory byId = list10.stream().filter(e -> e.getId().equals(Integer.valueOf(s))).findFirst().orElse(null);
                     if (byId != null) {
-                        names1.append(byId.getName()).append(",");
+                        names1.append(byId.getName()).append("#");
                     }
                 }
             }
@@ -1430,6 +1436,36 @@
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day);
         for (TStudyListen studyListen : studyListens) {
+            if(studyListen.getType()==null || studyListen.getType()==1){
+                String sort = studyListen.getSort();
+                if(sort!=null){
+                    String subject = studyListen.getSubject();
+                    String[] split = sort.split(",");
+                    String[] subjectIds = subject.split(",");
+                    ArrayList<Map<String, String>> maps = new ArrayList<>();
+                    for (int i = 0; i < split.length; i++) {
+                        HashMap<String, String> map = new HashMap<>();
+                        map.put("sort", split[i]);
+                        map.put("subject", subjectIds[i]);
+                        maps.add(map);
+                    }
+                    List<Map<String, String>> sort1 = maps.stream().sorted(Comparator.comparingInt(o -> Integer.parseInt(o.get("sort")))).collect(Collectors.toList());
+                    ArrayList<String> strings = new ArrayList<>();
+                    for (Map<String, String> stringStringMap : sort1) {
+                        String s = stringStringMap.get("subject");
+                        strings.add(s);
+                    }
+                    subject = strings.stream().collect(Collectors.joining(","));
+                    studyListen.setSubject(subject);
+                }
+
+            }
+
+
+        }
+        System.out.println("数据2!!"+studyListens);
+
+        for (TStudyListen studyListen : studyListens) {
             if (studyListen.getIsVip() == 0) {
                 // 需要会员查看
                 if (!isVip) {
@@ -1553,6 +1589,8 @@
         Boolean isVip = userService.isVip();
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day);
+
+
         for (TStudyPair pair : pairList) {
             if (pair.getIsVip() == 0) {
                 // 需要会员查看
@@ -1561,6 +1599,30 @@
                     return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!");
                 }
             }
+
+
+            String sort = pair.getSort();
+            if(sort!=null){
+                String subject = pair.getSubject();
+                String[] split = sort.split(",");
+                String[] subjectIds = subject.split(",");
+                ArrayList<Map<String, String>> maps = new ArrayList<>();
+                for (int i = 0; i < split.length; i++) {
+                    HashMap<String, String> map = new HashMap<>();
+                    map.put("sort", split[i]);
+                    map.put("subject", subjectIds[i]);
+                    maps.add(map);
+                }
+                List<Map<String, String>> sort1 = maps.stream().sorted(Comparator.comparingInt(o -> Integer.parseInt(o.get("sort")))).collect(Collectors.toList());
+                ArrayList<String> strings = new ArrayList<>();
+                for (Map<String, String> stringStringMap : sort1) {
+                    String s = stringStringMap.get("subject");
+                    strings.add(s);
+                }
+                subject = strings.stream().collect(Collectors.joining(","));
+                pair.setSubject(subject);
+            }
+
         }
         return studyService.pictureMateVoice(week, day, pairList, tokenService.getLoginUserStudy().getUserid());
     }
@@ -1577,9 +1639,12 @@
         }
         System.err.println("答题DTO"+answerQuestionDTO);
         TSubjectRecordDetail byId = subjectRecordDetailService.getById(answerQuestionDTO.getId());
-        byId.setUserId(null);
-        byId.setStatus(answerQuestionDTO.getStatus());
-        subjectRecordDetailService.updateById(byId);
+        if(byId.getStatus()==1){
+            byId.setUserId(null);
+            byId.setStatus(answerQuestionDTO.getStatus());
+            subjectRecordDetailService.updateById(byId);
+        }
+
         return R.ok();
     }
 

--
Gitblit v1.7.1