|
@@ -5,6 +5,7 @@ import com.xhkjedu.smarking.mapper.exam.*;
|
5
|
5
|
import com.xhkjedu.smarking.mapper.report.reportclass.*;
|
6
|
6
|
import com.xhkjedu.smarking.mapper.report.reportother.MsrExamMapper;
|
7
|
7
|
import com.xhkjedu.smarking.mapper.report.reportother.MsrReportparamMapper;
|
|
8
|
+import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentActionMapper;
|
8
|
9
|
import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentMapper;
|
9
|
10
|
import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectClassMapper;
|
10
|
11
|
import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectMapper;
|
|
@@ -16,6 +17,7 @@ import com.xhkjedu.smarking.model.report.reportclass.*;
|
16
|
17
|
import com.xhkjedu.smarking.model.report.reportother.MsrExam;
|
17
|
18
|
import com.xhkjedu.smarking.model.report.reportother.MsrReportparam;
|
18
|
19
|
import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
|
|
20
|
+import com.xhkjedu.smarking.model.report.reportstu.MsrStudentAction;
|
19
|
21
|
import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
|
20
|
22
|
import com.xhkjedu.smarking.model.report.reportsubject.MsrSubjectClass;
|
21
|
23
|
import com.xhkjedu.smarking.utils.MarkingUtil;
|
|
@@ -77,6 +79,10 @@ public class MsrExamService {
|
77
|
79
|
private MsrClassNearlineMapper msrClassNearlineMapper;
|
78
|
80
|
@Resource
|
79
|
81
|
private MsrClassGoodbadMapper msrClassGoodbadMapper;
|
|
82
|
+ @Resource
|
|
83
|
+ private MsrClassActionMapper msrClassActionMapper;
|
|
84
|
+ @Resource
|
|
85
|
+ private MsrStudentActionMapper msrStudentActionMapper;
|
80
|
86
|
|
81
|
87
|
|
82
|
88
|
/**
|
|
@@ -144,6 +150,127 @@ public class MsrExamService {
|
144
|
150
|
saveClassGoodBad(examid, "all", msrStudents);//重点学生-优劣名次统计
|
145
|
151
|
|
146
|
152
|
examMapper.updateExamState(examid, 3);
|
|
153
|
+ saveAction(examid, subjects, students);//行为分析
|
|
154
|
+ }
|
|
155
|
+
|
|
156
|
+ //违纪优秀分析
|
|
157
|
+ public void saveAction(Integer examid, List<MsPaper> subjects, List<MsClassStudent> students) {
|
|
158
|
+ String msids = subjects.stream().map(p -> p.getMsid().toString()).collect(Collectors.joining(","));
|
|
159
|
+ String subjectids = subjects.stream().map(MsPaper::getSubjectid).collect(Collectors.joining("','"));
|
|
160
|
+ Map<Integer, String> subjectIdMap = new HashMap<>();
|
|
161
|
+ Map<String, String> subjectNameMap = new HashMap<>();
|
|
162
|
+ for (MsPaper subject : subjects) {
|
|
163
|
+ String subjectid = subject.getSubjectid();
|
|
164
|
+ String subjectname = subject.getSubjectname();
|
|
165
|
+ subjectIdMap.put(subject.getMsid(), subjectid);
|
|
166
|
+ subjectNameMap.put(subjectid, subjectname);
|
|
167
|
+ }
|
|
168
|
+ Map<String, List<MsClassStudent>> collect = students.stream().collect(Collectors.groupingBy(s -> s.getSubjectid() + "_" + s.getStudentid()));
|
|
169
|
+ Map<String, List<Integer>> sscMap = new HashMap<>();//学生科目班级map
|
|
170
|
+ for (Map.Entry<String, List<MsClassStudent>> entry : collect.entrySet()) {
|
|
171
|
+ sscMap.put(entry.getKey(), entry.getValue().stream().map(MsClassStudent::getClassid).distinct().collect(Collectors.toList()));
|
|
172
|
+ }
|
|
173
|
+
|
|
174
|
+ List<MsrClassAction> classActions = new ArrayList<>();
|
|
175
|
+ List<MsrStudentAction> studentActions = new ArrayList<>();
|
|
176
|
+ //违纪行为
|
|
177
|
+ List<Map> bads = msrClassActionMapper.listBadActionByExamId(msids);
|
|
178
|
+ for (Map bad : bads) {
|
|
179
|
+ String subjectid = subjectIdMap.get((Integer) bad.get("msid"));
|
|
180
|
+ bad.put("subjectid", subjectid);
|
|
181
|
+ }
|
|
182
|
+ int actiontype = 1;
|
|
183
|
+ setActions(examid, classActions, studentActions, bads, actiontype, subjectNameMap, sscMap);
|
|
184
|
+ //优秀试卷
|
|
185
|
+ List<Map> goods = msrClassActionMapper.listGoodActionByExamId(examid, subjectids);
|
|
186
|
+ actiontype = 2;
|
|
187
|
+ setActions(examid, classActions, studentActions, goods, actiontype, subjectNameMap, sscMap);
|
|
188
|
+
|
|
189
|
+ //违规试卷
|
|
190
|
+ List<Map> badques = msrClassActionMapper.listBadQuesActionByExamId(examid, subjectids);
|
|
191
|
+ actiontype = 3;
|
|
192
|
+ setActions(examid, classActions, studentActions, badques, actiontype, subjectNameMap, sscMap);
|
|
193
|
+
|
|
194
|
+ if (N_Utils.isListNotEmpty(classActions)) msrClassActionMapper.insertList(classActions);
|
|
195
|
+ if (N_Utils.isListNotEmpty(studentActions)) msrStudentActionMapper.insertList(studentActions);
|
|
196
|
+ }
|
|
197
|
+
|
|
198
|
+ //处理行为数据
|
|
199
|
+ private void setActions(Integer examid, List<MsrClassAction> classActions, List<MsrStudentAction> studentActions
|
|
200
|
+ , List<Map> actionList, Integer actiontype, Map<String, String> subjectNameMap
|
|
201
|
+ , Map<String, List<Integer>> sscMap) {
|
|
202
|
+ if (N_Utils.isListNotEmpty(actionList)) {
|
|
203
|
+ List<Map> actions = new ArrayList<>();
|
|
204
|
+ for (Map map : actionList) {
|
|
205
|
+ String key = map.get("subjectid") + "_" + map.get("studentid");
|
|
206
|
+ List<Integer> classids = sscMap.get(key);
|
|
207
|
+ for (Integer classid : classids) {
|
|
208
|
+ Map ca = new HashMap(map);
|
|
209
|
+ ca.put("classid", classid);
|
|
210
|
+ actions.add(ca);
|
|
211
|
+ }
|
|
212
|
+ }
|
|
213
|
+ //班级行为分析
|
|
214
|
+ Map<Integer, List<Map>> ccollect = actions.stream().collect(Collectors.groupingBy(s -> (Integer) s.get("classid")
|
|
215
|
+ , LinkedHashMap::new, Collectors.toList()));
|
|
216
|
+ for (Map.Entry<Integer, List<Map>> entry : ccollect.entrySet()) {
|
|
217
|
+ List<Map> subjects = new ArrayList<>();
|
|
218
|
+ Map<String, List<Map>> scollect = entry.getValue().stream().collect(Collectors.groupingBy(s -> s.get("subjectid").toString()
|
|
219
|
+ , LinkedHashMap::new, Collectors.toList()));
|
|
220
|
+ for (Map.Entry<String, List<Map>> sentry : scollect.entrySet()) {
|
|
221
|
+ String subjectid = sentry.getKey();
|
|
222
|
+ int znum = (int) actions.stream().filter(s -> s.get("subjectid").equals(subjectid)).count();//总人数
|
|
223
|
+ List<Map> list = sentry.getValue();
|
|
224
|
+ Map subject = new HashMap();
|
|
225
|
+ subject.put("subjectid", subjectid);
|
|
226
|
+ subject.put("subjectname", subjectNameMap.get(subjectid));
|
|
227
|
+ int num = list.size();
|
|
228
|
+ subject.put("num", num);
|
|
229
|
+ subject.put("nrate", N_Utils.getIntegerDivideAndMulitiply(num, znum));
|
|
230
|
+ List<Map> students = new ArrayList<>();
|
|
231
|
+ for (Map s : list) {
|
|
232
|
+ Map stu = new HashMap();
|
|
233
|
+ Integer studentid = (Integer) s.get("studentid");
|
|
234
|
+ stu.put("studentid", studentid);
|
|
235
|
+ stu.put("num", s.get("num"));
|
|
236
|
+ stu.put("studentname", s.get("studentname"));
|
|
237
|
+ students.add(stu);
|
|
238
|
+ }
|
|
239
|
+ subject.put("students", students);
|
|
240
|
+ subjects.add(subject);
|
|
241
|
+ }
|
|
242
|
+ MsrClassAction ca = new MsrClassAction();
|
|
243
|
+ ca.setClassid(entry.getKey());
|
|
244
|
+ ca.setExamid(examid);
|
|
245
|
+ ca.setActiontype(actiontype);
|
|
246
|
+ String subjectjson = JSON.toJSONString(subjects);
|
|
247
|
+ ca.setSubjectjson(subjectjson);
|
|
248
|
+ classActions.add(ca);
|
|
249
|
+ }
|
|
250
|
+
|
|
251
|
+ //学生行为分析
|
|
252
|
+ Map<Integer, List<Map>> collect = actions.stream().collect(Collectors.groupingBy(s -> (Integer) s.get("studentid")
|
|
253
|
+ , LinkedHashMap::new, Collectors.toList()));
|
|
254
|
+ for (Map.Entry<Integer, List<Map>> entry : collect.entrySet()) {
|
|
255
|
+ List<Map> list = entry.getValue();
|
|
256
|
+ Map sq = list.get(0);
|
|
257
|
+ MsrStudentAction sa = new MsrStudentAction();
|
|
258
|
+ sa.setClassid((Integer) sq.get("classid"));
|
|
259
|
+ sa.setStudentid(entry.getKey());
|
|
260
|
+ sa.setExamid(examid);
|
|
261
|
+ sa.setActiontype(actiontype);
|
|
262
|
+ for (Map s : list) {
|
|
263
|
+ s.remove("classid");
|
|
264
|
+ s.remove("studentid");
|
|
265
|
+ s.remove("studentname");
|
|
266
|
+ s.remove("msid");
|
|
267
|
+ s.put("subjectname", subjectNameMap.get(s.get("subjectid").toString()));
|
|
268
|
+ }
|
|
269
|
+ String subjectjson = JSON.toJSONString(list);
|
|
270
|
+ sa.setSubjectjson(subjectjson);
|
|
271
|
+ studentActions.add(sa);
|
|
272
|
+ }
|
|
273
|
+ }
|
147
|
274
|
}
|
148
|
275
|
|
149
|
276
|
//保存学生成绩分析
|