Selaa lähdekoodia

获取考试设置状态、用户信息获取用实体类接收

tags/正式版本
雍文秀 2 vuotta sitten
vanhempi
commit
05b77ef788

+ 25
- 8
sexam/src/main/java/com/xhkjedu/sexam/controller/exam/EBaseController.java Näytä tiedosto

@@ -13,6 +13,7 @@ import com.xhkjedu.sexam.service.exam.EBaseService;
13 13
 import com.xhkjedu.sexam.service.notice.NoticeService;
14 14
 import com.xhkjedu.sexam.vo.exam.EBaseVo;
15 15
 import com.xhkjedu.sexam.vo.exam.ExamVo;
16
+import com.xhkjedu.sexam.vo.system.UserVo;
16 17
 import com.xhkjedu.utils.N_Utils;
17 18
 import com.xhkjedu.utils.PageUtil;
18 19
 import com.xhkjedu.vo.PageResult;
@@ -178,7 +179,7 @@ public class EBaseController {
178 179
         if (exam.getWwcnum() != 0) return new ResultVo(1, "还有考试试卷未设置完成");
179 180
         if (exam.getExamstate() != 0) return new ResultVo(0, "发布成功");
180 181
 
181
-        List<Map> students = eBaseService.listStuByExamId(examid);//获取考生
182
+        List<UserVo> students = eBaseService.listStuByExamId(examid);//获取考生
182 183
         eBaseService.updateExamStateStart(examid, examcomm, students);//发布考试
183 184
 
184 185
         if (notice == 2 && msg == 2) return new ResultVo(0, "发布成功");
@@ -190,7 +191,7 @@ public class EBaseController {
190 191
         String noticetitle = examname + "-考试公告";
191 192
         List<Map> classes = eBaseService.listClass(examid);
192 193
         String classids = classList.stream().map(c -> c.getClassid().toString()).collect(Collectors.joining(","));
193
-        List<Map> teachers = eBaseService.listTeacherByClassIds(classids);//获取考试班级任教老师
194
+        List<UserVo> teachers = eBaseService.listTeacherByClassIds(classids);//获取考试班级任教老师
194 195
         if (notice == 1) {
195 196
             for (Map s : classes) {
196 197
                 TNoticeClass nt = new TNoticeClass();
@@ -204,9 +205,9 @@ public class EBaseController {
204 205
             n.setClasses(classList);
205 206
             noticeList.add(n);
206 207
 
207
-            for (Map t : teachers) {
208
+            for (UserVo t : teachers) {
208 209
                 TNoticeTeacher nt = new TNoticeTeacher();
209
-                nt.setTeacherid((Integer) t.get("teacherid"));
210
+                nt.setTeacherid(t.getUserid());
210 211
                 teacherList.add(nt);
211 212
             }
212 213
             TNotice n2 = new TNotice();
@@ -218,16 +219,16 @@ public class EBaseController {
218 219
         }
219 220
         if (msg == 1) {
220 221
             String msgtxt = noticetitle + "\n" + examcomm;
221
-            List<String> userphones = students.stream().filter(s -> N_Utils.isNotEmpty(s.get("userphone")))
222
-                    .map(s -> s.get("userphone").toString()).collect(Collectors.toList());
222
+            List<String> userphones = students.stream().filter(s -> N_Utils.isNotEmpty(s.getUserphone()))
223
+                    .map(s -> s.getUserphone()).collect(Collectors.toList());
223 224
             for (String userphone : userphones) {
224 225
                 TMsg m = new TMsg();
225 226
                 m.setMsgtxt(msgtxt);
226 227
                 m.setUserphone(userphone);
227 228
                 msgList.add(m);
228 229
             }
229
-            userphones = teachers.stream().filter(s -> N_Utils.isNotEmpty(s.get("userphone")))
230
-                    .map(s -> s.get("userphone").toString()).collect(Collectors.toList());
230
+            userphones = teachers.stream().filter(s -> N_Utils.isNotEmpty(s.getUserphone()))
231
+                    .map(s -> s.getUserphone()).collect(Collectors.toList());
231 232
             for (String userphone : userphones) {
232 233
                 TMsg m = new TMsg();
233 234
                 m.setMsgtxt(msgtxt);
@@ -354,4 +355,20 @@ public class EBaseController {
354 355
         eBaseService.setSubjectTeacher(subject);
355 356
         return new ResultVo(0, "设置成功");
356 357
     }
358
+
359
+    /**
360
+     * 考试设置状态
361
+     *
362
+     * @return com.xhkjedu.vo.ResultVo
363
+     * @Param [eBase]
364
+     * @Author ywx
365
+     * @Date 2022/7/28 9:37
366
+     **/
367
+    @PostMapping("/get_set")
368
+    public ResultVo getSetState(@RequestBody EBase eBase) {
369
+        Integer examid = eBase.getExamid();
370
+        N_Utils.validation(new Object[]{examid, "考试id", 1});
371
+        Map map = eBaseService.getSetState(examid);
372
+        return new ResultVo(0, "获取考试设置状态成功", map);
373
+    }
357 374
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/exam/EBaseMapper.java Näytä tiedosto

@@ -35,4 +35,7 @@ public interface EBaseMapper extends TkMapper<EBase> {
35 35
 
36 36
     //根据考试id获取考试状态信息
37 37
     EBaseVo getExamStateById(@Param("examid") Integer examid);
38
+
39
+    //考试设置状态
40
+    Map getSetState(@Param("examid") Integer examid);
38 41
 }

+ 4
- 4
sexam/src/main/java/com/xhkjedu/sexam/mapper/system/UserMapper.java Näytä tiedosto

@@ -1,17 +1,17 @@
1 1
 package com.xhkjedu.sexam.mapper.system;
2 2
 
3
+import com.xhkjedu.sexam.vo.system.UserVo;
3 4
 import org.apache.ibatis.annotations.Param;
4 5
 
5 6
 import java.util.List;
6
-import java.util.Map;
7 7
 
8 8
 public interface UserMapper {
9 9
     //根据用户ids查找手机号
10
-    List<Map> listPhoneByUserIds(@Param("userids") List<Integer> userids);
10
+    List<UserVo> listPhoneByUserIds(@Param("userids") List<Integer> userids);
11 11
 
12 12
     //获取考生
13
-    List<Map> listStuByExamId(@Param("examid") Integer examid);
13
+    List<UserVo> listStuByExamId(@Param("examid") Integer examid);
14 14
 
15 15
     //获取考试班级任教老师
16
-    List<Map> listTeacherByClassIds(@Param("classids") String classids);
16
+    List<UserVo> listTeacherByClassIds(@Param("classids") String classids);
17 17
 }

+ 12
- 6
sexam/src/main/java/com/xhkjedu/sexam/service/exam/EBaseService.java Näytä tiedosto

@@ -14,6 +14,7 @@ import com.xhkjedu.sexam.model.exam.ESubject;
14 14
 import com.xhkjedu.sexam.model.paper.EPaper;
15 15
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudent;
16 16
 import com.xhkjedu.sexam.vo.exam.EBaseVo;
17
+import com.xhkjedu.sexam.vo.system.UserVo;
17 18
 import com.xhkjedu.utils.N_Utils;
18 19
 import com.xhkjedu.vo.ResultVo;
19 20
 import lombok.extern.slf4j.Slf4j;
@@ -148,7 +149,7 @@ public class EBaseService {
148 149
 
149 150
     //发布考试
150 151
     @Transactional(rollbackFor = Exception.class)
151
-    public void updateExamStateStart(Integer examid, String examcomm, List<Map> students) {
152
+    public void updateExamStateStart(Integer examid, String examcomm, List<UserVo> students) {
152 153
         //更改考试状态
153 154
         eBaseMapper.postExam(examid, examcomm);
154 155
         //发布考试,获取考试试卷题量和分值
@@ -160,13 +161,13 @@ public class EBaseService {
160 161
             Integer epid = paper.getEpid();
161 162
             Integer pnum = paper.getPnum();
162 163
             Double pscore = paper.getPscore();
163
-            for (Map student : students) {
164
+            for (UserVo student : students) {
164 165
                 EPaperStudent es = new EPaperStudent();
165 166
                 es.setExamid(examid);
166 167
                 es.setEsid(esid);
167 168
                 es.setEpid(epid);
168
-                es.setClassid((Integer) student.get("classid"));
169
-                es.setStudentid((Integer) student.get("userid"));
169
+                es.setClassid(student.getClassid());
170
+                es.setStudentid(student.getUserid());
170 171
                 es.setSstate(0);
171 172
                 es.setChecked(0);
172 173
                 es.setNum(pnum);
@@ -236,7 +237,7 @@ public class EBaseService {
236 237
     }
237 238
 
238 239
     //获取考生
239
-    public List<Map> listStuByExamId(Integer examid) {
240
+    public List<UserVo> listStuByExamId(Integer examid) {
240 241
         return userMapper.listStuByExamId(examid);
241 242
     }
242 243
 
@@ -250,7 +251,7 @@ public class EBaseService {
250 251
         return eSubjectMapper.countNoCompletePaper(examid);
251 252
     }
252 253
 
253
-    public List<Map> listTeacherByClassIds(String classids) {
254
+    public List<UserVo> listTeacherByClassIds(String classids) {
254 255
         return userMapper.listTeacherByClassIds(classids);
255 256
     }
256 257
 
@@ -258,4 +259,9 @@ public class EBaseService {
258 259
     public void setSubjectTeacher(ESubject subject) {
259 260
         eSubjectMapper.updateByPrimaryKeySelective(subject);
260 261
     }
262
+
263
+    //考试设置状态
264
+    public Map getSetState(Integer examid) {
265
+        return eBaseMapper.getSetState(examid);
266
+    }
261 267
 }

+ 5
- 4
sexam/src/main/java/com/xhkjedu/sexam/service/notice/NoticeService.java Näytä tiedosto

@@ -13,6 +13,7 @@ import com.xhkjedu.sexam.model.notice.TNoticeSchool;
13 13
 import com.xhkjedu.sexam.model.notice.TNoticeTeacher;
14 14
 import com.xhkjedu.sexam.utils.SMSSender;
15 15
 import com.xhkjedu.sexam.vo.exam.ZtMsgVo;
16
+import com.xhkjedu.sexam.vo.system.UserVo;
16 17
 import com.xhkjedu.utils.N_Utils;
17 18
 import org.springframework.stereotype.Service;
18 19
 import org.springframework.transaction.annotation.Transactional;
@@ -103,13 +104,13 @@ public class NoticeService {
103 104
                 }
104 105
             } else {//通知对象2老师
105 106
                 List<Integer> userids = msgList.stream().map(m -> m.getUserid()).distinct().collect(Collectors.toList());
106
-                List<Map> users = userMapper.listPhoneByUserIds(userids);//根据用户ids查找手机号
107
+                List<UserVo> users = userMapper.listPhoneByUserIds(userids);//根据用户ids查找手机号
107 108
                 Map<Integer, TMsg> msgMap = msgList.stream().collect(Collectors.toMap(m -> m.getUserid(), m -> m));
108 109
                 for (int i = 0; i < users.size(); i++) {
109
-                    Map u = users.get(i);
110
-                    String userphone = u.get("userphone").toString();
110
+                    UserVo u = users.get(i);
111
+                    String userphone = u.getUserphone();
111 112
                     if (N_Utils.isEmpty(userphone)) continue;
112
-                    TMsg m = msgMap.get(u.get("userid"));
113
+                    TMsg m = msgMap.get(u.getUserid());
113 114
                     m.setUserphone(userphone);
114 115
                     m.setCreatetime(createtime);
115 116
                     msgs.add(m);

+ 17
- 0
sexam/src/main/java/com/xhkjedu/sexam/vo/system/UserVo.java Näytä tiedosto

@@ -0,0 +1,17 @@
1
+package com.xhkjedu.sexam.vo.system;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * @author ywx
7
+ * @className UserVo
8
+ * @description 用户
9
+ * @date 2022/7/28 9:45
10
+ **/
11
+@Data
12
+public class UserVo {
13
+    private Integer userid;//用户id
14
+    private String username;//姓名
15
+    private String userphone;//手机号
16
+    private Integer classid;//班级id
17
+}

+ 13
- 0
sexam/src/main/resources/mapper/exam/EBaseMapper.xml Näytä tiedosto

@@ -67,4 +67,17 @@
67 67
         from e_base eb left join e_subject es on eb.examid = es.examid
68 68
         where eb.examid=#{examid}
69 69
     </select>
70
+    <!--考试设置状态-->
71
+    <select id="getSetState" resultType="java.util.Map">
72
+        select count(distinct case when es.begintime is null or es.begintime='' then es.esid else null end)esnum
73
+        ,min(es.esstate)esstate,min(ifnull(ep.correcttype,0))correcttype
74
+        ,(case when b.exammode=1 then (count(distinct es.esid)-count(distinct ei.esid))
75
+        else (select sum(ec.classnum)-count(ps.epsid) from e_class ec
76
+        left join e_paper_student ps on ec.examid=ps.examid and ps.sstate in(0,1)
77
+        where ec.examid=b.examid) end)papernum
78
+        from e_base b left join e_subject es on es.examid=b.examid
79
+        left join e_paper ep on ep.esid = es.esid
80
+        left join e_subject_invigilate ei on ei.esid = es.esid
81
+        where b.examid=#{examid}
82
+    </select>
70 83
 </mapper>

+ 1
- 1
sexam/src/main/resources/mapper/exam/ESubjectMapper.xml Näytä tiedosto

@@ -39,7 +39,7 @@
39 39
     <!--考试科目设置列表-->
40 40
     <select id="listSubjectSet" resultType="java.util.Map">
41 41
         select es.subjectid,es.subjectname,es.sdate,es.begintime,es.endtime,es.esstate
42
-        ,ep.correcttype
42
+        ,ep.correcttype,es.esid,ep.epid
43 43
         ,(select count(*) from e_subject_invigilate ei where ei.esid=es.esid)jkjsnum
44 44
         ,count(case when eps.sstate=3 then eps.epsid else null end)qknum
45 45
         ,count(case when eps.sstate=2 then eps.epsid else null end)tjnum

+ 3
- 3
sexam/src/main/resources/mapper/system/UserMapper.xml Näytä tiedosto

@@ -2,21 +2,21 @@
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.sexam.mapper.system.UserMapper">
4 4
     <!--根据用户ids查找手机号-->
5
-    <select id="listPhoneByUserIds" resultType="java.util.Map">
5
+    <select id="listPhoneByUserIds" resultType="com.xhkjedu.sexam.vo.system.UserVo">
6 6
         select userid,userphone from t_user where userid in
7 7
         <foreach collection="userids" item="userid" open="(" separator="," close=")">
8 8
             ${userid}
9 9
         </foreach>
10 10
     </select>
11 11
     <!--获取考生-->
12
-    <select id="listStuByExamId" resultType="java.util.Map">
12
+    <select id="listStuByExamId" resultType="com.xhkjedu.sexam.vo.system.UserVo">
13 13
         select u.userid,u.userphone,ec.classid
14 14
         from e_class ec left join t_class_student cs on ec.classid = cs.classid
15 15
         left join t_user u on cs.studentid = u.userid
16 16
         where ec.examid=#{examid}
17 17
     </select>
18 18
     <!--获取考试班级任教老师-->
19
-    <select id="listTeacherByClassIds" resultType="java.util.Map">
19
+    <select id="listTeacherByClassIds" resultType="com.xhkjedu.sexam.vo.system.UserVo">
20 20
         select u.userid,u.userphone
21 21
         from t_class_teacher ct left join t_user u on ct.studentid = u.userid
22 22
         where ct.classid in(${classids}) and u.userstate=1

Loading…
Peruuta
Tallenna