|
@@ -3,6 +3,7 @@ package com.xhkjedu.sexam.service.exam;
|
3
|
3
|
import com.xhkjedu.sexam.mapper.exam.EBaseMapper;
|
4
|
4
|
import com.xhkjedu.sexam.mapper.exam.EClassMapper;
|
5
|
5
|
import com.xhkjedu.sexam.mapper.exam.ESubjectMapper;
|
|
6
|
+import com.xhkjedu.sexam.mapper.system.UserMapper;
|
6
|
7
|
import com.xhkjedu.sexam.vo.exam.CTeacherVo;
|
7
|
8
|
import org.springframework.stereotype.Service;
|
8
|
9
|
|
|
@@ -22,18 +23,24 @@ public class ESubjectSearchService {
|
22
|
23
|
private EBaseMapper eBaseMapper;
|
23
|
24
|
@Resource
|
24
|
25
|
private ESubjectMapper eSubjectMapper;
|
|
26
|
+ @Resource
|
|
27
|
+ private UserMapper userMapper;
|
25
|
28
|
|
26
|
29
|
//查找设置
|
27
|
30
|
public List<Map> listSearchTeacher(Integer examid, Integer schoolid) {
|
28
|
31
|
List<Map> classes = eClassMapper.listByExamId(examid);
|
29
|
32
|
String classids = classes.stream().map(c -> c.get("classid").toString()).collect(Collectors.joining(","));
|
30
|
33
|
List<CTeacherVo> teachers = eClassMapper.listTeacherByClassIds(classids);//获取班级教师
|
31
|
|
- String teacherids = teachers.stream().map((CTeacherVo::getTeacherid)).map(String::valueOf).distinct().collect(Collectors.joining(","));
|
|
34
|
+ String teacherids =
|
|
35
|
+ teachers.stream().map((CTeacherVo::getTeacherid)).map(String::valueOf).distinct().collect(Collectors.joining(","
|
|
36
|
+ ));
|
32
|
37
|
List<CTeacherVo> subjects = eClassMapper.listSubjectByTeacherIds(teacherids);//获取教师科目
|
33
|
38
|
String subjectids = subjects.stream().map(CTeacherVo::getSubjectid).distinct().collect(Collectors.joining("','"));
|
34
|
39
|
List<CTeacherVo> subjects2 = eClassMapper.listSubjectBySubjectIds(subjectids);
|
35
|
|
- Map<String, String> subjectNameMap = subjects2.stream().collect(Collectors.toMap(CTeacherVo::getSubjectid, CTeacherVo::getSubjectname));
|
36
|
|
- Map<Integer, String> subjectMap = subjects.stream().collect(Collectors.toMap(CTeacherVo::getTeacherid, CTeacherVo::getSubjectid));
|
|
40
|
+ Map<String, String> subjectNameMap = subjects2.stream().collect(Collectors.toMap(CTeacherVo::getSubjectid,
|
|
41
|
+ CTeacherVo::getSubjectname));
|
|
42
|
+ Map<Integer, String> subjectMap = subjects.stream().collect(Collectors.toMap(CTeacherVo::getTeacherid,
|
|
43
|
+ CTeacherVo::getSubjectid));
|
37
|
44
|
List<CTeacherVo> users = eClassMapper.listTeacherBySchoolId(schoolid);//获取学校所有教师
|
38
|
45
|
for (CTeacherVo teacher : teachers) {
|
39
|
46
|
CTeacherVo vo = users.stream().filter(u -> u.getTeacherid().equals(teacher.getTeacherid())).findFirst().orElse(null);
|
|
@@ -68,7 +75,8 @@ public class ESubjectSearchService {
|
68
|
75
|
Map map = new HashMap();
|
69
|
76
|
String[] usernames = username.split(",");
|
70
|
77
|
List<Map> teachers = eClassMapper.listSearchTeacher(usernames, classid);
|
71
|
|
- Map<String, Object> nameMap = teachers.stream().collect(Collectors.toMap(t -> t.get("username").toString(), t -> t.get("teacherid")));
|
|
78
|
+ Map<String, Object> nameMap = teachers.stream().collect(Collectors.toMap(t -> t.get("username").toString(), t -> t.get(
|
|
79
|
+ "teacherid")));
|
72
|
80
|
StringBuilder sb = new StringBuilder();
|
73
|
81
|
for (String name : usernames) {
|
74
|
82
|
if (nameMap.get(name) == null) {
|
|
@@ -99,4 +107,28 @@ public class ESubjectSearchService {
|
99
|
107
|
map.put("subjects", subjects);
|
100
|
108
|
return map;
|
101
|
109
|
}
|
|
110
|
+
|
|
111
|
+ //主监考人查找
|
|
112
|
+ public List<Map> listMasterTeacher(Integer schoolid) {
|
|
113
|
+ return userMapper.listMasterTeacher(schoolid);
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ //主监考人快捷查找
|
|
117
|
+ public Map listQuickMasterTeacher(Integer schoolid, String username) {
|
|
118
|
+ Map map = new HashMap();
|
|
119
|
+ String[] usernames = username.split(",");
|
|
120
|
+ List<Map> teachers = userMapper.listQuickMasterTeacher(usernames, schoolid);
|
|
121
|
+ Map<String, Object> nameMap = teachers.stream().collect(Collectors.toMap(t -> t.get("username").toString(), t -> t.get(
|
|
122
|
+ "teacherid")));
|
|
123
|
+ StringBuilder sb = new StringBuilder();
|
|
124
|
+ for (String name : usernames) {
|
|
125
|
+ if (nameMap.get(name) == null) {
|
|
126
|
+ sb.append(name).append(",");
|
|
127
|
+ }
|
|
128
|
+ }
|
|
129
|
+ map.put("teachers", teachers);//匹配的教师
|
|
130
|
+ String notExist = sb.toString();//未匹配的教师
|
|
131
|
+ map.put("notExist", notExist.substring(0, notExist.length() - 1));
|
|
132
|
+ return map;
|
|
133
|
+ }
|
102
|
134
|
}
|