Browse Source

课堂活跃度最后统一计算

tags/正式版本
雍文秀 2 years ago
parent
commit
9c88c75a66

+ 4
- 38
sclass/src/main/java/com/xhkjedu/sclass/controller/classroom/ClassroomController.java View File

3
 import com.alibaba.fastjson.JSON;
3
 import com.alibaba.fastjson.JSON;
4
 import com.github.pagehelper.PageHelper;
4
 import com.github.pagehelper.PageHelper;
5
 import com.github.pagehelper.PageInfo;
5
 import com.github.pagehelper.PageInfo;
6
-import com.xhkjedu.sclass.model.classroom.TClassroom;
7
-import com.xhkjedu.sclass.model.classroom.TClassroomActivestudent;
8
-import com.xhkjedu.sclass.model.classroom.TClassroomAskstudent;
9
-import com.xhkjedu.sclass.model.classroom.TClassroomAskteacher;
10
-import com.xhkjedu.sclass.model.classroom.TClassroomFile;
11
-import com.xhkjedu.sclass.model.classroom.TClassroomPaper;
12
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperFile;
13
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperQtype;
14
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperScantron;
15
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperStudent;
16
-import com.xhkjedu.sclass.model.classroom.TClassroomSign;
6
+import com.xhkjedu.sclass.model.classroom.*;
17
 import com.xhkjedu.sclass.model.paperstudent.TPaperStudent;
7
 import com.xhkjedu.sclass.model.paperstudent.TPaperStudent;
18
 import com.xhkjedu.sclass.model.paperstudent.TPaperStudentScantron;
8
 import com.xhkjedu.sclass.model.paperstudent.TPaperStudentScantron;
19
 import com.xhkjedu.sclass.service.classroom.ClassroomPaperService;
9
 import com.xhkjedu.sclass.service.classroom.ClassroomPaperService;
20
 import com.xhkjedu.sclass.service.classroom.ClassroomService;
10
 import com.xhkjedu.sclass.service.classroom.ClassroomService;
21
-import com.xhkjedu.sclass.vo.classroom.ObjectiveVo;
22
-import com.xhkjedu.sclass.vo.classroom.ReportEQuestionVo;
23
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectCallVo;
24
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectExamVo;
25
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectVo;
26
-import com.xhkjedu.sclass.vo.classroom.RoomVo;
27
-import com.xhkjedu.sclass.vo.classroom.SubjectiveVo;
11
+import com.xhkjedu.sclass.vo.classroom.*;
28
 import com.xhkjedu.sclass.vo.paper.CheckClassVo;
12
 import com.xhkjedu.sclass.vo.paper.CheckClassVo;
29
 import com.xhkjedu.sclass.vo.paperstudent.StudentVo;
13
 import com.xhkjedu.sclass.vo.paperstudent.StudentVo;
30
 import com.xhkjedu.sclass.vo.room.RoomPVo;
14
 import com.xhkjedu.sclass.vo.room.RoomPVo;
71
         List<TClassroomAskteacher> askteacherList = new ArrayList<>();//结束课堂集合
55
         List<TClassroomAskteacher> askteacherList = new ArrayList<>();//结束课堂集合
72
         List<TClassroomAskstudent> askstudentList = new ArrayList<>();//结束课堂集合
56
         List<TClassroomAskstudent> askstudentList = new ArrayList<>();//结束课堂集合
73
         List<TClassroomSign> signList = new ArrayList<>();//结束课堂集合
57
         List<TClassroomSign> signList = new ArrayList<>();//结束课堂集合
74
-        List<TClassroomActivestudent> activestudentList = new ArrayList<>();//结束课堂集合
75
         List<TClassroomPaper> paperList = new ArrayList<>();//结束课堂集合
58
         List<TClassroomPaper> paperList = new ArrayList<>();//结束课堂集合
76
         List<TClassroomPaperStudent> stupaperList = new ArrayList<>();//结束课堂集合
59
         List<TClassroomPaperStudent> stupaperList = new ArrayList<>();//结束课堂集合
77
         List<TClassroomPaperFile> paperFileList = new ArrayList<>();//堂测附件集合
60
         List<TClassroomPaperFile> paperFileList = new ArrayList<>();//堂测附件集合
98
                 } else if (rtype.equals("askstudent")) {//互动--保存学生作答情况
81
                 } else if (rtype.equals("askstudent")) {//互动--保存学生作答情况
99
                     TClassroomAskstudent student = JSON.parseObject(jsonstr, TClassroomAskstudent.class);
82
                     TClassroomAskstudent student = JSON.parseObject(jsonstr, TClassroomAskstudent.class);
100
                     askstudentList.add(student);
83
                     askstudentList.add(student);
101
-                    TClassroomActivestudent as = new TClassroomActivestudent();
102
-                    as.setRoomid(student.getRoomid());
103
-                    as.setStudentid(student.getStudentid());
104
-                    activestudentList.add(as);
105
                 } else if (rtype.equals("sign")) {//学生--签到
84
                 } else if (rtype.equals("sign")) {//学生--签到
106
                     TClassroomSign sign = JSON.parseObject(jsonstr, TClassroomSign.class);
85
                     TClassroomSign sign = JSON.parseObject(jsonstr, TClassroomSign.class);
107
                     signList.add(sign);
86
                     signList.add(sign);
108
-                    TClassroomActivestudent as = new TClassroomActivestudent();
109
-                    as.setRoomid(sign.getRoomid());
110
-                    as.setStudentid(sign.getUserid());
111
-                    activestudentList.add(as);
112
                 } else if (rtype.equals("paper")) {//堂测--发布
87
                 } else if (rtype.equals("paper")) {//堂测--发布
113
                     TClassroomPaper paper = JSON.parseObject(jsonstr, TClassroomPaper.class);
88
                     TClassroomPaper paper = JSON.parseObject(jsonstr, TClassroomPaper.class);
114
 
89
 
159
             });
134
             });
160
         });
135
         });
161
         return classroomService.batchSaveClass(startclassList, stopclassList, savefileList
136
         return classroomService.batchSaveClass(startclassList, stopclassList, savefileList
162
-                , askteacherList, askstudentList, signList, activestudentList
137
+                , askteacherList, askstudentList, signList
163
                 , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList);
138
                 , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList);
164
     }
139
     }
165
 
140
 
183
         List<TClassroomAskteacher> askteacherList = new ArrayList<>();//结束课堂集合
158
         List<TClassroomAskteacher> askteacherList = new ArrayList<>();//结束课堂集合
184
         List<TClassroomAskstudent> askstudentList = new ArrayList<>();//结束课堂集合
159
         List<TClassroomAskstudent> askstudentList = new ArrayList<>();//结束课堂集合
185
         List<TClassroomSign> signList = new ArrayList<>();//结束课堂集合
160
         List<TClassroomSign> signList = new ArrayList<>();//结束课堂集合
186
-        List<TClassroomActivestudent> activestudentList = new ArrayList<>();//结束课堂集合
187
         List<TClassroomPaper> paperList = new ArrayList<>();//结束课堂集合
161
         List<TClassroomPaper> paperList = new ArrayList<>();//结束课堂集合
188
         List<TClassroomPaperStudent> stupaperList = new ArrayList<>();//结束课堂集合
162
         List<TClassroomPaperStudent> stupaperList = new ArrayList<>();//结束课堂集合
189
         List<TClassroomPaperFile> paperFileList = new ArrayList<>();//堂测附件集合
163
         List<TClassroomPaperFile> paperFileList = new ArrayList<>();//堂测附件集合
207
             } else if (rtype.equals("askstudent")) {//互动--保存学生作答情况
181
             } else if (rtype.equals("askstudent")) {//互动--保存学生作答情况
208
                 TClassroomAskstudent student = JSON.parseObject(jsonstr, TClassroomAskstudent.class);
182
                 TClassroomAskstudent student = JSON.parseObject(jsonstr, TClassroomAskstudent.class);
209
                 askstudentList.add(student);
183
                 askstudentList.add(student);
210
-                TClassroomActivestudent as = new TClassroomActivestudent();
211
-                as.setRoomid(student.getRoomid());
212
-                as.setStudentid(student.getStudentid());
213
-                activestudentList.add(as);
214
             } else if (rtype.equals("sign")) {//学生--签到
184
             } else if (rtype.equals("sign")) {//学生--签到
215
                 TClassroomSign sign = JSON.parseObject(jsonstr, TClassroomSign.class);
185
                 TClassroomSign sign = JSON.parseObject(jsonstr, TClassroomSign.class);
216
                 signList.add(sign);
186
                 signList.add(sign);
217
-                TClassroomActivestudent as = new TClassroomActivestudent();
218
-                as.setRoomid(sign.getRoomid());
219
-                as.setStudentid(sign.getUserid());
220
-                activestudentList.add(as);
221
             } else if (rtype.equals("paper")) {//堂测--发布
187
             } else if (rtype.equals("paper")) {//堂测--发布
222
                 TClassroomPaper paper = JSON.parseObject(jsonstr, TClassroomPaper.class);
188
                 TClassroomPaper paper = JSON.parseObject(jsonstr, TClassroomPaper.class);
223
 
189
 
267
             }
233
             }
268
         }
234
         }
269
         return classroomService.saveClass(startclass, stopclass, savefileList
235
         return classroomService.saveClass(startclass, stopclass, savefileList
270
-                , askteacherList, askstudentList, signList, activestudentList
236
+                , askteacherList, askstudentList, signList
271
                 , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList);
237
                 , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList);
272
     }
238
     }
273
 
239
 

+ 7
- 0
sclass/src/main/java/com/xhkjedu/sclass/mapper/classroom/ClassroomActivestudentMapper.java View File

44
 
44
 
45
     //批量更新活跃值排名
45
     //批量更新活跃值排名
46
     void updateBatchActiveRank(@Param("roomids") List<Long> roomids);
46
     void updateBatchActiveRank(@Param("roomids") List<Long> roomids);
47
+
48
+    //根据课堂id获取互动ids
49
+    String getAsktidsByRoomId(@Param("roomid") Long roomid);
50
+
51
+    //课堂学生
52
+    List<TClassroomActivestudent> listRoomStu(@Param("roomid") Long roomid, @Param("classid") Integer classid
53
+            ,@Param("asktids") String asktids);
47
 }
54
 }

+ 43
- 51
sclass/src/main/java/com/xhkjedu/sclass/service/classroom/ClassroomService.java View File

1
 package com.xhkjedu.sclass.service.classroom;
1
 package com.xhkjedu.sclass.service.classroom;
2
 
2
 
3
 import com.alibaba.fastjson.JSON;
3
 import com.alibaba.fastjson.JSON;
4
-import com.xhkjedu.sclass.mapper.classroom.ClassroomActivestudentMapper;
5
-import com.xhkjedu.sclass.mapper.classroom.ClassroomAskstudentMapper;
6
-import com.xhkjedu.sclass.mapper.classroom.ClassroomAskteacherMapper;
7
-import com.xhkjedu.sclass.mapper.classroom.ClassroomFileMapper;
8
-import com.xhkjedu.sclass.mapper.classroom.ClassroomMapper;
9
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperFileMapper;
10
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperMapper;
11
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperQtypeMapper;
12
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperScantronMapper;
13
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperStudentMapper;
14
-import com.xhkjedu.sclass.mapper.classroom.ClassroomPaperStudentScantronMapper;
15
-import com.xhkjedu.sclass.mapper.classroom.ClassroomSignMapper;
16
-import com.xhkjedu.sclass.model.classroom.TClassroom;
17
-import com.xhkjedu.sclass.model.classroom.TClassroomActivestudent;
18
-import com.xhkjedu.sclass.model.classroom.TClassroomAskstudent;
19
-import com.xhkjedu.sclass.model.classroom.TClassroomAskteacher;
20
-import com.xhkjedu.sclass.model.classroom.TClassroomFile;
21
-import com.xhkjedu.sclass.model.classroom.TClassroomPaper;
22
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperFile;
23
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperQtype;
24
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperScantron;
25
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperStudent;
26
-import com.xhkjedu.sclass.model.classroom.TClassroomPaperStudentScantron;
27
-import com.xhkjedu.sclass.model.classroom.TClassroomSign;
4
+import com.xhkjedu.sclass.mapper.classroom.*;
5
+import com.xhkjedu.sclass.model.classroom.*;
28
 import com.xhkjedu.sclass.utils.ArithUtil;
6
 import com.xhkjedu.sclass.utils.ArithUtil;
29
-import com.xhkjedu.sclass.vo.classroom.ObjectiveVo;
30
-import com.xhkjedu.sclass.vo.classroom.ReportEQuestionVo;
31
-import com.xhkjedu.sclass.vo.classroom.ReportExamVo;
32
-import com.xhkjedu.sclass.vo.classroom.ReportRoomVo;
33
-import com.xhkjedu.sclass.vo.classroom.RoomAskTeacherVo;
34
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectCallVo;
35
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectExamVo;
36
-import com.xhkjedu.sclass.vo.classroom.RoomCorrectVo;
37
-import com.xhkjedu.sclass.vo.classroom.SubjectiveVo;
7
+import com.xhkjedu.sclass.vo.classroom.*;
38
 import com.xhkjedu.sclass.vo.paper.CheckClassVo;
8
 import com.xhkjedu.sclass.vo.paper.CheckClassVo;
39
 import com.xhkjedu.utils.N_Utils;
9
 import com.xhkjedu.utils.N_Utils;
40
 import com.xhkjedu.vo.ResultVo;
10
 import com.xhkjedu.vo.ResultVo;
46
 import org.springframework.util.CollectionUtils;
16
 import org.springframework.util.CollectionUtils;
47
 
17
 
48
 import javax.annotation.Resource;
18
 import javax.annotation.Resource;
49
-import java.util.ArrayList;
50
-import java.util.Arrays;
51
-import java.util.List;
52
-import java.util.Map;
19
+import java.util.*;
53
 import java.util.stream.Collectors;
20
 import java.util.stream.Collectors;
54
 
21
 
55
 @Slf4j
22
 @Slf4j
556
      *
523
      *
557
      * @return com.xhkjedu.vo.ResultVo
524
      * @return com.xhkjedu.vo.ResultVo
558
      * @Param [startclassList, stopclassList, savefileList, askteacherList, askstudentList, signList
525
      * @Param [startclassList, stopclassList, savefileList, askteacherList, askstudentList, signList
559
-     * , activestudentList, paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList]
526
+     * , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList]
560
      * @Author ywx
527
      * @Author ywx
561
      * @Date 2022/6/28 16:51
528
      * @Date 2022/6/28 16:51
562
      **/
529
      **/
564
     public ResultVo batchSaveClass(List<TClassroom> startclassList, List<TClassroom> stopclassList
531
     public ResultVo batchSaveClass(List<TClassroom> startclassList, List<TClassroom> stopclassList
565
             , List<TClassroomFile> savefileList
532
             , List<TClassroomFile> savefileList
566
             , List<TClassroomAskteacher> askteacherList, List<TClassroomAskstudent> askstudentList
533
             , List<TClassroomAskteacher> askteacherList, List<TClassroomAskstudent> askstudentList
567
-            , List<TClassroomSign> signList, List<TClassroomActivestudent> activestudentList
534
+            , List<TClassroomSign> signList
568
             , List<TClassroomPaper> paperList, List<TClassroomPaperStudent> stupaperList
535
             , List<TClassroomPaper> paperList, List<TClassroomPaperStudent> stupaperList
569
             , List<TClassroomPaperFile> paperFileList, List<TClassroomPaperQtype> paperQtypeList
536
             , List<TClassroomPaperFile> paperFileList, List<TClassroomPaperQtype> paperQtypeList
570
             , List<TClassroomPaperScantron> paperScantronList) {
537
             , List<TClassroomPaperScantron> paperScantronList) {
577
             Map<Integer, Integer> classMap = classList.stream().collect(Collectors.toMap(TClassroom::getClassid, TClassroom::getClassnum));
544
             Map<Integer, Integer> classMap = classList.stream().collect(Collectors.toMap(TClassroom::getClassid, TClassroom::getClassnum));
578
             startclassList.forEach(r -> r.setClassnum(classMap.get(r.getClassid())));
545
             startclassList.forEach(r -> r.setClassnum(classMap.get(r.getClassid())));
579
             classroomMapper.batchSave(startclassList);//批量保存课堂
546
             classroomMapper.batchSave(startclassList);//批量保存课堂
580
-            classroomActivestudentMapper.batchSaveStuActive(startclassList);//批量添加学生课堂活跃度
581
             if (N_Utils.isListNotEmpty(signList)) classroomSignMapper.insertList(signList);//批量保存学生签到
547
             if (N_Utils.isListNotEmpty(signList)) classroomSignMapper.insertList(signList);//批量保存学生签到
582
 
548
 
583
             if (N_Utils.isListNotEmpty(askteacherList)) classroomAskteacherMapper.batchSave(askteacherList);//批量保存教师互动信息
549
             if (N_Utils.isListNotEmpty(askteacherList)) classroomAskteacherMapper.batchSave(askteacherList);//批量保存教师互动信息
584
             if (N_Utils.isListNotEmpty(askstudentList))
550
             if (N_Utils.isListNotEmpty(askstudentList))
585
                 classroomAskstudentMapper.insertList(askstudentList);//批量保存学生互动信息
551
                 classroomAskstudentMapper.insertList(askstudentList);//批量保存学生互动信息
586
 
552
 
587
-            if (N_Utils.isListNotEmpty(activestudentList))
588
-                classroomActivestudentMapper.batchUpdateActiveNum(activestudentList);//批量更新学生活跃值
589
-
590
             if (N_Utils.isListNotEmpty(savefileList)) classroomFileMapper.insertList(savefileList);//批量保存课堂图片
553
             if (N_Utils.isListNotEmpty(savefileList)) classroomFileMapper.insertList(savefileList);//批量保存课堂图片
591
 
554
 
592
             if (N_Utils.isListNotEmpty(paperList)) classroomPaperMapper.batchSave(paperList);//批量保存堂测
555
             if (N_Utils.isListNotEmpty(paperList)) classroomPaperMapper.batchSave(paperList);//批量保存堂测
608
 
571
 
609
             List<Long> roomids = startclassList.stream().map(TClassroom::getRoomid).collect(Collectors.toList());
572
             List<Long> roomids = startclassList.stream().map(TClassroom::getRoomid).collect(Collectors.toList());
610
             classroomMapper.updateBatchRoomRealStunum(roomids);//批量更新班级实际签到学生数量
573
             classroomMapper.updateBatchRoomRealStunum(roomids);//批量更新班级实际签到学生数量
611
-            classroomActivestudentMapper.updateBatchActiveRank(roomids);//批量更新活跃值排名
574
+            for (TClassroom c : startclassList) {
575
+                saveStuActive(c.getRoomid(), c.getClassid(), c.getSchoolid());
576
+            }
612
 
577
 
613
             classroomMapper.updateBatchRoomState(classids);//批量结束之前班级的课堂状态
578
             classroomMapper.updateBatchRoomState(classids);//批量结束之前班级的课堂状态
614
             resultVo.setCode(0);
579
             resultVo.setCode(0);
735
      * 保存单个课堂数据
700
      * 保存单个课堂数据
736
      *
701
      *
737
      * @return com.xhkjedu.vo.ResultVo
702
      * @return com.xhkjedu.vo.ResultVo
738
-     * @Param [startclass, stopclass, savefileList, askteacherList, askstudentList, signList, activestudentList
703
+     * @Param [startclass, stopclass, savefileList, askteacherList, askstudentList, signList
739
      * , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList]
704
      * , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList]
740
      * @Author ywx
705
      * @Author ywx
741
      * @Date 2022/6/30 11:12
706
      * @Date 2022/6/30 11:12
742
      **/
707
      **/
743
     public ResultVo saveClass(TClassroom startclass, TClassroom stopclass, List<TClassroomFile> savefileList
708
     public ResultVo saveClass(TClassroom startclass, TClassroom stopclass, List<TClassroomFile> savefileList
744
             , List<TClassroomAskteacher> askteacherList, List<TClassroomAskstudent> askstudentList, List<TClassroomSign> signList
709
             , List<TClassroomAskteacher> askteacherList, List<TClassroomAskstudent> askstudentList, List<TClassroomSign> signList
745
-            , List<TClassroomActivestudent> activestudentList, List<TClassroomPaper> paperList
710
+            , List<TClassroomPaper> paperList
746
             , List<TClassroomPaperStudent> stupaperList, List<TClassroomPaperFile> paperFileList
711
             , List<TClassroomPaperStudent> stupaperList, List<TClassroomPaperFile> paperFileList
747
             , List<TClassroomPaperQtype> paperQtypeList, List<TClassroomPaperScantron> paperScantronList) {
712
             , List<TClassroomPaperQtype> paperQtypeList, List<TClassroomPaperScantron> paperScantronList) {
748
         ResultVo resultVo = new ResultVo();
713
         ResultVo resultVo = new ResultVo();
755
             Integer num = classroomMapper.getStudentNumById(classid);//根据班级id获取学生数量
720
             Integer num = classroomMapper.getStudentNumById(classid);//根据班级id获取学生数量
756
             startclass.setClassnum(num);
721
             startclass.setClassnum(num);
757
             classroomMapper.save(startclass);//批量保存课堂
722
             classroomMapper.save(startclass);//批量保存课堂
758
-            classroomActivestudentMapper.saveStuActive(roomid, classid, schoolid);//批量添加学生课堂活跃度
759
             if (N_Utils.isListNotEmpty(signList)) classroomSignMapper.insertList(signList);//批量保存学生签到
723
             if (N_Utils.isListNotEmpty(signList)) classroomSignMapper.insertList(signList);//批量保存学生签到
760
 
724
 
761
             if (N_Utils.isListNotEmpty(askteacherList)) classroomAskteacherMapper.batchSave(askteacherList);//批量保存教师互动信息
725
             if (N_Utils.isListNotEmpty(askteacherList)) classroomAskteacherMapper.batchSave(askteacherList);//批量保存教师互动信息
762
             if (N_Utils.isListNotEmpty(askstudentList))
726
             if (N_Utils.isListNotEmpty(askstudentList))
763
                 classroomAskstudentMapper.insertList(askstudentList);//批量保存学生互动信息
727
                 classroomAskstudentMapper.insertList(askstudentList);//批量保存学生互动信息
764
 
728
 
765
-            if (N_Utils.isListNotEmpty(activestudentList))
766
-                classroomActivestudentMapper.batchUpdateActiveNum(activestudentList);//批量更新学生活跃值
767
-
768
             if (N_Utils.isListNotEmpty(savefileList)) classroomFileMapper.insertList(savefileList);//批量保存课堂图片
729
             if (N_Utils.isListNotEmpty(savefileList)) classroomFileMapper.insertList(savefileList);//批量保存课堂图片
769
 
730
 
770
             if (N_Utils.isListNotEmpty(paperList)) classroomPaperMapper.batchSave(paperList);//批量保存堂测
731
             if (N_Utils.isListNotEmpty(paperList)) classroomPaperMapper.batchSave(paperList);//批量保存堂测
785
             if (stopclass != null) classroomMapper.endClass(stopclass);//批量结束课堂
746
             if (stopclass != null) classroomMapper.endClass(stopclass);//批量结束课堂
786
 
747
 
787
             classroomMapper.updateBatchRoomRealStunum(Arrays.asList(roomid));//批量更新班级实际签到学生数量
748
             classroomMapper.updateBatchRoomRealStunum(Arrays.asList(roomid));//批量更新班级实际签到学生数量
788
-            classroomActivestudentMapper.updateActiveRank(roomid);//批量更新活跃值排名
749
+            classroomActivestudentMapper.saveStuActive(roomid, classid, schoolid);//更新学生活跃度
789
 
750
 
790
             classroomMapper.updateBatchRoomState(Arrays.asList(classid));//批量结束之前班级的课堂状态
751
             classroomMapper.updateBatchRoomState(Arrays.asList(classid));//批量结束之前班级的课堂状态
791
             resultVo.setCode(0);
752
             resultVo.setCode(0);
798
         return resultVo;
759
         return resultVo;
799
     }
760
     }
800
 
761
 
762
+    //更新学生活跃度 2022/10/17 课堂活跃度最后统一计算
763
+    public void saveStuActive(Long roomid, Integer classid, Integer schoolid) {
764
+        String asktids = classroomActivestudentMapper.getAsktidsByRoomId(roomid);
765
+        List<TClassroomActivestudent> students = classroomActivestudentMapper.listRoomStu(roomid, classid, asktids);
766
+        if(N_Utils.isListEmpty(students)) return;
767
+        Map<Integer, Integer> rank=new HashMap<>();
768
+        setRank(students,rank);//计算排名
769
+        int timestamp = N_Utils.getSecondTimestamp();
770
+        students.forEach(s -> {
771
+            s.setRoomid(roomid);
772
+            s.setSchoolid(schoolid);
773
+            s.setActiverank(rank.get(s.getActivenum()));
774
+            s.setCreatetime(timestamp);
775
+        });
776
+        classroomActivestudentMapper.insertList(students);
777
+    }
778
+
779
+    //计算排名
780
+    private void setRank(List<TClassroomActivestudent> students, Map<Integer, Integer> rank) {
781
+        List<Map.Entry<Integer, List<TClassroomActivestudent>>> gslist2 = students.stream()
782
+                .collect(Collectors.groupingBy(TClassroomActivestudent::getActivenum)).entrySet()
783
+                .stream().sorted((s1, s2) -> -Double.compare(s1.getKey(), s2.getKey())).collect(Collectors.toList());
784
+        Integer index = 1;
785
+        for (Map.Entry<Integer, List<TClassroomActivestudent>> entry : gslist2) {
786
+            for (TClassroomActivestudent cs : entry.getValue()) {
787
+                rank.put(cs.getActivenum(), index);
788
+            }
789
+            index = index + entry.getValue().size();
790
+        }
791
+    }
792
+
801
     /**
793
     /**
802
      * 根据课堂id获取课堂名称
794
      * 根据课堂id获取课堂名称
803
      *
795
      *

+ 14
- 0
sclass/src/main/resources/mapper/classroom/ClassroomActivestudentMapper.xml View File

43
             s.classid=${r.classid}
43
             s.classid=${r.classid}
44
         </foreach>
44
         </foreach>
45
     </insert>
45
     </insert>
46
+    <!--根据课堂id获取互动ids-->
47
+    <select id="getAsktidsByRoomId" resultType="java.lang.String">
48
+        select group_concat(asktid) from t_classroom_askteacher where roomid=#{roomid}
49
+    </select>
50
+    <!--课堂学生-->
51
+    <select id="listRoomStu" resultType="com.xhkjedu.sclass.model.classroom.TClassroomActivestudent">
52
+        select cs.studentid,(
53
+            (select count(distinct s.userid) from t_classroom_sign s where s.roomid=#{roomid} and s.userid=cs.studentid)
54
+        <if test="asktids!=null and asktids!=''">
55
+            +(select count(*) from t_classroom_askstudent s where s.asktid in(${asktids}) and s.studentid=cs.studentid)
56
+        </if>
57
+        )activenum
58
+        from t_class_student cs where cs.classid=#{classid}
59
+    </select>
46
 </mapper>
60
 </mapper>

Loading…
Cancel
Save