Преглед изворни кода

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

# Conflicts:
#	sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java
#	sexam/src/main/java/com/xhkjedu/sexam/utils/ExamUtil.java
tags/正式版本
王宁 пре 2 година
родитељ
комит
27d9285556

+ 0
- 3
sexam/src/main/java/com/xhkjedu/sexam/model/reportclass/ERclass.java Прегледај датотеку

@@ -37,9 +37,6 @@ public class ERclass extends BaseBean {
37 37
     //班级平均分
38 38
     private Double classavgscore;
39 39
 
40
-    //平均分排名
41
-    private Integer schoolrank;
42
-
43 40
     //校最高分
44 41
     private Double schoolmaxscore;
45 42
 

+ 66
- 31
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java Прегледај датотеку

@@ -31,9 +31,9 @@ import com.xhkjedu.sexam.vo.paper.EPaperQtypeVo;
31 31
 import com.xhkjedu.sexam.vo.report.ERClassScoreVo;
32 32
 import com.xhkjedu.sexam.vo.report.ERPaperVo;
33 33
 import com.xhkjedu.utils.N_Utils;
34
+
34 35
 import org.springframework.beans.BeanUtils;
35 36
 import org.springframework.stereotype.Service;
36
-
37 37
 import javax.annotation.Resource;
38 38
 import java.util.*;
39 39
 import java.util.stream.Collectors;
@@ -85,8 +85,8 @@ public class EReportGenerateService {
85 85
         int stunum = classes.stream().mapToInt(m -> (int) m.get("classnum")).sum();
86 86
         int subjectnum = subjects.size();
87 87
 
88
-        String subjectid = "zf";
89
-        String subjectname = "总分";
88
+        String subjectid;
89
+        String subjectname;
90 90
         Map<String, String> subjectMap = subjects.stream().collect(Collectors.toMap(m -> m.get("subjectid").toString(),
91 91
                 m -> m.get("subjectname").toString()));
92 92
         Map<String, ERPaperVo> paperMap = papers.stream().collect(Collectors.toMap(m -> m.getSubjectid(), m -> m));
@@ -95,11 +95,10 @@ public class EReportGenerateService {
95 95
         List<ERstudent> schoolSubjectStudents = new ArrayList<>();//学校科目学生成绩
96 96
         List<ERstudent> classStudents = new ArrayList<>();//班级学生成绩
97 97
         List<ERstudent> classSubjectStudents = new ArrayList<>();//班级科目学生成绩
98
-        Map<String, Integer> schoolRank = new HashMap<>();//学校分数排名
99
-        Map<String, Integer> schoolSubjectRank = new HashMap<>();//学校科目分数排名
100
-        Map<String, Integer> classRank = new HashMap<>();//班级分数排名
101
-        Map<String, Integer> classSubjectRank = new HashMap<>();//班级科目分数排名
102
-
98
+        Map<String, Integer> schoolStuRank = new HashMap<>();//学校学生分数排名
99
+        Map<String, Integer> schoolSubStuRank = new HashMap<>();//学校科目学生分数排名
100
+        Map<String, Integer> classStuRank = new HashMap<>();//班级学生分数排名
101
+        Map<String, Integer> classSubStuRank = new HashMap<>();//班级科目学生分数排名
103 102
         List<ERstudent> students = ePaperStudentMapper.listByExamId(examid);
104 103
         Map<Integer, List<ERstudent>> schoolCollect = students.stream().collect(Collectors.groupingBy(s -> s.getStudentid()));
105 104
         for (Map.Entry<Integer, List<ERstudent>> entry : schoolCollect.entrySet()) {
@@ -112,7 +111,10 @@ public class EReportGenerateService {
112 111
         Map<Integer, List<ERstudent>> cCollect = students.stream().collect(Collectors.groupingBy(s -> s.getClassid()));
113 112
         for (Map.Entry<Integer, List<ERstudent>> entry : cCollect.entrySet()) {
114 113
             Integer classid = entry.getKey();
114
+            subjectid = "zf";
115
+            subjectname = "总分";
115 116
             List<ERstudent> studentList = entry.getValue();
117
+
116 118
             Map<Integer, List<ERstudent>> sCollect = studentList.stream().collect(Collectors.groupingBy(s -> s.getStudentid()));
117 119
             for (Map.Entry<Integer, List<ERstudent>> csEntry : sCollect.entrySet()) {
118 120
                 ERstudent cs = new ERstudent();
@@ -136,7 +138,6 @@ public class EReportGenerateService {
136 138
         }
137 139
 
138 140
         DoubleSummaryStatistics schoolStatistics = schoolStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
139
-        DoubleSummaryStatistics sSStatistics = schoolSubjectStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
140 141
         DoubleSummaryStatistics classStatistics = classStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
141 142
         DoubleSummaryStatistics cSStatistics = classSubjectStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
142 143
         double schoolStatisticsMax = schoolStatistics.getMax();
@@ -192,26 +193,58 @@ public class EReportGenerateService {
192 193
             rs.setMaxscore(statistics.getMax());
193 194
             rs.setMinscore(statistics.getMin());
194 195
             rs.setAvgscore(statistics.getAverage());
195
-            rs.setStunum(list.stream().filter(l -> l.getSstate() == 2).collect(Collectors.toList()).size());
196
-            rs.setMissnum(list.stream().filter(l -> l.getSstate() == 3).collect(Collectors.toList()).size());
196
+            int yxnum = list.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
197
+                    .collect(Collectors.toList()).size();
198
+            int lhnum = list.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
199
+                    .collect(Collectors.toList()).size();
200
+            int jgnum = list.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
201
+                    .collect(Collectors.toList()).size();
202
+            int dfnum = list.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
203
+                    .collect(Collectors.toList()).size();
204
+            List<Double> scores = list.stream().map(l -> l.getScore()).collect(Collectors.toList());
205
+            rs.setYxrate(N_Utils.getIntegerDivideAndMulitiply(yxnum, stunum));
206
+            rs.setLhrate(N_Utils.getIntegerDivideAndMulitiply(lhnum, stunum));
207
+            rs.setJgrate(N_Utils.getIntegerDivideAndMulitiply(jgnum, stunum));
208
+            rs.setDfrate(N_Utils.getIntegerDivideAndMulitiply(dfnum, stunum));
209
+            rs.setBzc(ExamUtil.standardDiviation(scores));
210
+            int sknum = list.size();
211
+            rs.setStunum(sknum);//实考人数
212
+            rs.setMissnum(stunum - sknum);//缺考人数=计划人数-实考人数
197 213
             subjectList.add(rs);
198 214
 
199 215
             Map<Integer, List<ERstudent>> claCollect = list.stream().collect(Collectors.groupingBy(s -> s.getClassid()));
200 216
             for (Map.Entry<Integer, List<ERstudent>> entry : claCollect.entrySet()) {
201 217
                 Integer classid = entry.getKey();
202 218
                 List<ERstudent> rstudentList = entry.getValue();
203
-                statistics = rstudentList.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
219
+                DoubleSummaryStatistics claStatistics = rstudentList.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
204 220
                 ERclass rc = new ERclass();
205 221
                 rc.setExamid(examid);
206 222
                 rc.setClassid(classid);
207 223
                 rc.setSubjectid(subjectid);
208 224
                 rc.setSubjectname(subjectname);
209 225
                 rc.setAllscore(allscore);
210
-                rc.setClassmaxscore(statistics.getMax());
211
-                rc.setClassminscore(statistics.getMin());
212
-                rc.setClassavgscore(statistics.getAverage());
213
-                rc.setStunum(rstudentList.stream().filter(l -> l.getSstate() == 2).collect(Collectors.toList()).size());
214
-                rc.setMissnum(rstudentList.stream().filter(l -> l.getSstate() == 3).collect(Collectors.toList()).size());
226
+                rc.setClassmaxscore(claStatistics.getMax());
227
+                rc.setClassminscore(claStatistics.getMin());
228
+                rc.setClassavgscore(claStatistics.getAverage());
229
+                rc.setSchoolmaxscore(statistics.getMax());
230
+                rc.setSchoolavgscore(statistics.getAverage());
231
+                sknum = rstudentList.size();
232
+                rc.setStunum(sknum);//实考人数
233
+                rc.setMissnum(stunum - sknum);//缺考人数=计划人数-实考人数
234
+                yxnum = rstudentList.stream().filter(l -> l.getScore().compareTo(yxscore) != -1)
235
+                        .collect(Collectors.toList()).size();
236
+                lhnum = rstudentList.stream().filter(l -> l.getScore().compareTo(lhscore) != -1)
237
+                        .collect(Collectors.toList()).size();
238
+                jgnum = rstudentList.stream().filter(l -> l.getScore().compareTo(jgscore) != -1)
239
+                        .collect(Collectors.toList()).size();
240
+                dfnum = rstudentList.stream().filter(l -> l.getScore().compareTo(dfscore) != 1)
241
+                        .collect(Collectors.toList()).size();
242
+                scores = rstudentList.stream().map(l -> l.getScore()).collect(Collectors.toList());
243
+                rc.setYxrate(N_Utils.getIntegerDivideAndMulitiply(yxnum, stunum));
244
+                rc.setLhrate(N_Utils.getIntegerDivideAndMulitiply(lhnum, stunum));
245
+                rc.setJgrate(N_Utils.getIntegerDivideAndMulitiply(jgnum, stunum));
246
+                rc.setDfrate(N_Utils.getIntegerDivideAndMulitiply(dfnum, stunum));
247
+                rc.setBzc(ExamUtil.standardDiviation(scores));
215 248
                 classList.add(rc);
216 249
                 List<EPaperQsVo> typelist = JSON.parseArray(rp.getQnumjson(), EPaperQsVo.class);
217 250
                 for (EPaperQsVo t : typelist) {
@@ -243,29 +276,31 @@ public class EReportGenerateService {
243 276
         eRclassMapper.insertList(classList);
244 277
         eRsubjectMapper.insertList(subjectList);
245 278
 
246
-        setRank(schoolStudents, schoolRank, 1);//学校分数排名
247
-        setRank(schoolSubjectStudents, schoolSubjectRank, 2);//学校科目分数排名
248
-        setRank(classStudents, classRank, 3);//班级分数排名
249
-        setRank(classSubjectStudents, classSubjectRank, 4);//班级科目分数排名
279
+        setRank(schoolStudents, schoolStuRank, 1);//学校学生分数排名
280
+        setRank(schoolSubjectStudents, schoolSubStuRank, 2);//学校科目学生分数排名
281
+        setRank(classStudents, classStuRank, 3);//班级学生分数排名
282
+        setRank(classSubjectStudents, classSubStuRank, 4);//班级科目学生分数排名
250 283
 
251 284
         for (ERstudent cs : classStudents) {
252 285
             Integer studentid = cs.getStudentid();
253
-            cs.setClassrank(classRank.get(cs.getClassid() + "_" + studentid));
286
+            cs.setClassrank(classStuRank.get(cs.getClassid() + "_" + studentid));
254 287
             cs.setClassmaxscore(classStatistics.getMax());
255 288
             cs.setClassavgscore(classStatistics.getAverage());
256
-            cs.setSchoolrank(schoolRank.get(studentid));
289
+            cs.setSchoolrank(schoolStuRank.get(studentid));
257 290
             cs.setSchoolmaxscore(schoolStatisticsMax);
258 291
             cs.setSchoolavgscore(schoolStatisticsAverage);
259 292
         }
260 293
         eRstudentMapper.insertList(classStudents);
261 294
 
295
+        DoubleSummaryStatistics sSStatistics = schoolSubjectStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
262 296
         for (ERstudent cs : classSubjectStudents) {
263 297
             Integer studentid = cs.getStudentid();
264 298
             Integer classid = cs.getClassid();
265
-            cs.setClassrank(classRank.get(classid + "_" + studentid));
266
-            cs.setClassmaxscore(classStatistics.getMax());
267
-            cs.setClassavgscore(classStatistics.getAverage());
268
-            cs.setSchoolrank(schoolSubjectRank.get(classid + "_" + cs.getSubjectid() + "_" + studentid));
299
+            subjectid = cs.getSubjectid();
300
+            cs.setClassrank(classSubStuRank.get(classid + "_" + subjectid + "_" + studentid));
301
+            cs.setClassmaxscore(cSStatistics.getMax());
302
+            cs.setClassavgscore(cSStatistics.getAverage());
303
+            cs.setSchoolrank(schoolSubStuRank.get(subjectid + "_" + studentid));
269 304
             cs.setSchoolmaxscore(sSStatistics.getMax());
270 305
             cs.setSchoolavgscore(sSStatistics.getAverage());
271 306
         }
@@ -286,13 +321,13 @@ public class EReportGenerateService {
286 321
                 Integer studentid = cgs.getStudentid();
287 322
                 Integer classid = cgs.getClassid();
288 323
                 String subjectid = cgs.getSubjectid();
289
-                if (code == 1) {//学校
324
+                if (code == 1) {//学校学生
290 325
                     key = studentid.toString();
291
-                } else if (code == 2) {//学校科目
326
+                } else if (code == 2) {//学校科目学生
292 327
                     key = subjectid + "_" + studentid;
293
-                } else if (code == 3) {//班级
328
+                } else if (code == 3) {//班级学生
294 329
                     key = classid + "_" + studentid;
295
-                } else {//班级科目
330
+                } else {//班级科目学生
296 331
                     key = classid + "_" + subjectid + "_" + studentid;
297 332
                 }
298 333
                 rank.put(key, index);

+ 23
- 2
sexam/src/main/java/com/xhkjedu/sexam/utils/ExamUtil.java Прегледај датотеку

@@ -7,6 +7,7 @@ import java.math.BigInteger;
7 7
 import java.time.LocalDateTime;
8 8
 import java.time.ZoneId;
9 9
 import java.time.format.DateTimeFormatter;
10
+import java.util.List;
10 11
 import java.util.Map;
11 12
 import java.util.concurrent.ConcurrentHashMap;
12 13
 
@@ -113,7 +114,7 @@ public class ExamUtil {
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 118
         BigInteger biginta = new BigInteger(a + "");
118 119
         BigInteger bigintb = new BigInteger(b + "");
119 120
         return biginta.subtract(bigintb).longValue();
@@ -130,6 +131,26 @@ public class ExamUtil {
130 131
         BigDecimal b1 = new BigDecimal(Double.toString(v1));
131 132
         BigDecimal b2 = new BigDecimal(Double.toString(v2));
132 133
 
133
-        return b1.multiply(b2).setScale(0,BigDecimal.ROUND_HALF_UP).doubleValue();
134
+        return b1.multiply(b2).setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue();
135
+    }
136
+
137
+    //方差s^2=[(x1-x)^2 +...(xn-x)^2]/n 或者s^2=[(x1-x)^2 +...(xn-x)^2]/(n-1)
138
+    public static double variance(List<Double> x) {
139
+        int m = x.size();
140
+        double sum = 0;
141
+        for (int i = 0; i < m; i++) {//求和
142
+            sum += x.get(i);
143
+        }
144
+        double dAve = sum / m;//求平均值
145
+        double dVar = 0;
146
+        for (int i = 0; i < m; i++) {//求方差
147
+            dVar += (x.get(i) - dAve) * (x.get(i) - dAve);
148
+        }
149
+        return dVar / m;
150
+    }
151
+
152
+    //标准差σ=sqrt(s^2)
153
+    public static double standardDiviation(List<Double> x) {
154
+        return Math.sqrt(variance(x));
134 155
     }
135 156
 }

+ 1
- 1
sexam/src/main/resources/mapper/paperstudent/EPaperStudentMapper.xml Прегледај датотеку

@@ -190,6 +190,6 @@
190 190
 
191 191
     <select id="listByExamId" resultType="com.xhkjedu.sexam.model.reportstu.ERstudent">
192 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 194
     </select>
195 195
 </mapper>

Loading…
Откажи
Сачувај