|
@@ -1,40 +1,10 @@
|
1
|
1
|
package com.xhkjedu.sclass.service.classroom;
|
2
|
2
|
|
3
|
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
|
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
|
8
|
import com.xhkjedu.sclass.vo.paper.CheckClassVo;
|
39
|
9
|
import com.xhkjedu.utils.N_Utils;
|
40
|
10
|
import com.xhkjedu.vo.ResultVo;
|
|
@@ -46,10 +16,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
46
|
16
|
import org.springframework.util.CollectionUtils;
|
47
|
17
|
|
48
|
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
|
20
|
import java.util.stream.Collectors;
|
54
|
21
|
|
55
|
22
|
@Slf4j
|
|
@@ -556,7 +523,7 @@ public class ClassroomService {
|
556
|
523
|
*
|
557
|
524
|
* @return com.xhkjedu.vo.ResultVo
|
558
|
525
|
* @Param [startclassList, stopclassList, savefileList, askteacherList, askstudentList, signList
|
559
|
|
- * , activestudentList, paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList]
|
|
526
|
+ * , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList]
|
560
|
527
|
* @Author ywx
|
561
|
528
|
* @Date 2022/6/28 16:51
|
562
|
529
|
**/
|
|
@@ -564,7 +531,7 @@ public class ClassroomService {
|
564
|
531
|
public ResultVo batchSaveClass(List<TClassroom> startclassList, List<TClassroom> stopclassList
|
565
|
532
|
, List<TClassroomFile> savefileList
|
566
|
533
|
, List<TClassroomAskteacher> askteacherList, List<TClassroomAskstudent> askstudentList
|
567
|
|
- , List<TClassroomSign> signList, List<TClassroomActivestudent> activestudentList
|
|
534
|
+ , List<TClassroomSign> signList
|
568
|
535
|
, List<TClassroomPaper> paperList, List<TClassroomPaperStudent> stupaperList
|
569
|
536
|
, List<TClassroomPaperFile> paperFileList, List<TClassroomPaperQtype> paperQtypeList
|
570
|
537
|
, List<TClassroomPaperScantron> paperScantronList) {
|
|
@@ -577,16 +544,12 @@ public class ClassroomService {
|
577
|
544
|
Map<Integer, Integer> classMap = classList.stream().collect(Collectors.toMap(TClassroom::getClassid, TClassroom::getClassnum));
|
578
|
545
|
startclassList.forEach(r -> r.setClassnum(classMap.get(r.getClassid())));
|
579
|
546
|
classroomMapper.batchSave(startclassList);//批量保存课堂
|
580
|
|
- classroomActivestudentMapper.batchSaveStuActive(startclassList);//批量添加学生课堂活跃度
|
581
|
547
|
if (N_Utils.isListNotEmpty(signList)) classroomSignMapper.insertList(signList);//批量保存学生签到
|
582
|
548
|
|
583
|
549
|
if (N_Utils.isListNotEmpty(askteacherList)) classroomAskteacherMapper.batchSave(askteacherList);//批量保存教师互动信息
|
584
|
550
|
if (N_Utils.isListNotEmpty(askstudentList))
|
585
|
551
|
classroomAskstudentMapper.insertList(askstudentList);//批量保存学生互动信息
|
586
|
552
|
|
587
|
|
- if (N_Utils.isListNotEmpty(activestudentList))
|
588
|
|
- classroomActivestudentMapper.batchUpdateActiveNum(activestudentList);//批量更新学生活跃值
|
589
|
|
-
|
590
|
553
|
if (N_Utils.isListNotEmpty(savefileList)) classroomFileMapper.insertList(savefileList);//批量保存课堂图片
|
591
|
554
|
|
592
|
555
|
if (N_Utils.isListNotEmpty(paperList)) classroomPaperMapper.batchSave(paperList);//批量保存堂测
|
|
@@ -608,7 +571,9 @@ public class ClassroomService {
|
608
|
571
|
|
609
|
572
|
List<Long> roomids = startclassList.stream().map(TClassroom::getRoomid).collect(Collectors.toList());
|
610
|
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
|
578
|
classroomMapper.updateBatchRoomState(classids);//批量结束之前班级的课堂状态
|
614
|
579
|
resultVo.setCode(0);
|
|
@@ -735,14 +700,14 @@ public class ClassroomService {
|
735
|
700
|
* 保存单个课堂数据
|
736
|
701
|
*
|
737
|
702
|
* @return com.xhkjedu.vo.ResultVo
|
738
|
|
- * @Param [startclass, stopclass, savefileList, askteacherList, askstudentList, signList, activestudentList
|
|
703
|
+ * @Param [startclass, stopclass, savefileList, askteacherList, askstudentList, signList
|
739
|
704
|
* , paperList, stupaperList, paperFileList, paperQtypeList, paperScantronList]
|
740
|
705
|
* @Author ywx
|
741
|
706
|
* @Date 2022/6/30 11:12
|
742
|
707
|
**/
|
743
|
708
|
public ResultVo saveClass(TClassroom startclass, TClassroom stopclass, List<TClassroomFile> savefileList
|
744
|
709
|
, List<TClassroomAskteacher> askteacherList, List<TClassroomAskstudent> askstudentList, List<TClassroomSign> signList
|
745
|
|
- , List<TClassroomActivestudent> activestudentList, List<TClassroomPaper> paperList
|
|
710
|
+ , List<TClassroomPaper> paperList
|
746
|
711
|
, List<TClassroomPaperStudent> stupaperList, List<TClassroomPaperFile> paperFileList
|
747
|
712
|
, List<TClassroomPaperQtype> paperQtypeList, List<TClassroomPaperScantron> paperScantronList) {
|
748
|
713
|
ResultVo resultVo = new ResultVo();
|
|
@@ -755,16 +720,12 @@ public class ClassroomService {
|
755
|
720
|
Integer num = classroomMapper.getStudentNumById(classid);//根据班级id获取学生数量
|
756
|
721
|
startclass.setClassnum(num);
|
757
|
722
|
classroomMapper.save(startclass);//批量保存课堂
|
758
|
|
- classroomActivestudentMapper.saveStuActive(roomid, classid, schoolid);//批量添加学生课堂活跃度
|
759
|
723
|
if (N_Utils.isListNotEmpty(signList)) classroomSignMapper.insertList(signList);//批量保存学生签到
|
760
|
724
|
|
761
|
725
|
if (N_Utils.isListNotEmpty(askteacherList)) classroomAskteacherMapper.batchSave(askteacherList);//批量保存教师互动信息
|
762
|
726
|
if (N_Utils.isListNotEmpty(askstudentList))
|
763
|
727
|
classroomAskstudentMapper.insertList(askstudentList);//批量保存学生互动信息
|
764
|
728
|
|
765
|
|
- if (N_Utils.isListNotEmpty(activestudentList))
|
766
|
|
- classroomActivestudentMapper.batchUpdateActiveNum(activestudentList);//批量更新学生活跃值
|
767
|
|
-
|
768
|
729
|
if (N_Utils.isListNotEmpty(savefileList)) classroomFileMapper.insertList(savefileList);//批量保存课堂图片
|
769
|
730
|
|
770
|
731
|
if (N_Utils.isListNotEmpty(paperList)) classroomPaperMapper.batchSave(paperList);//批量保存堂测
|
|
@@ -785,7 +746,7 @@ public class ClassroomService {
|
785
|
746
|
if (stopclass != null) classroomMapper.endClass(stopclass);//批量结束课堂
|
786
|
747
|
|
787
|
748
|
classroomMapper.updateBatchRoomRealStunum(Arrays.asList(roomid));//批量更新班级实际签到学生数量
|
788
|
|
- classroomActivestudentMapper.updateActiveRank(roomid);//批量更新活跃值排名
|
|
749
|
+ classroomActivestudentMapper.saveStuActive(roomid, classid, schoolid);//更新学生活跃度
|
789
|
750
|
|
790
|
751
|
classroomMapper.updateBatchRoomState(Arrays.asList(classid));//批量结束之前班级的课堂状态
|
791
|
752
|
resultVo.setCode(0);
|
|
@@ -798,6 +759,37 @@ public class ClassroomService {
|
798
|
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
|
794
|
* 根据课堂id获取课堂名称
|
803
|
795
|
*
|