Przeglądaj źródła

待考界面添加接口

tags/正式版本
王宁 2 lat temu
rodzic
commit
b26f8d7f70

+ 8
- 0
sexam/src/main/java/com/xhkjedu/sexam/controller/paperstudent/EPaperStudentController.java Wyświetl plik

@@ -57,6 +57,14 @@ public class EPaperStudentController {
57 57
         return new ResultVo(0, "成功获取考试列表", pageResult);
58 58
     }
59 59
 
60
+    //待考界面--考试信息
61
+    @PostMapping("/info")
62
+    public ResultVo getExamSubjectPaper(@RequestBody EPaperStudent eps) {
63
+        N_Utils.validation(new Object[]{eps.getEpsid(), "学生id", 1});
64
+        Map map = ePaperStudentService.getExamSubjectPaperByEpsid(eps.getEpsid());
65
+        return new ResultVo(0, "成功获取考试信息", map);
66
+    }
67
+
60 68
     //学生开始考试(android)
61 69
     @PostMapping("/spa")
62 70
     public ResultVo startPaperForAndroid(@RequestBody EPaperStudent eps) {

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paperstudent/EPaperStudentMapper.java Wyświetl plik

@@ -25,6 +25,9 @@ public interface EPaperStudentMapper extends TkMapper<EPaperStudent> {
25 25
     //学生已结束考试列表
26 26
     List<Map> listExamsEndForStudent(@Param("studentid")Integer studentid);
27 27
 
28
+    //获取考试科目时间信息
29
+    Map getExamSubjectPaperByEpsid(@Param("epsid")Integer epsid);
30
+
28 31
     //考试试卷基本信息
29 32
     EPaperStudentVo getExamSubjectByEpsid(@Param("epsid")Integer epsid);
30 33
 

+ 12
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/paperstudent/EPaperStudentService.java Wyświetl plik

@@ -52,6 +52,18 @@ public class EPaperStudentService {
52 52
         return ePaperStudentMapper.listExamPapersForStudent(eps.getStudentid());
53 53
     }
54 54
 
55
+    public Map getExamSubjectPaperByEpsid(Integer epsid){
56
+        Map map = ePaperStudentMapper.getExamSubjectPaperByEpsid(epsid);
57
+        Long times = null;
58
+        if(map.get("sdate")!=null && map.get("begintime")!=null && map.get("endtime")!=null){
59
+            long bg = ExamUtil.strToTimestamp(map.get("sdate").toString() + " " + map.get("begintime").toString() + ":00");
60
+            long ed = ExamUtil.strToTimestamp(map.get("sdate").toString() + " " + map.get("endtime").toString() + ":00");
61
+            times = ExamUtil.subtract(ed,bg);
62
+        }
63
+        map.put("times",times);
64
+        return map;
65
+    }
66
+
55 67
     /**
56 68
      * 学生已结束考试列表
57 69
      *

+ 19
- 0
sexam/src/main/java/com/xhkjedu/sexam/utils/ExamUtil.java Wyświetl plik

@@ -3,6 +3,10 @@ package com.xhkjedu.sexam.utils;
3 3
 import lombok.extern.slf4j.Slf4j;
4 4
 
5 5
 import java.math.BigDecimal;
6
+import java.math.BigInteger;
7
+import java.time.LocalDateTime;
8
+import java.time.ZoneId;
9
+import java.time.format.DateTimeFormatter;
6 10
 import java.util.Map;
7 11
 import java.util.concurrent.ConcurrentHashMap;
8 12
 
@@ -100,4 +104,19 @@ public class ExamUtil {
100 104
         BigDecimal b2 = new BigDecimal(Double.toString(v2));
101 105
         return b1.multiply(b2).doubleValue();
102 106
     }
107
+
108
+    //字符串转为时间戳(秒)
109
+    public static long strToTimestamp(String str){
110
+        DateTimeFormatter ftf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
111
+        LocalDateTime parse = LocalDateTime.parse(str, ftf);
112
+        return LocalDateTime.from(parse).atZone(ZoneId.systemDefault()).toEpochSecond();
113
+    }
114
+
115
+    //两数相减
116
+    public static long subtract(long a,long b){
117
+        BigInteger biginta = new BigInteger(a + "");
118
+        BigInteger bigintb = new BigInteger(b + "");
119
+        return biginta.subtract(bigintb).longValue();
120
+
121
+    }
103 122
 }

+ 1
- 1
sexam/src/main/resources/mapper/paper/EPaperMapper.xml Wyświetl plik

@@ -52,7 +52,7 @@
52 52
     <select id="getExamPaperAndSubject" resultType="java.util.Map">
53 53
         select ep.epid,ep.esid,ep.ptype,e.examname,e.examstate,s.subjectname,ep.scantronfile,ep.scantronnote,ep.scantronwh
54 54
         ,ep.scantroncol,ep.cantronmiss,ep.cantronbad,ep.codetype,ep.cantroncode,ep.pnum,ep.pscore,ep.cantronbarcode,
55
-               ep.cantronqrcode,ep.cantronpage,ep.cantronloc,ep.scantronspace,sp.codenum
55
+               ep.cantronqrcode,ep.cantronpage,ep.cantronloc,ep.scantronspace,ep.codenum
56 56
         from e_paper ep left join e_base e on ep.examid=e.examid
57 57
         left join t_subject s on ep.subjectid=s.subjectid where ep.epid=#{epid}
58 58
     </select>

+ 9
- 0
sexam/src/main/resources/mapper/paperstudent/EPaperStudentMapper.xml Wyświetl plik

@@ -39,6 +39,15 @@
39 39
         order by e.examdate desc,es.sdate desc,es.begintime desc
40 40
     </select>
41 41
 
42
+    <!--获取考试科目时间信息-->
43
+    <select id="getExamSubjectPaperByEpsid" resultType="java.util.Map">
44
+        select ps.epsid,e.examname,e.examcomm,es.subjectid,es.subjectname,es.sdate,es.begintime,es.endtime,p.ptype
45
+        from e_paper_student ps left join e_base e on ps.examid=e.examid
46
+        left join e_subject es on ps.esid=es.esid and ps.examid=es.examid
47
+        left join e_paper p on ps.epid=p.epid
48
+        where ps.epsid=#{epsid}
49
+    </select>
50
+
42 51
     <!--考试试卷基本信息-->
43 52
     <select id="getExamSubjectByEpsid" resultType="com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo">
44 53
         select ps.epsid,ps.examid,ps.esid,ps.classid,ps.studentid,es.subjectid,es.subjectname,es.sdate,es.begintime,es.endtime,

Ładowanie…
Anuluj
Zapisz