Browse Source

待考界面添加接口

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

+ 8
- 0
sexam/src/main/java/com/xhkjedu/sexam/controller/paperstudent/EPaperStudentController.java View File

57
         return new ResultVo(0, "成功获取考试列表", pageResult);
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
     //学生开始考试(android)
68
     //学生开始考试(android)
61
     @PostMapping("/spa")
69
     @PostMapping("/spa")
62
     public ResultVo startPaperForAndroid(@RequestBody EPaperStudent eps) {
70
     public ResultVo startPaperForAndroid(@RequestBody EPaperStudent eps) {

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

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

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

52
         return ePaperStudentMapper.listExamPapersForStudent(eps.getStudentid());
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 View File

3
 import lombok.extern.slf4j.Slf4j;
3
 import lombok.extern.slf4j.Slf4j;
4
 
4
 
5
 import java.math.BigDecimal;
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
 import java.util.Map;
10
 import java.util.Map;
7
 import java.util.concurrent.ConcurrentHashMap;
11
 import java.util.concurrent.ConcurrentHashMap;
8
 
12
 
100
         BigDecimal b2 = new BigDecimal(Double.toString(v2));
104
         BigDecimal b2 = new BigDecimal(Double.toString(v2));
101
         return b1.multiply(b2).doubleValue();
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 View File

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

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

39
         order by e.examdate desc,es.sdate desc,es.begintime desc
39
         order by e.examdate desc,es.sdate desc,es.begintime desc
40
     </select>
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
     <select id="getExamSubjectByEpsid" resultType="com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo">
52
     <select id="getExamSubjectByEpsid" resultType="com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo">
44
         select ps.epsid,ps.examid,ps.esid,ps.classid,ps.studentid,es.subjectid,es.subjectname,es.sdate,es.begintime,es.endtime,
53
         select ps.epsid,ps.examid,ps.esid,ps.classid,ps.studentid,es.subjectid,es.subjectname,es.sdate,es.begintime,es.endtime,

Loading…
Cancel
Save