Browse Source

Merge remote-tracking branch 'origin/master' into ywx

tags/正式版本
雍文秀 2 years ago
parent
commit
9523bef8ce

+ 3
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/mapper/question/QuestionMapper.java View File

93
      * @Date 2022/7/25 16:55
93
      * @Date 2022/7/25 16:55
94
      **/
94
      **/
95
     void saveBathQuestion(@Param("list") List<TQuestion> list);
95
     void saveBathQuestion(@Param("list") List<TQuestion> list);
96
+
97
+    //获取科目下听力题数量
98
+    Integer getQuestionHasHearNum(@Param("subjectid")String subjectid);
96
 }
99
 }

+ 5
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/service/question/QuestionService.java View File

371
         question.setCreatetime(timestamp);
371
         question.setCreatetime(timestamp);
372
         String questionid = StudyUtil.getId();
372
         String questionid = StudyUtil.getId();
373
         question.setQuestionid(questionid);
373
         question.setQuestionid(questionid);
374
+
375
+        if(question.getHashear() == null){
376
+            question.setHashear(0);
377
+        }
378
+
374
         saveQues.add(question);
379
         saveQues.add(question);
375
         map.put("questionid",questionid);
380
         map.put("questionid",questionid);
376
 
381
 

+ 40
- 5
sstudy/src/main/java/com/xhkjedu/sstudy/service/question/UserBasketService.java View File

2
 
2
 
3
 import com.xhkjedu.sstudy.mapper.question.QuestionMapper;
3
 import com.xhkjedu.sstudy.mapper.question.QuestionMapper;
4
 import com.xhkjedu.sstudy.mapper.question.UserBasketMapper;
4
 import com.xhkjedu.sstudy.mapper.question.UserBasketMapper;
5
+import com.xhkjedu.sstudy.mapper.subjectbook.SubjectMapper;
5
 import com.xhkjedu.sstudy.model.question.TUserBasket;
6
 import com.xhkjedu.sstudy.model.question.TUserBasket;
6
 import com.xhkjedu.utils.N_Utils;
7
 import com.xhkjedu.utils.N_Utils;
7
 import com.xhkjedu.sstudy.vo.question.QuestionVo;
8
 import com.xhkjedu.sstudy.vo.question.QuestionVo;
9
 import org.springframework.stereotype.Service;
10
 import org.springframework.stereotype.Service;
10
 
11
 
11
 import javax.annotation.Resource;
12
 import javax.annotation.Resource;
13
+import java.util.ArrayList;
12
 import java.util.List;
14
 import java.util.List;
13
 import java.util.stream.Collectors;
15
 import java.util.stream.Collectors;
14
 
16
 
24
     private UserBasketMapper userBasketMapper;
26
     private UserBasketMapper userBasketMapper;
25
     @Resource
27
     @Resource
26
     private QuestionMapper questionMapper;
28
     private QuestionMapper questionMapper;
29
+    @Resource
30
+    private SubjectMapper subjectMapper;
27
 
31
 
28
     //添加
32
     //添加
29
     public Integer save(TUserBasket model) {
33
     public Integer save(TUserBasket model) {
57
     //获取列表
61
     //获取列表
58
     public List <UserBasketVo> findAll(Integer userid, String subjectid) {
62
     public List <UserBasketVo> findAll(Integer userid, String subjectid) {
59
         List<UserBasketVo> baskets = userBasketMapper.findAll(userid, subjectid);
63
         List<UserBasketVo> baskets = userBasketMapper.findAll(userid, subjectid);
60
-        for (UserBasketVo b : baskets) {
61
-            List<QuestionVo> questions = b.getQuestions();
62
-            b.setPtnum(questions.size());
63
-            Double scoretotal = questions.stream().collect(Collectors.summingDouble(QuestionVo::getScore));
64
-            b.setPtscore(scoretotal);
64
+        String sujectname = subjectMapper.getSubjectnameById(subjectid);
65
+        //英语学科时处理听力题
66
+        if(sujectname.contains("英语")){
67
+            List<QuestionVo> hearqs  = new ArrayList<>();
68
+            for (UserBasketVo b : baskets) {
69
+                List<QuestionVo> questions = b.getQuestions();
70
+
71
+                List<QuestionVo> tllist = questions.stream().filter( o -> o.getHashear() ==1).collect(Collectors.toList());
72
+                if(N_Utils.isNotEmpty(tllist)){
73
+                    hearqs.addAll(tllist);
74
+
75
+                    questions = questions.stream().filter( o -> o.getHashear() ==0).collect(Collectors.toList());
76
+                }
77
+                b.setPtnum(questions.size());
78
+                Double scoretotal = questions.stream().collect(Collectors.summingDouble(QuestionVo::getScore));
79
+                b.setPtscore(scoretotal);
80
+                b.setQuestions(questions);
81
+            }
82
+
83
+            if(N_Utils.isNotEmpty(hearqs)){
84
+                UserBasketVo tlvo = new UserBasketVo();
85
+                tlvo.setQtypename("听力题");
86
+                tlvo.setPtnum(hearqs.size());
87
+                Double scoretotal = hearqs.stream().collect(Collectors.summingDouble(QuestionVo::getScore));
88
+                tlvo.setPtscore(scoretotal);
89
+                tlvo.setQuestions(hearqs);
90
+                baskets.add(0,tlvo);
91
+
92
+            }
93
+        }else{
94
+            for (UserBasketVo b : baskets) {
95
+                List<QuestionVo> questions = b.getQuestions();
96
+                b.setPtnum(questions.size());
97
+                Double scoretotal = questions.stream().collect(Collectors.summingDouble(QuestionVo::getScore));
98
+                b.setPtscore(scoretotal);
99
+            }
65
         }
100
         }
66
         return baskets;
101
         return baskets;
67
     }
102
     }

+ 8
- 5
sstudy/src/main/java/com/xhkjedu/sstudy/service/subjectbook/SubjectQuestiontypeService.java View File

1
 package com.xhkjedu.sstudy.service.subjectbook;
1
 package com.xhkjedu.sstudy.service.subjectbook;
2
 
2
 
3
+import com.xhkjedu.sstudy.mapper.question.QuestionMapper;
3
 import com.xhkjedu.sstudy.mapper.subjectbook.SubjectMapper;
4
 import com.xhkjedu.sstudy.mapper.subjectbook.SubjectMapper;
4
 import com.xhkjedu.sstudy.mapper.subjectbook.SubjectQuestiontypeMapper;
5
 import com.xhkjedu.sstudy.mapper.subjectbook.SubjectQuestiontypeMapper;
5
 import com.xhkjedu.sstudy.model.subjectbook.TSubjectQuestiontype;
6
 import com.xhkjedu.sstudy.model.subjectbook.TSubjectQuestiontype;
9
 import org.springframework.beans.factory.annotation.Autowired;
10
 import org.springframework.beans.factory.annotation.Autowired;
10
 import org.springframework.stereotype.Service;
11
 import org.springframework.stereotype.Service;
11
 
12
 
13
+import javax.annotation.Resource;
12
 import java.util.HashMap;
14
 import java.util.HashMap;
13
 import java.util.List;
15
 import java.util.List;
14
 import java.util.Map;
16
 import java.util.Map;
25
     private SubjectQuestiontypeMapper subjectQuestiontypeMapper;
27
     private SubjectQuestiontypeMapper subjectQuestiontypeMapper;
26
     @Autowired
28
     @Autowired
27
     private SubjectMapper subjectMapper;
29
     private SubjectMapper subjectMapper;
30
+    @Resource
31
+    private QuestionMapper questionMapper;
28
 
32
 
29
     /**
33
     /**
30
      *功能描述 获取科目下所有题型
34
      *功能描述 获取科目下所有题型
109
         String  subjectname = subjectMapper.getSubjectnameById(sqtype.getSubjectid());
113
         String  subjectname = subjectMapper.getSubjectnameById(sqtype.getSubjectid());
110
         if(subjectname.contains("英语")){
114
         if(subjectname.contains("英语")){
111
             //如果是英语题获取英语题对应试题包含听力题的题型
115
             //如果是英语题获取英语题对应试题包含听力题的题型
112
-            List<Map> heartypes = subjectQuestiontypeMapper.listQtypesHasHear(sqtype);
113
-            if(heartypes!=null && heartypes.size()>0){
116
+//            List<Map> heartypes = subjectQuestiontypeMapper.listQtypesHasHear(sqtype);//获取有听力题的题型
117
+            Integer hearnum = questionMapper.getQuestionHasHearNum(sqtype.getSubjectid());
118
+            if(hearnum!=null && hearnum >0){
114
                 Map tlmap = new HashMap();
119
                 Map tlmap = new HashMap();
115
                 tlmap.put("qtypename","听力题");
120
                 tlmap.put("qtypename","听力题");
116
-                tlmap.put("qtypes",heartypes);
117
                 list.add(0,tlmap);
121
                 list.add(0,tlmap);
118
             }
122
             }
119
         }
123
         }
120
         return list;
124
         return list;
121
     }
125
     }
122
-
123
-    }
126
+}

+ 5
- 0
sstudy/src/main/resources/mapper/question/QuestionMapper.xml View File

313
         </foreach>
313
         </foreach>
314
     </insert>
314
     </insert>
315
 
315
 
316
+    <!--获取科目下听力题数量-->
317
+    <select id="getQuestionHasHearNum" resultType="java.lang.Integer">
318
+        select count(*) from t_question where hashear=1 and qstate=1 and subjectid=#{subjectid}
319
+    </select>
320
+
316
 </mapper>
321
 </mapper>

+ 3
- 1
sstudy/src/main/resources/mapper/question/UserBasketMapper.xml View File

21
             <result property="count" column="count"></result>
21
             <result property="count" column="count"></result>
22
             <result property="qlevel" column="qlevel"></result>
22
             <result property="qlevel" column="qlevel"></result>
23
             <result property="snum" column="snum"></result>
23
             <result property="snum" column="snum"></result>
24
+            <result property="hashear" column="hashear"></result>
25
+            <result property="hearfile" column="hearfile"></result>
24
             <collection property="points" ofType="com.xhkjedu.sstudy.vo.subjectbook.PointVo">
26
             <collection property="points" ofType="com.xhkjedu.sstudy.vo.subjectbook.PointVo">
25
                 <result property="pointid" column="pointid"></result>
27
                 <result property="pointid" column="pointid"></result>
26
                 <result property="pointname" column="pointname"></result>
28
                 <result property="pointname" column="pointname"></result>
53
     </resultMap>
55
     </resultMap>
54
     <select id="findAll" resultMap="basketResult">
56
     <select id="findAll" resultMap="basketResult">
55
         select ub.*,q.questionid,q.score,q.complexity,q.ctype,q.qstem,q.qoption,q.qanswer,q.qanalyze,q.createtime
57
         select ub.*,q.questionid,q.score,q.complexity,q.ctype,q.qstem,q.qoption,q.qanswer,q.qanalyze,q.createtime
56
-        ,q.count,qp.pointid,p.pointname,q.qlevel,q.snum
58
+        ,q.count,qp.pointid,p.pointname,q.qlevel,q.snum,q.hashear,q.hearfile
57
         from t_user_basket ub left join t_subject_questiontype tsq on ub.qtypeid = tsq.qtypeid
59
         from t_user_basket ub left join t_subject_questiontype tsq on ub.qtypeid = tsq.qtypeid
58
         left join t_question q on ub.questionid = q.questionid
60
         left join t_question q on ub.questionid = q.questionid
59
         left join t_question_point qp on q.questionid = qp.questionid
61
         left join t_question_point qp on q.questionid = qp.questionid

Loading…
Cancel
Save