Browse Source

考试报告

tags/正式版本
雍文秀 2 years ago
parent
commit
738b22fc3f

+ 0
- 3
sexam/src/main/java/com/xhkjedu/sexam/model/reportclass/ERclass.java View File

37
     //班级平均分
37
     //班级平均分
38
     private Double classavgscore;
38
     private Double classavgscore;
39
 
39
 
40
-    //平均分排名
41
-    private Integer schoolrank;
42
-
43
     //校最高分
40
     //校最高分
44
     private Double schoolmaxscore;
41
     private Double schoolmaxscore;
45
 
42
 

+ 67
- 30
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java View File

20
 import com.xhkjedu.sexam.model.reportclass.ERclassQuestionError;
20
 import com.xhkjedu.sexam.model.reportclass.ERclassQuestionError;
21
 import com.xhkjedu.sexam.model.reportclass.ERclassQuestionPoint;
21
 import com.xhkjedu.sexam.model.reportclass.ERclassQuestionPoint;
22
 import com.xhkjedu.sexam.model.reportstu.ERstudent;
22
 import com.xhkjedu.sexam.model.reportstu.ERstudent;
23
+import com.xhkjedu.sexam.utils.ExamUtil;
23
 import com.xhkjedu.sexam.vo.paper.EPaperQsVo;
24
 import com.xhkjedu.sexam.vo.paper.EPaperQsVo;
24
 import com.xhkjedu.sexam.vo.report.ERPaperVo;
25
 import com.xhkjedu.sexam.vo.report.ERPaperVo;
26
+import com.xhkjedu.utils.N_Utils;
25
 import org.springframework.stereotype.Service;
27
 import org.springframework.stereotype.Service;
26
 
28
 
27
 import javax.annotation.Resource;
29
 import javax.annotation.Resource;
73
         int stunum = classes.stream().mapToInt(m -> (int) m.get("classnum")).sum();
75
         int stunum = classes.stream().mapToInt(m -> (int) m.get("classnum")).sum();
74
         int subjectnum = subjects.size();
76
         int subjectnum = subjects.size();
75
 
77
 
76
-        String subjectid = "zf";
77
-        String subjectname = "总分";
78
+        String subjectid;
79
+        String subjectname;
78
         Map<String, String> subjectMap = subjects.stream().collect(Collectors.toMap(m -> m.get("subjectid").toString(),
80
         Map<String, String> subjectMap = subjects.stream().collect(Collectors.toMap(m -> m.get("subjectid").toString(),
79
                 m -> m.get("subjectname").toString()));
81
                 m -> m.get("subjectname").toString()));
80
         Map<String, ERPaperVo> paperMap = papers.stream().collect(Collectors.toMap(m -> m.getSubjectid(), m -> m));
82
         Map<String, ERPaperVo> paperMap = papers.stream().collect(Collectors.toMap(m -> m.getSubjectid(), m -> m));
83
         List<ERstudent> schoolSubjectStudents = new ArrayList<>();//学校科目学生成绩
85
         List<ERstudent> schoolSubjectStudents = new ArrayList<>();//学校科目学生成绩
84
         List<ERstudent> classStudents = new ArrayList<>();//班级学生成绩
86
         List<ERstudent> classStudents = new ArrayList<>();//班级学生成绩
85
         List<ERstudent> classSubjectStudents = new ArrayList<>();//班级科目学生成绩
87
         List<ERstudent> classSubjectStudents = new ArrayList<>();//班级科目学生成绩
86
-        Map<String, Integer> schoolRank = new HashMap<>();//学校分数排名
87
-        Map<String, Integer> schoolSubjectRank = new HashMap<>();//学校科目分数排名
88
-        Map<String, Integer> classRank = new HashMap<>();//班级分数排名
89
-        Map<String, Integer> classSubjectRank = new HashMap<>();//班级科目分数排名
90
-
88
+        Map<String, Integer> schoolStuRank = new HashMap<>();//学校学生分数排名
89
+        Map<String, Integer> schoolSubStuRank = new HashMap<>();//学校科目学生分数排名
90
+        Map<String, Integer> classStuRank = new HashMap<>();//班级学生分数排名
91
+        Map<String, Integer> classSubStuRank = new HashMap<>();//班级科目学生分数排名
91
         List<ERstudent> students = ePaperStudentMapper.listByExamId(examid);
92
         List<ERstudent> students = ePaperStudentMapper.listByExamId(examid);
92
         Map<Integer, List<ERstudent>> schoolCollect = students.stream().collect(Collectors.groupingBy(s -> s.getStudentid()));
93
         Map<Integer, List<ERstudent>> schoolCollect = students.stream().collect(Collectors.groupingBy(s -> s.getStudentid()));
93
         for (Map.Entry<Integer, List<ERstudent>> entry : schoolCollect.entrySet()) {
94
         for (Map.Entry<Integer, List<ERstudent>> entry : schoolCollect.entrySet()) {
100
         Map<Integer, List<ERstudent>> cCollect = students.stream().collect(Collectors.groupingBy(s -> s.getClassid()));
101
         Map<Integer, List<ERstudent>> cCollect = students.stream().collect(Collectors.groupingBy(s -> s.getClassid()));
101
         for (Map.Entry<Integer, List<ERstudent>> entry : cCollect.entrySet()) {
102
         for (Map.Entry<Integer, List<ERstudent>> entry : cCollect.entrySet()) {
102
             Integer classid = entry.getKey();
103
             Integer classid = entry.getKey();
104
+            subjectid = "zf";
105
+            subjectname = "总分";
103
             List<ERstudent> studentList = entry.getValue();
106
             List<ERstudent> studentList = entry.getValue();
107
+
104
             Map<Integer, List<ERstudent>> sCollect = studentList.stream().collect(Collectors.groupingBy(s -> s.getStudentid()));
108
             Map<Integer, List<ERstudent>> sCollect = studentList.stream().collect(Collectors.groupingBy(s -> s.getStudentid()));
105
             for (Map.Entry<Integer, List<ERstudent>> csEntry : sCollect.entrySet()) {
109
             for (Map.Entry<Integer, List<ERstudent>> csEntry : sCollect.entrySet()) {
106
                 ERstudent cs = new ERstudent();
110
                 ERstudent cs = new ERstudent();
124
         }
128
         }
125
 
129
 
126
         DoubleSummaryStatistics schoolStatistics = schoolStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
130
         DoubleSummaryStatistics schoolStatistics = schoolStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
127
-        DoubleSummaryStatistics sSStatistics = schoolSubjectStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
128
         DoubleSummaryStatistics classStatistics = classStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
131
         DoubleSummaryStatistics classStatistics = classStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
129
         DoubleSummaryStatistics cSStatistics = classSubjectStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
132
         DoubleSummaryStatistics cSStatistics = classSubjectStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
130
         double schoolStatisticsMax = schoolStatistics.getMax();
133
         double schoolStatisticsMax = schoolStatistics.getMax();
180
             rs.setMaxscore(statistics.getMax());
183
             rs.setMaxscore(statistics.getMax());
181
             rs.setMinscore(statistics.getMin());
184
             rs.setMinscore(statistics.getMin());
182
             rs.setAvgscore(statistics.getAverage());
185
             rs.setAvgscore(statistics.getAverage());
183
-            rs.setStunum(list.stream().filter(l -> l.getSstate() == 2).collect(Collectors.toList()).size());
184
-            rs.setMissnum(list.stream().filter(l -> l.getSstate() == 3).collect(Collectors.toList()).size());
186
+            int yxnum = list.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
187
+                    .collect(Collectors.toList()).size();
188
+            int lhnum = list.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
189
+                    .collect(Collectors.toList()).size();
190
+            int jgnum = list.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
191
+                    .collect(Collectors.toList()).size();
192
+            int dfnum = list.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
193
+                    .collect(Collectors.toList()).size();
194
+            List<Double> scores = list.stream().map(l -> l.getScore()).collect(Collectors.toList());
195
+            rs.setYxrate(N_Utils.getIntegerDivideAndMulitiply(yxnum, stunum));
196
+            rs.setLhrate(N_Utils.getIntegerDivideAndMulitiply(lhnum, stunum));
197
+            rs.setJgrate(N_Utils.getIntegerDivideAndMulitiply(jgnum, stunum));
198
+            rs.setDfrate(N_Utils.getIntegerDivideAndMulitiply(dfnum, stunum));
199
+            rs.setBzc(ExamUtil.standardDiviation(scores));
200
+            int sknum = list.size();
201
+            rs.setStunum(sknum);//实考人数
202
+            rs.setMissnum(stunum - sknum);//缺考人数=计划人数-实考人数
185
             subjectList.add(rs);
203
             subjectList.add(rs);
186
 
204
 
187
             Map<Integer, List<ERstudent>> claCollect = list.stream().collect(Collectors.groupingBy(s -> s.getClassid()));
205
             Map<Integer, List<ERstudent>> claCollect = list.stream().collect(Collectors.groupingBy(s -> s.getClassid()));
188
             for (Map.Entry<Integer, List<ERstudent>> entry : claCollect.entrySet()) {
206
             for (Map.Entry<Integer, List<ERstudent>> entry : claCollect.entrySet()) {
189
                 Integer classid = entry.getKey();
207
                 Integer classid = entry.getKey();
190
                 List<ERstudent> rstudentList = entry.getValue();
208
                 List<ERstudent> rstudentList = entry.getValue();
191
-                statistics = rstudentList.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
209
+                DoubleSummaryStatistics claStatistics = rstudentList.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
192
                 ERclass rc = new ERclass();
210
                 ERclass rc = new ERclass();
193
                 rc.setExamid(examid);
211
                 rc.setExamid(examid);
194
                 rc.setClassid(classid);
212
                 rc.setClassid(classid);
195
                 rc.setSubjectid(subjectid);
213
                 rc.setSubjectid(subjectid);
196
                 rc.setSubjectname(subjectname);
214
                 rc.setSubjectname(subjectname);
197
                 rc.setAllscore(allscore);
215
                 rc.setAllscore(allscore);
198
-                rc.setClassmaxscore(statistics.getMax());
199
-                rc.setClassminscore(statistics.getMin());
200
-                rc.setClassavgscore(statistics.getAverage());
201
-                rc.setStunum(rstudentList.stream().filter(l -> l.getSstate() == 2).collect(Collectors.toList()).size());
202
-                rc.setMissnum(rstudentList.stream().filter(l -> l.getSstate() == 3).collect(Collectors.toList()).size());
216
+                rc.setClassmaxscore(claStatistics.getMax());
217
+                rc.setClassminscore(claStatistics.getMin());
218
+                rc.setClassavgscore(claStatistics.getAverage());
219
+                rc.setSchoolmaxscore(statistics.getMax());
220
+                rc.setSchoolavgscore(statistics.getAverage());
221
+                sknum = rstudentList.size();
222
+                rc.setStunum(sknum);//实考人数
223
+                rc.setMissnum(stunum - sknum);//缺考人数=计划人数-实考人数
224
+                yxnum = rstudentList.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
225
+                        .collect(Collectors.toList()).size();
226
+                lhnum = rstudentList.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
227
+                        .collect(Collectors.toList()).size();
228
+                jgnum = rstudentList.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
229
+                        .collect(Collectors.toList()).size();
230
+                dfnum = rstudentList.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
231
+                        .collect(Collectors.toList()).size();
232
+                scores = rstudentList.stream().map(l -> l.getScore()).collect(Collectors.toList());
233
+                rc.setYxrate(N_Utils.getIntegerDivideAndMulitiply(yxnum, stunum));
234
+                rc.setLhrate(N_Utils.getIntegerDivideAndMulitiply(lhnum, stunum));
235
+                rc.setJgrate(N_Utils.getIntegerDivideAndMulitiply(jgnum, stunum));
236
+                rc.setDfrate(N_Utils.getIntegerDivideAndMulitiply(dfnum, stunum));
237
+                rc.setBzc(ExamUtil.standardDiviation(scores));
203
                 classList.add(rc);
238
                 classList.add(rc);
204
                 List<EPaperQsVo> typelist = JSON.parseArray(rp.getQnumjson(), EPaperQsVo.class);
239
                 List<EPaperQsVo> typelist = JSON.parseArray(rp.getQnumjson(), EPaperQsVo.class);
205
                 for (EPaperQsVo t : typelist) {
240
                 for (EPaperQsVo t : typelist) {
231
         eRclassMapper.insertList(classList);
266
         eRclassMapper.insertList(classList);
232
         eRsubjectMapper.insertList(subjectList);
267
         eRsubjectMapper.insertList(subjectList);
233
 
268
 
234
-        setRank(schoolStudents, schoolRank, 1);//学校分数排名
235
-        setRank(schoolSubjectStudents, schoolSubjectRank, 2);//学校科目分数排名
236
-        setRank(classStudents, classRank, 3);//班级分数排名
237
-        setRank(classSubjectStudents, classSubjectRank, 4);//班级科目分数排名
269
+        setRank(schoolStudents, schoolStuRank, 1);//学校学生分数排名
270
+        setRank(schoolSubjectStudents, schoolSubStuRank, 2);//学校科目学生分数排名
271
+        setRank(classStudents, classStuRank, 3);//班级学生分数排名
272
+        setRank(classSubjectStudents, classSubStuRank, 4);//班级科目学生分数排名
238
 
273
 
239
         for (ERstudent cs : classStudents) {
274
         for (ERstudent cs : classStudents) {
240
             Integer studentid = cs.getStudentid();
275
             Integer studentid = cs.getStudentid();
241
-            cs.setClassrank(classRank.get(cs.getClassid() + "_" + studentid));
276
+            cs.setClassrank(classStuRank.get(cs.getClassid() + "_" + studentid));
242
             cs.setClassmaxscore(classStatistics.getMax());
277
             cs.setClassmaxscore(classStatistics.getMax());
243
             cs.setClassavgscore(classStatistics.getAverage());
278
             cs.setClassavgscore(classStatistics.getAverage());
244
-            cs.setSchoolrank(schoolRank.get(studentid));
279
+            cs.setSchoolrank(schoolStuRank.get(studentid));
245
             cs.setSchoolmaxscore(schoolStatisticsMax);
280
             cs.setSchoolmaxscore(schoolStatisticsMax);
246
             cs.setSchoolavgscore(schoolStatisticsAverage);
281
             cs.setSchoolavgscore(schoolStatisticsAverage);
247
         }
282
         }
248
         eRstudentMapper.insertList(classStudents);
283
         eRstudentMapper.insertList(classStudents);
249
 
284
 
285
+        DoubleSummaryStatistics sSStatistics = schoolSubjectStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
250
         for (ERstudent cs : classSubjectStudents) {
286
         for (ERstudent cs : classSubjectStudents) {
251
             Integer studentid = cs.getStudentid();
287
             Integer studentid = cs.getStudentid();
252
             Integer classid = cs.getClassid();
288
             Integer classid = cs.getClassid();
253
-            cs.setClassrank(classRank.get(classid + "_" + studentid));
254
-            cs.setClassmaxscore(classStatistics.getMax());
255
-            cs.setClassavgscore(classStatistics.getAverage());
256
-            cs.setSchoolrank(schoolSubjectRank.get(classid + "_" + cs.getSubjectid() + "_" + studentid));
289
+            subjectid = cs.getSubjectid();
290
+            cs.setClassrank(classSubStuRank.get(classid + "_" + subjectid + "_" + studentid));
291
+            cs.setClassmaxscore(cSStatistics.getMax());
292
+            cs.setClassavgscore(cSStatistics.getAverage());
293
+            cs.setSchoolrank(schoolSubStuRank.get(subjectid + "_" + studentid));
257
             cs.setSchoolmaxscore(sSStatistics.getMax());
294
             cs.setSchoolmaxscore(sSStatistics.getMax());
258
             cs.setSchoolavgscore(sSStatistics.getAverage());
295
             cs.setSchoolavgscore(sSStatistics.getAverage());
259
         }
296
         }
274
                 Integer studentid = cgs.getStudentid();
311
                 Integer studentid = cgs.getStudentid();
275
                 Integer classid = cgs.getClassid();
312
                 Integer classid = cgs.getClassid();
276
                 String subjectid = cgs.getSubjectid();
313
                 String subjectid = cgs.getSubjectid();
277
-                if (code == 1) {//学校
314
+                if (code == 1) {//学校学生
278
                     key = studentid.toString();
315
                     key = studentid.toString();
279
-                } else if (code == 2) {//学校科目
316
+                } else if (code == 2) {//学校科目学生
280
                     key = subjectid + "_" + studentid;
317
                     key = subjectid + "_" + studentid;
281
-                } else if (code == 3) {//班级
318
+                } else if (code == 3) {//班级学生
282
                     key = classid + "_" + studentid;
319
                     key = classid + "_" + studentid;
283
-                } else {//班级科目
320
+                } else {//班级科目学生
284
                     key = classid + "_" + subjectid + "_" + studentid;
321
                     key = classid + "_" + subjectid + "_" + studentid;
285
                 }
322
                 }
286
                 rank.put(key, index);
323
                 rank.put(key, index);

+ 22
- 1
sexam/src/main/java/com/xhkjedu/sexam/utils/ExamUtil.java View File

7
 import java.time.LocalDateTime;
7
 import java.time.LocalDateTime;
8
 import java.time.ZoneId;
8
 import java.time.ZoneId;
9
 import java.time.format.DateTimeFormatter;
9
 import java.time.format.DateTimeFormatter;
10
+import java.util.List;
10
 import java.util.Map;
11
 import java.util.Map;
11
 import java.util.concurrent.ConcurrentHashMap;
12
 import java.util.concurrent.ConcurrentHashMap;
12
 
13
 
113
     }
114
     }
114
 
115
 
115
     //两数相减
116
     //两数相减
116
-    public static long subtract(long a,long b){
117
+    public static long subtract(long a, long b) {
117
         BigInteger biginta = new BigInteger(a + "");
118
         BigInteger biginta = new BigInteger(a + "");
118
         BigInteger bigintb = new BigInteger(b + "");
119
         BigInteger bigintb = new BigInteger(b + "");
119
         return biginta.subtract(bigintb).longValue();
120
         return biginta.subtract(bigintb).longValue();
120
 
121
 
121
     }
122
     }
123
+
124
+    //方差s^2=[(x1-x)^2 +...(xn-x)^2]/n 或者s^2=[(x1-x)^2 +...(xn-x)^2]/(n-1)
125
+    public static double variance(List<Double> x) {
126
+        int m = x.size();
127
+        double sum = 0;
128
+        for (int i = 0; i < m; i++) {//求和
129
+            sum += x.get(i);
130
+        }
131
+        double dAve = sum / m;//求平均值
132
+        double dVar = 0;
133
+        for (int i = 0; i < m; i++) {//求方差
134
+            dVar += (x.get(i) - dAve) * (x.get(i) - dAve);
135
+        }
136
+        return dVar / m;
137
+    }
138
+
139
+    //标准差σ=sqrt(s^2)
140
+    public static double standardDiviation(List<Double> x) {
141
+        return Math.sqrt(variance(x));
142
+    }
122
 }
143
 }

+ 1
- 1
sexam/src/main/resources/mapper/paperstudent/EPaperStudentMapper.xml View File

190
 
190
 
191
     <select id="listByExamId" resultType="com.xhkjedu.sexam.model.reportstu.ERstudent">
191
     <select id="listByExamId" resultType="com.xhkjedu.sexam.model.reportstu.ERstudent">
192
         select classid,examid,subjectid,studentid,stuscore score,sstate
192
         select classid,examid,subjectid,studentid,stuscore score,sstate
193
-        from e_paper_student where examid=#{examid}
193
+        from e_paper_student where examid=#{examid} and sstate!=0
194
     </select>
194
     </select>
195
 </mapper>
195
 </mapper>

Loading…
Cancel
Save