Browse Source

Merge remote-tracking branch 'cloud-schoolapi/ywx'

tags/正式版本
王宁 2 years ago
parent
commit
6f30abc0be

+ 2
- 1
sexam/src/main/java/com/xhkjedu/sexam/controller/exam/EBaseController.java View File

@@ -214,7 +214,8 @@ public class EBaseController {
214 214
         if (exam.getExamstate() != 0) return new ResultVo(0, "发布成功");
215 215
 
216 216
         List<UserVo> students = eBaseService.listStuByExamId(examid);//获取考生
217
-        eBaseService.updateExamStateStart(examid, examcomm, students,exam.getExammode());//发布考试
217
+        Integer code = eBaseService.updateExamStateStart(examid, examcomm, students, exam.getExammode());//发布考试
218
+        if (code == 1) return new ResultVo(1, "发布考试失败");
218 219
 
219 220
         if (notice == 2 && msg == 2) return new ResultVo(0, "发布成功");
220 221
 

+ 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);

+ 74
- 67
sexam/src/main/java/com/xhkjedu/sexam/service/exam/EBaseService.java View File

@@ -212,77 +212,84 @@ public class EBaseService {
212 212
 
213 213
     //发布考试
214 214
     @Transactional(rollbackFor = Exception.class)
215
-    public void updateExamStateStart(Integer examid, String examcomm, List<UserVo> students,Integer exammode) {
216
-        //更改考试状态
217
-        eBaseMapper.postExam(examid, examcomm);
218
-        //发布考试,获取考试试卷题量和分值
219
-        List<EPaper> papers = ePaperMapper.listNumAndScoreByExamId(examid);
220
-        List<EPaperStudent> studentList = new ArrayList<>();
221
-        int timestamp = N_Utils.getSecondTimestamp();
222
-        for (EPaper paper : papers) {
223
-            Integer esid = paper.getEsid();
224
-            Integer epid = paper.getEpid();
225
-            Integer pnum = paper.getPnum();
226
-            Double pscore = paper.getPscore();
227
-            String subjectid = paper.getSubjectid();
228
-            for (UserVo student : students) {
229
-                EPaperStudent es = new EPaperStudent();
230
-                es.setExamid(examid);
231
-                es.setEsid(esid);
232
-                es.setEpid(epid);
233
-                es.setSubjectid(subjectid);
234
-                es.setClassid(student.getClassid());
235
-                es.setStudentid(student.getUserid());
236
-                es.setSstate(0);
237
-                es.setChecked(0);
238
-                es.setNum(pnum);
239
-                es.setScore(pscore);
240
-                es.setStuscore(0.0);
241
-                es.setCosttime(0);
242
-                es.setCreatetime(timestamp);
243
-                es.setHasbad(0);
244
-                studentList.add(es);
215
+    public Integer updateExamStateStart(Integer examid, String examcomm, List<UserVo> students,Integer exammode) {
216
+        try {
217
+            //更改考试状态
218
+            eBaseMapper.postExam(examid, examcomm);
219
+            //发布考试,获取考试试卷题量和分值
220
+            List<EPaper> papers = ePaperMapper.listNumAndScoreByExamId(examid);
221
+            List<EPaperStudent> studentList = new ArrayList<>();
222
+            int timestamp = N_Utils.getSecondTimestamp();
223
+            for (EPaper paper : papers) {
224
+                Integer esid = paper.getEsid();
225
+                Integer epid = paper.getEpid();
226
+                Integer pnum = paper.getPnum();
227
+                Double pscore = paper.getPscore();
228
+                String subjectid = paper.getSubjectid();
229
+                for (UserVo student : students) {
230
+                    EPaperStudent es = new EPaperStudent();
231
+                    es.setExamid(examid);
232
+                    es.setEsid(esid);
233
+                    es.setEpid(epid);
234
+                    es.setSubjectid(subjectid);
235
+                    es.setClassid(student.getClassid());
236
+                    es.setStudentid(student.getUserid());
237
+                    es.setSstate(0);
238
+                    es.setChecked(0);
239
+                    es.setNum(pnum);
240
+                    es.setScore(pscore);
241
+                    es.setStuscore(0.0);
242
+                    es.setCosttime(0);
243
+                    es.setCreatetime(timestamp);
244
+                    es.setHasbad(0);
245
+                    studentList.add(es);
246
+                }
245 247
             }
246
-        }
247
-        ePaperStudentMapper.insertList(studentList);//保存考试学生信息
248
-
249
-        //2022-09-26线上线下统计时均需要试题,发布考试时直接把学生和试题关联上
250
-        //代表线下考试,生成学生和试题的关联关系
251
-        List<EPaperStudentQuestion> stuqlist = new ArrayList<>();
252
-        for (EPaper paper : papers) {
253
-            Integer epid = paper.getEpid();
254
-            //获取试卷中所有试题
255
-            List<EPaperQtypeQuestion> queslist = ePaperQtypeQuestionMapper.listQuestionsByEpid(epid);
256
-            //获取该还是卷下试题学生信息
257
-            List<EPaperStudent> paperstulist = studentList.stream().filter(s -> s.getEpid().equals(epid)).collect(Collectors.toList());
258
-            for (EPaperStudent ps : paperstulist) {
259
-                for(EPaperQtypeQuestion q : queslist){
260
-                    EPaperStudentQuestion epsq = new EPaperStudentQuestion();
261
-                    epsq.setClassid(ps.getClassid());
262
-                    epsq.setStudentid(ps.getStudentid());
263
-                    epsq.setExamid(ps.getExamid());
264
-                    epsq.setSubjectid(ps.getSubjectid());
265
-                    epsq.setEpid(epid);
266
-                    epsq.setEpsid(ps.getId());
267
-                    epsq.setEptqid(q.getEptqid());
268
-                    epsq.setCtype(q.getCtype());
269
-                    epsq.setQuestionid(q.getQuestionid());
270
-                    epsq.setQn(q.getQn());
271
-                    epsq.setQorder(q.getQorder());
272
-                    epsq.setAnswered(0);
273
-                    epsq.setAnswertype(0);
274
-                    epsq.setConverted(0);
275
-                    epsq.setCosttime(0);
276
-                    epsq.setQscore(q.getScore());
277
-                    epsq.setStuscore(0.0);
278
-                    epsq.setChecked(0);
279
-                    epsq.setGood(0);
280
-                    epsq.setBad(0);
281
-                    stuqlist.add(epsq);
248
+            ePaperStudentMapper.insertList(studentList);//保存考试学生信息
249
+
250
+            //2022-09-26线上线下统计时均需要试题,发布考试时直接把学生和试题关联上
251
+            //代表线下考试,生成学生和试题的关联关系
252
+            List<EPaperStudentQuestion> stuqlist = new ArrayList<>();
253
+            for (EPaper paper : papers) {
254
+                Integer epid = paper.getEpid();
255
+                //获取试卷中所有试题
256
+                List<EPaperQtypeQuestion> queslist = ePaperQtypeQuestionMapper.listQuestionsByEpid(epid);
257
+                //获取该还是卷下试题学生信息
258
+                List<EPaperStudent> paperstulist = studentList.stream().filter(s -> s.getEpid().equals(epid)).collect(Collectors.toList());
259
+                for (EPaperStudent ps : paperstulist) {
260
+                    for(EPaperQtypeQuestion q : queslist){
261
+                        EPaperStudentQuestion epsq = new EPaperStudentQuestion();
262
+                        epsq.setClassid(ps.getClassid());
263
+                        epsq.setStudentid(ps.getStudentid());
264
+                        epsq.setExamid(ps.getExamid());
265
+                        epsq.setSubjectid(ps.getSubjectid());
266
+                        epsq.setEpid(epid);
267
+                        epsq.setEpsid(ps.getId());
268
+                        epsq.setEptqid(q.getEptqid());
269
+                        epsq.setCtype(q.getCtype());
270
+                        epsq.setQuestionid(q.getQuestionid());
271
+                        epsq.setQn(q.getQn());
272
+                        epsq.setQorder(q.getQorder());
273
+                        epsq.setAnswered(0);
274
+                        epsq.setAnswertype(0);
275
+                        epsq.setConverted(0);
276
+                        epsq.setCosttime(0);
277
+                        epsq.setQscore(q.getScore());
278
+                        epsq.setStuscore(0.0);
279
+                        epsq.setChecked(0);
280
+                        epsq.setGood(0);
281
+                        epsq.setBad(0);
282
+                        stuqlist.add(epsq);
283
+                    }
282 284
                 }
283 285
             }
286
+            ePaperStudentQuestionMapper.insertList(stuqlist);
287
+        } catch (Exception e) {
288
+            log.error("发布考试失败:"+e.getMessage());
289
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
290
+            return 1;
284 291
         }
285
-        ePaperStudentQuestionMapper.insertList(stuqlist);
292
+        return 0;
286 293
     }
287 294
 
288 295
     //结束考试

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

+ 2
- 2
sexam/src/main/resources/mapper/exam/EBaseMapper.xml View File

@@ -66,12 +66,12 @@
66 66
     </update>
67 67
     <!--考试基本信息-->
68 68
     <select id="findById" resultType="java.util.Map">
69
-        select examid,examname,gradeid,examdate,examtype,exammode,monitored,examstate
69
+        select examid,examname,gradeid,examdate,examtype,exammode,monitored,examstate,showrank
70 70
         from e_base where examid=#{examid}
71 71
     </select>
72 72
     <!--考试基本信息(带考试人数)-->
73 73
     <select id="findById2" resultType="java.util.Map">
74
-        select b.examid,b.examname,b.examdate,b.examtype,b.gradeid,b.exammode,b.monitored,b.examstate,b.examcomm
74
+        select b.examid,b.examname,b.examdate,b.examtype,b.gradeid,b.exammode,b.monitored,b.examstate,b.examcomm,showrank
75 75
         ,(select sum(c.classnum) from e_class c where c.examid=b.examid)examnum
76 76
         from e_base b where b.examid=#{examid}
77 77
     </select>

+ 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