Browse Source

阅卷、监考设置教师查找不限制班级

tags/正式版本
雍文秀 2 years ago
parent
commit
8de76b300c

+ 6
- 8
sexam/src/main/java/com/xhkjedu/sexam/controller/exam/ESubjectSearchController.java View File

@@ -3,7 +3,6 @@ package com.xhkjedu.sexam.controller.exam;
3 3
 import com.xhkjedu.sexam.model.exam.EBase;
4 4
 import com.xhkjedu.sexam.model.exam.EClassStudent;
5 5
 import com.xhkjedu.sexam.model.exam.ESubject;
6
-import com.xhkjedu.sexam.model.exam.ESubjectInvigilate;
7 6
 import com.xhkjedu.sexam.service.exam.ESubjectSearchService;
8 7
 import com.xhkjedu.utils.N_Utils;
9 8
 import com.xhkjedu.vo.ResultVo;
@@ -38,10 +37,9 @@ public class ESubjectSearchController {
38 37
      **/
39 38
     @PostMapping("/list_st")
40 39
     public ResultVo listSearchTeacher(@RequestBody EBase base) {
41
-        Integer examid = base.getExamid();
42 40
         Integer schoolid = base.getSchoolid();
43
-        N_Utils.validation(new Object[]{examid, "考试id", 1, schoolid, "学校id", 1});
44
-        List<Map> list = eSubjectSearchService.listSearchTeacher(examid, schoolid);
41
+        N_Utils.validation(new Object[]{schoolid, "学校id", 1});
42
+        List<Map> list = eSubjectSearchService.listSearchTeacher(schoolid);
45 43
         return new ResultVo(0, "获取成功", list);
46 44
     }
47 45
 
@@ -54,11 +52,11 @@ public class ESubjectSearchController {
54 52
      * @Date 2022/7/19 14:33
55 53
      **/
56 54
     @PostMapping("/list_qt")
57
-    public ResultVo listQuickTeacher(@RequestBody ESubjectInvigilate subject) {
55
+    public ResultVo listQuickTeacher(@RequestBody EBase subject) {
58 56
         String username = subject.getCreatename();
59
-        Integer classid = subject.getClassid();
60
-        N_Utils.validation(new Object[]{username, "姓名", 2});
61
-        Map list = eSubjectSearchService.listQuickTeacher(username, classid);
57
+        Integer schoolid = subject.getSchoolid();
58
+        N_Utils.validation(new Object[]{username, "姓名", 2, schoolid, "学校id", 1});
59
+        Map list = eSubjectSearchService.listQuickTeacher(username, schoolid);
62 60
         return new ResultVo(0, "获取成功", list);
63 61
     }
64 62
 

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

@@ -30,8 +30,8 @@ public interface EClassMapper extends TkMapper<EClass> {
30 30
     //获取学校所有教师
31 31
     List<CTeacherVo> listTeacherBySchoolId(@Param("schoolid") Integer schoolid);
32 32
 
33
-    //班级教师查找
34
-    List<Map> listSearchTeacher(@Param("usernames") String[] usernames, @Param("classid") Integer classid);
33
+    //学校教师查找
34
+    List<Map> listSearchTeacher(@Param("usernames") String[] usernames, @Param("schoolid") Integer schoolid);
35 35
 
36 36
     //按班设置教师列表
37 37
     List<Map> listClassTeacher(@Param("classids") String classids, @Param("subjectid") String subjectid);

+ 17
- 35
sexam/src/main/java/com/xhkjedu/sexam/service/exam/ESubjectSearchService.java View File

@@ -33,54 +33,36 @@ public class ESubjectSearchService {
33 33
     private EPaperCorrectquestionMapper ePaperCorrectquestionMapper;
34 34
 
35 35
     //查找设置
36
-    public List<Map> listSearchTeacher(Integer examid, Integer schoolid) {
37
-        List<Map> classes = eClassMapper.listByExamId(examid);
38
-        String classids = classes.stream().map(c -> c.get("classid").toString()).collect(Collectors.joining(","));
39
-        List<CTeacherVo> teachers = eClassMapper.listTeacherByClassIds(classids);//获取班级教师
40
-        String teacherids =
41
-                teachers.stream().map((CTeacherVo::getTeacherid)).map(String::valueOf).distinct().collect(Collectors.joining(","
42
-                ));
36
+    public List<Map> listSearchTeacher(Integer schoolid) {
37
+        List<CTeacherVo> users = eClassMapper.listTeacherBySchoolId(schoolid);//获取学校所有教师
38
+        String teacherids = users.stream().map(u -> u.getTeacherid().toString()).collect(Collectors.joining(","));
43 39
         List<CTeacherVo> subjects = eClassMapper.listSubjectByTeacherIds(teacherids);//获取教师科目
44 40
         String subjectids = subjects.stream().map(CTeacherVo::getSubjectid).distinct().collect(Collectors.joining("','"));
45 41
         List<CTeacherVo> subjects2 = eClassMapper.listSubjectBySubjectIds(subjectids);
46
-        Map<String, String> subjectNameMap = subjects2.stream().collect(Collectors.toMap(CTeacherVo::getSubjectid,
47
-                CTeacherVo::getSubjectname));
48 42
         Map<Integer, String> subjectMap = subjects.stream().collect(Collectors.toMap(CTeacherVo::getTeacherid,
49 43
                 CTeacherVo::getSubjectid));
50
-        List<CTeacherVo> users = eClassMapper.listTeacherBySchoolId(schoolid);//获取学校所有教师
51
-        for (CTeacherVo teacher : teachers) {
52
-            CTeacherVo vo = users.stream().filter(u -> u.getTeacherid().equals(teacher.getTeacherid())).findFirst().orElse(null);
53
-            if (vo != null) {
54
-                teacher.setUsername(vo.getUsername());
55
-                teacher.setLoginname(vo.getLoginname());
56
-                teacher.setUsersex(vo.getUsersex());
57
-            }
44
+        for (CTeacherVo teacher : users) {
58 45
             teacher.setSubjectid(subjectMap.get(teacher.getTeacherid()));
59 46
         }
60
-        for (Map cmap : classes) {
61
-            Integer classid = (Integer) cmap.get("classid");
62
-            LinkedHashMap<String, List<CTeacherVo>> scollect = teachers.stream()
63
-                    .filter(t -> t.getClassid().equals(classid) && t.getUsername() != null && t.getSubjectid() != null)
64
-                    .collect(Collectors.groupingBy(t -> t.getSubjectid(), LinkedHashMap::new, Collectors.toList()));
65
-            List<Map> subjectTeachers = new ArrayList<>();
66
-            for (Map.Entry<String, List<CTeacherVo>> entry : scollect.entrySet()) {
67
-                String subjectid = entry.getKey();
68
-                Map st = new HashMap();
69
-                st.put("subjectid", subjectid);
70
-                st.put("subjectname", subjectNameMap.get(subjectid));
71
-                st.put("teachers", entry.getValue());
72
-                subjectTeachers.add(st);
73
-            }
74
-            cmap.put("subjectTeachers", subjectTeachers);
47
+        List<Map> subjectTeachers = new ArrayList<>();
48
+        List<CTeacherVo> teachers;
49
+        for (CTeacherVo s : subjects2) {
50
+            String subjectid = s.getSubjectid();
51
+            teachers = users.stream().filter(u -> subjectid.equals(u.getSubjectid())).collect(Collectors.toList());
52
+            Map st = new HashMap();
53
+            st.put("subjectid", subjectid);
54
+            st.put("subjectname", s.getSubjectname());
55
+            st.put("teachers", teachers);
56
+            subjectTeachers.add(st);
75 57
         }
76
-        return classes;
58
+        return subjectTeachers;
77 59
     }
78 60
 
79 61
     //快捷设置
80
-    public Map listQuickTeacher(String username, Integer classid) {
62
+    public Map listQuickTeacher(String username, Integer schoolid) {
81 63
         Map map = new HashMap();
82 64
         String[] usernames = username.split(",");
83
-        List<Map> teachers = eClassMapper.listSearchTeacher(usernames, classid);
65
+        List<Map> teachers = eClassMapper.listSearchTeacher(usernames, schoolid);
84 66
         Map<String, Object> nameMap = teachers.stream().map(t-> t.get("username").toString()).distinct().collect(Collectors.toMap(t->t,t->t));
85 67
         StringBuilder sb = new StringBuilder();
86 68
         for (String name : usernames) {

+ 5
- 7
sexam/src/main/resources/mapper/exam/EClassMapper.xml View File

@@ -39,17 +39,15 @@
39 39
     <select id="listTeacherBySchoolId" resultType="com.xhkjedu.sexam.vo.exam.CTeacherVo">
40 40
         select userid teacherid,username,loginname,usersex from t_user where schoolid=#{schoolid} and usertype=1 and userstate=1
41 41
     </select>
42
-    <!--班级教师查找-->
42
+    <!--学校教师查找-->
43 43
     <select id="listSearchTeacher" resultType="java.util.Map">
44
-        select ct.teacherid,u.username,u.loginname,u.usersex,sb.subjectid
45
-        from t_class_teacher ct left join t_user u on ct.teacherid = u.userid
46
-        left join t_teacher_powersb tp on tp.teacherid=ct.teacherid
47
-        left join t_subject_book sb on tp.lsbid = sb.lsbid
48
-        where ct.classid=#{classid} and u.usertype=1 and u.userstate=1 and u.username in
44
+        select u.userid teacherid,u.username,u.loginname,u.usersex
45
+        from t_user u
46
+        where u.schoolid=#{schoolid} and u.usertype=1 and u.userstate=1 and u.username in
49 47
         <foreach collection="usernames" item="username" open="(" separator="," close=")">
50 48
             #{username}
51 49
         </foreach>
52
-        group by ct.teacherid
50
+        group by u.userid
53 51
     </select>
54 52
 
55 53
     <!--按班设置教师列表-->

Loading…
Cancel
Save