Browse Source

违纪优秀分析

ywx
雍文秀 1 week ago
parent
commit
febac3246d

+ 24
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportclass/MsrClassActionMapper.java View File

@@ -0,0 +1,24 @@
1
+package com.xhkjedu.smarking.mapper.report.reportclass;
2
+
3
+import com.xhkjedu.base.TkMapper;
4
+import com.xhkjedu.smarking.model.report.reportclass.MsrClassAction;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
8
+import java.util.Map;
9
+
10
+/**
11
+ * @Description 考试报告违纪优秀分析表 Mapper 接口
12
+ * @Author auto
13
+ * @Date 2025-01-02
14
+ */
15
+public interface MsrClassActionMapper extends TkMapper<MsrClassAction> {
16
+    //违纪行为
17
+    List<Map> listBadActionByExamId(@Param("msids") String msids);
18
+
19
+    //优秀试卷
20
+    List<Map> listGoodActionByExamId(@Param("examid") Integer examid,@Param("subjectids") String subjectids);
21
+
22
+    //违规试卷
23
+    List<Map> listBadQuesActionByExamId(@Param("examid") Integer examid,@Param("subjectids") String subjectids);
24
+}

+ 12
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/report/reportstu/MsrStudentActionMapper.java View File

@@ -0,0 +1,12 @@
1
+package com.xhkjedu.smarking.mapper.report.reportstu;
2
+
3
+import com.xhkjedu.base.TkMapper;
4
+import com.xhkjedu.smarking.model.report.reportstu.MsrStudentAction;
5
+
6
+/**
7
+ * @Description 考试报告学生违纪优秀分析表 Mapper 接口
8
+ * @Author auto
9
+ * @Date 2025-01-03
10
+ */
11
+public interface MsrStudentActionMapper extends TkMapper<MsrStudentAction> {
12
+}

+ 28
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportclass/MsrClassAction.java View File

@@ -0,0 +1,28 @@
1
+package com.xhkjedu.smarking.model.report.reportclass;
2
+
3
+import com.xhkjedu.model.BaseBean;
4
+import lombok.Data;
5
+
6
+import javax.persistence.Id;
7
+import javax.persistence.Table;
8
+
9
+/**
10
+ * @Description 考试报告违纪优秀分析表
11
+ * @Author auto
12
+ * @Date 2025-01-02
13
+ */
14
+@Data
15
+@Table(name = "msr_class_action")
16
+public class MsrClassAction extends BaseBean {
17
+    @Id
18
+    //考试报告违纪优秀分析id
19
+    private Integer mcaid;
20
+    //班级id
21
+    private Integer classid;
22
+    //考试id
23
+    private Integer examid;
24
+    //类型1违纪2优秀试卷3违纪试卷
25
+    private Integer actiontype;
26
+    //科目信息
27
+    private String subjectjson;
28
+}

+ 30
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportstu/MsrStudentAction.java View File

@@ -0,0 +1,30 @@
1
+package com.xhkjedu.smarking.model.report.reportstu;
2
+
3
+import com.xhkjedu.model.BaseBean;
4
+import lombok.Data;
5
+
6
+import javax.persistence.Id;
7
+import javax.persistence.Table;
8
+
9
+/**
10
+ * @Description 考试报告学生违纪优秀分析表
11
+ * @Author auto
12
+ * @Date 2025-01-03
13
+ */
14
+@Data
15
+@Table(name = "msr_student_action")
16
+public class MsrStudentAction extends BaseBean {
17
+    @Id
18
+    //考试报告学生违纪优秀分析id
19
+    private Integer msaid;
20
+    //班级id
21
+    private Integer classid;
22
+    //学生id
23
+    private Integer studentid;
24
+    //考试id
25
+    private Integer examid;
26
+    //类型1违纪2优秀
27
+    private Integer actiontype;
28
+    //科目信息
29
+    private String subjectjson;
30
+}

+ 127
- 0
smarking/src/main/java/com/xhkjedu/smarking/service/report/reportother/MsrExamService.java View File

@@ -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
     //保存学生成绩分析

+ 1
- 1
smarking/src/main/resources/mapper/exam/MsSubjectMapper.xml View File

@@ -168,7 +168,7 @@
168 168
     </select>
169 169
     <!--考试报告科目列表-->
170 170
     <select id="listReportSubject" resultType="com.xhkjedu.smarking.model.paper.MsPaper">
171
-        select s.subjectid,s.subjectname,p.mpid,p.pnum,p.mergepnum,p.pscore,p.correcttype,p.ptype
171
+        select s.subjectid,s.subjectname,s.msid,p.mpid,p.pnum,p.mergepnum,p.pscore,p.correcttype,p.ptype
172 172
         from ms_subject s inner join ms_paper p on s.msid=p.msid
173 173
         where s.examid=#{examid} and s.msid=2
174 174
         <if test="exammode!=3">

+ 25
- 0
smarking/src/main/resources/mapper/report/reportclass/MsrClassActionMapper.xml View File

@@ -0,0 +1,25 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.xhkjedu.smarking.mapper.report.reportclass.MsrClassActionMapper">
4
+    <!--违纪行为-->
5
+    <select id="listBadActionByExamId" resultType="java.util.Map">
6
+        select sb.studentid,sb.msid,count(sb.msbsid)num,u.username as studentname
7
+        from ms_subject_badstudent sb inner join t_user u on sb.studentid=u.userid
8
+        where sb.msid in(#{msids})
9
+        group by studentid,sb.msid
10
+    </select>
11
+    <!--优秀试卷-->
12
+    <select id="listGoodActionByExamId" resultType="java.util.Map">
13
+        select psq.studentid,psq.subjectid,count(distinct psq.qorder)num,u.username as studentname
14
+        from ms_paper_student_question psq inner join t_user u on psq.studentid=u.userid
15
+        where psq.examid=#{examid} and psq.subjectid in(#{subjectids}) and hasgood=1
16
+        group by psq.studentid, psq.subjectid
17
+    </select>
18
+    <!--违规试卷-->
19
+    <select id="listBadQuesActionByExamId" resultType="java.util.Map">
20
+        select psq.studentid,psq.subjectid,count(distinct psq.qorder)num,u.username as studentname
21
+        from ms_paper_student_question psq inner join t_user u on psq.studentid=u.userid
22
+        where psq.examid=#{examid} and psq.subjectid in(#{subjectids}) and hasbad=1
23
+        group by psq.studentid, psq.subjectid
24
+    </select>
25
+</mapper>

+ 4
- 0
smarking/src/main/resources/mapper/report/reportstu/MsrStudentActionMapper.xml View File

@@ -0,0 +1,4 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentActionMapper">
4
+</mapper>

Loading…
Cancel
Save