Explorar el Código

考试详情改版 阅卷设置 监考设置 考试基础信息参数校验

tags/正式版本
雍文秀 hace 2 años
padre
commit
01b4607ac4

+ 34
- 2
sexam/src/main/java/com/xhkjedu/sexam/controller/exam/EBaseController.java Ver fichero

@@ -1,5 +1,6 @@
1 1
 package com.xhkjedu.sexam.controller.exam;
2 2
 
3
+import com.alibaba.fastjson.JSON;
3 4
 import com.github.pagehelper.PageHelper;
4 5
 import com.github.pagehelper.PageInfo;
5 6
 import com.xhkjedu.sexam.model.exam.EBase;
@@ -14,6 +15,7 @@ import com.xhkjedu.sexam.service.notice.NoticeService;
14 15
 import com.xhkjedu.sexam.service.report.EReportGenerateService;
15 16
 import com.xhkjedu.sexam.vo.exam.EBaseVo;
16 17
 import com.xhkjedu.sexam.vo.exam.ExamVo;
18
+import com.xhkjedu.sexam.vo.paper.EPaperVo;
17 19
 import com.xhkjedu.sexam.vo.system.UserVo;
18 20
 import com.xhkjedu.utils.N_Utils;
19 21
 import com.xhkjedu.utils.PageUtil;
@@ -59,6 +61,9 @@ public class EBaseController {
59 61
     public ResultVo add(@RequestBody EBase eBase) {
60 62
         if (N_Utils.isListEmpty(eBase.getClassids())) return new ResultVo(1, "考试班级不能为空");
61 63
         if (N_Utils.isListEmpty(eBase.getSubjects())) return new ResultVo(1, "考试科目不能为空");
64
+        if ("NaN-aN-aN".equals(eBase.getExamdate())) {
65
+            return new ResultVo(1,"日期格式不正确");
66
+        }
62 67
         return eBaseService.save(eBase);
63 68
     }
64 69
 
@@ -79,8 +84,19 @@ public class EBaseController {
79 84
         Integer createid = map.getHandleid();
80 85
         Integer examid = map.getExamid();
81 86
         N_Utils.validation(new Object[]{schoolid, "学校id", 1, createid, "操作人id", 1, examid, "考试id", 1});
82
-        Integer examstate = eBaseService.getExamState(examid);
83
-        if (2 <= examstate) return new ResultVo(1, "考试已结束禁止操作");
87
+        EBaseVo vo = eBaseService.getExamStateAndMode(examid);
88
+        if (2 <= vo.getExamstate()) return new ResultVo(1, "考试已结束禁止操作");
89
+
90
+        if (JSON.toJSONString(subjects).contains("NaN-aN-aN")) {
91
+            return new ResultVo(1,"日期格式不正确");
92
+        }
93
+        if (vo.getExammode() == 1) {//线上的考试必须有时间
94
+            for (ESubject es : subjects) {
95
+                if (N_Utils.isEmpty(es.getSdate()) || N_Utils.isEmpty(es.getBegintime()) || N_Utils.isEmpty(es.getEndtime())) {
96
+                    return new ResultVo(1, "考试时间不能为空");
97
+                }
98
+            }
99
+        }
84 100
         List<TNotice> noticeList = new ArrayList<>();
85 101
         List<TMsg> msgList = new ArrayList<>();
86 102
         String examname = eBaseService.getNameByExamId(examid);
@@ -190,6 +206,7 @@ public class EBaseController {
190 206
         EBaseVo exam = eBaseService.getExamStateById(examid);//根据考试id获取考试状态
191 207
         String examname = exam.getExamname();
192 208
         Integer schoolid = exam.getSchoolid();
209
+        if (exam.getExammode() == 1 && exam.getBegintime() == 0) return new ResultVo(1, "还有考试试卷未设置时间");
193 210
         if (exam.getWwcnum() != 0) return new ResultVo(1, "还有考试试卷未设置完成");
194 211
         if (exam.getAnswered() == 0) return new ResultVo(1, "还有考试试卷未设置正确答案");
195 212
         if (exam.getExamstate() != 0) return new ResultVo(0, "发布成功");
@@ -529,4 +546,19 @@ public class EBaseController {
529 546
         return new ResultVo(0, "获取考试未批阅试题数量成功", num);
530 547
     }
531 548
 
549
+    /*
550
+     * 缺考详情
551
+     * @Param [vo]
552
+     * @Author ywx
553
+     * @Date 2022/11/9 17:24
554
+     * @return com.xhkjedu.vo.ResultVo
555
+     **/
556
+    @PostMapping("/list_qkd")
557
+    public ResultVo listQkDetail(@RequestBody EPaperVo vo) {
558
+        Integer epid = vo.getEpid();
559
+        N_Utils.validation(new Object[]{epid, "试卷id", 1});
560
+        List<Map> list = eBaseService.listQkDetail(epid);
561
+        return new ResultVo(0, "获取缺考详情成功", list);
562
+    }
563
+
532 564
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/exam/EBaseMapper.java Ver fichero

@@ -57,4 +57,7 @@ public interface EBaseMapper extends TkMapper<EBase> {
57 57
 
58 58
     //考试未批阅试题数量
59 59
     Integer getNoCheckNum(@Param("examid") Integer examid);
60
+
61
+    //根据考试id获取状态和模式
62
+    EBaseVo getExamStateAndMode(@Param("examid") Integer examid);
60 63
 }

+ 4
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/exam/ESubjectInvigilateMapper.java Ver fichero

@@ -2,6 +2,7 @@ package com.xhkjedu.sexam.mapper.exam;
2 2
 
3 3
 import com.xhkjedu.sexam.base.TkMapper;
4 4
 import com.xhkjedu.sexam.model.exam.ESubjectInvigilate;
5
+import com.xhkjedu.sexam.vo.exam.EITeacherVo;
5 6
 import com.xhkjedu.sexam.vo.paper.EPTeacherVo;
6 7
 import org.apache.ibatis.annotations.Param;
7 8
 
@@ -24,4 +25,7 @@ public interface ESubjectInvigilateMapper extends TkMapper<ESubjectInvigilate> {
24 25
 
25 26
     //缺考学生列表
26 27
     List<Map> listMissStu(@Param("vo") EPTeacherVo vo);
28
+
29
+    //监考教师
30
+    List<EITeacherVo> listUserByEsIds(@Param("esids") String esids);
27 31
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paperstudent/EPaperStudentMapper.java Ver fichero

@@ -102,4 +102,7 @@ public interface EPaperStudentMapper extends TkMapper<EPaperStudent> {
102 102
 
103 103
     //根据试卷学生id获取考试状态和考试科目状态和时间
104 104
     Map getExamStateSubjectStateByEpsid(@Param("epsid") Integer epsid);
105
+
106
+    //缺考详情
107
+    List<Map> listQkDetail(@Param("epid") Integer epid);
105 108
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/system/UserMapper.java Ver fichero

@@ -30,4 +30,7 @@ public interface UserMapper {
30 30
 
31 31
     //根据用户id获取用户类型
32 32
     Integer getUsertypeByUserid(@Param("userid")Integer userid);
33
+
34
+    //根据用户ids查找用户
35
+    List<Map> listByUserIds(@Param("userids") String userids);
33 36
 }

+ 18
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/exam/EBaseService.java Ver fichero

@@ -432,4 +432,22 @@ public class EBaseService {
432 432
     public Integer getNoCheckNum(Integer examid) {
433 433
         return eBaseMapper.getNoCheckNum(examid);
434 434
     }
435
+
436
+    //根据考试id获取状态和模式
437
+    public EBaseVo getExamStateAndMode(Integer examid) {
438
+        return eBaseMapper.getExamStateAndMode(examid);
439
+    }
440
+
441
+    //缺考详情
442
+    public List<Map> listQkDetail(Integer epid) {
443
+        List<Map> list = ePaperStudentMapper.listQkDetail(epid);
444
+        for (Map c : list) {
445
+            List<Map> students=new ArrayList<>();
446
+            String userids = c.get("userids").toString();
447
+            if(N_Utils.isNotEmpty(userids)) students = userMapper.listByUserIds(userids);
448
+            c.put("students", students);
449
+            c.remove("userids");
450
+        }
451
+        return list;
452
+    }
435 453
 }

+ 33
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/exam/ESubjectInvigilateService.java Ver fichero

@@ -1,12 +1,14 @@
1 1
 package com.xhkjedu.sexam.service.exam;
2 2
 
3 3
 import com.alibaba.fastjson.JSON;
4
+import com.alibaba.fastjson.serializer.SerializerFeature;
4 5
 import com.xhkjedu.config.MissingParametersException;
5 6
 import com.xhkjedu.sexam.mapper.exam.EBaseMapper;
6 7
 import com.xhkjedu.sexam.mapper.exam.EClassMapper;
7 8
 import com.xhkjedu.sexam.mapper.exam.ESubjectInvigilateMapper;
8 9
 import com.xhkjedu.sexam.mapper.exam.ESubjectMapper;
9 10
 import com.xhkjedu.sexam.model.exam.ESubjectInvigilate;
11
+import com.xhkjedu.sexam.vo.exam.EITeacherVo;
10 12
 import com.xhkjedu.sexam.vo.paper.EPTeacherVo;
11 13
 import com.xhkjedu.utils.N_Utils;
12 14
 import org.springframework.stereotype.Service;
@@ -17,6 +19,7 @@ import java.util.ArrayList;
17 19
 import java.util.HashMap;
18 20
 import java.util.List;
19 21
 import java.util.Map;
22
+import java.util.stream.Collectors;
20 23
 
21 24
 @Service
22 25
 public class ESubjectInvigilateService {
@@ -49,6 +52,36 @@ public class ESubjectInvigilateService {
49 52
     public Map listSubject(Integer examid) {
50 53
         Map map = eBaseMapper.findById(examid);
51 54
         List<Map> subjects = eSubjectInvigilateMapper.listSubject(examid);//监考设置列表
55
+        String esids = subjects.stream().map(s -> s.get("esid").toString()).collect(Collectors.joining(","));
56
+        List<EITeacherVo> users = eSubjectInvigilateMapper.listUserByEsIds(esids);
57
+        List<Map> classes = eClassMapper.listByExamId(examid);//考试班级
58
+        for (Map s : subjects) {
59
+            Integer esid = (Integer) s.get("esid");
60
+            if (N_Utils.isListEmpty(users)) users = new ArrayList<>();
61
+            String majorname = users.stream().filter(u -> esid.equals(u.getEsid()) && u.getMajored() == 1)
62
+                    .map(u -> u.getUsername()).distinct().collect(Collectors.joining("、"));
63
+            s.put("majorname", majorname);
64
+            long einum = users.stream().filter(u -> !N_Utils.isEmptyInteger(u.getClassid()))
65
+                    .map(u -> u.getClassid()).distinct().count();
66
+            s.put("einum", einum);
67
+            for (Map c : classes) {
68
+                Integer classid = (Integer) c.get("classid");
69
+                List<Map> teachers=new ArrayList<>();
70
+                for (EITeacherVo u : users) {
71
+                    if(esid.equals(u.getEsid())&& (1 == u.getMajored() || classid.equals(u.getClassid()))){
72
+                        Map t=new HashMap();
73
+                        t.put("teacherid",u.getTeacherid());
74
+                        t.put("username",u.getUsername());
75
+                        t.put("loginname",u.getLoginname());
76
+                        teachers.add(t);
77
+                    }
78
+                }
79
+                c.put("teachers", teachers.stream().distinct().collect(Collectors.toList()));
80
+            }
81
+            //关闭引用检测,避免循环给classes赋值出现"$ref":"$[0]"现象
82
+            String str = JSON.toJSONString(classes, SerializerFeature.DisableCircularReferenceDetect);
83
+            s.put("classes", JSON.parseArray(str, Map.class));
84
+        }
52 85
         map.put("subjects", subjects);
53 86
         return map;
54 87
     }

+ 31
- 5
sexam/src/main/java/com/xhkjedu/sexam/service/exam/ESubjectSearchService.java Ver fichero

@@ -4,17 +4,15 @@ import com.xhkjedu.sexam.mapper.exam.EBaseMapper;
4 4
 import com.xhkjedu.sexam.mapper.exam.EClassMapper;
5 5
 import com.xhkjedu.sexam.mapper.exam.EClassStudentMapper;
6 6
 import com.xhkjedu.sexam.mapper.exam.ESubjectMapper;
7
+import com.xhkjedu.sexam.mapper.paper.EPaperCorrectclassMapper;
8
+import com.xhkjedu.sexam.mapper.paper.EPaperCorrectquestionMapper;
7 9
 import com.xhkjedu.sexam.mapper.system.UserMapper;
8 10
 import com.xhkjedu.sexam.vo.exam.CTeacherVo;
9 11
 import com.xhkjedu.utils.N_Utils;
10 12
 import org.springframework.stereotype.Service;
11 13
 
12 14
 import javax.annotation.Resource;
13
-import java.util.ArrayList;
14
-import java.util.HashMap;
15
-import java.util.LinkedHashMap;
16
-import java.util.List;
17
-import java.util.Map;
15
+import java.util.*;
18 16
 import java.util.stream.Collectors;
19 17
 
20 18
 @Service
@@ -29,6 +27,10 @@ public class ESubjectSearchService {
29 27
     private UserMapper userMapper;
30 28
     @Resource
31 29
     private EClassStudentMapper eClassStudentMapper;
30
+    @Resource
31
+    private EPaperCorrectclassMapper ePaperCorrectclassMapper;
32
+    @Resource
33
+    private EPaperCorrectquestionMapper ePaperCorrectquestionMapper;
32 34
 
33 35
     //查找设置
34 36
     public List<Map> listSearchTeacher(Integer examid, Integer schoolid) {
@@ -110,6 +112,30 @@ public class ESubjectSearchService {
110 112
     public Map listSubject(Integer examid) {
111 113
         Map map = eBaseMapper.findById(examid);
112 114
         List<Map> subjects = eSubjectMapper.listSubjectCSet(examid);//考试科目阅卷设置列表
115
+        for (Map s : subjects) {
116
+            Integer correcttype = (Integer) s.get("correcttype");
117
+            Integer epid = (Integer) s.get("epid");
118
+            List<Map> list=new ArrayList<>();
119
+            if (correcttype == 1) {
120
+                list = eClassMapper.listByExamId(examid);//考试班级
121
+                List<Map> users = ePaperCorrectclassMapper.listByEpId(epid);//试卷批阅人
122
+                for (Map m : list) {
123
+                    List<Map> teachers = users.stream().filter(u -> u.get("classid").equals(m.get("classid")))
124
+                            .sorted(Comparator.comparing(t->t.get("username").toString())).collect(Collectors.toList());
125
+                    m.put("teachers", teachers);
126
+                }
127
+            } else if (correcttype == 2) {
128
+                list = ePaperCorrectquestionMapper.listQnByEpId(epid);
129
+                List<Map> users = ePaperCorrectquestionMapper.listByEpId(epid);//试卷批阅人
130
+                for (Map q : list) {
131
+                    Object qorder = q.get("qorder");
132
+                    List<Map> teachers = users.stream().filter(u -> u.get("qorder").equals(qorder))
133
+                            .sorted(Comparator.comparing(t->t.get("username").toString())).collect(Collectors.toList());
134
+                    q.put("teachers", teachers);
135
+                }
136
+            }
137
+            s.put("correctList", list);
138
+        }
113 139
         map.put("subjects", subjects);
114 140
         return map;
115 141
     }

+ 20
- 0
sexam/src/main/java/com/xhkjedu/sexam/vo/exam/EITeacherVo.java Ver fichero

@@ -0,0 +1,20 @@
1
+package com.xhkjedu.sexam.vo.exam;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * 
7
+ * @Param 监考教师
8
+ * @Author ywx
9
+ * @Date 2022/11/9 16:21
10
+ * @return 
11
+ **/
12
+@Data
13
+public class EITeacherVo {
14
+    private Integer esid;//考试科目id
15
+    private Integer classid;//班级id
16
+    private Integer majored;//是否是主监考0不是1是
17
+    private Integer teacherid;//教师id
18
+    private String username;//姓名
19
+    private String loginname;//账号
20
+}

+ 5
- 0
sexam/src/main/resources/mapper/exam/EBaseMapper.xml Ver fichero

@@ -122,4 +122,9 @@
122 122
         select count(*) from e_paper_student_question
123 123
         where examid=#{examid} and answered=1 and checked!=2
124 124
     </select>
125
+    <!--根据考试id获取状态和模式-->
126
+    <select id="getExamStateAndMode" resultType="com.xhkjedu.sexam.vo.exam.EBaseVo">
127
+        select eb.examstate,eb.exammode
128
+        from e_base eb where eb.examid=#{examid}
129
+    </select>
125 130
 </mapper>

+ 11
- 8
sexam/src/main/resources/mapper/exam/ESubjectInvigilateMapper.xml Ver fichero

@@ -7,13 +7,10 @@
7 7
     </delete>
8 8
     <!--监考设置列表-->
9 9
     <select id="listSubject" resultType="java.util.Map">
10
-        select s.*,ifnull(ep.pnum,0)pnum,ifnull(ep.pscore,0)pscore,ep.correcttype
11
-        from (select s.esid,s.subjectid,s.sdate,s.begintime,s.endtime,s.esstate,s.subjectname
12
-        ,group_concat(u.username separator '、')majorname
13
-        ,count(DISTINCT ei.classid) einum
14
-        from e_subject s left join e_subject_invigilate ei on ei.esid=s.esid
15
-        left join t_user u on u.userid=ei.teacherid and ei.majored=1
16
-        where s.examid=#{examid} group by s.esid)s left join e_paper ep on s.esid = ep.esid
10
+        select s.esid,s.subjectid,s.sdate,s.begintime,s.endtime,s.esstate,s.subjectname
11
+        ,ifnull(ep.pnum,0)pnum,ifnull(ep.pscore,0)pscore,ep.correcttype
12
+        from e_subject s left join e_paper ep on s.esid = ep.esid
13
+        where s.examid=#{examid} group by s.esid
17 14
     </select>
18 15
     <!--考试监考人-->
19 16
     <select id="listByEsId" resultType="java.util.Map">
@@ -64,6 +61,12 @@
64 61
         select eps.studentid,u.username,eps.sstate
65 62
         from e_paper_student eps  left join t_user u on eps.studentid = u.userid
66 63
         where eps.esid=#{vo.esid} and eps.sstate in(0,3) and eps.classid in(${vo.classids})
67
-        order by convert(u.username using gbk)
64
+        order by convert(u.username using gbk),u.userid
65
+    </select>
66
+    <!--考试监考人-->
67
+    <select id="listUserByEsIds" resultType="com.xhkjedu.sexam.vo.exam.EITeacherVo">
68
+        select ei.esid,ei.classid,ei.majored,ei.teacherid,u.username,u.loginname
69
+        from e_subject_invigilate ei left join t_user u on ei.teacherid = u.userid
70
+        where ei.esid in(${esids}) order by convert(u.username using gbk),u.userid
68 71
     </select>
69 72
 </mapper>

+ 36
- 4
sexam/src/main/resources/mapper/exam/ESubjectMapper.xml Ver fichero

@@ -21,8 +21,11 @@
21 21
     </update>
22 22
     <!--考试科目列表-->
23 23
     <select id="listSubject" resultType="java.util.Map">
24
-        select es.subjectid,es.subjectname,es.sdate,es.begintime,es.endtime,es.teacherid,u.username
25
-        from e_subject es left join t_user u on es.teacherid=u.userid
24
+        select es.subjectid,es.subjectname,es.sdate,es.begintime,es.endtime
25
+        ,(case when es.esstate!=0 then ep.handleid else es.teacherid end)teacherid
26
+        ,(select u.username from t_user u where u.userid=
27
+        (case when es.esstate!=0 then ep.handleid else ifnull(es.teacherid,0) end))username
28
+        from e_subject es left join e_paper ep on es.esid = ep.esid
26 29
         where examid=#{examid} order by es.esid
27 30
     </select>
28 31
     <!--根据考试科目id获取考试id-->
@@ -30,10 +33,39 @@
30 33
         select examid from e_subject where esid=#{esid} limit 1
31 34
     </select>
32 35
     <!--考试科目设置列表-->
33
-    <select id="listSubjectSet" resultType="java.util.Map">
36
+    <resultMap id="subjectResult" type="java.util.Map">
37
+        <collection property="yjteachers" ofType="java.util.Map" javaType="java.util.List"
38
+                    select="listYjTeacher" column="epid=epid,correcttype=correcttype">
39
+        </collection>
40
+        <collection property="jkteachers" ofType="java.util.Map" javaType="java.util.List"
41
+                    select="listJkTeacher" column="esid=esid">
42
+        </collection>
43
+    </resultMap>
44
+    <select id="listYjTeacher" resultType="java.util.Map">
45
+        <if test="correcttype==2">
46
+            select u.username,u.loginname
47
+            from t_user u where u.userid in(select distinct epc.teacherid
48
+            from e_paper_correctquestion epc where epc.epid=#{epid})
49
+            order by convert(u.username using gbk),u.userid
50
+        </if>
51
+        <if test="correcttype!=2">
52
+            select u.username,u.loginname
53
+            from t_user u where u.userid in(select distinct epc.teacherid
54
+            from e_paper_correctclass epc where epc.epid=#{epid})
55
+            order by convert(u.username using gbk),u.userid
56
+        </if>
57
+    </select>
58
+    <select id="listJkTeacher" resultType="java.util.Map">
59
+        select u.username,u.loginname
60
+        from t_user u where u.userid in(select distinct ei.teacherid
61
+        from e_subject_invigilate ei where ei.esid=#{esid})
62
+        order by convert(u.username using gbk),u.userid
63
+    </select>
64
+    <select id="listSubjectSet" resultMap="subjectResult">
34 65
         select es.subjectid,es.subjectname,es.sdate,es.begintime,es.endtime,es.esstate
35 66
         ,ep.correcttype,es.esid,ep.epid,ep.ptype
36
-        ,(select count(distinct ei.teacherid) from e_subject_invigilate ei where ei.esid=es.esid)jkjsnum
67
+        ,(select u.username from t_user u where u.userid=
68
+        (case when es.esstate!=0 then ep.handleid else ifnull(es.teacherid,0) end))cjteacher
37 69
         ,count(distinct case when eps.sstate=3 then eps.epsid else null end)qknum
38 70
         ,count(distinct case when eps.sstate=2 then eps.epsid else null end)tjnum
39 71
         ,ifnull(truncate(count(case when psq.answered=1 AND psq.checked=2 then psq.epsqid else null end)*100/

+ 9
- 0
sexam/src/main/resources/mapper/paperstudent/EPaperStudentMapper.xml Ver fichero

@@ -338,4 +338,13 @@
338 338
         left join e_base b on b.examid = eps.examid left join e_subject s on eps.esid=s.esid
339 339
         where eps.epsid=#{epsid}
340 340
     </select>
341
+    <!--缺考详情-->
342
+    <select id="listQkDetail" resultType="java.util.Map">
343
+        select ec.classid,ec.classname,ec.classnum
344
+        ,count(distinct case when eps.sstate=3 then eps.epsid else null end)qknum
345
+        ,group_concat(case when eps.sstate=3 then eps.studentid else null end)userids
346
+        ,truncate(count(distinct case when eps.sstate=3 then eps.epsid else null end)*100/count(*),2)qkrate
347
+        from e_paper_student eps left join e_class ec on eps.examid=ec.examid and eps.classid=ec.classid
348
+        where eps.epid=#{epid} group by eps.classid order by ec.ecid
349
+    </select>
341 350
 </mapper>

+ 6
- 0
sexam/src/main/resources/mapper/system/UserMapper.xml Ver fichero

@@ -58,4 +58,10 @@
58 58
     <select id="getUsertypeByUserid" resultType="java.lang.Integer">
59 59
         select usertype from t_user where userid=#{userid}
60 60
     </select>
61
+    <!--根据用户ids查找用户-->
62
+    <select id="listByUserIds" resultType="java.util.Map">
63
+        select u.username,u.loginname
64
+        from t_user u where u.userid in(${userids})
65
+        order by convert(u.username using gbk),u.userid
66
+    </select>
61 67
 </mapper>

Loading…
Cancelar
Guardar