|
@@ -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) {
|