Browse Source

考试设置

tags/正式版本
雍文秀 2 years ago
parent
commit
076c2f748b

+ 43
- 0
sexam/src/main/java/com/xhkjedu/sexam/controller/exam/EBaseController.java View File

@@ -3,6 +3,7 @@ package com.xhkjedu.sexam.controller.exam;
3 3
 import com.github.pagehelper.PageHelper;
4 4
 import com.github.pagehelper.PageInfo;
5 5
 import com.xhkjedu.sexam.model.exam.EBase;
6
+import com.xhkjedu.sexam.model.exam.EClassStudent;
6 7
 import com.xhkjedu.sexam.model.exam.ESubject;
7 8
 import com.xhkjedu.sexam.service.exam.EBaseService;
8 9
 import com.xhkjedu.utils.N_Utils;
@@ -101,6 +102,8 @@ public class EBaseController {
101 102
 
102 103
     @PostMapping("/list")
103 104
     public ResultVo list(@RequestBody EBase eBase) {
105
+        N_Utils.validation(new Object[]{eBase.getSchoolid(), "学校id"
106
+                , 1, eBase.getPage(), "页码", 1, eBase.getPageSize(), "显示条数", 1});
104 107
         PageHelper.startPage(eBase.getPage(), eBase.getPageSize());
105 108
         List<Map> list = eBaseService.listAll(eBase);
106 109
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
@@ -138,4 +141,44 @@ public class EBaseController {
138 141
         eBaseService.updateExamState(examid, 2);
139 142
         return new ResultVo(0, "结束成功");
140 143
     }
144
+
145
+    /**
146
+     * 获取考试班级
147
+     *
148
+     * @return com.xhkjedu.vo.ResultVo
149
+     * @Param [eBase]
150
+     * @Author ywx
151
+     * @Date 2022/7/18 16:12
152
+     **/
153
+    @PostMapping("/list_class")
154
+    public ResultVo listClass(@RequestBody EBase eBase) {
155
+        Integer examid = eBase.getExamid();
156
+        N_Utils.validation(new Object[]{examid, "考试id", 1});
157
+        Map map = eBaseService.listClass(examid);
158
+        return new ResultVo(0, "获取考试班级成功", map);
159
+    }
160
+
161
+    /**
162
+     * 获取考试学生
163
+     *
164
+     * @return com.xhkjedu.vo.ResultVo
165
+     * @Param [eBase]
166
+     * @Author ywx
167
+     * @Date 2022/7/18 16:57
168
+     **/
169
+    @PostMapping("/list_stu")
170
+    public ResultVo listStu(@RequestBody EBase eBase) {
171
+        Integer examid = eBase.getExamid();
172
+        N_Utils.validation(new Object[]{examid, "考试id", 1});
173
+        List<Map> list = eBaseService.listStu(eBase);
174
+        return new ResultVo(0, "获取考试学生成功", list);
175
+    }
176
+
177
+    @PostMapping("/del_stu")
178
+    public ResultVo delStu(@RequestBody EClassStudent student) {
179
+        Integer ecsid = student.getEcsid();
180
+        N_Utils.validation(new Object[]{ecsid, "考试id", 1});
181
+        eBaseService.delStu(ecsid);
182
+        return new ResultVo(0, "移除考试学生成功");
183
+    }
141 184
 }

+ 8
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/exam/EClassMapper.java View File

@@ -5,7 +5,15 @@ import com.xhkjedu.sexam.model.exam.EClass;
5 5
 import org.apache.ibatis.annotations.Param;
6 6
 
7 7
 import java.util.List;
8
+import java.util.Map;
8 9
 
9 10
 public interface EClassMapper extends TkMapper<EClass> {
11
+    //获取班级基本信息列表
10 12
     List<EClass> listByClassIds(@Param("classids") List<Integer> classids);
13
+
14
+    //考试班级
15
+    List<Map> listByExamId(@Param("examid") Integer examid);
16
+
17
+    //更新考试班级人数
18
+    void updateClassNumByCsId(@Param("ecsid") Integer ecsid);
11 19
 }

+ 6
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/exam/EClassStudentMapper.java View File

@@ -1,11 +1,17 @@
1 1
 package com.xhkjedu.sexam.mapper.exam;
2 2
 
3 3
 import com.xhkjedu.sexam.base.TkMapper;
4
+import com.xhkjedu.sexam.model.exam.EBase;
4 5
 import com.xhkjedu.sexam.model.exam.EClassStudent;
5 6
 import org.apache.ibatis.annotations.Param;
6 7
 
7 8
 import java.util.List;
9
+import java.util.Map;
8 10
 
9 11
 public interface EClassStudentMapper extends TkMapper<EClassStudent> {
12
+    //获取班级学生列表
10 13
     List<EClassStudent> listByClassIds(@Param("classids") List<Integer> classids);
14
+
15
+    //考试学生
16
+    List<Map> listByExamId(@Param("base") EBase base);
11 17
 }

+ 6
- 0
sexam/src/main/java/com/xhkjedu/sexam/model/exam/EBase.java View File

@@ -56,9 +56,15 @@ public class EBase extends BaseBean {
56 56
     //科目ids
57 57
     private List<String> subjectids;
58 58
 
59
+    @Transient
59 60
     //开始时间
60 61
     private String begindate;
61 62
 
63
+    @Transient
62 64
     //结束时间
63 65
     private String enddate;
66
+
67
+    //姓名
68
+    @Transient
69
+    private String username;
64 70
 }

+ 23
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/exam/EBaseService.java View File

@@ -19,6 +19,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
19 19
 
20 20
 import javax.annotation.Resource;
21 21
 import java.util.ArrayList;
22
+import java.util.HashMap;
22 23
 import java.util.List;
23 24
 import java.util.Map;
24 25
 import java.util.stream.Collectors;
@@ -154,4 +155,26 @@ public class EBaseService {
154 155
     public void updateExamState(Integer examid, int examstate) {
155 156
         eBaseMapper.updateExamState(examid, examstate);
156 157
     }
158
+
159
+    //获取考试班级
160
+    public Map listClass(Integer examid) {
161
+        Map map = new HashMap();
162
+        List<Map> classes = eClassMapper.listByExamId(examid);
163
+        int classnum = classes.stream().mapToInt(m -> (Integer) m.get("classnum")).sum();
164
+        map.put("classnum", classnum);
165
+        map.put("classes", classes);
166
+        return map;
167
+    }
168
+
169
+    //考试学生
170
+    public List<Map> listStu(EBase base) {
171
+        return eClassStudentMapper.listByExamId(base);
172
+    }
173
+
174
+    //移除考试学生
175
+    @Transactional(rollbackFor = Exception.class)
176
+    public void delStu(Integer ecsid) {
177
+        eClassStudentMapper.deleteByPrimaryKey(ecsid);
178
+        eClassMapper.updateClassNumByCsId(ecsid);
179
+    }
157 180
 }

+ 11
- 12
sexam/src/main/resources/mapper/exam/EBaseMapper.xml View File

@@ -14,21 +14,20 @@
14 14
     <!--考试列表-->
15 15
     <select id="listAll" resultType="java.util.Map">
16 16
         select b.examid,b.examname,b.examdate,b.gradeid,b.examtype,b.exammode,b.monitored
17
-        ,b.examstate,b.deleted,group_concat(s.subjectname order by s.subjectorder separator '|')subjectname
17
+        ,b.examstate,group_concat(s.subjectname order by s.subjectorder separator '|')subjectname
18 18
         ,min(es.esstate)esstate
19 19
         from e_base b left join e_subject es on es.examid=b.examid
20 20
         left join t_subject s on es.subjectid=s.subjectid
21
-        <where>
22
-            <if test="base.gradeid!=null and base.gradeid!=0">
23
-                and b.gradeid=#{base.gradeid}
24
-            </if>
25
-            <if test="base.examstate!=null and base.examstate!=0">
26
-                and b.examstate=#{base.examstate}
27
-            </if>
28
-            <if test="base.begindate!=null and base.begindate!=''">
29
-                and b.examdate between #{base.begindate} and #{base.enddate}
30
-            </if>
31
-        </where>
21
+        where b.schoolid=#{base.schoolid} and b.deleted=1
22
+        <if test="base.gradeid!=null and base.gradeid!=0">
23
+            and b.gradeid=#{base.gradeid}
24
+        </if>
25
+        <if test="base.examstate!=null and base.examstate!=-1">
26
+            and b.examstate=#{base.examstate}
27
+        </if>
28
+        <if test="base.begindate!=null and base.begindate!=''">
29
+            and b.examdate between #{base.begindate} and #{base.enddate}
30
+        </if>
32 31
         group by b.examid order by b.examid desc
33 32
     </select>
34 33
     <!--修改考试状态-->

+ 10
- 0
sexam/src/main/resources/mapper/exam/EClassMapper.xml View File

@@ -9,4 +9,14 @@
9 9
             ${classid}
10 10
         </foreach>
11 11
     </select>
12
+    <!--考试班级-->
13
+    <select id="listByExamId" resultType="java.util.Map">
14
+        select classid,classname,classnum from e_class where examid=#{examid}
15
+    </select>
16
+    <!--更新考试班级人数-->
17
+    <update id="updateClassNumByCsId">
18
+        update e_class c right join e_class_student cs on c.examid=cs.examid and c.classid = cs.classid
19
+        set c.classnum=(select count(*) from e_class_student s where s.examid=c.examid and s.classid=c.classid)
20
+        where cs.ecsid=#{ecsid}
21
+    </update>
12 22
 </mapper>

+ 6
- 0
sexam/src/main/resources/mapper/exam/EClassStudentMapper.xml View File

@@ -9,4 +9,10 @@
9 9
             ${classid}
10 10
         </foreach>
11 11
     </select>
12
+    <!--考试学生-->
13
+    <select id="listByExamId" resultType="java.util.Map">
14
+        select es.ecsid,es.classid,u.username,u.studentno,u.usersex
15
+        from e_class_student es left join t_user u on es.studentid = u.userid
16
+        where es.examid=#{base.examid}
17
+    </select>
12 18
 </mapper>

Loading…
Cancel
Save