Browse Source

定时更新当天考试学生提交状态

tags/正式版本
雍文秀 2 years ago
parent
commit
7ffce2417e

+ 6
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paperstudent/EPaperStudentMapper.java View File

@@ -105,4 +105,10 @@ public interface EPaperStudentMapper extends TkMapper<EPaperStudent> {
105 105
 
106 106
     //缺考详情
107 107
     List<Map> listQkDetail(@Param("epid") Integer epid);
108
+
109
+    //当天进行中考试列表
110
+    List<Map> listExam();
111
+
112
+    //更新当天进行中考试已提交的学生状态为已进场
113
+    Integer updateSstateByEsIds(@Param("esids") String esids);
108 114
 }

+ 29
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/paperstudent/EPaperStudentService.java View File

@@ -892,4 +892,33 @@ public class EPaperStudentService {
892 892
         batchids = batchids.stream().distinct().collect(Collectors.toList());
893 893
         eScanbatchMapper.updateBatchErrornum(batchids);//更改异常已处理数量
894 894
     }
895
+
896
+    /*
897
+     * 定时更新学生考试状态
898
+     * @Param [esids(考试科目ids), cs(执行的次数), stime(隔几毫秒执行一次)]
899
+     * @Author ywx
900
+     * @Date 2022/11/9 19:02
901
+     * @return java.lang.Integer
902
+     **/
903
+    public Integer update(String esids, Integer cs, Integer stime) {
904
+        Integer num = 0;
905
+        try {
906
+            if (N_Utils.isEmpty(esids)) {
907
+                List<Map> list = ePaperStudentMapper.listExam();
908
+                esids = list.stream().map(s -> s.get("esid").toString()).collect(Collectors.joining(","));
909
+                log.info(JSON.toJSONString(list));
910
+            }
911
+            if (N_Utils.isEmpty(esids)) return 0;
912
+            for (int i = 0; i < cs; i++) {
913
+                Integer unum = ePaperStudentMapper.updateSstateByEsIds(esids);
914
+                num += unum;
915
+                log.error("本次更新:【" + unum + "】条");
916
+                Thread.sleep(stime);
917
+            }
918
+            log.error("共更新:【" + num + "】条");
919
+        } catch (InterruptedException e) {
920
+            log.error("定时更新学生考试状态出错", e.getMessage());
921
+        }
922
+        return num;
923
+    }
895 924
 }

+ 9
- 0
sexam/src/main/resources/mapper/paperstudent/EPaperStudentMapper.xml View File

@@ -347,4 +347,13 @@
347 347
         from e_paper_student eps left join e_class ec on eps.examid=ec.examid and eps.classid=ec.classid
348 348
         where eps.epid=#{epid} group by eps.classid order by ec.ecid
349 349
     </select>
350
+    <!--当天进行中考试列表-->
351
+    <select id="listExam" resultType="java.util.Map">
352
+        SELECT b.examname,s.* FROM e_subject s LEFT JOIN e_base b ON s.examid=b.examid
353
+        WHERE s.sdate=DATE_FORMAT(now(),'%Y-%m-%d') AND b.examstate=1 and s.pstate=1
354
+    </select>
355
+    <!--更新当天进行中考试已提交的学生状态为已进场-->
356
+    <update id="updateSstateByEsIds">
357
+        UPDATE e_paper_student SET sstate=1 WHERE esid in(${esids}) AND sstate=2
358
+    </update>
350 359
 </mapper>

Loading…
Cancel
Save