Browse Source

扫描批次、关联学生试卷

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

+ 14
- 7
sexam/src/main/java/com/xhkjedu/sexam/controller/paperstudent/EPaperStudentController.java View File

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper;
4 4
 import com.github.pagehelper.PageInfo;
5 5
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudent;
6 6
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
7
+import com.xhkjedu.sexam.model.paperstudent.EScanerror;
7 8
 import com.xhkjedu.sexam.service.paperstudent.EPaperStudentService;
8 9
 import com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo;
9 10
 import com.xhkjedu.sexam.vo.paperstudent.PaperStudentWebVo;
@@ -123,13 +124,7 @@ public class EPaperStudentController {
123 124
         }
124 125
     }
125 126
 
126
-    /**
127
-     * @Description 保存扫描的答题卡
128
-     * @Param [ps]
129
-     * @Return com.xhkjedu.vo.ResultVo
130
-     * @Author wn
131
-     * @Date 2022/8/3 14:35
132
-     **/
127
+    //保存扫描的答题卡
133 128
     @PostMapping("/sca")
134 129
     public ResultVo saveCommitPaperScantron(@RequestBody PaperStudentWebVo ps) {
135 130
         try {
@@ -142,5 +137,17 @@ public class EPaperStudentController {
142 137
         }
143 138
     }
144 139
 
140
+    //保存扫描出错答题卡
141
+    @PostMapping("/scaer")
142
+    public ResultVo saveScanPaperError(@RequestBody EScanerror eScanerror) {
143
+        try {
144
+            N_Utils.validation(new Object[]{eScanerror.getBatchid(),"批次id",1});
145
+            ePaperStudentService.saveScanPaperError(eScanerror);
146
+            return new ResultVo(0, "成功保存出错答题卡");
147
+        } catch (Exception e) {
148
+            log.error("保存出错答题卡失败:" + e.getMessage());
149
+            return new ResultVo(1, "保存出错答题卡失败");
150
+        }
151
+    }
145 152
 
146 153
 }

+ 35
- 0
sexam/src/main/java/com/xhkjedu/sexam/controller/paperstudent/EScanbatchController.java View File

@@ -0,0 +1,35 @@
1
+package com.xhkjedu.sexam.controller.paperstudent;
2
+
3
+import com.xhkjedu.sexam.model.paperstudent.EPaperStudent;
4
+import com.xhkjedu.sexam.model.paperstudent.EScanbatch;
5
+import com.xhkjedu.sexam.service.paperstudent.EScanbatchService;
6
+import com.xhkjedu.utils.N_Utils;
7
+import com.xhkjedu.vo.ResultVo;
8
+import org.springframework.web.bind.annotation.PostMapping;
9
+import org.springframework.web.bind.annotation.RequestBody;
10
+import org.springframework.web.bind.annotation.RequestMapping;
11
+import org.springframework.web.bind.annotation.RestController;
12
+
13
+import javax.annotation.Resource;
14
+import java.util.List;
15
+import java.util.Map;
16
+
17
+/**
18
+ * @Description: TODO 答题卡扫描
19
+ * @Author: wn
20
+ * @CreateTime: 2022-08-11  09:43
21
+ */
22
+@RestController
23
+@RequestMapping("/scan")
24
+public class EScanbatchController {
25
+    @Resource
26
+    private EScanbatchService eScanbatchService;
27
+
28
+    //保持批次信息
29
+    @PostMapping("/save")
30
+    public ResultVo saveEscanbatch(@RequestBody EScanbatch eScanbatch) {
31
+        N_Utils.validation(new Object[]{eScanbatch.getEpid(),"试卷id",1,eScanbatch.getBatchname(),"设备",2});
32
+        Map map = eScanbatchService.saveScanBatch(eScanbatch);
33
+        return new ResultVo(0, "成功保存", map);
34
+    }
35
+}

+ 25
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paperstudent/EScanbatchMapper.java View File

@@ -0,0 +1,25 @@
1
+package com.xhkjedu.sexam.mapper.paperstudent;
2
+
3
+import com.xhkjedu.sexam.base.TkMapper;
4
+import com.xhkjedu.sexam.model.paperstudent.EScanbatch;
5
+import io.lettuce.core.dynamic.annotation.Param;
6
+import org.springframework.stereotype.Repository;
7
+
8
+@Repository
9
+public interface EScanbatchMapper extends TkMapper<EScanbatch> {
10
+
11
+    //获取指定设备试卷批次数量
12
+    Integer getBatchNameLikeNum(@Param("batchname")String batchname);
13
+
14
+    //修改批次扫描数量
15
+    void updateScannum(@Param("batchid")Integer batchid);
16
+
17
+    //修改批次缺考数量
18
+    void updateQknum(@Param("batchid")Integer batchid);
19
+
20
+    //修改批次违规数量
21
+    void updateWgnum(@Param("batchid")Integer batchid);
22
+
23
+    //更改出错数量
24
+    void updateErrornum(@Param("batchid")Integer batchid);
25
+}

+ 9
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paperstudent/EScanerrorMapper.java View File

@@ -0,0 +1,9 @@
1
+package com.xhkjedu.sexam.mapper.paperstudent;
2
+
3
+import com.xhkjedu.sexam.base.TkMapper;
4
+import com.xhkjedu.sexam.model.paperstudent.EScanerror;
5
+import org.springframework.stereotype.Repository;
6
+
7
+@Repository
8
+public interface EScanerrorMapper extends TkMapper<EScanerror> {
9
+}

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/model/paperstudent/EPaperStudent.java View File

@@ -66,4 +66,7 @@ public class EPaperStudent extends BaseBean {
66 66
 
67 67
     //创建时间
68 68
     private Integer createtime;
69
+
70
+    //扫描批次id
71
+    private Integer batchid;
69 72
 }

+ 0
- 3
sexam/src/main/java/com/xhkjedu/sexam/model/paperstudent/EPaperStudentQuestion.java View File

@@ -79,9 +79,6 @@ public class EPaperStudentQuestion extends BaseBean {
79 79
     //违纪试卷0默认1违纪
80 80
     private Integer bad;
81 81
 
82
-    //学生答题卡作答图片
83
-    private String stupic;
84
-
85 82
     @Transient
86 83
     private String stuname;//学生姓名
87 84
 

+ 1
- 1
sexam/src/main/java/com/xhkjedu/sexam/model/paperstudent/EScanbatch.java View File

@@ -11,8 +11,8 @@ import javax.persistence.Table;
11 11
  * @Author: wn
12 12
  * @CreateTime: 2022-08-11  09:06
13 13
  */
14
-@Data
15 14
 @Table(name = "e_scanbatch")
15
+@Data
16 16
 public class EScanbatch extends BaseBean {
17 17
     @Id
18 18
     private Integer batchid;

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/model/paperstudent/EScanerror.java View File

@@ -26,4 +26,7 @@ public class EScanerror extends BaseBean {
26 26
     //错误内容
27 27
     private String errorjson;
28 28
 
29
+    //创建时间
30
+    private Integer createtime;
31
+
29 32
 }

+ 60
- 5
sexam/src/main/java/com/xhkjedu/sexam/service/paperstudent/EPaperStudentService.java View File

@@ -5,12 +5,15 @@ import com.xhkjedu.sexam.mapper.paper.EPaperFileMapper;
5 5
 import com.xhkjedu.sexam.mapper.paper.EPaperQtypeMapper;
6 6
 import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentMapper;
7 7
 import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentQuestionMapper;
8
+import com.xhkjedu.sexam.mapper.paperstudent.EScanbatchMapper;
9
+import com.xhkjedu.sexam.mapper.paperstudent.EScanerrorMapper;
8 10
 import com.xhkjedu.sexam.mapper.system.UserMapper;
9 11
 import com.xhkjedu.sexam.model.paper.EPaperFile;
10 12
 import com.xhkjedu.sexam.model.paper.EPaperQtype;
11 13
 import com.xhkjedu.sexam.model.paper.EPaperQtypeQuestion;
12 14
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudent;
13 15
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
16
+import com.xhkjedu.sexam.model.paperstudent.EScanerror;
14 17
 import com.xhkjedu.sexam.utils.ConvertUtil;
15 18
 import com.xhkjedu.sexam.utils.ExamUtil;
16 19
 import com.xhkjedu.sexam.vo.paperstudent.EPaperStudentVo;
@@ -45,6 +48,10 @@ public class EPaperStudentService {
45 48
     private UserMapper userMapper;
46 49
     @Resource
47 50
     private EPaperFileMapper ePaperFileMapper;
51
+    @Resource
52
+    private EScanbatchMapper eScanbatchMapper;
53
+    @Resource
54
+    private EScanerrorMapper eScanerrorMapper;
48 55
     @Autowired
49 56
     private ConvertUtil convertUtil;
50 57
 
@@ -411,11 +418,13 @@ public class EPaperStudentService {
411 418
      * @Author wn
412 419
      * @Date 2022/8/3 9:17
413 420
      **/
421
+    @Transactional(rollbackFor = Exception.class)
414 422
     public void saveCommitPaperForScantron(PaperStudentWebVo pswvo) throws Exception{
415 423
         //更加学生姓名和准考证号找到对应学生
416 424
         Integer userid = userMapper.getUseridByExamno(pswvo.getExamno());
417 425
         if(!N_Utils.isTrueInteger(userid)){
418
-            throw new Exception("考号有误");
426
+            updateScanErrorInfo(2,pswvo);
427
+//            throw new Exception("考号有误");
419 428
         }
420 429
         //获取学生试卷
421 430
         EPaperStudent ps = ePaperStudentMapper.getPaperStudentByStuidAndEpid(pswvo.getEpid(),userid);
@@ -423,7 +432,8 @@ public class EPaperStudentService {
423 432
 
424 433
         //试卷不存在
425 434
         if(ps == null) {
426
-            throw new Exception("学生试卷不存在");
435
+            updateScanErrorInfo(3,pswvo);
436
+//            throw new Exception("学生试卷不存在");
427 437
         }
428 438
 
429 439
         if(pswvo.getSstate() == 3){
@@ -432,14 +442,20 @@ public class EPaperStudentService {
432 442
             paperStudent.setEpsid(pswvo.getEpsid());
433 443
             paperStudent.setStupic(JSON.toJSONString(pswvo.getStupic()));
434 444
             paperStudent.setSstate(3);
435
-            if(!N_Utils.isEmptyInteger(pswvo.getSstate())){
436
-                paperStudent.setHasbad(0);
437
-            }else{
445
+            paperStudent.setBatchid(pswvo.getBatchid());
446
+            if(N_Utils.isEmptyInteger(pswvo.getHasbad())){
438 447
                 paperStudent.setHasbad(1);
448
+            }else{
449
+                paperStudent.setHasbad(0);
439 450
             }
440 451
 
441 452
             ePaperStudentMapper.updateStudentPaperState(paperStudent);
442 453
             ePaperStudentQuestionMapper.updateStuQuestionChecked(pswvo.getEpsid(),userid);
454
+            eScanbatchMapper.updateQknum(pswvo.getBatchid());//更改缺考数量
455
+            //更改违规数量
456
+            if(paperStudent.getHasbad() == 1){
457
+                eScanbatchMapper.updateWgnum(paperStudent.getBatchid());
458
+            }
443 459
         }else{
444 460
             List<EPaperStudentQuestion> sqlist = pswvo.getQuestions();//学生提交试卷中试题
445 461
 
@@ -465,6 +481,13 @@ public class EPaperStudentService {
465 481
             paperStudent.setStupic(JSON.toJSONString(pswvo.getStupic()));
466 482
             paperStudent.setSstate(2);
467 483
             paperStudent.setStuscore(paperscore);
484
+            paperStudent.setBatchid(pswvo.getBatchid());
485
+            if(N_Utils.isEmptyInteger(pswvo.getHasbad())){
486
+                paperStudent.setHasbad(1);
487
+            }else{
488
+                paperStudent.setHasbad(0);
489
+            }
490
+
468 491
             int checked = 0;
469 492
             if(checknum == sqlist.size()){
470 493
                 checked = 2;
@@ -473,6 +496,12 @@ public class EPaperStudentService {
473 496
 
474 497
             ePaperStudentQuestionMapper.updateBatchStuQuestion(sqlist);
475 498
             ePaperStudentMapper.updateStudentPaper(paperStudent);
499
+            //扫描完成更改批次数量
500
+            eScanbatchMapper.updateScannum(paperStudent.getBatchid());
501
+            //更改违规数量
502
+            if(paperStudent.getHasbad() == 1){
503
+                eScanbatchMapper.updateWgnum(paperStudent.getBatchid());
504
+            }
476 505
             if(checked == 0){
477 506
                 //获取试卷中需要合并图片的试题
478 507
                 chandleStudentQuestionNoconvertedPic(pswvo.getEpsid(),2);
@@ -480,4 +509,30 @@ public class EPaperStudentService {
480 509
         }
481 510
     }
482 511
 
512
+    //更新扫描出错信息
513
+    private void updateScanErrorInfo(Integer errortype,PaperStudentWebVo pswvo){
514
+        //识别出错
515
+        EScanerror er = new EScanerror();
516
+        er.setBatchid(pswvo.getBatchid());
517
+        er.setErrortype(errortype);
518
+        er.setErrorjson(JSON.toJSONString(pswvo));
519
+        er.setCreatetime(N_Utils.getSecondTimestamp());
520
+        eScanerrorMapper.insertSelective(er);
521
+        eScanbatchMapper.updateErrornum(pswvo.getBatchid());
522
+    }
523
+
524
+    /**
525
+     * @description 保存扫描出错信息
526
+     * @param: [eScanerror]
527
+     * @return: void
528
+     * @author: wn
529
+     * @date:
530
+     **/
531
+    public void saveScanPaperError(EScanerror eScanerror){
532
+        eScanerror.setErrortype(1);
533
+        eScanerror.setCreatetime(N_Utils.getSecondTimestamp());
534
+        eScanerrorMapper.insertSelective(eScanerror);
535
+        eScanbatchMapper.updateErrornum(eScanerror.getBatchid());
536
+    }
537
+
483 538
 }

+ 59
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/paperstudent/EScanbatchService.java View File

@@ -0,0 +1,59 @@
1
+package com.xhkjedu.sexam.service.paperstudent;
2
+
3
+import com.xhkjedu.sexam.mapper.paper.EPaperMapper;
4
+import com.xhkjedu.sexam.mapper.paperstudent.EScanbatchMapper;
5
+import com.xhkjedu.sexam.model.paperstudent.EScanbatch;
6
+import com.xhkjedu.utils.N_Utils;
7
+import org.springframework.stereotype.Repository;
8
+import org.springframework.stereotype.Service;
9
+
10
+import javax.annotation.Resource;
11
+import java.util.HashMap;
12
+import java.util.Map;
13
+
14
+/**
15
+ * @Description: TODO
16
+ * @Author: wn
17
+ * @CreateTime: 2022-08-11  09:31
18
+ */
19
+@Service
20
+public class EScanbatchService {
21
+    @Resource
22
+    private EScanbatchMapper eScanbatchMapper;
23
+    @Resource
24
+    private EPaperMapper ePaperMapper;
25
+
26
+    /**
27
+     * @description: 保持扫描试卷批次信息
28
+     * @param: [eScanbatch]
29
+     * @return: java.util.Map
30
+     * @author: wn
31
+     * @date: 2022/8/11/011 9:42
32
+     **/
33
+    public Map saveScanBatch(EScanbatch eScanbatch){
34
+        String batchname = eScanbatch.getBatchname() + "-" + eScanbatch.getEpid() + "-";
35
+        //获取数据库中该批次名的扫描批次数量
36
+        Integer bnum = eScanbatchMapper.getBatchNameLikeNum(batchname);
37
+        if(bnum == null || bnum == 0){
38
+            bnum = 1;
39
+        }else{
40
+            bnum++;
41
+        }
42
+        batchname = batchname + bnum;
43
+        //对应考试id
44
+        Integer examid = ePaperMapper.getExamIdByEpId(eScanbatch.getEpid());
45
+        eScanbatch.setBatchname(batchname);
46
+        eScanbatch.setExamid(examid);
47
+        eScanbatch.setScannum(0);
48
+        eScanbatch.setErrornum(0);
49
+        eScanbatch.setQknum(0);
50
+        eScanbatch.setWgnum(0);
51
+        eScanbatch.setCreatetime(N_Utils.getSecondTimestamp());
52
+        eScanbatchMapper.insertUseGeneratedKeys(eScanbatch);
53
+        Integer batchid = eScanbatch.getId();
54
+        Map rtnmap = new HashMap<>();
55
+        rtnmap.put("batchid",batchid);
56
+        rtnmap.put("batchname",batchname);
57
+        return rtnmap;
58
+    }
59
+}

+ 2
- 0
sexam/src/main/java/com/xhkjedu/sexam/vo/paperstudent/PaperStudentWebVo.java View File

@@ -32,4 +32,6 @@ public class PaperStudentWebVo {
32 32
 
33 33
     private Integer hasbad;//会否违规0未违规1违规
34 34
 
35
+    private Integer batchid;//答题卡扫描批次
36
+
35 37
 }

+ 1
- 6
sexam/src/main/resources/mapper/paperstudent/EPaperStudentQuestionMapper.xml View File

@@ -30,7 +30,7 @@
30 30
 
31 31
     <!--获取试卷中未合并图片-->
32 32
     <select id="listStuQuesitonStuAnswerPic" resultType="com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion">
33
-        select epsqid,stuanswer,stupic from e_paper_student_question
33
+        select epsqid,stuanswer from e_paper_student_question
34 34
         where epsid=#{epsid} and answertype=1 and answered=1 and converted=0 order by qorder
35 35
     </select>
36 36
 
@@ -90,11 +90,6 @@
90 90
                     when epsqid=#{q.epsqid} then #{q.checktime}
91 91
                 </foreach>
92 92
             </trim>
93
-            <trim prefix="stupic = case" suffix="end,">
94
-                <foreach collection="list" item="q">
95
-                    when epsqid=#{q.epsqid} then #{q.stupic}
96
-                </foreach>
97
-            </trim>
98 93
         </trim>
99 94
         <where>
100 95
             <foreach collection="list" item="q" separator="or">

+ 30
- 0
sexam/src/main/resources/mapper/paperstudent/EScanbatchMapper.xml View File

@@ -0,0 +1,30 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.xhkjedu.sexam.mapper.paperstudent.EScanbatchMapper">
4
+
5
+    <!--获取指定设备试卷批次数量-->
6
+    <select id="getBatchNameLikeNum" resultType="java.lang.Integer" parameterType="java.lang.String">
7
+        select count(*) from e_scanbatch where batchname like concat(#{batchname,jdbcType=VARCHAR},'%')
8
+    </select>
9
+
10
+    <!--更改扫描数量-->
11
+    <update id="updateScannum">
12
+        update e_scanbatch set scannum=(select count(*) from e_paper_student ps where ps.sstate=2 and ps.batchid=#{batchid})
13
+        where batchid=#{batchid}
14
+    </update>
15
+    <!--更改缺考数量-->
16
+    <update id="updateQknum">
17
+        update e_scanbatch set qknum=(select count(*) from e_paper_student ps where ps.sstate=3 and ps.batchid=#{batchid})
18
+        where batchid=#{batchid}
19
+    </update>
20
+    <!--更改违规数量-->
21
+    <update id="updateWgnum">
22
+        update e_scanbatch set wgnum=(select count(*) from e_paper_student ps where ps.hasbad=1 and ps.batchid=#{batchid})
23
+        where batchid=#{batchid}
24
+    </update>
25
+    <!--更改出错数量-->
26
+    <update id="updateErrornum">
27
+        update e_scanbatch set errornum=(select count(*) from e_scanerror e where e.batchid=#{batchid}) where batchid=#{batchid}
28
+    </update>
29
+
30
+</mapper>

Loading…
Cancel
Save