Ver código fonte

教师阅卷

tags/正式版本
雍文秀 2 anos atrás
pai
commit
53684be60a

+ 5
- 2
sexam/src/main/java/com/xhkjedu/sexam/controller/paper/EPaperCorrectTeacherController.java Ver arquivo

@@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController;
19 19
 import javax.annotation.Resource;
20 20
 import java.util.List;
21 21
 import java.util.Map;
22
+import java.util.concurrent.ExecutionException;
23
+import java.util.concurrent.Future;
22 24
 
23 25
 /**
24 26
  * @author ywx
@@ -133,11 +135,12 @@ public class EPaperCorrectTeacherController {
133 135
      * @Date 2022/7/28 15:30
134 136
      **/
135 137
     @PostMapping("/correct")
136
-    public ResultVo correctQuestion(@RequestBody EPaperStudentQuestion vo) {
138
+    public ResultVo correctQuestion(@RequestBody EPaperStudentQuestion vo) throws ExecutionException, InterruptedException {
137 139
         Integer epsid = vo.getEpsid();
138 140
         Integer epsqid = vo.getEpsqid();
139 141
         Integer checkid = vo.getCheckid();
140 142
         N_Utils.validation(new Object[]{epsid, "试卷学生id", 1, epsqid, "试卷学生试题id", 1, checkid, "批阅人", 1});
141
-        return correctTeacherService.correctQuestion(vo);
143
+        Future<ResultVo> future = correctTeacherService.correctQuestion(vo);
144
+        return future.get();
142 145
     }
143 146
 }

+ 13
- 7
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperCorrectTeacherService.java Ver arquivo

@@ -8,12 +8,14 @@ import com.xhkjedu.utils.N_Utils;
8 8
 import com.xhkjedu.vo.ResultVo;
9 9
 import lombok.extern.slf4j.Slf4j;
10 10
 import org.springframework.scheduling.annotation.Async;
11
+import org.springframework.scheduling.annotation.AsyncResult;
11 12
 import org.springframework.stereotype.Service;
12 13
 
13 14
 import javax.annotation.Resource;
14 15
 import java.util.HashMap;
15 16
 import java.util.List;
16 17
 import java.util.Map;
18
+import java.util.concurrent.Future;
17 19
 import java.util.concurrent.locks.Lock;
18 20
 import java.util.concurrent.locks.ReentrantLock;
19 21
 
@@ -77,13 +79,17 @@ public class EPaperCorrectTeacherService {
77 79
 
78 80
     //批阅试题
79 81
     @Async("asyncPoolTaskExecutor")
80
-    public ResultVo correctQuestion(EPaperStudentQuestion psq) {
81
-        correctTeacherMapper.correctQuestion(psq);
82
-        Integer epsid = psq.getEpsid();
83
-        Integer num = correctTeacherMapper.getNotCorrect(epsid);//学生未批改试题数量
84
-        if (num == 0) {//批阅完成修改学生试卷批阅状态
85
-            correctTeacherMapper.updateCheckStuById(epsid, psq.getCheckid());
82
+    public Future<ResultVo> correctQuestion(EPaperStudentQuestion psq) {
83
+        try {
84
+            correctTeacherMapper.correctQuestion(psq);
85
+            Integer epsid = psq.getEpsid();
86
+            Integer num = correctTeacherMapper.getNotCorrect(epsid);//学生未批改试题数量
87
+            if (num == 0) {//批阅完成修改学生试卷批阅状态
88
+                correctTeacherMapper.updateCheckStuById(epsid, psq.getCheckid());
89
+            }
90
+            return new AsyncResult<>(new ResultVo(0, "批阅成功"));
91
+        } catch (Exception e) {
92
+            return new AsyncResult<>(new ResultVo(1, e.getMessage()));
86 93
         }
87
-        return new ResultVo(0, "批阅成功");
88 94
     }
89 95
 }

+ 5
- 5
sexam/src/main/resources/mapper/paper/EPaperCorrectTeacherMapper.xml Ver arquivo

@@ -59,8 +59,8 @@
59 59
     </select>
60 60
     <!--试题批阅情况-->
61 61
     <select id="getCheckQuestion" resultType="com.xhkjedu.sexam.vo.paper.EPaperSQuestionVo">
62
-        select count(psq.epsqid)tjnum,count(case when psq.checked=1 then psq.epsqid else null end)pynum
63
-        ,count(case when psq.checked=1 and psq.checkid=#{teacherid} then psq.epsqid else null end)wpynum
62
+        select count(psq.epsqid)tjnum,count(case when psq.checked=2 then psq.epsqid else null end)pynum
63
+        ,count(case when psq.checked=2 and psq.checkid=#{teacherid} then psq.epsqid else null end)wpynum
64 64
         from e_paper_student_question psq where psq.epid=#{epid} and psq.qorder=#{qorder} and psq.answered=1
65 65
     </select>
66 66
     <!--修改试卷学生试题为批阅中-->
@@ -70,20 +70,20 @@
70 70
     <!--获取上一份批阅试题-->
71 71
     <select id="getPreQuestion" resultType="java.util.Map">
72 72
         select psq.epsqid,psq.stuanswer,psq.qn,psq.qorder,psq.qscore,psq.stuscore,psq.good,psq.bad,psq.epsid
73
-        from e_paper_student_question psq where psq.epid=#{epid} and psq.checked=1 and psq.checkid=#{teacherid}
73
+        from e_paper_student_question psq where psq.epid=#{epid} and psq.checked=2 and psq.checkid=#{teacherid}
74 74
         order by psq.checktime desc limit 1
75 75
     </select>
76 76
     <!--阅卷记录-->
77 77
     <select id="listRecord" resultType="java.util.Map">
78 78
         select psq.epsqid,psq.stuanswer,psq.qorder,psq.qscore,psq.stuscore,psq.good,psq.bad,psq.checktime
79 79
         from e_paper_student_question psq where psq.epid=#{epid} and psq.qorder=#{qorder}
80
-        and psq.checked=1 and psq.checkid=#{teacherid}
80
+        and psq.checked=2 and psq.checkid=#{teacherid}
81 81
         order by psq.checktime desc
82 82
     </select>
83 83
     <!--批阅试题-->
84 84
     <update id="correctQuestion">
85 85
         update e_paper_student_question
86
-        set stuscore=#{psq.stuscore},checked=1
86
+        set stuscore=#{psq.stuscore},checked=2
87 87
         ,checkid=#{psq.checkid},checktime=unix_timestamp()
88 88
         ,good=#{psq.good},bad=#{psq.bad}
89 89
         <if test="psq.stuanswer!=null and psq.stuanswer!=''">

Carregando…
Cancelar
Salvar