|
@@ -0,0 +1,993 @@
|
|
1
|
+package com.xhkjedu.smarking.service.report.generate;
|
|
2
|
+
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
|
4
|
+import com.xhkjedu.smarking.mapper.report.reportclass.*;
|
|
5
|
+import com.xhkjedu.smarking.model.report.reportclass.*;
|
|
6
|
+import com.xhkjedu.smarking.model.report.reportother.MsrReportparam;
|
|
7
|
+import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
|
|
8
|
+import com.xhkjedu.smarking.service.report.reportother.MsrReportparamService;
|
|
9
|
+import com.xhkjedu.smarking.utils.MarkingUtil;
|
|
10
|
+import com.xhkjedu.smarking.vo.report.reportclass.ClassTopVo;
|
|
11
|
+import com.xhkjedu.smarking.vo.report.reportclass.RankRateGroupVo;
|
|
12
|
+import com.xhkjedu.smarking.vo.report.reportother.RankGroupVo;
|
|
13
|
+import com.xhkjedu.smarking.vo.report.reportother.SzJsonVo;
|
|
14
|
+import com.xhkjedu.utils.N_Utils;
|
|
15
|
+import org.springframework.stereotype.Service;
|
|
16
|
+
|
|
17
|
+import javax.annotation.Resource;
|
|
18
|
+import java.util.*;
|
|
19
|
+import java.util.stream.Collectors;
|
|
20
|
+
|
|
21
|
+/**
|
|
22
|
+ *@Description : 班级生成报告服务
|
|
23
|
+ *@Author ywx
|
|
24
|
+ *Date 2025/1/3 11:07
|
|
25
|
+ **/
|
|
26
|
+@Service
|
|
27
|
+public class ReportGenerateClassService {
|
|
28
|
+ @Resource
|
|
29
|
+ private MsrReportparamService msrReportparamService;
|
|
30
|
+ @Resource
|
|
31
|
+ private MsrClassSubjectMapper msrClassSubjectMapper;
|
|
32
|
+ @Resource
|
|
33
|
+ private MsrClassTopMapper msrClassTopMapper;
|
|
34
|
+ @Resource
|
|
35
|
+ private MsrClassSubjectGradeMapper msrClassSubjectGradeMapper;
|
|
36
|
+ @Resource
|
|
37
|
+ private MsrClassRankgroupMapper msrClassRankgroupMapper;
|
|
38
|
+ @Resource
|
|
39
|
+ private MsrClassRankrateMapper msrClassRankrateMapper;
|
|
40
|
+ @Resource
|
|
41
|
+ private MsrClassSectionMapper msrClassSectionMapper;
|
|
42
|
+ @Resource
|
|
43
|
+ private MsrClassNearlineMapper msrClassNearlineMapper;
|
|
44
|
+ @Resource
|
|
45
|
+ private MsrClassGoodbadMapper msrClassGoodbadMapper;
|
|
46
|
+
|
|
47
|
+ //班级学科前60分析
|
|
48
|
+ public void saveClassTop(Integer examid, List<MsrStudent> msrStudents) {
|
|
49
|
+ List<MsrClassTop> msrClassTops = new ArrayList<>();//班级学科前60分析
|
|
50
|
+ Map<String, ClassTopVo> lsMap = new HashMap<>();//处于年级60%得分map
|
|
51
|
+ Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
|
|
52
|
+ for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
|
|
53
|
+ MarkingUtil.studentsDistinct(entry, null);
|
|
54
|
+ String subjectid = entry.getKey().split("_")[1];
|
|
55
|
+ List<Double> scores = entry.getValue().stream().map(MsrStudent::getStuscore).sorted().collect(Collectors.toList());
|
|
56
|
+ Double lsscore = MarkingUtil.cynjdf(scores, 0.6);
|
|
57
|
+ List<MsrStudent> lsstudents = entry.getValue().stream().filter(s -> s.getStuscore().compareTo(lsscore) >= 0).collect(Collectors.toList());
|
|
58
|
+ ClassTopVo classTopVo = new ClassTopVo();
|
|
59
|
+ classTopVo.setSubjectid(subjectid);
|
|
60
|
+ classTopVo.setLsscore(lsscore);
|
|
61
|
+ classTopVo.setXtnum(lsstudents.size());
|
|
62
|
+ double average = lsstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
|
|
63
|
+ classTopVo.setXtavgscore(N_Utils.formatDouble(average, 2));
|
|
64
|
+ String xtstuids = lsstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
|
65
|
+ classTopVo.setXtstuids(xtstuids);
|
|
66
|
+ lsMap.put(subjectid, classTopVo);
|
|
67
|
+ }
|
|
68
|
+ setClassTop(examid, collect, lsMap, msrClassTops);
|
|
69
|
+ Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
|
|
70
|
+ setClassTop(examid, scCollect, lsMap, msrClassTops);
|
|
71
|
+ msrClassTopMapper.insertList(msrClassTops);
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ //班级学科前60计算
|
|
75
|
+ private void setClassTop(Integer examid, Map<String, List<MsrStudent>> scCollect, Map<String, ClassTopVo> lsMap
|
|
76
|
+ , List<MsrClassTop> msrClassTops) {
|
|
77
|
+ Integer totalnum;
|
|
78
|
+ String subjectid;
|
|
79
|
+ for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
|
|
80
|
+ String key = entry.getKey();
|
|
81
|
+ Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
|
82
|
+ subjectid = key.split("_")[1];
|
|
83
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
84
|
+ totalnum = studentList.size();//区间总人数
|
|
85
|
+
|
|
86
|
+ MsrClassTop msrClassTop = new MsrClassTop();
|
|
87
|
+ msrClassTop.setExamid(examid);
|
|
88
|
+ msrClassTop.setClassid(classid);
|
|
89
|
+ msrClassTop.setSubjectid(subjectid);
|
|
90
|
+ msrClassTop.setStunum(totalnum);
|
|
91
|
+ ClassTopVo classTopVo = lsMap.get(subjectid);//处于年级60%得分
|
|
92
|
+ Double lsscore = classTopVo.getLsscore();
|
|
93
|
+ List<MsrStudent> lsstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(lsscore) >= 0).collect(Collectors.toList());
|
|
94
|
+ msrClassTop.setBtnum(lsstudents.size());
|
|
95
|
+ msrClassTop.setBtrate(N_Utils.getIntegerDivideAndMulitiply(msrClassTop.getBtnum(), totalnum));
|
|
96
|
+ double average = lsstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
|
|
97
|
+ msrClassTop.setBtavgscore(N_Utils.formatDouble(average, 2));
|
|
98
|
+ String btstuids = lsstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
|
99
|
+ msrClassTop.setBtstuids(btstuids);
|
|
100
|
+ msrClassTop.setXtnum(classTopVo.getXtnum());
|
|
101
|
+ msrClassTop.setXtavgscore(classTopVo.getXtavgscore());
|
|
102
|
+ msrClassTop.setXtstuids(classTopVo.getXtstuids());
|
|
103
|
+ msrClassTops.add(msrClassTop);
|
|
104
|
+ }
|
|
105
|
+ }
|
|
106
|
+
|
|
107
|
+ //班级学科四率等级分析
|
|
108
|
+ public void saveClassSubjectGrade(Integer examid, String reportcode, List<MsrStudent> msrStudents) {
|
|
109
|
+ Map<String, List<SzJsonVo>> qjMap = formatSzJson(msrReportparamService.getMsrReportParams(examid, "scorerate", reportcode));
|
|
110
|
+ List<MsrClassSubjectGrade> msrClassSubjectGrades = new ArrayList<>();//班级学科分析
|
|
111
|
+ Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
|
|
112
|
+ Map<String, Integer> rsMap = new HashMap<>();//学科人数map
|
|
113
|
+ for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
|
|
114
|
+ MarkingUtil.studentsDistinct(entry, rsMap);
|
|
115
|
+ }
|
|
116
|
+ setClassSubjectGrade(examid, reportcode, collect, qjMap, msrClassSubjectGrades, rsMap);
|
|
117
|
+ Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
|
|
118
|
+ setClassSubjectGrade(examid, reportcode, scCollect, qjMap, msrClassSubjectGrades, rsMap);
|
|
119
|
+ msrClassSubjectGradeMapper.insertList(msrClassSubjectGrades);
|
|
120
|
+ }
|
|
121
|
+
|
|
122
|
+ //格式化报告参数
|
|
123
|
+ private Map<String, List<SzJsonVo>> formatSzJson(List<MsrReportparam> list) {
|
|
124
|
+ Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
|
|
125
|
+ for (MsrReportparam param : list) {
|
|
126
|
+ qjMap.put(param.getSubjectid(), JSON.parseArray(param.getSzjson(), SzJsonVo.class));
|
|
127
|
+ }
|
|
128
|
+ return qjMap;
|
|
129
|
+ }
|
|
130
|
+
|
|
131
|
+ //班级学科四率等级计算
|
|
132
|
+ private void setClassSubjectGrade(Integer examid, String reportcode, Map<String, List<MsrStudent>> scCollect
|
|
133
|
+ , Map<String, List<SzJsonVo>> qjMap, List<MsrClassSubjectGrade> msrClassSubjectGrades
|
|
134
|
+ , Map<String, Integer> rsMap) {
|
|
135
|
+ int totalnum;
|
|
136
|
+ String subjectid;
|
|
137
|
+ for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
|
|
138
|
+ String key = entry.getKey();
|
|
139
|
+ Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
|
140
|
+ subjectid = key.split("_")[1];
|
|
141
|
+ List<SzJsonVo> list = qjMap.get(subjectid);
|
|
142
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
143
|
+ totalnum = rsMap.get(subjectid);//科目总人数
|
|
144
|
+ Double fullscore1 = studentList.get(0).getFullscore();
|
|
145
|
+ for (SzJsonVo rg : list) {
|
|
146
|
+ String qjname = rg.getDjkey();
|
|
147
|
+ double min = MarkingUtil.mul(rg.getMinvalue(), fullscore1);
|
|
148
|
+ double max = MarkingUtil.mul(rg.getMaxvalue(), fullscore1);
|
|
149
|
+ List<MsrStudent> qjstudents;
|
|
150
|
+ if (fullscore1.compareTo(max) == 0) {
|
|
151
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(min) >= 0).collect(Collectors.toList());
|
|
152
|
+ } else {
|
|
153
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(min) >= 0 && s.getStuscore().compareTo(max) < 0).collect(Collectors.toList());
|
|
154
|
+ }
|
|
155
|
+ int qjnum = qjstudents.size();
|
|
156
|
+ MsrClassSubjectGrade classSubjectGrade = new MsrClassSubjectGrade();
|
|
157
|
+ classSubjectGrade.setExamid(examid);
|
|
158
|
+ classSubjectGrade.setSubjectid(subjectid);
|
|
159
|
+ classSubjectGrade.setClassid(classid);
|
|
160
|
+ classSubjectGrade.setReportcode(reportcode);
|
|
161
|
+ classSubjectGrade.setRangename(qjname);
|
|
162
|
+ classSubjectGrade.setRangenum(qjnum);
|
|
163
|
+ classSubjectGrade.setRangerate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
|
|
164
|
+ double qjavg = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
|
|
165
|
+ classSubjectGrade.setDjscore(N_Utils.formatDouble(qjavg, 2));
|
|
166
|
+ classSubjectGrade.setDjrate(N_Utils.getDoubleDivideAndMulitiply(qjavg, fullscore1));
|
|
167
|
+ String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
|
168
|
+ classSubjectGrade.setStuids(stuids);
|
|
169
|
+ msrClassSubjectGrades.add(classSubjectGrade);
|
|
170
|
+ }
|
|
171
|
+ }
|
|
172
|
+ Map<String, List<MsrClassSubjectGrade>> collect = msrClassSubjectGrades.stream().collect(Collectors.groupingBy(g -> g.getSubjectid() + "_" + g.getRangename()));
|
|
173
|
+ for (Map.Entry<String, List<MsrClassSubjectGrade>> entry : collect.entrySet()) {
|
|
174
|
+ List<MsrClassSubjectGrade> nearlineList = entry.getValue();
|
|
175
|
+ List<Integer> nums = new ArrayList<>();
|
|
176
|
+ for (MsrClassSubjectGrade classSubjectGrade : nearlineList) {
|
|
177
|
+ nums.add(classSubjectGrade.getRangenum());
|
|
178
|
+ }
|
|
179
|
+ Map<Integer, Integer> rspm = MarkingUtil.rspm(nums);//人数排名
|
|
180
|
+ for (MsrClassSubjectGrade classSubjectGrade : nearlineList) {
|
|
181
|
+ classSubjectGrade.setRangenumrank(rspm.get(classSubjectGrade.getRangenum()));
|
|
182
|
+ }
|
|
183
|
+ }
|
|
184
|
+ }
|
|
185
|
+
|
|
186
|
+ //班级学科分析
|
|
187
|
+ public void saveClassSubject(Integer examid, List<MsrStudent> msrStudents) {
|
|
188
|
+ List<MsrClassSubject> msrClassSubjects = new ArrayList<>();//班级学科分析
|
|
189
|
+ Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
|
|
190
|
+ List<MsrReportparam> scorerate = msrReportparamService.getMsrReportParams(examid, "scorerate", "zh");
|
|
191
|
+ Map<String, SzJsonVo> tsMap = new HashMap<>();//得分率头部学生比例map
|
|
192
|
+ int subjectnum = 0;
|
|
193
|
+ for (MsrReportparam reportparam : scorerate) {
|
|
194
|
+ SzJsonVo sz = new SzJsonVo();
|
|
195
|
+ String szjson = reportparam.getSzjson();
|
|
196
|
+ Integer rptype = reportparam.getRptype();
|
|
197
|
+ if (rptype.equals(2)) {
|
|
198
|
+ Map<String, Object> map = JSON.parseObject(szjson, Map.class);
|
|
199
|
+ sz.setAlltop(N_Utils.obj2Int(map.get("alltop")));
|
|
200
|
+ sz.setAllbottom(N_Utils.obj2Int(map.get("allbottom")));
|
|
201
|
+ }
|
|
202
|
+ String subjectid = reportparam.getSubjectid();
|
|
203
|
+ tsMap.put(subjectid, sz);
|
|
204
|
+ if (!"zf".equals(subjectid)) {
|
|
205
|
+ subjectnum++;
|
|
206
|
+ }
|
|
207
|
+ }
|
|
208
|
+ Map<String, Integer> rsMap = new HashMap<>();//学科人数map
|
|
209
|
+ Map<String, List<Integer>> qkMap = new LinkedHashMap<>();//全科及格率学生map
|
|
210
|
+ for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
|
|
211
|
+ MarkingUtil.studentsDistinct(entry, rsMap);
|
|
212
|
+ String key = entry.getKey();
|
|
213
|
+ String subjectid = key.split("_")[1];
|
|
214
|
+ SzJsonVo sz = tsMap.get(subjectid);
|
|
215
|
+ if (N_Utils.isTrueInteger(sz.getAlltop())) {
|
|
216
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
217
|
+ List<Double> scores = studentList.stream().map(MsrStudent::getStuscore).sorted().collect(Collectors.toList());
|
|
218
|
+ int totalnum = scores.size();
|
|
219
|
+ int index = (int) Math.ceil(MarkingUtil.div(MarkingUtil.mul(sz.getAlltop(), totalnum), 100));
|
|
220
|
+ if (index > totalnum) index = totalnum;
|
|
221
|
+ int goodvalue = studentList.subList(totalnum - index, totalnum).stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMax();
|
|
222
|
+ int index2 = (int) Math.ceil(MarkingUtil.div(MarkingUtil.mul(sz.getAllbottom(), totalnum), 100));
|
|
223
|
+ if (index2 > totalnum) index2 = totalnum;
|
|
224
|
+ int badvalue = studentList.subList(0, index2).stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMin();
|
|
225
|
+ sz.setGoodvalue(goodvalue);
|
|
226
|
+ sz.setBadvalue(badvalue);
|
|
227
|
+ }
|
|
228
|
+ //全科及格率
|
|
229
|
+ if (subjectid.equals("zf")) {
|
|
230
|
+ List<MsrClassSubjectGrade> grades = msrClassSubjectGradeMapper.listSubjectGradeForQk(examid, "zh");
|
|
231
|
+ if (N_Utils.isListNotEmpty(grades)) {
|
|
232
|
+ Map<String, List<MsrClassSubjectGrade>> rcollect = grades.stream().collect(Collectors.groupingBy(MsrClassSubjectGrade::getRangename, LinkedHashMap::new, Collectors.toList()));
|
|
233
|
+ for (Map.Entry<String, List<MsrClassSubjectGrade>> rentry : rcollect.entrySet()) {
|
|
234
|
+ String rkey = rentry.getKey();
|
|
235
|
+ List<MsrClassSubjectGrade> gradeList = rentry.getValue();
|
|
236
|
+ String stuids = gradeList.get(0).getStuids();
|
|
237
|
+ List<Integer> ids = new ArrayList<>();
|
|
238
|
+ for (String id : stuids.split(",")) {
|
|
239
|
+ ids.add(N_Utils.obj2Int(id));
|
|
240
|
+ }
|
|
241
|
+ if (subjectnum == 1) {
|
|
242
|
+ qkMap.put(rkey, ids);
|
|
243
|
+ } else if (N_Utils.isListNotEmpty(ids)) {
|
|
244
|
+ for (int i = 1; i < gradeList.size(); i++) {
|
|
245
|
+ MsrClassSubjectGrade grade = gradeList.get(i);
|
|
246
|
+ String stuids2 = grade.getStuids();
|
|
247
|
+ List<Integer> ids2 = new ArrayList<>();
|
|
248
|
+ for (String id2 : stuids2.split(",")) {
|
|
249
|
+ ids2.add(N_Utils.obj2Int(id2));
|
|
250
|
+ }
|
|
251
|
+ //交集
|
|
252
|
+ if (N_Utils.isListEmpty(ids2)) {
|
|
253
|
+ ids = new ArrayList<>();
|
|
254
|
+ break;
|
|
255
|
+ }
|
|
256
|
+ ids = ids.stream().filter(ids2::contains).collect(Collectors.toList());
|
|
257
|
+ if (N_Utils.isListEmpty(ids)) {
|
|
258
|
+ ids = new ArrayList<>();
|
|
259
|
+ break;
|
|
260
|
+ }
|
|
261
|
+
|
|
262
|
+ }
|
|
263
|
+ }
|
|
264
|
+ qkMap.put(rkey, ids);
|
|
265
|
+ }
|
|
266
|
+ }
|
|
267
|
+ }
|
|
268
|
+ }
|
|
269
|
+ List<MsrReportparam> params = msrReportparamService.getMsrReportParams(examid, "allrate", "all");
|
|
270
|
+ SzJsonVo vo = JSON.parseObject(params.get(0).getSzjson(), SzJsonVo.class);
|
|
271
|
+ String calformula = vo.getCalformula();
|
|
272
|
+ Map<String, MsrClassSubject> csMap = new HashMap<>();//班级学科map
|
|
273
|
+ setClassSubject(examid, collect, msrClassSubjects, csMap, calformula, tsMap, qkMap);
|
|
274
|
+ Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
|
|
275
|
+ setClassSubject(examid, scCollect, msrClassSubjects, csMap, calformula, tsMap, qkMap);
|
|
276
|
+
|
|
277
|
+ Map<String, List<MsrClassSubject>> scollect = msrClassSubjects.stream().collect(Collectors.groupingBy(MsrClassSubject::getSubjectid));
|
|
278
|
+ for (Map.Entry<String, List<MsrClassSubject>> entry : scollect.entrySet()) {
|
|
279
|
+ List<MsrClassSubject> nearlineList = entry.getValue();
|
|
280
|
+ if (entry.getKey().equals("zf")) {
|
|
281
|
+ Map<String, List<Integer>> qknum = new LinkedHashMap<>();
|
|
282
|
+ for (MsrClassSubject cs : nearlineList) {
|
|
283
|
+ List<MsrClassSubjectGrade> grades = cs.getGrades();
|
|
284
|
+ for (MsrClassSubjectGrade grade : grades) {
|
|
285
|
+ String rangename = grade.getRangename();
|
|
286
|
+ Integer rangenum = grade.getRangenum();
|
|
287
|
+ if (qknum.containsKey(rangename)) {
|
|
288
|
+ qknum.get(rangename).add(rangenum);
|
|
289
|
+ } else {
|
|
290
|
+ qknum.put(rangename, new ArrayList<>(Collections.singletonList(rangenum)));
|
|
291
|
+ }
|
|
292
|
+ }
|
|
293
|
+ }
|
|
294
|
+ Map<String, Map<Integer, Integer>> qkpm = new LinkedHashMap<>();
|
|
295
|
+ for (Map.Entry<String, List<Integer>> entry2 : qknum.entrySet()) {
|
|
296
|
+ Map<Integer, Integer> rspm = MarkingUtil.rspm(entry2.getValue());
|
|
297
|
+ qkpm.put(entry2.getKey(), rspm);
|
|
298
|
+ }
|
|
299
|
+
|
|
300
|
+ for (MsrClassSubject cs : nearlineList) {
|
|
301
|
+ List<MsrClassSubjectGrade> grades = cs.getGrades();
|
|
302
|
+ for (MsrClassSubjectGrade grade : grades) {
|
|
303
|
+ String rangename = grade.getRangename();
|
|
304
|
+ Integer rangenum = grade.getRangenum();
|
|
305
|
+ Integer rank = qkpm.get(rangename).get(rangenum);
|
|
306
|
+ grade.setRangenumrank(rank);
|
|
307
|
+ }
|
|
308
|
+ cs.setQkjgl(JSON.toJSONString(grades));
|
|
309
|
+ }
|
|
310
|
+ }
|
|
311
|
+ List<Double> classavgscore = new ArrayList<>();//班级平均分列表
|
|
312
|
+ List<Double> bzf = new ArrayList<>();//标准分列表
|
|
313
|
+ List<Double> cjl = new ArrayList<>();//超均率列表
|
|
314
|
+ List<Double> bjl = new ArrayList<>();//比均率列表
|
|
315
|
+ List<Double> zws = new ArrayList<>();//中位数列表
|
|
316
|
+ List<Double> ljc = new ArrayList<>();//离均差列表
|
|
317
|
+ List<Double> zs = new ArrayList<>();//众数列表
|
|
318
|
+ for (MsrClassSubject cs : nearlineList) {
|
|
319
|
+ classavgscore.add(cs.getClassavgscore());
|
|
320
|
+ bzf.add(cs.getBzf());
|
|
321
|
+ cjl.add(cs.getCjl());
|
|
322
|
+ bjl.add(cs.getBjl());
|
|
323
|
+ zws.add(cs.getZws());
|
|
324
|
+ ljc.add(cs.getLjc());
|
|
325
|
+ zs.add(cs.getZsmax());
|
|
326
|
+ }
|
|
327
|
+ Map<Double, Integer> pjfpm = MarkingUtil.fspm(classavgscore);//班级平均分排名
|
|
328
|
+ Map<Double, Integer> bzfpm = MarkingUtil.fspm(bzf);//标准分排名
|
|
329
|
+ Map<Double, Integer> cjlpm = MarkingUtil.fspm(cjl);//超均率排名
|
|
330
|
+ Map<Double, Integer> bjlpm = MarkingUtil.fspm(bjl);//比均率排名
|
|
331
|
+ Map<Double, Integer> zwspm = MarkingUtil.fspm(zws);//中位数排名
|
|
332
|
+ Map<Double, Integer> ljcpm = MarkingUtil.fspm(ljc);//离均差排名
|
|
333
|
+ Map<Double, Integer> zspm = MarkingUtil.fspm(zs);//众数排名
|
|
334
|
+ for (MsrClassSubject cs : nearlineList) {
|
|
335
|
+ cs.setClassavgrank(pjfpm.get(cs.getClassavgscore()));
|
|
336
|
+ cs.setBzfrank(bzfpm.get(cs.getBzf()));
|
|
337
|
+ cs.setCjlrank(cjlpm.get(cs.getCjl()));
|
|
338
|
+ cs.setBjlrank(bjlpm.get(cs.getBjl()));
|
|
339
|
+ cs.setZwsrank(zwspm.get(cs.getZws()));
|
|
340
|
+ cs.setLjcrank(ljcpm.get(cs.getLjc()));
|
|
341
|
+ cs.setZsrank(zspm.get(cs.getZsmax()));
|
|
342
|
+ }
|
|
343
|
+ }
|
|
344
|
+ msrClassSubjectMapper.insertList(msrClassSubjects);
|
|
345
|
+ }
|
|
346
|
+
|
|
347
|
+ //班级学科计算
|
|
348
|
+ private void setClassSubject(Integer examid, Map<String, List<MsrStudent>> scCollect
|
|
349
|
+ , List<MsrClassSubject> msrClassSubjects, Map<String, MsrClassSubject> csMap, String calformula
|
|
350
|
+ , Map<String, SzJsonVo> tsMap, Map<String, List<Integer>> qkMap) {
|
|
351
|
+ String subjectid;
|
|
352
|
+ MsrClassSubject zf = csMap.get("zf");
|
|
353
|
+ for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
|
|
354
|
+ String key = entry.getKey();
|
|
355
|
+ Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
|
356
|
+ subjectid = key.split("_")[1];
|
|
357
|
+ SzJsonVo ts = tsMap.get(subjectid);
|
|
358
|
+ MsrClassSubject gs = csMap.get(subjectid);
|
|
359
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
360
|
+ studentList.sort(Comparator.comparing(MsrStudent::getStuscore));
|
|
361
|
+ MsrStudent minStudent = studentList.get(0);
|
|
362
|
+ int stunum = studentList.size();
|
|
363
|
+ MsrStudent maxStudent = studentList.get(stunum - 1);
|
|
364
|
+ Double fullscore = minStudent.getFullscore();
|
|
365
|
+ MsrClassSubject msrClassSubject = new MsrClassSubject();
|
|
366
|
+ if ("zf".equals(subjectid)) {
|
|
367
|
+ List<Integer> studentids = studentList.stream().map(MsrStudent::getStudentid).collect(Collectors.toList());
|
|
368
|
+ List<MsrClassSubjectGrade> grades = new ArrayList<>();
|
|
369
|
+ for (Map.Entry<String, List<Integer>> entry2 : qkMap.entrySet()) {
|
|
370
|
+ String key2 = entry2.getKey();
|
|
371
|
+ List<Integer> ids = entry2.getValue();
|
|
372
|
+ //ids与studentList的studentid交集
|
|
373
|
+ List<Integer> ids2 = ids.stream().filter(studentids::contains).collect(Collectors.toList());
|
|
374
|
+ MsrClassSubjectGrade grade = new MsrClassSubjectGrade();
|
|
375
|
+ grade.setRangename(key2);
|
|
376
|
+ int rangenum = ids2.size();
|
|
377
|
+ grade.setRangenum(rangenum);
|
|
378
|
+ grade.setRangerate(N_Utils.getIntegerDivideAndMulitiply(rangenum, stunum));
|
|
379
|
+ grade.setStuids(ids2.stream().map(Object::toString).collect(Collectors.joining(",")));
|
|
380
|
+ grades.add(grade);
|
|
381
|
+ }
|
|
382
|
+ msrClassSubject.setGrades(grades);
|
|
383
|
+ }
|
|
384
|
+ msrClassSubject.setExamid(examid);
|
|
385
|
+ msrClassSubject.setSubjectid(subjectid);
|
|
386
|
+ msrClassSubject.setClassid(classid);
|
|
387
|
+ msrClassSubject.setFullscore(fullscore);
|
|
388
|
+ msrClassSubject.setClassmaxscore(maxStudent.getStuscore());
|
|
389
|
+ msrClassSubject.setClassmaxrank(maxStudent.getSchoolrank());
|
|
390
|
+ msrClassSubject.setClassminscore(minStudent.getStuscore());
|
|
391
|
+ msrClassSubject.setClassminrank(minStudent.getSchoolrank());
|
|
392
|
+ List<Double> scores = studentList.stream().map(MsrStudent::getStuscore).collect(Collectors.toList());
|
|
393
|
+ double classavgscore = N_Utils.formatDouble(scores.stream().mapToDouble(Double::doubleValue).summaryStatistics().getAverage(), 2);
|
|
394
|
+ msrClassSubject.setClassavgscore(classavgscore);
|
|
395
|
+ double classavgrate = N_Utils.getDoubleDivideAndMulitiply(classavgscore, fullscore);
|
|
396
|
+ msrClassSubject.setClassavgrate(classavgrate);
|
|
397
|
+ msrClassSubject.setBzc(MarkingUtil.bzc(scores));
|
|
398
|
+ if (classid.equals(0)) {
|
|
399
|
+ msrClassSubject.setSchoolmaxscore(msrClassSubject.getClassmaxscore());
|
|
400
|
+ msrClassSubject.setSchoolminscore(msrClassSubject.getClassminscore());
|
|
401
|
+ msrClassSubject.setSchoolavgscore(msrClassSubject.getClassavgscore());
|
|
402
|
+ msrClassSubject.setSchoolavgrate(msrClassSubject.getClassavgrate());
|
|
403
|
+ msrClassSubject.setBzf(0.0);
|
|
404
|
+ msrClassSubject.setCjl(0.0);
|
|
405
|
+ msrClassSubject.setLjc(0.0);
|
|
406
|
+ msrClassSubject.setBjl(1.0);
|
|
407
|
+ msrClassSubject.setDfgxzs(0.0);
|
|
408
|
+ msrClassSubject.setPjfgxzs(0.0);
|
|
409
|
+ } else {
|
|
410
|
+ Double schoolavgscore = gs.getClassavgscore();
|
|
411
|
+ msrClassSubject.setSchoolmaxscore(gs.getClassmaxscore());
|
|
412
|
+ msrClassSubject.setSchoolminscore(gs.getClassminscore());
|
|
413
|
+ msrClassSubject.setSchoolavgscore(schoolavgscore);
|
|
414
|
+ msrClassSubject.setSchoolavgrate(gs.getClassavgrate());
|
|
415
|
+ msrClassSubject.setBzf(MarkingUtil.bzf(classavgscore, schoolavgscore, gs.getBzc()));
|
|
416
|
+ msrClassSubject.setCjl(MarkingUtil.cjl(classavgscore, schoolavgscore));
|
|
417
|
+ msrClassSubject.setLjc(MarkingUtil.sub(classavgscore, schoolavgscore));
|
|
418
|
+ msrClassSubject.setBjl(1.0);
|
|
419
|
+ msrClassSubject.setDfgxzs(MarkingUtil.sub(classavgrate, zf.getClassavgrate()));
|
|
420
|
+ msrClassSubject.setPjfgxzs(MarkingUtil.sub(classavgscore, zf.getClassavgscore()));
|
|
421
|
+ }
|
|
422
|
+ msrClassSubject.setZws(MarkingUtil.zws(scores));
|
|
423
|
+ List<Double> zs = MarkingUtil.zs(scores);
|
|
424
|
+ msrClassSubject.setZs(JSON.toJSONString(zs));
|
|
425
|
+ msrClassSubject.setZsmax(zs.stream().max(Double::compareTo).orElse(0.0));
|
|
426
|
+ if (N_Utils.isNotEmpty(calformula)) {
|
|
427
|
+ calformula = calformula.replaceAll("平均分", msrClassSubject.getClassavgscore() + "");
|
|
428
|
+ calformula = calformula.replaceAll("标准差", msrClassSubject.getBzc() + "");
|
|
429
|
+ calformula = calformula.replaceAll("最高分", msrClassSubject.getClassmaxscore() + "");
|
|
430
|
+ calformula = calformula.replaceAll("最低分", msrClassSubject.getClassminscore() + "");
|
|
431
|
+ calformula = calformula.replaceAll("超均率", msrClassSubject.getCjl() + "");
|
|
432
|
+ calformula = calformula.replaceAll("标准分", msrClassSubject.getBzf() + "");
|
|
433
|
+ calformula = calformula.replaceAll("中位数", msrClassSubject.getZws() + "");
|
|
434
|
+ calformula = calformula.replaceAll("离均差", msrClassSubject.getLjc() + "");
|
|
435
|
+ calformula = calformula.replaceAll("比均率", msrClassSubject.getBjl() + "");
|
|
436
|
+ calformula = calformula.replaceAll("众数", msrClassSubject.getZsmax() + "");
|
|
437
|
+ msrClassSubject.setZhl(MarkingUtil.evaluate(calformula));
|
|
438
|
+ }
|
|
439
|
+
|
|
440
|
+ if (N_Utils.isTrueInteger(ts.getAlltop())) {
|
|
441
|
+ Double goodAvgScore = N_Utils.formatDouble(studentList.stream().filter(s -> s.getSchoolrank().compareTo(ts.getGoodvalue()) <= 0)
|
|
442
|
+ .mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2);
|
|
443
|
+ Double badAvgScore = N_Utils.formatDouble(studentList.stream().filter(s -> s.getSchoolrank().compareTo(ts.getBadvalue()) >= 0)
|
|
444
|
+ .mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2);
|
|
445
|
+ msrClassSubject.setJhl(MarkingUtil.div(badAvgScore, goodAvgScore));
|
|
446
|
+ }
|
|
447
|
+
|
|
448
|
+ if (classid.equals(0)) {
|
|
449
|
+ csMap.put(subjectid, msrClassSubject);
|
|
450
|
+ }
|
|
451
|
+ msrClassSubjects.add(msrClassSubject);
|
|
452
|
+ }
|
|
453
|
+ }
|
|
454
|
+
|
|
455
|
+ //学科报告-班级学科名次分组分析
|
|
456
|
+ public void saveClassRankGroup(Integer examid, List<MsrStudent> msrStudents) {
|
|
457
|
+ List<MsrClassRankgroup> classRankGroups = new ArrayList<>();
|
|
458
|
+ Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
|
|
459
|
+ Map<String, List<RankGroupVo>> groupsMap = new HashMap<>();
|
|
460
|
+ Map<String, Integer> rsMap = new HashMap<>();//学科人数map
|
|
461
|
+ for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
|
|
462
|
+ MarkingUtil.studentsDistinct(entry, rsMap);
|
|
463
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
464
|
+ int maxRank = studentList.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMax();
|
|
465
|
+ List<RankGroupVo> groups = MarkingUtil.rankGroup(maxRank, 10);
|
|
466
|
+ groupsMap.put(studentList.get(0).getSubjectid(), groups);
|
|
467
|
+ }
|
|
468
|
+ setClassRankGroup(examid, collect, classRankGroups, groupsMap);
|
|
469
|
+ Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
|
|
470
|
+ setClassRankGroup(examid, scCollect, classRankGroups, groupsMap);
|
|
471
|
+ msrClassRankgroupMapper.insertList(classRankGroups);
|
|
472
|
+ }
|
|
473
|
+
|
|
474
|
+ //学科报告-班级学科名次分组计算
|
|
475
|
+ private void setClassRankGroup(Integer examid, Map<String, List<MsrStudent>> scCollect
|
|
476
|
+ , List<MsrClassRankgroup> classRankGroups, Map<String, List<RankGroupVo>> groupsMap) {
|
|
477
|
+ String subjectid;
|
|
478
|
+ for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
|
|
479
|
+ String key = entry.getKey();
|
|
480
|
+ Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
|
481
|
+ subjectid = key.split("_")[1];
|
|
482
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
483
|
+ List<RankGroupVo> groups = groupsMap.get(subjectid);
|
|
484
|
+ for (RankGroupVo group : groups) {
|
|
485
|
+ int maxvalue = group.getMaxvalue();
|
|
486
|
+ int minvalue = group.getMinvalue();
|
|
487
|
+ List<MsrStudent> qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(minvalue) >= 0 && s.getSchoolrank().compareTo(maxvalue) <= 0).collect(Collectors.toList());
|
|
488
|
+ MsrClassRankgroup cg = new MsrClassRankgroup();
|
|
489
|
+ cg.setExamid(examid);
|
|
490
|
+ cg.setClassid(classid);
|
|
491
|
+ cg.setSubjectid(subjectid);
|
|
492
|
+ cg.setRname(group.getGroupname());
|
|
493
|
+ cg.setRnum(qjstudents.size());
|
|
494
|
+ String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
|
495
|
+ cg.setStuids(stuids);
|
|
496
|
+ classRankGroups.add(cg);
|
|
497
|
+ }
|
|
498
|
+ }
|
|
499
|
+ }
|
|
500
|
+
|
|
501
|
+ //综合报表-名次和比例分析
|
|
502
|
+ public void saveClassRankRate(Integer examid, List<MsrStudent> msrStudents) {
|
|
503
|
+ List<MsrReportparam> params = msrReportparamService.getMsrReportParams(examid, "rankrate", "zh");
|
|
504
|
+ Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
|
|
505
|
+ Map<String, Integer> tMap = new HashMap<>();
|
|
506
|
+ for (MsrReportparam param : params) {
|
|
507
|
+ String subjectid = param.getSubjectid();
|
|
508
|
+ qjMap.put(subjectid, JSON.parseArray(param.getSzjson(), SzJsonVo.class));
|
|
509
|
+ tMap.put(subjectid, param.getRptype());
|
|
510
|
+ }
|
|
511
|
+ List<MsrClassRankrate> classRankrates = new ArrayList<>();
|
|
512
|
+ Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
|
|
513
|
+ Map<String, List<RankRateGroupVo>> sgMap = new HashMap<>();//学科名次分组map
|
|
514
|
+ Map<String, Integer> rsMap = new HashMap<>();//学科人数map
|
|
515
|
+ for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
|
|
516
|
+ MarkingUtil.studentsDistinct(entry, rsMap);
|
|
517
|
+ List<RankRateGroupVo> subjectGroupList = new ArrayList<>();//学科名次分组列表
|
|
518
|
+ String subjectid = entry.getKey().split("_")[1];
|
|
519
|
+ List<SzJsonVo> list = qjMap.get(subjectid);
|
|
520
|
+ Integer rptype = tMap.get(subjectid);
|
|
521
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
522
|
+ if (rptype.equals(3)) {
|
|
523
|
+ studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
|
|
524
|
+ }
|
|
525
|
+ int totalnum = studentList.size();//总人数
|
|
526
|
+ Double max = null;
|
|
527
|
+ Integer minRank = null;
|
|
528
|
+ int minIndex = 0;
|
|
529
|
+ Object minRate = null;
|
|
530
|
+ for (SzJsonVo rg : list) {
|
|
531
|
+ Object djvalue = rg.getDjvalue();
|
|
532
|
+ RankRateGroupVo group = new RankRateGroupVo();
|
|
533
|
+ List<MsrStudent> qjstudents;
|
|
534
|
+ String ztname;
|
|
535
|
+ String ctname;
|
|
536
|
+ if (rptype.equals(1)) {//按名次
|
|
537
|
+ ztname = "前" + djvalue + "名";
|
|
538
|
+ Integer rank = N_Utils.obj2Int(djvalue);
|
|
539
|
+ if (minRank == null) {
|
|
540
|
+ qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
|
|
541
|
+ } else {
|
|
542
|
+ Integer finalMinRank = minRank;
|
|
543
|
+ qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(finalMinRank) > 0 && s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
|
|
544
|
+ group.setMinrank(minRank);
|
|
545
|
+ }
|
|
546
|
+ group.setMaxrank(rank);
|
|
547
|
+ minRank = rank;
|
|
548
|
+ double minScore = N_Utils.handleInfinity(qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getMin());
|
|
549
|
+ ctname = ">=" + minScore + "分";
|
|
550
|
+ } else if (rptype.equals(2)) {//按分数
|
|
551
|
+ ztname = ">=" + djvalue + "分";
|
|
552
|
+ Double score = MarkingUtil.objToDouble(djvalue);
|
|
553
|
+ double minScore = score;
|
|
554
|
+ if (max == null) {
|
|
555
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
|
|
556
|
+ } else {
|
|
557
|
+ Double finalMax = max;
|
|
558
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0 && s.getStuscore().compareTo(finalMax) < 0).collect(Collectors.toList());
|
|
559
|
+ group.setMaxscore(max);
|
|
560
|
+ }
|
|
561
|
+ group.setMinscore(minScore);
|
|
562
|
+ max = score;
|
|
563
|
+ minRank = qjstudents.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMin();
|
|
564
|
+ ctname = "前" + minRank + "名";
|
|
565
|
+ } else {//按比例
|
|
566
|
+ if (minIndex == 0) {
|
|
567
|
+ ztname = "前" + djvalue + "%";
|
|
568
|
+ } else {
|
|
569
|
+ ztname = "前" + minRate + "%-" + djvalue + "%";
|
|
570
|
+ }
|
|
571
|
+ int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, djvalue));
|
|
572
|
+ if (index > totalnum) index = totalnum;
|
|
573
|
+ qjstudents = studentList.subList(minIndex, index);
|
|
574
|
+ minIndex = index;
|
|
575
|
+ minRate = djvalue;
|
|
576
|
+ DoubleSummaryStatistics statistics = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics();
|
|
577
|
+ double minScore = N_Utils.handleInfinity(statistics.getMin());
|
|
578
|
+ double maxScore = N_Utils.handleInfinity(statistics.getMax());
|
|
579
|
+ ctname = "[" + minScore + "-" + maxScore + "]";
|
|
580
|
+ group.setMaxscore(maxScore);
|
|
581
|
+ group.setMinscore(minScore);
|
|
582
|
+ }
|
|
583
|
+ group.setRtype(rptype);
|
|
584
|
+ group.setZtname(ztname);
|
|
585
|
+ group.setCtname(ctname);
|
|
586
|
+ subjectGroupList.add(group);
|
|
587
|
+ }
|
|
588
|
+ sgMap.put(subjectid, subjectGroupList);
|
|
589
|
+ }
|
|
590
|
+ setClassRankRate(examid, collect, classRankrates, sgMap, rsMap);
|
|
591
|
+ Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
|
|
592
|
+ setClassRankRate(examid, scCollect, classRankrates, sgMap, rsMap);
|
|
593
|
+ msrClassRankrateMapper.insertList(classRankrates);
|
|
594
|
+ }
|
|
595
|
+
|
|
596
|
+ //综合报表-名次和比例计算
|
|
597
|
+ private void setClassRankRate(Integer examid, Map<String, List<MsrStudent>> scCollect
|
|
598
|
+ , List<MsrClassRankrate> classRankrates, Map<String, List<RankRateGroupVo>> sgMap
|
|
599
|
+ , Map<String, Integer> rsMap) {
|
|
600
|
+ int totalnum;
|
|
601
|
+ String subjectid;
|
|
602
|
+ for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
|
|
603
|
+ String key = entry.getKey();
|
|
604
|
+ Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
|
605
|
+ subjectid = key.split("_")[1];
|
|
606
|
+ totalnum = rsMap.get(subjectid);
|
|
607
|
+ List<RankRateGroupVo> list = sgMap.get(subjectid);
|
|
608
|
+ Integer rptype = list.get(0).getRtype();
|
|
609
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
610
|
+ if (rptype.equals(3)) {
|
|
611
|
+ studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
|
|
612
|
+ }
|
|
613
|
+ int stunum = studentList.size();//参考人数
|
|
614
|
+ for (int i = 0; i < list.size(); i++) {
|
|
615
|
+ RankRateGroupVo rg = list.get(i);
|
|
616
|
+ List<MsrStudent> qjstudents;
|
|
617
|
+ if (rptype.equals(1)) {//按名次
|
|
618
|
+ if (i == 0) {
|
|
619
|
+ qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rg.getMaxrank()) >= 0).collect(Collectors.toList());
|
|
620
|
+ } else {
|
|
621
|
+ qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rg.getMaxrank()) >= 0 && s.getSchoolrank().compareTo(rg.getMinrank()) < 0).collect(Collectors.toList());
|
|
622
|
+ }
|
|
623
|
+ } else {//按分数
|
|
624
|
+ if (i == 0) {
|
|
625
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(rg.getMinscore()) >= 0).collect(Collectors.toList());
|
|
626
|
+ } else {
|
|
627
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(rg.getMinscore()) >= 0 && s.getStuscore().compareTo(rg.getMaxscore()) < 0).collect(Collectors.toList());
|
|
628
|
+ }
|
|
629
|
+ }
|
|
630
|
+ int qjnum = qjstudents.size();
|
|
631
|
+ MsrClassRankrate rankrate = new MsrClassRankrate();
|
|
632
|
+ rankrate.setExamid(examid);
|
|
633
|
+ rankrate.setSubjectid(subjectid);
|
|
634
|
+ rankrate.setClassid(classid);
|
|
635
|
+ rankrate.setStunum(stunum);
|
|
636
|
+ rankrate.setRtype(rptype);
|
|
637
|
+ rankrate.setZtname(rg.getZtname());
|
|
638
|
+ rankrate.setCtname(rg.getCtname());
|
|
639
|
+ rankrate.setRnum(qjnum);
|
|
640
|
+ rankrate.setRrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
|
|
641
|
+ String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
|
642
|
+ rankrate.setStuids(stuids);
|
|
643
|
+ classRankrates.add(rankrate);
|
|
644
|
+ }
|
|
645
|
+ }
|
|
646
|
+ }
|
|
647
|
+
|
|
648
|
+ //分段统计
|
|
649
|
+ public void saveClassSection(Integer examid, Integer type, String reportcode, List<MsrStudent> msrStudents) {
|
|
650
|
+ List<MsrReportparam> params = msrReportparamService.getMsrReportParams(examid, "scoresection", reportcode);
|
|
651
|
+ Integer rptype = params.get(0).getRptype();
|
|
652
|
+ Map<String, List<RankGroupVo>> fdMap = new HashMap<>();
|
|
653
|
+ if (rptype.equals(0)) {//固定步长
|
|
654
|
+ for (MsrReportparam param : params) {
|
|
655
|
+ SzJsonVo vo = JSON.parseObject(param.getSzjson(), SzJsonVo.class);
|
|
656
|
+ List<RankGroupVo> groups = MarkingUtil.fdScore(N_Utils.obj2Int(vo.getMaxvalue()), N_Utils.obj2Int(vo.getMinvalue()), N_Utils.obj2Int(vo.getDjvalue()), type);
|
|
657
|
+ fdMap.put(param.getSubjectid(), groups);
|
|
658
|
+ }
|
|
659
|
+ } else {//不定步长
|
|
660
|
+ for (MsrReportparam param : params) {
|
|
661
|
+ List<SzJsonVo> vos = JSON.parseArray(param.getSzjson(), SzJsonVo.class);
|
|
662
|
+ List<RankGroupVo> groups = MarkingUtil.fdScore(vos, type);
|
|
663
|
+ fdMap.put(param.getSubjectid(), groups);
|
|
664
|
+ }
|
|
665
|
+ }
|
|
666
|
+
|
|
667
|
+ List<MsrClassSection> classSections = new ArrayList<>();
|
|
668
|
+ Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
|
|
669
|
+ for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
|
|
670
|
+ MarkingUtil.studentsDistinct(entry, null);
|
|
671
|
+ }
|
|
672
|
+ setClassSection(examid, type, reportcode, collect, fdMap, classSections);
|
|
673
|
+ Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
|
|
674
|
+ setClassSection(examid, type, reportcode, scCollect, fdMap, classSections);
|
|
675
|
+ msrClassSectionMapper.insertList(classSections);
|
|
676
|
+ }
|
|
677
|
+
|
|
678
|
+ //分段统计-计算
|
|
679
|
+ private void setClassSection(Integer examid, Integer type, String reportcode, Map<String, List<MsrStudent>> scCollect
|
|
680
|
+ , Map<String, List<RankGroupVo>> fdMap, List<MsrClassSection> classSections) {
|
|
681
|
+ String subjectid;
|
|
682
|
+ for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
|
|
683
|
+ String key = entry.getKey();
|
|
684
|
+ Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
|
685
|
+ subjectid = key.split("_")[1];
|
|
686
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
687
|
+ Integer stunum = studentList.size();
|
|
688
|
+ List<RankGroupVo> groups = fdMap.get(subjectid);
|
|
689
|
+ for (int i = 0; i < groups.size(); i++) {
|
|
690
|
+ RankGroupVo group = groups.get(i);
|
|
691
|
+ int maxvalue = group.getMaxvalue();
|
|
692
|
+ int minvalue = group.getMinvalue();
|
|
693
|
+ List<MsrStudent> qjstudents;
|
|
694
|
+ if (type.equals(1)) {
|
|
695
|
+ if (i == 0) {
|
|
696
|
+ qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), minvalue) >= 0 && MarkingUtil.sub(s.getStuscore(), maxvalue) <= 0).collect(Collectors.toList());
|
|
697
|
+ } else {
|
|
698
|
+ qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), minvalue) >= 0 && MarkingUtil.sub(s.getStuscore(), maxvalue) < 0).collect(Collectors.toList());
|
|
699
|
+ }
|
|
700
|
+ } else {
|
|
701
|
+ qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), maxvalue) >= 0).collect(Collectors.toList());
|
|
702
|
+ }
|
|
703
|
+ MsrClassSection classSection = new MsrClassSection();
|
|
704
|
+ classSection.setExamid(examid);
|
|
705
|
+ classSection.setClassid(classid);
|
|
706
|
+ classSection.setSubjectid(subjectid);
|
|
707
|
+ classSection.setStunum(stunum);
|
|
708
|
+ classSection.setType(type);
|
|
709
|
+ classSection.setReportcode(reportcode);
|
|
710
|
+ classSection.setFzfw(group.getGroupname());
|
|
711
|
+ int qjnum = qjstudents.size();
|
|
712
|
+ classSection.setFzfwnum(qjnum);
|
|
713
|
+ classSection.setFzfwrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, stunum));
|
|
714
|
+ String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
|
715
|
+ classSection.setStuids(stuids);
|
|
716
|
+ classSections.add(classSection);
|
|
717
|
+ }
|
|
718
|
+ }
|
|
719
|
+ }
|
|
720
|
+
|
|
721
|
+ //分档上线分析
|
|
722
|
+ public void saveClassNearLine(Integer examid, List<MsrStudent> msrStudents) {
|
|
723
|
+ List<MsrReportparam> params = msrReportparamService.getMsrReportParams(examid, "gradescore", "all");
|
|
724
|
+ Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
|
|
725
|
+ Map<String, Integer> tMap = new HashMap<>();
|
|
726
|
+ for (MsrReportparam param : params) {
|
|
727
|
+ String subjectid = param.getSubjectid();
|
|
728
|
+ qjMap.put(subjectid, JSON.parseArray(param.getSzjson(), SzJsonVo.class));
|
|
729
|
+ tMap.put(subjectid, param.getRptype());
|
|
730
|
+ }
|
|
731
|
+ params = msrReportparamService.getMsrReportParams(examid, "nearline", "all");
|
|
732
|
+ List<SzJsonVo> vos = JSON.parseArray(params.get(0).getSzjson(), SzJsonVo.class);
|
|
733
|
+ Map<Integer, List<Integer>> zfSx = null;//学生总分是否上线
|
|
734
|
+ List<MsrClassNearline> classNearlines = new ArrayList<>();
|
|
735
|
+ Map<String, List<MsrStudent>> collect0 = MarkingUtil.getSubjectCollect(msrStudents);
|
|
736
|
+ Map<String, Integer> rsMap = new HashMap<>();//学科人数map
|
|
737
|
+ for (Map.Entry<String, List<MsrStudent>> entry : collect0.entrySet()) {
|
|
738
|
+ MarkingUtil.studentsDistinct(entry, rsMap);
|
|
739
|
+ if (entry.getKey().endsWith("zf")) {
|
|
740
|
+ zfSx = setZfsxMap(entry.getValue(), qjMap, tMap);
|
|
741
|
+ }
|
|
742
|
+ setClassNearLine(examid, entry, qjMap, tMap, vos, zfSx, classNearlines, rsMap);
|
|
743
|
+ }
|
|
744
|
+ Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
|
|
745
|
+ for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
|
|
746
|
+ setClassNearLine(examid, entry, qjMap, tMap, vos, zfSx, classNearlines, rsMap);
|
|
747
|
+ }
|
|
748
|
+ Map<String, List<MsrClassNearline>> collect = classNearlines.stream().collect(Collectors.groupingBy(l -> l.getSubjectid() + "_" + l.getDworder()));
|
|
749
|
+ for (Map.Entry<String, List<MsrClassNearline>> entry : collect.entrySet()) {
|
|
750
|
+ List<MsrClassNearline> nearlineList = entry.getValue();
|
|
751
|
+ List<Integer> nums = new ArrayList<>();
|
|
752
|
+ for (MsrClassNearline nearline : nearlineList) {
|
|
753
|
+ nums.add(nearline.getSxnum());
|
|
754
|
+ }
|
|
755
|
+ Map<Integer, Integer> rspm = MarkingUtil.rspm(nums);//人数排名
|
|
756
|
+ for (MsrClassNearline nearline : nearlineList) {
|
|
757
|
+ nearline.setSxrank(rspm.get(nearline.getSxnum()));
|
|
758
|
+ }
|
|
759
|
+ }
|
|
760
|
+ msrClassNearlineMapper.insertList(classNearlines);
|
|
761
|
+ }
|
|
762
|
+
|
|
763
|
+ //分档上线计算
|
|
764
|
+ private void setClassNearLine(Integer examid, Map.Entry<String, List<MsrStudent>> entry, Map<String, List<SzJsonVo>> qjMap
|
|
765
|
+ , Map<String, Integer> tMap, List<SzJsonVo> vos, Map<Integer, List<Integer>> zfSx
|
|
766
|
+ , List<MsrClassNearline> classNearlines, Map<String, Integer> rsMap) {
|
|
767
|
+ String key = entry.getKey();
|
|
768
|
+ Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
|
769
|
+ String subjectid = key.split("_")[1];
|
|
770
|
+ int totalnum = rsMap.get(subjectid);
|
|
771
|
+ List<SzJsonVo> list = qjMap.get(subjectid);
|
|
772
|
+ Integer rptype = tMap.get(subjectid);
|
|
773
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
774
|
+ if (rptype.equals(3)) {
|
|
775
|
+ studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
|
|
776
|
+ }
|
|
777
|
+ Double max = null;
|
|
778
|
+ Integer minRank = null;
|
|
779
|
+ int minIndex = 0;
|
|
780
|
+ for (int i = 0; i < list.size(); i++) {
|
|
781
|
+ SzJsonVo fd = vos.get(i);
|
|
782
|
+ Double fdMaxScore = fd.getMaxvalue();//档位浮动分数
|
|
783
|
+ if (fdMaxScore == null) fdMaxScore = MarkingUtil.objToDouble(fd.getDjvalue());
|
|
784
|
+ Double fdMinScore = fd.getMinvalue();//档位浮动分数
|
|
785
|
+ if (fdMinScore == null) {
|
|
786
|
+ fdMinScore = fdMaxScore;
|
|
787
|
+ }
|
|
788
|
+ SzJsonVo rg = list.get(i);
|
|
789
|
+ Object djvalue = rg.getDjvalue();
|
|
790
|
+ double dwscore;
|
|
791
|
+ List<MsrStudent> qjstudents;//上线学生列表
|
|
792
|
+ List<MsrStudent> ljstudents;//累计上线学生列表
|
|
793
|
+ if (rptype.equals(1)) {//按名次
|
|
794
|
+ Integer rank = N_Utils.obj2Int(djvalue);
|
|
795
|
+ ljstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
|
|
796
|
+ if (minRank == null) {
|
|
797
|
+ qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
|
|
798
|
+ } else {
|
|
799
|
+ Integer finalMinRank = minRank;
|
|
800
|
+ qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(finalMinRank) >= 0 && s.getSchoolrank().compareTo(rank) < 0).collect(Collectors.toList());
|
|
801
|
+ }
|
|
802
|
+ minRank = rank;
|
|
803
|
+ dwscore = N_Utils.handleInfinity(qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getMin());
|
|
804
|
+ } else if (rptype.equals(2)) {//按分数
|
|
805
|
+ Double score = MarkingUtil.objToDouble(djvalue);
|
|
806
|
+ ljstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
|
|
807
|
+ if (max == null) {
|
|
808
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
|
|
809
|
+ } else {
|
|
810
|
+ Double finalMax = max;
|
|
811
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0 && s.getStuscore().compareTo(finalMax) < 0).collect(Collectors.toList());
|
|
812
|
+ }
|
|
813
|
+ dwscore = MarkingUtil.objToDouble(djvalue);
|
|
814
|
+ max = score;
|
|
815
|
+ minRank = qjstudents.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMin();
|
|
816
|
+ } else {//按比例
|
|
817
|
+ int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, djvalue));
|
|
818
|
+ if (index > totalnum) index = totalnum;
|
|
819
|
+ qjstudents = studentList.subList(minIndex, index);
|
|
820
|
+ minIndex = index;
|
|
821
|
+ DoubleSummaryStatistics statistics = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics();
|
|
822
|
+ dwscore = N_Utils.handleInfinity(statistics.getMin());
|
|
823
|
+ ljstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(dwscore) >= 0).collect(Collectors.toList());
|
|
824
|
+ }
|
|
825
|
+ int qjnum = qjstudents.size();
|
|
826
|
+ MsrClassNearline nearline = new MsrClassNearline();
|
|
827
|
+ nearline.setExamid(examid);
|
|
828
|
+ nearline.setSubjectid(subjectid);
|
|
829
|
+ nearline.setClassid(classid);
|
|
830
|
+ Integer dworder = i + 1;
|
|
831
|
+ String dwname = N_Utils.NumberToChn(dworder) + "档";
|
|
832
|
+ nearline.setDwname(dwname);
|
|
833
|
+ nearline.setDworder(dworder);
|
|
834
|
+ nearline.setDwscore(dwscore);
|
|
835
|
+ nearline.setSxnum(qjnum);
|
|
836
|
+ nearline.setSxrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
|
|
837
|
+ int ljsxnum = ljstudents.size();
|
|
838
|
+ nearline.setLjsxnum(ljsxnum);
|
|
839
|
+ nearline.setLjsxrate(N_Utils.getIntegerDivideAndMulitiply(ljsxnum, totalnum));
|
|
840
|
+ if (!"zf".equals(subjectid)) {
|
|
841
|
+ List<Integer> zfsxIds = zfSx.get(dworder);//总分上线学生id列表
|
|
842
|
+ int zfsxnum = zfsxIds.size();
|
|
843
|
+ List<MsrStudent> ssxIds = qjstudents.stream().filter(s -> zfsxIds.contains(s.getStudentid())).collect(Collectors.toList());
|
|
844
|
+ Integer ssxnum = ssxIds.size();//双上线人数
|
|
845
|
+ nearline.setSsxnum(ssxnum);
|
|
846
|
+ nearline.setStuids2(ssxIds.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
|
|
847
|
+ //总分上线学科未上线人数
|
|
848
|
+ List<Integer> dksxIds = qjstudents.stream().map(MsrStudent::getStudentid).collect(Collectors.toList());
|
|
849
|
+ List<Integer> zfsxxkwsxIds = new ArrayList<>(zfsxIds);
|
|
850
|
+ zfsxxkwsxIds.removeAll(dksxIds);
|
|
851
|
+ int zfsxxkwsxnum = zfsxxkwsxIds.size();
|
|
852
|
+ nearline.setZfsxxkwsxnum(zfsxxkwsxnum);
|
|
853
|
+ nearline.setStuids5(zfsxxkwsxIds.stream().map(Object::toString).collect(Collectors.joining(",")));
|
|
854
|
+ nearline.setGxrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, zfsxnum));
|
|
855
|
+ nearline.setMzxrate(N_Utils.getIntegerDivideAndMulitiply(ssxnum, qjnum));
|
|
856
|
+ }
|
|
857
|
+ nearline.setSxrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
|
|
858
|
+ double ljMax = MarkingUtil.add(dwscore, fdMaxScore);
|
|
859
|
+ double ljMin = MarkingUtil.sub(dwscore, fdMinScore);
|
|
860
|
+ List<MsrStudent> ljStudents = studentList.stream().filter(s -> s.getStuscore().compareTo(ljMax) <= 0 && s.getStuscore().compareTo(ljMin) >= 0).collect(Collectors.toList());
|
|
861
|
+ nearline.setLjsnum(ljStudents.size());
|
|
862
|
+ nearline.setLjsavgscore(N_Utils.formatDouble(ljStudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2));
|
|
863
|
+ nearline.setStuids3(ljStudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
|
|
864
|
+ nearline.setStuids4(ljstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
|
|
865
|
+ String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
|
866
|
+ nearline.setStuids(stuids);
|
|
867
|
+ classNearlines.add(nearline);
|
|
868
|
+ }
|
|
869
|
+ }
|
|
870
|
+
|
|
871
|
+ //总分上线分析
|
|
872
|
+ private Map<Integer, List<Integer>> setZfsxMap(List<MsrStudent> studentList, Map<String, List<SzJsonVo>> qjMap
|
|
873
|
+ , Map<String, Integer> tMap) {
|
|
874
|
+ Map<Integer, List<Integer>> zfSx = new HashMap<>();
|
|
875
|
+ String subjectid = "zf";
|
|
876
|
+ int totalnum;
|
|
877
|
+ List<SzJsonVo> list = qjMap.get(subjectid);
|
|
878
|
+ Integer rptype = tMap.get(subjectid);
|
|
879
|
+ if (rptype.equals(3)) {
|
|
880
|
+ studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
|
|
881
|
+ }
|
|
882
|
+ totalnum = studentList.size();//总人数
|
|
883
|
+ Double max = null;
|
|
884
|
+ Integer minRank = null;
|
|
885
|
+ int minIndex = 0;
|
|
886
|
+ for (int i = 0; i < list.size(); i++) {
|
|
887
|
+ SzJsonVo rg = list.get(i);
|
|
888
|
+ Object djvalue = rg.getDjvalue();
|
|
889
|
+ List<MsrStudent> qjstudents;//上线学生列表
|
|
890
|
+ if (rptype.equals(1)) {//按名次
|
|
891
|
+ Integer rank = N_Utils.obj2Int(djvalue);
|
|
892
|
+ if (minRank == null) {
|
|
893
|
+ qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) <= 0).collect(Collectors.toList());
|
|
894
|
+ } else {
|
|
895
|
+ Integer finalMinRank = minRank;
|
|
896
|
+ qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(finalMinRank) >= 0 && s.getSchoolrank().compareTo(rank) < 0).collect(Collectors.toList());
|
|
897
|
+ }
|
|
898
|
+ minRank = rank;
|
|
899
|
+ } else if (rptype.equals(2)) {//按分数
|
|
900
|
+ Double score = MarkingUtil.objToDouble(djvalue);
|
|
901
|
+ if (max == null) {
|
|
902
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
|
|
903
|
+ } else {
|
|
904
|
+ Double finalMax = max;
|
|
905
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0 && s.getStuscore().compareTo(finalMax) < 0).collect(Collectors.toList());
|
|
906
|
+ }
|
|
907
|
+ max = score;
|
|
908
|
+ minRank = qjstudents.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMin();
|
|
909
|
+ } else {//按比例
|
|
910
|
+ int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, djvalue));
|
|
911
|
+ if (index > totalnum) index = totalnum;
|
|
912
|
+ qjstudents = studentList.subList(minIndex, index);
|
|
913
|
+ minIndex = index;
|
|
914
|
+ }
|
|
915
|
+
|
|
916
|
+ Integer dworder = i + 1;
|
|
917
|
+ List<Integer> ids = qjstudents.stream().map(MsrStudent::getStudentid).collect(Collectors.toList());
|
|
918
|
+ zfSx.put(dworder, ids);
|
|
919
|
+ }
|
|
920
|
+ return zfSx;
|
|
921
|
+ }
|
|
922
|
+
|
|
923
|
+ //重点学生-优劣名次统计
|
|
924
|
+ public void saveClassGoodBad(Integer examid, String all, List<MsrStudent> msrStudents) {
|
|
925
|
+ List<MsrReportparam> params = msrReportparamService.getMsrReportParams(examid, "keystu", all);
|
|
926
|
+ SzJsonVo fd = JSON.parseObject(params.get(0).getSzjson(), SzJsonVo.class);
|
|
927
|
+ List<MsrClassGoodbad> classGoodbads = new ArrayList<>();
|
|
928
|
+ Map<String, List<MsrStudent>> collect = MarkingUtil.getSubjectCollect(msrStudents);
|
|
929
|
+ Map<String, Integer> rsMap = new HashMap<>();//学科人数map
|
|
930
|
+ for (Map.Entry<String, List<MsrStudent>> entry : collect.entrySet()) {
|
|
931
|
+ MarkingUtil.studentsDistinct(entry, rsMap);
|
|
932
|
+ setClassGoodBag(examid, entry, fd, classGoodbads, rsMap);
|
|
933
|
+ }
|
|
934
|
+ Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
|
|
935
|
+ for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
|
|
936
|
+ setClassGoodBag(examid, entry, fd, classGoodbads, rsMap);
|
|
937
|
+ }
|
|
938
|
+ msrClassGoodbadMapper.insertList(classGoodbads);
|
|
939
|
+ }
|
|
940
|
+
|
|
941
|
+ //重点学生-优劣名次计算
|
|
942
|
+ private void setClassGoodBag(Integer examid, Map.Entry<String, List<MsrStudent>> entry, SzJsonVo fd
|
|
943
|
+ , List<MsrClassGoodbad> classGoodbads, Map<String, Integer> rsMap) {
|
|
944
|
+ String key = entry.getKey();
|
|
945
|
+ Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
|
946
|
+ String subjectid = key.split("_")[1];
|
|
947
|
+ int totalnum;
|
|
948
|
+ Integer goodtype = fd.getGoodtype();
|
|
949
|
+ Integer badtype = fd.getBadtype();
|
|
950
|
+ List<MsrStudent> studentList = entry.getValue().stream().sorted(Comparator.comparing(MsrStudent::getSchoolrank)).collect(Collectors.toList());
|
|
951
|
+ Double avgScore = N_Utils.formatDouble(studentList.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2);
|
|
952
|
+ totalnum = rsMap.get(subjectid);//科目总人数
|
|
953
|
+ Integer goodvalue = fd.getGoodvalue();
|
|
954
|
+ Integer badvalue = fd.getBadvalue();
|
|
955
|
+ List<MsrStudent> yxStudents;//优秀学生列表
|
|
956
|
+ List<MsrStudent> dtgStudents;//待提高学生列表
|
|
957
|
+ List<MsrStudent> dbStudents;//学科短板学生列表
|
|
958
|
+ if (goodtype.equals(1)) {//按名次
|
|
959
|
+ yxStudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(goodvalue) <= 0).collect(Collectors.toList());
|
|
960
|
+ } else {//按比例
|
|
961
|
+ int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, goodvalue));
|
|
962
|
+ if (index > totalnum) index = totalnum;
|
|
963
|
+ yxStudents = studentList.subList(0, index);
|
|
964
|
+ }
|
|
965
|
+ if (badtype.equals(1)) {//按名次
|
|
966
|
+ dtgStudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(badvalue) <= 0).collect(Collectors.toList());
|
|
967
|
+ } else {//按比例
|
|
968
|
+ int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, badvalue));
|
|
969
|
+ if (index > totalnum) index = totalnum;
|
|
970
|
+ //取后index个
|
|
971
|
+ dtgStudents = studentList.subList(totalnum - index, totalnum);
|
|
972
|
+ }
|
|
973
|
+ dbStudents = studentList.stream().filter(s -> s.getStuscore().compareTo(avgScore) <= 0).collect(Collectors.toList());
|
|
974
|
+ int yxnum = yxStudents.size();
|
|
975
|
+ MsrClassGoodbad goodbad = new MsrClassGoodbad();
|
|
976
|
+ goodbad.setExamid(examid);
|
|
977
|
+ goodbad.setSubjectid(subjectid);
|
|
978
|
+ goodbad.setClassid(classid);
|
|
979
|
+ goodbad.setYxnum(yxnum);
|
|
980
|
+ goodbad.setYxrate(N_Utils.getIntegerDivideAndMulitiply(yxnum, totalnum));
|
|
981
|
+ goodbad.setYxavgscore(N_Utils.formatDouble(yxStudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2));
|
|
982
|
+ int dtgnum = dtgStudents.size();
|
|
983
|
+ goodbad.setDtgnum(dtgnum);
|
|
984
|
+ goodbad.setDtgrate(N_Utils.getIntegerDivideAndMulitiply(dtgnum, totalnum));
|
|
985
|
+ goodbad.setDtgavgscore(N_Utils.formatDouble(dtgStudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage(), 2));
|
|
986
|
+ goodbad.setDbnum(dbStudents.size());
|
|
987
|
+ goodbad.setStuids(yxStudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
|
|
988
|
+ goodbad.setStuids2(dtgStudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
|
|
989
|
+ goodbad.setStuids3(dbStudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(",")));
|
|
990
|
+ classGoodbads.add(goodbad);
|
|
991
|
+ }
|
|
992
|
+
|
|
993
|
+}
|