|
@@ -1,12 +1,27 @@
|
1
|
1
|
package com.xhkjedu.sexam.service.report;
|
2
|
2
|
|
3
|
|
-import com.xhkjedu.sexam.mapper.exam.EBaseMapper;
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
4
|
4
|
import com.xhkjedu.sexam.mapper.exam.EClassMapper;
|
5
|
|
-import com.xhkjedu.sexam.mapper.exam.ESubjectMapper;
|
6
|
5
|
import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentMapper;
|
7
|
6
|
import com.xhkjedu.sexam.mapper.report.ERbaseMapper;
|
|
7
|
+import com.xhkjedu.sexam.mapper.report.EReportGenerateMapper;
|
|
8
|
+import com.xhkjedu.sexam.mapper.report.ERsubjectMapper;
|
|
9
|
+import com.xhkjedu.sexam.mapper.reportclass.ERclassMapper;
|
|
10
|
+import com.xhkjedu.sexam.mapper.reportclass.ERclassQtypeMapper;
|
|
11
|
+import com.xhkjedu.sexam.mapper.reportclass.ERclassQuestionErrorMapper;
|
|
12
|
+import com.xhkjedu.sexam.mapper.reportclass.ERclassQuestionMapper;
|
|
13
|
+import com.xhkjedu.sexam.mapper.reportclass.ERclassQuestionPointMapper;
|
8
|
14
|
import com.xhkjedu.sexam.mapper.reportstu.ERstudentMapper;
|
|
15
|
+import com.xhkjedu.sexam.model.report.ERbase;
|
|
16
|
+import com.xhkjedu.sexam.model.report.ERsubject;
|
|
17
|
+import com.xhkjedu.sexam.model.reportclass.ERclass;
|
|
18
|
+import com.xhkjedu.sexam.model.reportclass.ERclassQtype;
|
|
19
|
+import com.xhkjedu.sexam.model.reportclass.ERclassQuestion;
|
|
20
|
+import com.xhkjedu.sexam.model.reportclass.ERclassQuestionError;
|
|
21
|
+import com.xhkjedu.sexam.model.reportclass.ERclassQuestionPoint;
|
9
|
22
|
import com.xhkjedu.sexam.model.reportstu.ERstudent;
|
|
23
|
+import com.xhkjedu.sexam.vo.paper.EPaperQsVo;
|
|
24
|
+import com.xhkjedu.sexam.vo.report.ERPaperVo;
|
10
|
25
|
import org.springframework.stereotype.Service;
|
11
|
26
|
|
12
|
27
|
import javax.annotation.Resource;
|
|
@@ -26,45 +41,52 @@ import java.util.stream.Collectors;
|
26
|
41
|
@Service
|
27
|
42
|
public class EReportGenerateService {
|
28
|
43
|
@Resource
|
29
|
|
- private EBaseMapper eBaseMapper;
|
|
44
|
+ private EReportGenerateMapper eReportGenerateMapper;
|
30
|
45
|
@Resource
|
31
|
46
|
private EClassMapper eClassMapper;
|
32
|
47
|
@Resource
|
33
|
|
- private ESubjectMapper eSubjectMapper;
|
34
|
|
- @Resource
|
35
|
48
|
private EPaperStudentMapper ePaperStudentMapper;
|
36
|
49
|
|
37
|
50
|
@Resource
|
38
|
51
|
private ERbaseMapper eRbaseMapper;
|
39
|
52
|
@Resource
|
40
|
53
|
private ERstudentMapper eRstudentMapper;
|
|
54
|
+ @Resource
|
|
55
|
+ private ERsubjectMapper eRsubjectMapper;
|
|
56
|
+ @Resource
|
|
57
|
+ private ERclassMapper eRclassMapper;
|
|
58
|
+ @Resource
|
|
59
|
+ private ERclassQtypeMapper eRclassQtypeMapper;
|
|
60
|
+ @Resource
|
|
61
|
+ private ERclassQuestionMapper eRclassQuestionMapper;
|
|
62
|
+ @Resource
|
|
63
|
+ private ERclassQuestionPointMapper eRclassQuestionPointMapper;
|
|
64
|
+ @Resource
|
|
65
|
+ private ERclassQuestionErrorMapper eRclassQuestionErrorMapper;
|
41
|
66
|
|
42
|
67
|
//生成考试报告
|
43
|
68
|
public void generateExamReport(Integer examid) {
|
44
|
69
|
List<Map> classes = eClassMapper.listByExamId(examid);
|
45
|
|
- List<Map> subjects = eSubjectMapper.listSubject(examid);
|
|
70
|
+ List<Map> subjects = eReportGenerateMapper.listSubject(examid);
|
|
71
|
+ List<ERPaperVo> papers = eReportGenerateMapper.listPaper(examid);
|
46
|
72
|
int classnum = classes.size();
|
47
|
73
|
int stunum = classes.stream().mapToInt(m -> (int) m.get("classnum")).sum();
|
48
|
74
|
int subjectnum = subjects.size();
|
49
|
|
- /*ERbase rbase = new ERbase();
|
50
|
|
- rbase.setExamid(examid);
|
51
|
|
- rbase.setClassnum(classnum);
|
52
|
|
- rbase.setStunum(stunum);
|
53
|
|
- rbase.setSubjectnum(subjectnum);
|
54
|
|
- eRbaseMapper.insertSelective(rbase);*/
|
55
|
75
|
|
56
|
76
|
String subjectid = "zf";
|
57
|
77
|
String subjectname = "总分";
|
58
|
78
|
Map<String, String> subjectMap = subjects.stream().collect(Collectors.toMap(m -> m.get("subjectid").toString(),
|
59
|
79
|
m -> m.get("subjectname").toString()));
|
|
80
|
+ Map<String, ERPaperVo> paperMap = papers.stream().collect(Collectors.toMap(m -> m.getSubjectid(), m -> m));
|
60
|
81
|
|
61
|
82
|
List<ERstudent> schoolStudents = new ArrayList<>();//学校学生成绩
|
|
83
|
+ List<ERstudent> schoolSubjectStudents = new ArrayList<>();//学校科目学生成绩
|
62
|
84
|
List<ERstudent> classStudents = new ArrayList<>();//班级学生成绩
|
63
|
|
- List<ERstudent> subjectStudents = new ArrayList<>();//科目学生成绩、
|
|
85
|
+ List<ERstudent> classSubjectStudents = new ArrayList<>();//班级科目学生成绩
|
64
|
86
|
Map<String, Integer> schoolRank = new HashMap<>();//学校分数排名
|
|
87
|
+ Map<String, Integer> schoolSubjectRank = new HashMap<>();//学校科目分数排名
|
65
|
88
|
Map<String, Integer> classRank = new HashMap<>();//班级分数排名
|
66
|
|
- Map<String, Integer> ssubjectRank = new HashMap<>();//学校科目分数排名
|
67
|
|
- Map<String, Integer> csubjectRank = new HashMap<>();//班级科目分数排名
|
|
89
|
+ Map<String, Integer> classSubjectRank = new HashMap<>();//班级科目分数排名
|
68
|
90
|
|
69
|
91
|
List<ERstudent> students = ePaperStudentMapper.listByExamId(examid);
|
70
|
92
|
Map<Integer, List<ERstudent>> schoolCollect = students.stream().collect(Collectors.groupingBy(s -> s.getStudentid()));
|
|
@@ -75,8 +97,6 @@ public class EReportGenerateService {
|
75
|
97
|
cs.setScore(entry.getValue().stream().mapToDouble(s -> s.getScore()).sum());
|
76
|
98
|
schoolStudents.add(cs);
|
77
|
99
|
}
|
78
|
|
- setRank(schoolStudents, schoolRank, 1);//学校分数排名
|
79
|
|
-
|
80
|
100
|
Map<Integer, List<ERstudent>> cCollect = students.stream().collect(Collectors.groupingBy(s -> s.getClassid()));
|
81
|
101
|
for (Map.Entry<Integer, List<ERstudent>> entry : cCollect.entrySet()) {
|
82
|
102
|
Integer classid = entry.getKey();
|
|
@@ -91,8 +111,6 @@ public class EReportGenerateService {
|
91
|
111
|
cs.setScore(csEntry.getValue().stream().mapToDouble(s -> s.getScore()).sum());
|
92
|
112
|
classStudents.add(cs);
|
93
|
113
|
}
|
94
|
|
- setRank(classStudents, classRank, 2);//班级分数排名
|
95
|
|
-
|
96
|
114
|
Map<String, List<ERstudent>> subCollect = studentList.stream().collect(Collectors.groupingBy(s -> s.getSubjectid()));
|
97
|
115
|
for (Map.Entry<String, List<ERstudent>> ssEntry : subCollect.entrySet()) {
|
98
|
116
|
subjectid = ssEntry.getKey();
|
|
@@ -100,35 +118,146 @@ public class EReportGenerateService {
|
100
|
118
|
studentList = ssEntry.getValue();
|
101
|
119
|
for (ERstudent cs : studentList) {
|
102
|
120
|
cs.setSubjectname(subjectname);
|
103
|
|
- subjectStudents.add(cs);
|
|
121
|
+ classSubjectStudents.add(cs);
|
104
|
122
|
}
|
105
|
123
|
}
|
106
|
|
- setRank(subjectStudents, ssubjectRank, 3);//科目分数排名
|
107
|
124
|
}
|
108
|
125
|
|
109
|
126
|
DoubleSummaryStatistics schoolStatistics = schoolStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
|
|
127
|
+ DoubleSummaryStatistics sSStatistics = schoolSubjectStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
|
110
|
128
|
DoubleSummaryStatistics classStatistics = classStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
|
|
129
|
+ DoubleSummaryStatistics cSStatistics = classSubjectStudents.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
|
|
130
|
+ double schoolStatisticsMax = schoolStatistics.getMax();
|
|
131
|
+ double schoolStatisticsAverage = schoolStatistics.getAverage();
|
|
132
|
+ double schoolStatisticsMin = schoolStatistics.getMin();
|
|
133
|
+
|
|
134
|
+ ERbase rbase = new ERbase();
|
|
135
|
+ rbase.setExamid(examid);
|
|
136
|
+ rbase.setClassnum(classnum);
|
|
137
|
+ rbase.setStunum(stunum);
|
|
138
|
+ rbase.setMissnum(students.stream().filter(l -> l.getSstate() == 3)
|
|
139
|
+ .map(l -> l.getStudentid()).distinct().collect(Collectors.toList()).size());
|
|
140
|
+ rbase.setSubjectnum(subjectnum);
|
|
141
|
+ rbase.setMaxscore(schoolStatisticsMax);
|
|
142
|
+ rbase.setAvgscore(schoolStatisticsAverage);
|
|
143
|
+ rbase.setMixscore(schoolStatisticsMin);
|
|
144
|
+ eRbaseMapper.insertSelective(rbase);
|
|
145
|
+
|
|
146
|
+ Map<String, List<ERstudent>> subCollect = students.stream().collect(Collectors.groupingBy(s -> s.getSubjectid()));
|
|
147
|
+ List<ERsubject> subjectList = new ArrayList<>();//考试报告科目情况
|
|
148
|
+ List<ERclass> classList = new ArrayList<>();//考试报告班级情况
|
|
149
|
+ List<ERclassQtype> qtypeList = new ArrayList<>();//考试报告班级题型情况
|
|
150
|
+ List<ERclassQuestion> questionList = new ArrayList<>();//考试报告班级试题情况
|
|
151
|
+ List<ERclassQuestionError> errorList = new ArrayList<>();//考试报告班级高频错题情况
|
|
152
|
+ List<ERclassQuestionPoint> pointList = new ArrayList<>();//考试报告班级试题知识点情况
|
|
153
|
+ for (Map.Entry<String, List<ERstudent>> ssEntry : subCollect.entrySet()) {
|
|
154
|
+ subjectid = ssEntry.getKey();
|
|
155
|
+ subjectname = subjectMap.get(subjectid);
|
|
156
|
+ List<ERstudent> list = ssEntry.getValue();
|
|
157
|
+ Map<Integer, List<ERstudent>> sCollect = list.stream().collect(Collectors.groupingBy(s -> s.getStudentid()));
|
|
158
|
+ for (Map.Entry<Integer, List<ERstudent>> csEntry : sCollect.entrySet()) {
|
|
159
|
+ ERstudent cs = new ERstudent();
|
|
160
|
+ cs.setClassid(0);
|
|
161
|
+ cs.setStudentid(csEntry.getKey());
|
|
162
|
+ cs.setSubjectid(subjectid);
|
|
163
|
+ cs.setSubjectname(subjectname);
|
|
164
|
+ cs.setScore(csEntry.getValue().stream().mapToDouble(s -> s.getScore()).sum());
|
|
165
|
+ schoolSubjectStudents.add(cs);
|
|
166
|
+ }
|
|
167
|
+ ERPaperVo rp = paperMap.get(subjectid);
|
|
168
|
+ Double allscore = rp.getPscore();//满分
|
|
169
|
+ double yxscore = allscore * 0.85;//优秀分
|
|
170
|
+ double lhscore = allscore * 0.7;//良好分
|
|
171
|
+ double jgscore = allscore * 0.6;//及格分
|
|
172
|
+ double dfscore = allscore * 0.4;//低分
|
|
173
|
+
|
|
174
|
+ DoubleSummaryStatistics statistics = list.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
|
|
175
|
+ ERsubject rs = new ERsubject();
|
|
176
|
+ rs.setExamid(examid);
|
|
177
|
+ rs.setSubjectid(subjectid);
|
|
178
|
+ rs.setSubjectname(subjectname);
|
|
179
|
+ rs.setScore(allscore);
|
|
180
|
+ rs.setMaxscore(statistics.getMax());
|
|
181
|
+ rs.setMinscore(statistics.getMin());
|
|
182
|
+ 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());
|
|
185
|
+ subjectList.add(rs);
|
|
186
|
+
|
|
187
|
+ Map<Integer, List<ERstudent>> claCollect = list.stream().collect(Collectors.groupingBy(s -> s.getClassid()));
|
|
188
|
+ for (Map.Entry<Integer, List<ERstudent>> entry : claCollect.entrySet()) {
|
|
189
|
+ Integer classid = entry.getKey();
|
|
190
|
+ List<ERstudent> rstudentList = entry.getValue();
|
|
191
|
+ statistics = rstudentList.stream().mapToDouble(s -> s.getScore()).summaryStatistics();
|
|
192
|
+ ERclass rc = new ERclass();
|
|
193
|
+ rc.setExamid(examid);
|
|
194
|
+ rc.setClassid(classid);
|
|
195
|
+ rc.setSubjectid(subjectid);
|
|
196
|
+ rc.setSubjectname(subjectname);
|
|
197
|
+ 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());
|
|
203
|
+ classList.add(rc);
|
|
204
|
+ List<EPaperQsVo> typelist = JSON.parseArray(rp.getQnumjson(), EPaperQsVo.class);
|
|
205
|
+ for (EPaperQsVo t : typelist) {
|
|
206
|
+ ERclassQtype rt = new ERclassQtype();
|
|
207
|
+ rt.setExamid(examid);
|
|
208
|
+ rt.setClassid(classid);
|
|
209
|
+ rt.setSubjectid(subjectid);
|
|
210
|
+ rt.setQtypename(t.getQtname());
|
|
211
|
+ rt.setScore(t.getScore());
|
|
212
|
+ rt.setNum(t.getNum());
|
|
213
|
+ rt.setSrate(t.getSrate());
|
|
214
|
+ qtypeList.add(rt);
|
|
215
|
+ }
|
|
216
|
+
|
|
217
|
+ List<Map> points = JSON.parseArray(rp.getQnumjson(), Map.class);
|
|
218
|
+ for (Map p : points) {
|
|
219
|
+ ERclassQuestionPoint rqp = new ERclassQuestionPoint();
|
|
220
|
+ rqp.setExamid(examid);
|
|
221
|
+ rqp.setClassid(classid);
|
|
222
|
+ rqp.setSubjectid(subjectid);
|
|
223
|
+ rqp.setPointname(p.get("pointname").toString());
|
|
224
|
+ rqp.setScore((Double) p.get("score"));
|
|
225
|
+ rqp.setSrate((Double) p.get("srate"));
|
|
226
|
+ pointList.add(rqp);
|
|
227
|
+ }
|
|
228
|
+ }
|
|
229
|
+ }
|
|
230
|
+
|
|
231
|
+ eRclassMapper.insertList(classList);
|
|
232
|
+ eRsubjectMapper.insertList(subjectList);
|
|
233
|
+
|
|
234
|
+ setRank(schoolStudents, schoolRank, 1);//学校分数排名
|
|
235
|
+ setRank(schoolSubjectStudents, schoolSubjectRank, 2);//学校科目分数排名
|
|
236
|
+ setRank(classStudents, classRank, 3);//班级分数排名
|
|
237
|
+ setRank(classSubjectStudents, classSubjectRank, 4);//班级科目分数排名
|
|
238
|
+
|
111
|
239
|
for (ERstudent cs : classStudents) {
|
112
|
240
|
Integer studentid = cs.getStudentid();
|
113
|
|
- cs.setClassrank(classRank.get(cs.getClassid()+"_"+ studentid));
|
|
241
|
+ cs.setClassrank(classRank.get(cs.getClassid() + "_" + studentid));
|
114
|
242
|
cs.setClassmaxscore(classStatistics.getMax());
|
115
|
243
|
cs.setClassavgscore(classStatistics.getAverage());
|
116
|
244
|
cs.setSchoolrank(schoolRank.get(studentid));
|
117
|
|
- cs.setSchoolmaxscore(schoolStatistics.getMax());
|
118
|
|
- cs.setSchoolavgscore(schoolStatistics.getAverage());
|
|
245
|
+ cs.setSchoolmaxscore(schoolStatisticsMax);
|
|
246
|
+ cs.setSchoolavgscore(schoolStatisticsAverage);
|
119
|
247
|
}
|
120
|
248
|
eRstudentMapper.insertList(classStudents);
|
121
|
249
|
|
122
|
|
- for (ERstudent cs : subjectStudents) {
|
|
250
|
+ for (ERstudent cs : classSubjectStudents) {
|
123
|
251
|
Integer studentid = cs.getStudentid();
|
124
|
|
- cs.setClassrank(classRank.get(cs.getClassid()+"_"+ studentid));
|
|
252
|
+ Integer classid = cs.getClassid();
|
|
253
|
+ cs.setClassrank(classRank.get(classid + "_" + studentid));
|
125
|
254
|
cs.setClassmaxscore(classStatistics.getMax());
|
126
|
255
|
cs.setClassavgscore(classStatistics.getAverage());
|
127
|
|
- cs.setSchoolrank(schoolRank.get(studentid));
|
128
|
|
- cs.setSchoolmaxscore(schoolStatistics.getMax());
|
129
|
|
- cs.setSchoolavgscore(schoolStatistics.getAverage());
|
|
256
|
+ cs.setSchoolrank(schoolSubjectRank.get(classid + "_" + cs.getSubjectid() + "_" + studentid));
|
|
257
|
+ cs.setSchoolmaxscore(sSStatistics.getMax());
|
|
258
|
+ cs.setSchoolavgscore(sSStatistics.getAverage());
|
130
|
259
|
}
|
131
|
|
- eRstudentMapper.insertList(subjectStudents);
|
|
260
|
+ eRstudentMapper.insertList(classSubjectStudents);
|
132
|
261
|
}
|
133
|
262
|
|
134
|
263
|
//分数排名
|
|
@@ -147,10 +276,12 @@ public class EReportGenerateService {
|
147
|
276
|
String subjectid = cgs.getSubjectid();
|
148
|
277
|
if (code == 1) {//学校
|
149
|
278
|
key = studentid.toString();
|
150
|
|
- } else if (code == 2) {//班级
|
151
|
|
- key = classid + "_" + studentid;
|
152
|
|
- } else {//科目
|
|
279
|
+ } else if (code == 2) {//学校科目
|
153
|
280
|
key = subjectid + "_" + studentid;
|
|
281
|
+ } else if (code == 3) {//班级
|
|
282
|
+ key = classid + "_" + studentid;
|
|
283
|
+ } else {//班级科目
|
|
284
|
+ key = classid + "_" + subjectid + "_" + studentid;
|
154
|
285
|
}
|
155
|
286
|
rank.put(key, index);
|
156
|
287
|
}
|