Browse Source

考生管理

ywx
雍文秀 2 months ago
parent
commit
17d4c33e5d

+ 15
- 0
scommons/src/main/java/com/xhkjedu/utils/N_Utils.java View File

@@ -153,6 +153,21 @@ public class N_Utils {
153 153
         }
154 154
     }
155 155
 
156
+    /**
157
+     * @Description 对象转数字
158
+     * @Date 2024/10/21 16:49
159
+     * @Author YWX
160
+     * @Param [str]
161
+     * @Return java.lang.Integer
162
+     **/
163
+    public static Integer obj2Int(Object str){
164
+        if (isNotEmpty(str)){
165
+            return Integer.parseInt(str.toString());
166
+        } else {
167
+            return 0;
168
+        }
169
+    }
170
+
156 171
     /**
157 172
      * 日期转时间戳(秒)
158 173
      * @Param [data, strType]

+ 115
- 8
smarking/src/main/java/com/xhkjedu/smarking/controller/exam/MsClassStudentController.java View File

@@ -4,6 +4,8 @@ import com.github.pagehelper.PageHelper;
4 4
 import com.github.pagehelper.PageInfo;
5 5
 import com.xhkjedu.smarking.model.exam.MsClassStudent;
6 6
 import com.xhkjedu.smarking.service.exam.MsClassStudentService;
7
+import com.xhkjedu.smarking.vo.exam.CStudentVo;
8
+import com.xhkjedu.smarking.vo.exam.SCStudentVo;
7 9
 import com.xhkjedu.utils.N_Utils;
8 10
 import com.xhkjedu.utils.PageUtil;
9 11
 import com.xhkjedu.vo.PageResult;
@@ -26,15 +28,38 @@ public class MsClassStudentController {
26 28
     private MsClassStudentService msClassStudentService;
27 29
 
28 30
     /**
29
-     * @return com.xhkjedu.vo.ResultVo
30
-     * @Description 新增
31
-     * @Param [msClassStudent]
32
-     * @Author auto
33
-     * @Date 2024-10-15
31
+     * @Description 新增考生-按学生
32
+     * @Date 2024/10/22 9:36
33
+     * @Author YWX
34
+     * @Param [cs]
35
+     * @Return com.xhkjedu.vo.ResultVo
34 36
      **/
35
-    @PostMapping("/save")
36
-    public ResultVo save(@RequestBody MsClassStudent msClassStudent) {
37
-        msClassStudentService.add(msClassStudent);
37
+    @PostMapping("/save_by_student")
38
+    public ResultVo saveByStudent(@RequestBody SCStudentVo cs) {
39
+        N_Utils.validation(new Object[]{
40
+                cs.getExamid(), "考试id", 1
41
+                , cs.getSubjectids(), "科目", 3
42
+                , cs.getStudents(), "学生", 3
43
+        });
44
+        msClassStudentService.saveByStudent(cs);
45
+        return new ResultVo(0, "保存成功!");
46
+    }
47
+
48
+    /**
49
+     * @Description 新增考生-按班级
50
+     * @Date 2024/10/22 11:42
51
+     * @Author YWX
52
+     * @Param [cs]
53
+     * @Return com.xhkjedu.vo.ResultVo
54
+     **/
55
+    @PostMapping("/save_by_class")
56
+    public ResultVo saveByClass(@RequestBody SCStudentVo cs) {
57
+        N_Utils.validation(new Object[]{
58
+                cs.getExamid(), "考试id", 1
59
+                , cs.getSubjectids(), "科目", 3
60
+                , cs.getClassids(), "班级", 3
61
+        });
62
+        msClassStudentService.saveByClass(cs);
38 63
         return new ResultVo(0, "保存成功!");
39 64
     }
40 65
 
@@ -62,4 +87,86 @@ public class MsClassStudentController {
62 87
             return new ResultVo(0, "查询成功!", pageResult);
63 88
         }
64 89
     }
90
+
91
+    /**
92
+     * @Description 移除单个科目学生
93
+     * @Date 2024/10/22 14:13
94
+     * @Author YWX
95
+     * @Param [cs]
96
+     * @Return com.xhkjedu.vo.ResultVo
97
+     **/
98
+    @PostMapping("/delete_by_student")
99
+    public ResultVo deleteByStudent(@RequestBody CStudentVo cs) {
100
+        N_Utils.validation(new Object[]{
101
+                cs.getMcsid(), "阅卷考试学生ID", 1
102
+        });
103
+        msClassStudentService.deleteByStudent(cs);
104
+        return new ResultVo(0, "移除成功!");
105
+    }
106
+
107
+    /**
108
+     * @Description 移除班级学生
109
+     * @Date 2024/10/22 14:17
110
+     * @Author YWX
111
+     * @Param [cs]
112
+     * @Return com.xhkjedu.vo.ResultVo
113
+     **/
114
+    @PostMapping("/delete_by_class")
115
+    public ResultVo deleteByClass(@RequestBody CStudentVo cs) {
116
+        N_Utils.validation(new Object[]{
117
+                cs.getExamid(), "考试id", 1
118
+                , cs.getClassid(), "班级", 1
119
+        });
120
+        msClassStudentService.deleteByClass(cs);
121
+        return new ResultVo(0, "移除成功!");
122
+    }
123
+
124
+    /**
125
+     * @Description 考试班级列表
126
+     * @Date 2024/10/22 16:49
127
+     * @Author YWX
128
+     * @Param [cs]
129
+     * @Return com.xhkjedu.vo.ResultVo
130
+     **/
131
+    @PostMapping("/list_class")
132
+    public ResultVo listClass(@RequestBody CStudentVo cs) {
133
+        N_Utils.validation(new Object[]{
134
+                cs.getExamid(), "考试id", 1
135
+        });
136
+        return new ResultVo(0, "查询成功!", msClassStudentService.listClass(cs));
137
+    }
138
+
139
+    /**
140
+     * @Description 班级搜索列表
141
+     * @Date 2024/10/22 16:53
142
+     * @Author YWX
143
+     * @Param [cs]
144
+     * @Return com.xhkjedu.vo.ResultVo
145
+     **/
146
+    @PostMapping("/search_class")
147
+    public ResultVo searchClass(@RequestBody CStudentVo cs) {
148
+        N_Utils.validation(new Object[]{
149
+                cs.getExamid(), "考试id", 1
150
+                , cs.getSchoolid(), "学校id", 1
151
+                , cs.getClasstype(), "班级类型", 1
152
+        });
153
+        return new ResultVo(0, "查询成功!", msClassStudentService.searchClass(cs));
154
+    }
155
+
156
+    /**
157
+     * @Description 学生搜索列表
158
+     * @Date 2024/10/22 17:05
159
+     * @Author YWX
160
+     * @Param [cs]
161
+     * @Return com.xhkjedu.vo.ResultVo
162
+     **/
163
+    @PostMapping("/search_student")
164
+    public ResultVo searchStudent(@RequestBody CStudentVo cs) {
165
+        N_Utils.validation(new Object[]{
166
+                cs.getExamid(), "考试id", 1
167
+                , cs.getSchoolid(), "学校id", 1
168
+                , cs.getClasstype(), "班级类型", 1
169
+        });
170
+        return new ResultVo(0, "查询成功!", msClassStudentService.searchStudent(cs));
171
+    }
65 172
 }

+ 2
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/exam/MsClassMapper.java View File

@@ -37,4 +37,6 @@ public interface MsClassMapper extends TkMapper<MsClass> {
37 37
 
38 38
     //按班设置教师列表
39 39
     List<Map> listClassTeacher(@Param("classids") String classids,@Param("subjectid") String subjectid);
40
+
41
+    void batchSave(@Param("list") List<MsClass> classes);
40 42
 }

+ 25
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/exam/MsClassStudentMapper.java View File

@@ -2,6 +2,7 @@ package com.xhkjedu.smarking.mapper.exam;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.exam.MsClassStudent;
5
+import com.xhkjedu.smarking.vo.exam.CStudentVo;
5 6
 import org.apache.ibatis.annotations.Param;
6 7
 
7 8
 import java.util.List;
@@ -27,4 +28,28 @@ public interface MsClassStudentMapper extends TkMapper<MsClassStudent> {
27 28
 
28 29
     //考生信息列表
29 30
     List<Map> listAll(@Param("cs") MsClassStudent msClassStudent);
31
+
32
+    //批量保存考试学生信息
33
+    void batchSave(@Param("list") List<MsClassStudent> students);
34
+
35
+    //根据学生ids获取没有考号学生数量
36
+    Integer getNoExamNoNumByStudentIds(@Param("studentIds") List<Integer> studentIds);
37
+
38
+    //移除单个科目学生
39
+    void deleteByStu(@Param("cs") CStudentVo cs);
40
+
41
+    //移除班级学生
42
+    void deleteByClass(@Param("cs") CStudentVo cs);
43
+
44
+    //根据科目和学生id获取班级id
45
+    List<Integer> listBySubjectIdAndStuId(@Param("cs") CStudentVo cs);
46
+
47
+    //考试班级列表
48
+    List<Map> listClass(@Param("cs") CStudentVo cs);
49
+
50
+    //班级搜索列表
51
+    List<Map> searchClass(@Param("cs") CStudentVo cs);
52
+
53
+    //学生搜索列表
54
+    List<Map> searchStudent(@Param("cs") CStudentVo cs);
30 55
 }

+ 3
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperMapper.java View File

@@ -43,4 +43,7 @@ public interface MsPaperMapper extends TkMapper<MsPaper> {
43 43
 
44 44
     //根据科目id获取试卷基础信息
45 45
     MsPaper getPaperBaseByMsid(@Param("msid") Integer msid);
46
+
47
+    //根据考试id和科目id获取试卷信息
48
+    MsPaper getPaperByExamIdAndSubjectId(@Param("examId") Integer examId, @Param("subjectId") String subjectId);
46 49
 }

+ 10
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/stupaper/MsPaperStudentMapper.java View File

@@ -1,7 +1,12 @@
1 1
 package com.xhkjedu.smarking.mapper.stupaper;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4
+import com.xhkjedu.smarking.model.exam.MsClassStudent;
4 5
 import com.xhkjedu.smarking.model.stupaper.MsPaperStudent;
6
+import com.xhkjedu.smarking.vo.exam.CStudentVo;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.util.List;
5 10
 
6 11
 /**
7 12
  * @Description 阅卷试卷学生表 Mapper 接口
@@ -9,4 +14,9 @@ import com.xhkjedu.smarking.model.stupaper.MsPaperStudent;
9 14
  * @Date 2024-10-15
10 15
  */
11 16
 public interface MsPaperStudentMapper extends TkMapper<MsPaperStudent> {
17
+    //批量保存学生试卷
18
+    void batchSave(@Param("list") List<MsPaperStudent> paperStudents);
19
+
20
+    //获取学生科目试卷状态
21
+    Integer getStateByStudentIdAndSubjectId(@Param("cs") CStudentVo cs);
12 22
 }

+ 181
- 10
smarking/src/main/java/com/xhkjedu/smarking/service/exam/MsClassStudentService.java View File

@@ -1,12 +1,22 @@
1 1
 package com.xhkjedu.smarking.service.exam;
2 2
 
3
-import com.xhkjedu.smarking.mapper.exam.MsClassStudentMapper;
4
-import com.xhkjedu.smarking.mapper.exam.MsSubjectMapper;
3
+import com.xhkjedu.exception.ServiceException;
4
+import com.xhkjedu.smarking.mapper.exam.*;
5
+import com.xhkjedu.smarking.mapper.paper.MsPaperMapper;
6
+import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentMapper;
7
+import com.xhkjedu.smarking.model.exam.MsClass;
5 8
 import com.xhkjedu.smarking.model.exam.MsClassStudent;
9
+import com.xhkjedu.smarking.model.paper.MsPaper;
10
+import com.xhkjedu.smarking.model.stupaper.MsPaperStudent;
11
+import com.xhkjedu.smarking.vo.exam.CStudentVo;
12
+import com.xhkjedu.smarking.vo.exam.SCStudentVo;
13
+import com.xhkjedu.utils.N_Utils;
6 14
 import org.springframework.stereotype.Service;
15
+import org.springframework.transaction.annotation.Transactional;
7 16
 
8 17
 import javax.annotation.Resource;
9 18
 import java.util.*;
19
+import java.util.stream.Collectors;
10 20
 
11 21
 /**
12 22
  * @Description 阅卷考试学生表 服务实现类
@@ -19,16 +29,96 @@ public class MsClassStudentService {
19 29
     private MsClassStudentMapper msClassStudentMapper;
20 30
     @Resource
21 31
     private MsSubjectMapper msSubjectMapper;
32
+    @Resource
33
+    private MsClassMapper msClassMapper;
34
+    @Resource
35
+    private MsExamMapper msExamMapper;
36
+    @Resource
37
+    private MsPaperMapper msPaperMapper;
38
+    @Resource
39
+    private MsPaperStudentMapper msPaperStudentMapper;
22 40
 
23 41
     /**
24
-     * @return void
25
-     * @Description 新增
26
-     * @Param [msClassStudent]
27
-     * @Author auto
28
-     * @Date 2024-10-15
42
+     * @Description 新增考生-按学生
43
+     * @Date 2024/10/22 9:36
44
+     * @Author YWX
45
+     * @Param [cs]
46
+     * @Return void
29 47
      **/
30
-    public void add(MsClassStudent msClassStudent) {
31
-        msClassStudentMapper.insert(msClassStudent);
48
+    @Transactional(rollbackFor = Exception.class)
49
+    public void saveByStudent(SCStudentVo cs) {
50
+        List<Integer> classIds = cs.getStudents().stream().map(MsClassStudent::getClassid).distinct().collect(Collectors.toList());
51
+        cs.setClassids(classIds);
52
+        saveClassAndStudent(cs);
53
+    }
54
+
55
+    //保存班级和学生信息
56
+    private void saveClassAndStudent(SCStudentVo cs) {
57
+        Integer examid = cs.getExamid();
58
+        Map exam = msExamMapper.findById(examid);
59
+        if (exam.get("fixedscore").equals(1)) {
60
+            throw new ServiceException("一键统分后,不支持添加考生!");
61
+        }
62
+        List<MsClassStudent> studentsList = cs.getStudents();
63
+        if (!exam.get("exammode").equals(3)) {//线下考试
64
+            List<Integer> studentIds = studentsList.stream().map(MsClassStudent::getStudentid).distinct().collect(Collectors.toList());
65
+            Integer num = msClassStudentMapper.getNoExamNoNumByStudentIds(studentIds);//根据学生ids获取没有考号学生数量
66
+            if (num != 0) throw new ServiceException("有学生未设置考号,请先设置");
67
+        }
68
+        List<MsClass> classList = msClassMapper.listByClassIds(cs.getClassids());
69
+        List<MsClass> classes = new ArrayList<>();
70
+        List<MsClassStudent> students = new ArrayList<>();
71
+        List<MsPaperStudent> paperStudents = new ArrayList<>();
72
+        boolean fb = !exam.get("examstate").equals(0);
73
+        for (String subjectid : cs.getSubjectids()) {
74
+            for (MsClass msClass : classList) {
75
+                //MsClass msClass = c;
76
+                msClass.setExamid(examid);
77
+                msClass.setSubjectid(subjectid);
78
+                classes.add(msClass);
79
+            }
80
+            MsPaper paper = null;
81
+            if (fb) paper = msPaperMapper.getPaperByExamIdAndSubjectId(examid, subjectid);
82
+            for (MsClassStudent stu : studentsList) {
83
+                //没有学生对应班级科目信息,添加学生信息
84
+                MsClassStudent student = new MsClassStudent();
85
+                student.setExamid(examid);
86
+                student.setSubjectid(subjectid);
87
+                student.setClassid(stu.getClassid());
88
+                student.setStudentid(stu.getStudentid());
89
+                students.add(student);
90
+                if (fb) {//考试已发布,没有学生对应科目试卷添加学生试卷
91
+                    MsPaperStudent paperStudent = new MsPaperStudent();
92
+                    paperStudent.setExamid(examid);
93
+                    paperStudent.setMsid(paper.getMsid());
94
+                    paperStudent.setMpid(paper.getMpid());
95
+                    paperStudent.setSubjectid(subjectid);
96
+                    paperStudent.setStudentid(stu.getStudentid());
97
+                    paperStudent.setPnum(paper.getPnum());
98
+                    paperStudent.setPscore(paper.getPscore());
99
+                    paperStudent.setCreatetime(N_Utils.getSecondTimestamp());
100
+                    paperStudents.add(paperStudent);
101
+                }
102
+            }
103
+        }
104
+
105
+        msClassMapper.batchSave(classes);
106
+        msClassStudentMapper.batchSave(students);
107
+        if (N_Utils.isListNotEmpty(paperStudents)) msPaperStudentMapper.batchSave(paperStudents);
108
+    }
109
+
110
+    /**
111
+     * @Description 新增考生-按班级
112
+     * @Date 2024/10/22 11:42
113
+     * @Author YWX
114
+     * @Param [cs]
115
+     * @Return void
116
+     **/
117
+    @Transactional(rollbackFor = Exception.class)
118
+    public void saveByClass(SCStudentVo cs) {
119
+        List<MsClassStudent> studentsList = msClassStudentMapper.listByClassIds(cs.getClassids());
120
+        cs.setStudents(studentsList);
121
+        saveClassAndStudent(cs);
32 122
     }
33 123
 
34 124
     /**
@@ -46,8 +136,89 @@ public class MsClassStudentService {
46 136
         }
47 137
         List<Map> list = msClassStudentMapper.listAll(msClassStudent);
48 138
         for (Map map : list) {
49
-            map.put("subjectname", subjectMap.get(map.get("subjectid")));
139
+            map.put("subjectname", subjectMap.get(map.get("subjectid").toString()));
50 140
         }
51 141
         return list;
52 142
     }
143
+
144
+    /**
145
+     * @Description 移除单个科目学生
146
+     * @Date 2024/10/22 14:13
147
+     * @Author YWX
148
+     * @Param [cs]
149
+     * @Return void
150
+     **/
151
+    public void deleteByStudent(CStudentVo cs) {
152
+        Integer mcsid = cs.getMcsid();
153
+        MsClassStudent student = msClassStudentMapper.selectByPrimaryKey(mcsid);
154
+        if (student == null) return;
155
+        Integer examid = student.getExamid();
156
+        Map exam = msExamMapper.findById(examid);
157
+        if (exam.get("fixedscore").equals(1)) throw new ServiceException("一键统分后,不支持移除考生!");
158
+        cs.setExamid(examid);
159
+        cs.setSubjectid(student.getSubjectid());
160
+        cs.setStudentid(student.getStudentid());
161
+        List<Integer> classIds = msClassStudentMapper.listBySubjectIdAndStuId(cs);
162
+        if (classIds.size() == 1) {//如果学生只在一个班级,则移除班级学生和试卷信息
163
+            msClassStudentMapper.deleteByStu(cs);
164
+        } else {//如果学生在多个班级,只移除班级学生信息
165
+            msClassStudentMapper.deleteByPrimaryKey(mcsid);
166
+        }
167
+
168
+    }
169
+
170
+    /**
171
+     * @Description 移除班级学生
172
+     * @Date 2024/10/22 14:17
173
+     * @Author YWX
174
+     * @Param [cs]
175
+     * @Return void
176
+     **/
177
+    public void deleteByClass(CStudentVo cs) {
178
+        Map exam = msExamMapper.findById(cs.getExamid());
179
+        if (exam.get("fixedscore").equals(1)) throw new ServiceException("一键统分后,不支持移除考生!");
180
+        msClassStudentMapper.deleteByClass(cs);
181
+    }
182
+
183
+    /**
184
+     * @Description 考试班级列表
185
+     * @Date 2024/10/22 16:50
186
+     * @Author YWX
187
+     * @Param [cs]
188
+     * @Return java.util.List<java.util.Map>
189
+     **/
190
+    public List<Map> listClass(CStudentVo cs) {
191
+        return msClassStudentMapper.listClass(cs);
192
+    }
193
+
194
+    /**
195
+     * @Description 班级搜索列表
196
+     * @Date 2024/10/22 16:57
197
+     * @Author YWX
198
+     * @Param [cs]
199
+     * @Return java.util.List<java.util.Map>
200
+     **/
201
+    public List<Map> searchClass(CStudentVo cs) {
202
+        setParam(cs);
203
+        return msClassStudentMapper.searchClass(cs);
204
+    }
205
+
206
+    private void setParam(CStudentVo cs) {
207
+        Map exam = msExamMapper.findById(cs.getExamid());
208
+        if (exam == null) throw new ServiceException("考试不存在!");
209
+        cs.setGradeid(N_Utils.obj2Int(exam.get("gradeid")));
210
+        cs.setYear(N_Utils.obj2Int(exam.get("year")));
211
+    }
212
+
213
+    /**
214
+     * @Description 学生搜索列表
215
+     * @Date 2024/10/22 17:05
216
+     * @Author YWX
217
+     * @Param [cs]
218
+     * @Return java.util.List<java.util.Map>
219
+     **/
220
+    public List<Map> searchStudent(CStudentVo cs) {
221
+        setParam(cs);
222
+        return msClassStudentMapper.searchStudent(cs);
223
+    }
53 224
 }

+ 32
- 0
smarking/src/main/java/com/xhkjedu/smarking/vo/exam/CStudentVo.java View File

@@ -0,0 +1,32 @@
1
+package com.xhkjedu.smarking.vo.exam;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * @Description 班级学生信息
7
+ * @Author YWX
8
+ * @Date 2024/10/21 17:36
9
+ **/
10
+@Data
11
+public class CStudentVo {
12
+    //阅卷考试学生ID
13
+    private Integer mcsid;
14
+    //考试id
15
+    private Integer examid;
16
+    //科目id
17
+    private String subjectid;
18
+    //班级id
19
+    private Integer classid;
20
+    //学生id
21
+    private Integer studentid;
22
+    //班级类型1行政班2虚拟班
23
+    private Integer classtype;
24
+    //学校id
25
+    private Integer schoolid;
26
+    //学校当前年份
27
+    private Integer year;
28
+    //年级
29
+    private Integer gradeid;
30
+    //学生姓名
31
+    private String studentname;
32
+}

+ 27
- 0
smarking/src/main/java/com/xhkjedu/smarking/vo/exam/SCStudentVo.java View File

@@ -0,0 +1,27 @@
1
+package com.xhkjedu.smarking.vo.exam;
2
+
3
+import com.xhkjedu.smarking.model.exam.MsClassStudent;
4
+import lombok.Data;
5
+
6
+import java.util.List;
7
+
8
+/**
9
+ * @Description 阅卷考试学生表
10
+ * @Author auto
11
+ * @Date 2024-10-15
12
+ */
13
+@Data
14
+public class SCStudentVo {
15
+    //阅卷考试学生ID
16
+    private Integer mcsid;
17
+    //考试id
18
+    private Integer examid;
19
+    //科目ID
20
+    private List<String> subjectids;
21
+    //班级id
22
+    private List<Integer> classids;
23
+    //班级id
24
+    private Integer classid;
25
+    //学生列表
26
+    private List<MsClassStudent> students;
27
+}

+ 7
- 0
smarking/src/main/resources/mapper/exam/MsClassMapper.xml View File

@@ -1,6 +1,13 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.smarking.mapper.exam.MsClassMapper">
4
+    <insert id="batchSave">
5
+        insert ignore into ms_class(examid,subjectid,classid,classname,schoolid)
6
+        values
7
+        <foreach collection="list" item="item" separator=",">
8
+            (#{item.examid},#{item.subjectid},#{item.classid},#{item.classname},#{item.schoolid})
9
+        </foreach>
10
+    </insert>
4 11
     <!--获取班级基本信息列表-->
5 12
     <select id="listByClassIds" resultType="com.xhkjedu.smarking.model.exam.MsClass">
6 13
         select classid,classname,schoolid from t_class

+ 69
- 4
smarking/src/main/resources/mapper/exam/MsClassStudentMapper.xml View File

@@ -1,6 +1,14 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.smarking.mapper.exam.MsClassStudentMapper">
4
+    <!--批量保存考试学生信息-->
5
+    <insert id="batchSave">
6
+        insert ignore into ms_class_student(examid,subjectid,classid,studentid)
7
+        values
8
+        <foreach collection="list" item="item" separator=",">
9
+            (#{item.examid},#{item.subjectid},#{item.classid},#{item.studentid})
10
+        </foreach>
11
+    </insert>
4 12
     <!--根据班级ids获取没有考号学生数量-->
5 13
     <select id="getNoExamNoNumByClassIds" resultType="java.lang.Integer">
6 14
         select count(u.userid) from t_class_student cs left join t_user u on cs.studentid=u.userid
@@ -8,7 +16,7 @@
8 16
         <foreach collection="classids" item="classid" index="index" open="(" separator="," close=")">
9 17
             ${classid}
10 18
         </foreach>
11
-        and (u.examno='' or u.examno is null)
19
+        and u.userstate=1 and (u.examno is null or u.examno='')
12 20
     </select>
13 21
     <!--获取考试关联学校的准备考号长度-->
14 22
     <select id="listSchoolExamNoLength" resultType="java.lang.Integer">
@@ -22,11 +30,13 @@
22 30
     </select>
23 31
     <!--获取班级学生列表-->
24 32
     <select id="listByClassIds" resultType="com.xhkjedu.smarking.model.exam.MsClassStudent">
25
-        select classid,studentid from t_class_student
33
+        select classid,studentid
34
+        from t_class_student cs left join t_user u on cs.studentid=u.userid
26 35
         where classid in
27 36
         <foreach collection="classids" item="classid" index="index" open="(" separator="," close=")">
28 37
             ${classid}
29 38
         </foreach>
39
+        and u.usertype=2 and u.userstate=1
30 40
     </select>
31 41
     <!--根据考号搜索参加考试学生-->
32 42
     <select id="listStudentByExamIdAnExamno" resultType="java.util.Map">
@@ -40,7 +50,7 @@
40 50
     </select>
41 51
     <!--考生信息列表-->
42 52
     <select id="listAll" resultType="java.util.Map">
43
-        select es.mcsid,es.classid,es.subjectid,u.username,u.examno,u.usersex,ec.classname
53
+        select es.mcsid,es.examid,es.classid,es.subjectid,u.username,u.examno,u.usersex,ec.classname
44 54
         from ms_class_student es left join t_user u on es.studentid = u.userid
45 55
         left join ms_class ec on es.classid=ec.classid and es.examid=ec.examid and es.subjectid=ec.subjectid
46 56
         where es.examid=#{cs.examid} and ec.schoolid=#{cs.schoolid}
@@ -55,5 +65,60 @@
55 65
         </if>
56 66
         order by es.mcsid desc
57 67
     </select>
58
-
68
+    <!--根据学生ids获取没有考号学生数量-->
69
+    <select id="getNoExamNoNumByStudentIds" resultType="java.lang.Integer">
70
+        select count(u.userid) from t_user u
71
+        where u.userid in
72
+        <foreach collection="studentIds" item="studentid" index="index" open="(" separator="," close=")">
73
+            ${studentid}
74
+        </foreach>
75
+        and (u.examno is null or u.examno='')
76
+    </select>
77
+    <!--根据科目和学生id获取班级id-->
78
+    <select id="listBySubjectIdAndStuId" resultType="java.lang.Integer">
79
+        select classid from ms_class_student where examid=#{cs.examid} and subjectid=#{cs.subjectid} and studentid=#{cs.studentid}
80
+    </select>
81
+    <!--考试班级列表-->
82
+    <select id="listClass" resultType="java.util.Map">
83
+        select c.classid,c.classname,count(distinct cs.studentid) as classnum
84
+        from ms_class c left join ms_class_student cs on c.examid=cs.examid and c.classid=cs.classid
85
+        where c.examid=#{cs.examid}
86
+        group by c.classid
87
+        order by c.mcid
88
+    </select>
89
+    <!--班级搜索列表-->
90
+    <select id="searchClass" resultType="java.util.Map">
91
+        select c.classid,c.classname,count(distinct cs.studentid) as classnum
92
+        ,count(distinct if((u.examno is null or u.examno=''),u.userid,null)) as noexamnum
93
+        from t_class c left join t_class_student cs on c.classid=cs.classid
94
+        left join t_user u on cs.studentid=u.userid
95
+        where c.schoolid=#{cs.schoolid} and c.classtype=#{cs.classtype} and c.classstate=1
96
+        and c.gradeid=#{cs.gradeid} and c.year=#{cs.year}
97
+        and u.userstate=1 and u.usertype=2
98
+        group by c.classid
99
+        having classnum>0
100
+    </select>
101
+    <!--学生搜索列表-->
102
+    <select id="searchStudent" resultType="java.util.Map">
103
+        select cs.classid,c.classname,cs.studentid,u.examno
104
+        from t_class c right join t_class_student cs on c.classid=cs.classid
105
+        left join t_user u on cs.studentid=u.userid
106
+        where c.schoolid=#{cs.schoolid} and c.classtype=#{cs.classtype} and c.classstate=1
107
+        and c.gradeid=#{cs.gradeid} and c.year=#{cs.year}
108
+        and u.userstate=1 and u.usertype=2
109
+        group by cs.classid,cs.studentid
110
+    </select>
111
+    <!--移除单个科目学生-->
112
+    <delete id="deleteByStu">
113
+        delete ps.*,cs.*
114
+        from ms_class_student cs left join ms_paper_student ps on cs.examid=ps.examid and cs.subjectid=ps.subjectid and cs.studentid=ps.studentid
115
+        where cs.examid=#{cs.examid} and cs.studentid=#{cs.studentid}
116
+    </delete>
117
+    <!--移除班级学生-->
118
+    <delete id="deleteByClass">
119
+        delete ps.*,cs.*,c.*
120
+        from ms_class c left join ms_class_student cs on c.examid=cs.examid and c.classid=cs.classid
121
+                        left join ms_paper_student ps on cs.examid=ps.examid and cs.studentid=ps.studentid
122
+        where c.examid=#{c.examid} and c.classid=#{c.classid}
123
+    </delete>
59 124
 </mapper>

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

@@ -50,7 +50,7 @@
50 50
     <!--考试基本信息-->
51 51
     <select id="findById" resultType="java.util.Map">
52 52
         select examid,examname,gradeid,examdate,examtype,exammode,monitored,examstate,teashowrank,stushowrank,stuzero,examcomm
53
-        ,fixedscore,schoolid,hashb
53
+        ,fixedscore,schoolid,hashb,year
54 54
         from ms_exam where examid=#{examid}
55 55
     </select>
56 56
 </mapper>

+ 5
- 0
smarking/src/main/resources/mapper/paper/MsPaperMapper.xml View File

@@ -80,5 +80,10 @@
80 80
     <select id="getPaperBaseByMsid" resultType="com.xhkjedu.smarking.model.paper.MsPaper">
81 81
         select p.* from ms_paper p left join ms_subject s on s.msid=p.msid where s.msid=#{msid}
82 82
     </select>
83
+    <!--根据考试id和科目id获取试卷信息-->
84
+    <select id="getPaperByExamIdAndSubjectId" resultType="com.xhkjedu.smarking.model.paper.MsPaper">
85
+        select mpid, examid, msid, subjectid, ptype, pnum, pscore, answered, hasfile, hearnum, hearfile
86
+        from ms_paper where examid=#{examid} and subjectid=#{subjectid}
87
+    </select>
83 88
 
84 89
 </mapper>

+ 13
- 0
smarking/src/main/resources/mapper/stupaper/MsPaperStudentMapper.xml View File

@@ -1,4 +1,17 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentMapper">
4
+    <!--批量保存学生试卷-->
5
+    <insert id="batchSave">
6
+        insert ignore into ms_paper_student (examid,subjectid,classid,studentid)
7
+        values
8
+        <foreach collection="list" item="item" separator=",">
9
+            (#{item.examid},#{item.subjectid},#{item.classid},#{item.studentid})
10
+        </foreach>
11
+    </insert>
12
+    <!--获取学生科目试卷状态-->
13
+    <select id="getStateByStudentIdAndSubjectId" resultType="java.lang.Integer">
14
+        select sstate
15
+        from ms_paper_student where examid=#{cs.examid} and subjectid=#{cs.subjectid} and studentid=#{cs.studentid}
16
+    </select>
4 17
 </mapper>

Loading…
Cancel
Save