Pārlūkot izejas kodu

考试报告

tags/正式版本
雍文秀 pirms 2 gadiem
vecāks
revīzija
c77a703b47

+ 3
- 2
sexam/src/main/java/com/xhkjedu/sexam/controller/paper/EPaperCorrectTeacherController.java Parādīt failu

@@ -82,8 +82,9 @@ public class EPaperCorrectTeacherController {
82 82
     public ResultVo getCorrectQuestion(@RequestBody EPTeacherVo vo) {
83 83
         Integer teacherid = vo.getTeacherid();
84 84
         String eptqids = vo.getEptqids();
85
-        N_Utils.validation(new Object[]{teacherid, "教师id", 1, eptqids, "试卷试题ids", 2});
86
-        return correctTeacherService.getCorrectQuestion(teacherid, eptqids, vo.getClassids());
85
+        Integer esid = vo.getEsid();
86
+        N_Utils.validation(new Object[]{teacherid, "教师id", 1, eptqids, "试卷试题ids", 2, esid, "考试科目id", 1});
87
+        return correctTeacherService.getCorrectQuestion(teacherid, eptqids, vo.getClassids(), esid);
87 88
     }
88 89
 
89 90
     /**

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paper/EPaperCorrectTeacherMapper.java Parādīt failu

@@ -38,4 +38,7 @@ public interface EPaperCorrectTeacherMapper {
38 38
 
39 39
     //修改学生试卷批阅状态
40 40
     void updateCheckStuById(@Param("epsid") Integer epsid, @Param("checkid") Integer checkid);
41
+
42
+    //根据考试科目id获取考试名称
43
+    Map getExamNameByEsId(@Param("esid") Integer esid);
41 44
 }

+ 7
- 4
sexam/src/main/java/com/xhkjedu/sexam/mapper/paperstudent/EPaperStudentMapper.java Parādīt failu

@@ -3,6 +3,7 @@ package com.xhkjedu.sexam.mapper.paperstudent;
3 3
 import com.xhkjedu.sexam.base.TkMapper;
4 4
 import com.xhkjedu.sexam.model.paper.EPaperQtype;
5 5
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudent;
6
+import com.xhkjedu.sexam.model.reportstu.ERstudent;
6 7
 import com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo;
7 8
 import org.apache.ibatis.annotations.Param;
8 9
 import org.springframework.stereotype.Repository;
@@ -44,14 +45,16 @@ public interface EPaperStudentMapper extends TkMapper<EPaperStudent> {
44 45
     List<EPaperQtype> listStuPaperFjQuestionsForWeb(@Param("epsid")Integer epsid);
45 46
 
46 47
     //学生提交试卷
47
-    int updateStudentPaper(@Param("ps")EPaperStudent ps);
48
+    int updateStudentPaper(@Param("ps") EPaperStudent ps);
48 49
 
49 50
     //更新缺考字段
50
-    void updateStudentPaperState(@Param("ps")EPaperStudent ps);
51
+    void updateStudentPaperState(@Param("ps") EPaperStudent ps);
51 52
 
52 53
     //根据试卷id批量修改该试卷学生得分
53
-    void updateBathStudentPaperScoreByEpid(@Param("epid")Integer epid);
54
+    void updateBathStudentPaperScoreByEpid(@Param("epid") Integer epid);
54 55
 
55 56
     //根据试卷id和学生id获取学生试卷信息
56
-    EPaperStudent getPaperStudentByStuidAndEpid(@Param("epid")Integer epid,@Param("studentid")Integer studentid);
57
+    EPaperStudent getPaperStudentByStuidAndEpid(@Param("epid") Integer epid, @Param("studentid") Integer studentid);
58
+
59
+    List<ERstudent> listByExamId(@Param("examid") Integer examid);
57 60
 }

+ 5
- 0
sexam/src/main/java/com/xhkjedu/sexam/model/reportstu/ERstudent.java Parādīt failu

@@ -5,6 +5,7 @@ import lombok.Data;
5 5
 
6 6
 import javax.persistence.Id;
7 7
 import javax.persistence.Table;
8
+import javax.persistence.Transient;
8 9
 
9 10
 @Table(name = "e_rstudent")
10 11
 @Data
@@ -57,4 +58,8 @@ public class ERstudent extends BaseBean {
57 58
 
58 59
     //下次目标
59 60
     private Integer nextgoal;
61
+
62
+    @Transient
63
+    //状态0未进场1已进场2已交卷3缺考
64
+    private Integer sstate;
60 65
 }

+ 3
- 4
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperCorrectTeacherService.java Parādīt failu

@@ -12,7 +12,6 @@ import org.springframework.scheduling.annotation.AsyncResult;
12 12
 import org.springframework.stereotype.Service;
13 13
 
14 14
 import javax.annotation.Resource;
15
-import java.util.HashMap;
16 15
 import java.util.List;
17 16
 import java.util.Map;
18 17
 import java.util.concurrent.Future;
@@ -38,13 +37,13 @@ public class EPaperCorrectTeacherService {
38 37
     }
39 38
 
40 39
     //随机获取待批试题
41
-    public ResultVo getCorrectQuestion(Integer teacherid, String eptqids, String classids) {
40
+    public ResultVo getCorrectQuestion(Integer teacherid, String eptqids, String classids, Integer esid) {
42 41
         lock.lock();
43
-        Map map = new HashMap();
42
+        Map map = correctTeacherMapper.getExamNameByEsId(esid);//根据考试科目id获取考试名称
44 43
         try {
45 44
             //随机获取一条待批阅试题
46 45
             EPaperSQuestionVo sq = correctTeacherMapper.getCorrectQuestion(teacherid, eptqids, classids);
47
-            if (sq == null) return new ResultVo(1, "已批阅完成");
46
+            if (sq == null) return new ResultVo(0, "已批阅完成");
48 47
             //修改试卷学生试题为批阅中
49 48
             correctTeacherMapper.updateCheckQuestionById(sq.getEpsqid(), teacherid);
50 49
             //试题批阅情况

+ 160
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java Parādīt failu

@@ -0,0 +1,160 @@
1
+package com.xhkjedu.sexam.service.report;
2
+
3
+import com.xhkjedu.sexam.mapper.exam.EBaseMapper;
4
+import com.xhkjedu.sexam.mapper.exam.EClassMapper;
5
+import com.xhkjedu.sexam.mapper.exam.ESubjectMapper;
6
+import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentMapper;
7
+import com.xhkjedu.sexam.mapper.report.ERbaseMapper;
8
+import com.xhkjedu.sexam.mapper.reportstu.ERstudentMapper;
9
+import com.xhkjedu.sexam.model.reportstu.ERstudent;
10
+import org.springframework.stereotype.Service;
11
+
12
+import javax.annotation.Resource;
13
+import java.util.ArrayList;
14
+import java.util.DoubleSummaryStatistics;
15
+import java.util.HashMap;
16
+import java.util.List;
17
+import java.util.Map;
18
+import java.util.stream.Collectors;
19
+
20
+/**
21
+ * @author ywx
22
+ * @classname EReportGenerateService
23
+ * @description 考试报告生成
24
+ * @date 2022/8/8 10:04
25
+ **/
26
+@Service
27
+public class EReportGenerateService {
28
+    @Resource
29
+    private EBaseMapper eBaseMapper;
30
+    @Resource
31
+    private EClassMapper eClassMapper;
32
+    @Resource
33
+    private ESubjectMapper eSubjectMapper;
34
+    @Resource
35
+    private EPaperStudentMapper ePaperStudentMapper;
36
+
37
+    @Resource
38
+    private ERbaseMapper eRbaseMapper;
39
+    @Resource
40
+    private ERstudentMapper eRstudentMapper;
41
+
42
+    //生成考试报告
43
+    public void generateExamReport(Integer examid) {
44
+        List<Map> classes = eClassMapper.listByExamId(examid);
45
+        List<Map> subjects = eSubjectMapper.listSubject(examid);
46
+        int classnum = classes.size();
47
+        int stunum = classes.stream().mapToInt(m -> (int) m.get("classnum")).sum();
48
+        int subjectnum = subjects.size();
49
+        /*ERbase rbase = new ERbase();
50
+        rbase.setExamid(examid);
51
+        rbase.setClassnum(classnum);
52
+        rbase.setStunum(stunum);
53
+        rbase.setSubjectnum(subjectnum);
54
+        eRbaseMapper.insertSelective(rbase);*/
55
+
56
+        String subjectid = "zf";
57
+        String subjectname = "总分";
58
+        Map<String, String> subjectMap = subjects.stream().collect(Collectors.toMap(m -> m.get("subjectid").toString(),
59
+                m -> m.get("subjectname").toString()));
60
+
61
+        List<ERstudent> schoolStudents = new ArrayList<>();//学校学生成绩
62
+        List<ERstudent> classStudents = new ArrayList<>();//班级学生成绩
63
+        List<ERstudent> subjectStudents = new ArrayList<>();//科目学生成绩、
64
+        Map<String, Integer> schoolRank = new HashMap<>();//学校分数排名
65
+        Map<String, Integer> classRank = new HashMap<>();//班级分数排名
66
+        Map<String, Integer> ssubjectRank = new HashMap<>();//学校科目分数排名
67
+        Map<String, Integer> csubjectRank = new HashMap<>();//班级科目分数排名
68
+
69
+        List<ERstudent> students = ePaperStudentMapper.listByExamId(examid);
70
+        Map<Integer, List<ERstudent>> schoolCollect = students.stream().collect(Collectors.groupingBy(s -> s.getStudentid()));
71
+        for (Map.Entry<Integer, List<ERstudent>> entry : schoolCollect.entrySet()) {
72
+            Integer studentid = entry.getKey();
73
+            ERstudent cs = new ERstudent();
74
+            cs.setStudentid(studentid);
75
+            cs.setScore(entry.getValue().stream().mapToDouble(s -> s.getScore()).sum());
76
+            schoolStudents.add(cs);
77
+        }
78
+        setRank(schoolStudents, schoolRank, 1);//学校分数排名
79
+
80
+        Map<Integer, List<ERstudent>> cCollect = students.stream().collect(Collectors.groupingBy(s -> s.getClassid()));
81
+        for (Map.Entry<Integer, List<ERstudent>> entry : cCollect.entrySet()) {
82
+            Integer classid = entry.getKey();
83
+            List<ERstudent> studentList = entry.getValue();
84
+            Map<Integer, List<ERstudent>> sCollect = studentList.stream().collect(Collectors.groupingBy(s -> s.getStudentid()));
85
+            for (Map.Entry<Integer, List<ERstudent>> csEntry : sCollect.entrySet()) {
86
+                ERstudent cs = new ERstudent();
87
+                cs.setClassid(classid);
88
+                cs.setStudentid(csEntry.getKey());
89
+                cs.setSubjectid(subjectid);
90
+                cs.setSubjectname(subjectname);
91
+                cs.setScore(csEntry.getValue().stream().mapToDouble(s -> s.getScore()).sum());
92
+                classStudents.add(cs);
93
+            }
94
+            setRank(classStudents, classRank, 2);//班级分数排名
95
+
96
+            Map<String, List<ERstudent>> subCollect = studentList.stream().collect(Collectors.groupingBy(s -> s.getSubjectid()));
97
+            for (Map.Entry<String, List<ERstudent>> ssEntry : subCollect.entrySet()) {
98
+                subjectid = ssEntry.getKey();
99
+                subjectname = subjectMap.get(subjectid);
100
+                studentList = ssEntry.getValue();
101
+                for (ERstudent cs : studentList) {
102
+                    cs.setSubjectname(subjectname);
103
+                    subjectStudents.add(cs);
104
+                }
105
+            }
106
+            setRank(subjectStudents, ssubjectRank, 3);//科目分数排名
107
+        }
108
+
109
+        DoubleSummaryStatistics schoolStatistics = schoolStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
110
+        DoubleSummaryStatistics classStatistics = classStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
111
+        for (ERstudent cs : classStudents) {
112
+            Integer studentid = cs.getStudentid();
113
+            cs.setClassrank(classRank.get(cs.getClassid()+"_"+ studentid));
114
+            cs.setClassmaxscore(classStatistics.getMax());
115
+            cs.setClassavgscore(classStatistics.getAverage());
116
+            cs.setSchoolrank(schoolRank.get(studentid));
117
+            cs.setSchoolmaxscore(schoolStatistics.getMax());
118
+            cs.setSchoolavgscore(schoolStatistics.getAverage());
119
+        }
120
+        eRstudentMapper.insertList(classStudents);
121
+
122
+        for (ERstudent cs : subjectStudents) {
123
+            Integer studentid = cs.getStudentid();
124
+            cs.setClassrank(classRank.get(cs.getClassid()+"_"+ studentid));
125
+            cs.setClassmaxscore(classStatistics.getMax());
126
+            cs.setClassavgscore(classStatistics.getAverage());
127
+            cs.setSchoolrank(schoolRank.get(studentid));
128
+            cs.setSchoolmaxscore(schoolStatistics.getMax());
129
+            cs.setSchoolavgscore(schoolStatistics.getAverage());
130
+        }
131
+        eRstudentMapper.insertList(subjectStudents);
132
+    }
133
+
134
+    //分数排名
135
+    private void setRank(List<ERstudent> students, Map<String, Integer> rank, Integer code) {
136
+        students =
137
+                students.stream().sorted((s1, s2) -> -Double.compare(s1.getScore(), s2.getScore())).collect(Collectors.toList());
138
+        List<Map.Entry<Double, List<ERstudent>>> gslist2 = students.stream()
139
+                .collect(Collectors.groupingBy(ERstudent::getScore)).entrySet()
140
+                .stream().sorted((s1, s2) -> -Double.compare(s1.getKey(), s2.getKey())).collect(Collectors.toList());
141
+        Integer index = 1;
142
+        String key;
143
+        for (Map.Entry<Double, List<ERstudent>> entry : gslist2) {
144
+            for (ERstudent cgs : entry.getValue()) {
145
+                Integer studentid = cgs.getStudentid();
146
+                Integer classid = cgs.getClassid();
147
+                String subjectid = cgs.getSubjectid();
148
+                if (code == 1) {//学校
149
+                    key = studentid.toString();
150
+                } else if (code == 2) {//班级
151
+                    key = classid + "_" + studentid;
152
+                } else {//科目
153
+                    key = subjectid + "_" + studentid;
154
+                }
155
+                rank.put(key, index);
156
+            }
157
+            index = index + entry.getValue().size();
158
+        }
159
+    }
160
+}

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/vo/paper/EPTeacherVo.java Parādīt failu

@@ -10,6 +10,9 @@ import lombok.Data;
10 10
  **/
11 11
 @Data
12 12
 public class EPTeacherVo {
13
+    //考试科目id
14
+    private Integer esid;
15
+
13 16
     //试卷id
14 17
     private Integer epid;
15 18
 

+ 5
- 0
sexam/src/main/resources/mapper/paper/EPaperCorrectTeacherMapper.xml Parādīt failu

@@ -101,4 +101,9 @@
101 101
         ,ps.stuscore=(select sum(psq.stuscore) from e_paper_student_question psq where psq.epsid=ps.epsid)
102 102
         where ps.epsid=#{epsid}
103 103
     </update>
104
+    <!--根据考试科目id获取考试名称-->
105
+    <select id="getExamNameByEsId" resultType="java.util.Map">
106
+        select es.subjectname,eb.examname
107
+        from e_subject es left join e_base eb on eb.examid = es.examid where es.esid=#{esid}
108
+    </select>
104 109
 </mapper>

+ 5
- 0
sexam/src/main/resources/mapper/paperstudent/EPaperStudentMapper.xml Parādīt failu

@@ -187,4 +187,9 @@
187 187
     <select id="getPaperStudentByStuidAndEpid" resultType="com.xhkjedu.sexam.model.paperstudent.EPaperStudent">
188 188
         select * from e_paper_student where epid=#{epid} and studentid=#{studentid} order by epsid desc limit 1
189 189
     </select>
190
+
191
+    <select id="listByExamId" resultType="com.xhkjedu.sexam.model.reportstu.ERstudent">
192
+        select classid,examid,subjectid,studentid,stuscore score,sstate
193
+        from e_paper_student where examid=#{examid}
194
+    </select>
190 195
 </mapper>

Notiek ielāde…
Atcelt
Saglabāt