Browse Source

扫描

ywx
王宁 2 months ago
parent
commit
a9dd2a78cc

+ 2
- 2
smarking/src/main/java/com/xhkjedu/smarking/controller/paper/MsPaperBackController.java View File

@@ -34,7 +34,7 @@ public class MsPaperBackController {
34 34
     @PostMapping("/save")
35 35
     public ResultVo save(@RequestBody MsPaperBack msPaperBack) {
36 36
         msPaperBackService.add(msPaperBack);
37
-        return new ResultVo(0, "保存成功");
37
+        return new ResultVo(0, "保存成功");
38 38
     }
39 39
 
40 40
     /**
@@ -52,6 +52,6 @@ public class MsPaperBackController {
52 52
         PageHelper.startPage(page, size);
53 53
         List<MsPaperBack> list = msPaperBackService.queryList(msPaperBack);
54 54
         PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
55
-        return new ResultVo(0, "查询成功", pageResult);
55
+        return new ResultVo(0, "查询成功", pageResult);
56 56
     }
57 57
 }

+ 2
- 2
smarking/src/main/java/com/xhkjedu/smarking/controller/paper/MsPaperBlockController.java View File

@@ -36,7 +36,7 @@ public class MsPaperBlockController {
36 36
     public ResultVo listPaperBlocks(@RequestBody MsPaper msPaper) {
37 37
         N_Utils.validation(new Object[]{msPaper.getMsid(), "考试科目id",1});
38 38
         List<MsPaperBlock> list = msPaperBlockService.listPaperBlockQuestions(msPaper.getMsid());
39
-        return new ResultVo(0, "查询成功", list);
39
+        return new ResultVo(0, "查询成功", list);
40 40
     }
41 41
 
42 42
     /*
@@ -53,7 +53,7 @@ public class MsPaperBlockController {
53 53
             return new ResultVo(1, "题块不能为空!");
54 54
         }
55 55
         Integer mpid = msPaperBlockService.save(params);
56
-        return new ResultVo(0, "保存成功", mpid);
56
+        return new ResultVo(0, "保存成功", mpid);
57 57
     }
58 58
 
59 59
 

+ 38
- 17
smarking/src/main/java/com/xhkjedu/smarking/controller/scan/MsScanbatchController.java View File

@@ -3,15 +3,20 @@ package com.xhkjedu.smarking.controller.scan;
3 3
 import com.github.pagehelper.PageHelper;
4 4
 import com.github.pagehelper.PageInfo;
5 5
 import com.xhkjedu.smarking.model.scan.MsScanbatch;
6
+import com.xhkjedu.smarking.model.scan.MsScanbatchPaper;
6 7
 import com.xhkjedu.smarking.service.scan.MsScanbatchService;
7 8
 import com.xhkjedu.utils.N_Utils;
8 9
 import com.xhkjedu.utils.PageUtil;
9 10
 import com.xhkjedu.vo.PageResult;
10 11
 import com.xhkjedu.vo.ResultVo;
11
-import org.springframework.web.bind.annotation.*;
12
+import org.springframework.web.bind.annotation.PostMapping;
13
+import org.springframework.web.bind.annotation.RequestBody;
14
+import org.springframework.web.bind.annotation.RequestMapping;
15
+import org.springframework.web.bind.annotation.RestController;
12 16
 
13 17
 import javax.annotation.Resource;
14 18
 import java.util.List;
19
+import java.util.Map;
15 20
 
16 21
 /**
17 22
  * @Description 阅卷答题卡扫描批次表相关操作
@@ -19,7 +24,7 @@ import java.util.List;
19 24
  * @Date 2024-10-15
20 25
  */
21 26
 @RestController
22
-@RequestMapping("/msScanbatch")
27
+@RequestMapping("/mscan")
23 28
 public class MsScanbatchController {
24 29
     @Resource
25 30
     private MsScanbatchService msScanbatchService;
@@ -33,25 +38,41 @@ public class MsScanbatchController {
33 38
      **/
34 39
     @PostMapping("/save")
35 40
     public ResultVo save(@RequestBody MsScanbatch msScanbatch) {
36
-        msScanbatchService.add(msScanbatch);
37
-        return new ResultVo(0, "保存成功!");
41
+        N_Utils.validation(new Object[]{msScanbatch.getMpid(), "试卷id", 1});
42
+        Map<String,Object> map = msScanbatchService.save(msScanbatch);
43
+        return new ResultVo(0, "保存成功", map);
38 44
     }
39 45
 
40
-    /**
41
-     * @Description 列表
46
+    /*
47
+     * @Description 批次下试卷
48
+     * @Date 2024/10/24 16:30:20
49
+     * @Author WN
42 50
      * @Param [msScanbatch]
43
-     * @Author auto
44
-     * @Date 2024-10-15
45
-     * @return com.xhkjedu.vo.ResultVo
51
+     * @Return com.xhkjedu.vo.ResultVo
46 52
      **/
47
-    @PostMapping("/list")
48
-    public ResultVo queryList(@RequestBody MsScanbatch msScanbatch) {
53
+    @PostMapping("/papers")
54
+    public ResultVo listPaperByBatchid(@RequestBody MsScanbatch msScanbatch) {
49 55
         Integer page = msScanbatch.getPage();
50
-        Integer size = msScanbatch.getPageSize();
51
-        N_Utils.validation(new Object[]{page, "显示页码", 1, size, "显示条数", 1});
52
-        PageHelper.startPage(page, size);
53
-        List<MsScanbatch> list = msScanbatchService.queryList(msScanbatch);
54
-        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
55
-        return new ResultVo(0, "查询成功!", pageResult);
56
+        Integer pageSize = msScanbatch.getPageSize();
57
+        N_Utils.validation(new Object[]{page, "显示页码", 1, pageSize, "显示条数", 1,msScanbatch.getBatchid(), "批次id", 1});
58
+        PageHelper.startPage(page, pageSize);
59
+        List<MsScanbatchPaper> papers = msScanbatchService.listPaperByBatchid(msScanbatch.getBatchid());
60
+        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(papers));
61
+        return new ResultVo(0, "获取成功", pageResult);
62
+    }
63
+
64
+    /*
65
+     * @Description 扫描答卷
66
+     * @Date 2024/10/24 15:12:56
67
+     * @Author WN
68
+     * @Param [msScanbatch]
69
+     * @Return com.xhkjedu.vo.ResultVo
70
+     **/
71
+    @PostMapping("/scan_paper")
72
+    public ResultVo getExamScanPaper(@RequestBody MsScanbatch msScanbatch) {
73
+        Integer mpid = msScanbatch.getMpid();
74
+        N_Utils.validation(new Object[]{mpid, "试卷id", 1});
75
+        Map<String, Object> map = msScanbatchService.getExamPaperScanInfo(mpid);
76
+        return new ResultVo(0, "查询成功", map);
56 77
     }
57 78
 }

+ 3
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/paper/MsPaperMapper.java View File

@@ -46,4 +46,7 @@ public interface MsPaperMapper extends TkMapper<MsPaper> {
46 46
 
47 47
     //根据考试id和科目id获取试卷信息
48 48
     MsPaper getPaperByExamIdAndSubjectId(@Param("examId") Integer examId, @Param("subjectId") String subjectId);
49
+
50
+    //根据试卷ID获取考试ID
51
+    Integer getExamidByMpid(@Param("mpid") Integer mpid);
49 52
 }

+ 16
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/scan/MsScanbatchMapper.java View File

@@ -2,6 +2,10 @@ package com.xhkjedu.smarking.mapper.scan;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.scan.MsScanbatch;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
8
+import java.util.Map;
5 9
 
6 10
 /**
7 11
  * @Description 阅卷答题卡扫描批次表 Mapper 接口
@@ -9,4 +13,16 @@ import com.xhkjedu.smarking.model.scan.MsScanbatch;
9 13
  * @Date 2024-10-15
10 14
  */
11 15
 public interface MsScanbatchMapper extends TkMapper<MsScanbatch> {
16
+
17
+    //扫描答卷-考试试卷信息
18
+    Map<String, Object> getExamPaperScanInfo(@Param("mpid")Integer mpid);
19
+
20
+    //扫描答卷-扫描信息
21
+    List<Map<String,Object>> listScanBatchForPaper(@Param("mpid")Integer mpid);
22
+
23
+    //获取批次名称模糊数量
24
+    Integer getBatchNumByBatchname(@Param("batchname")String batchname);
25
+
26
+    //获取试卷所有扫描批次
27
+    List<Map<String,Object>> listScanBatchByMpidForSel(@Param("mpid")Integer mpid);
12 28
 }

+ 6
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/scan/MsScanbatchPaperMapper.java View File

@@ -2,6 +2,9 @@ package com.xhkjedu.smarking.mapper.scan;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.scan.MsScanbatchPaper;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
5 8
 
6 9
 /**
7 10
  * @Description 批阅扫描试卷表 Mapper 接口
@@ -9,4 +12,7 @@ import com.xhkjedu.smarking.model.scan.MsScanbatchPaper;
9 12
  * @Date 2024-10-15
10 13
  */
11 14
 public interface MsScanbatchPaperMapper extends TkMapper<MsScanbatchPaper> {
15
+
16
+    //获取批次下所有试卷
17
+    List<MsScanbatchPaper> listPaperByBatchid(@Param("batchid") Integer batchid);
12 18
 }

+ 5
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/scan/MsScanbatch.java View File

@@ -5,6 +5,7 @@ import lombok.Data;
5 5
 
6 6
 import javax.persistence.Id;
7 7
 import javax.persistence.Table;
8
+import javax.persistence.Transient;
8 9
 
9 10
 /**
10 11
  * @Description 阅卷答题卡扫描批次表
@@ -35,4 +36,8 @@ public class MsScanbatch extends BaseBean {
35 36
     private Integer createid;
36 37
     //创建时间
37 38
     private Integer createtime;
39
+
40
+    //扫描设备
41
+    @Transient
42
+    private String device;
38 43
 }

+ 71
- 11
smarking/src/main/java/com/xhkjedu/smarking/service/scan/MsScanbatchService.java View File

@@ -1,11 +1,18 @@
1 1
 package com.xhkjedu.smarking.service.scan;
2 2
 
3
+import com.xhkjedu.smarking.mapper.exam.MsClassMapper;
4
+import com.xhkjedu.smarking.mapper.paper.MsPaperMapper;
3 5
 import com.xhkjedu.smarking.mapper.scan.MsScanbatchMapper;
6
+import com.xhkjedu.smarking.mapper.scan.MsScanbatchPaperMapper;
4 7
 import com.xhkjedu.smarking.model.scan.MsScanbatch;
8
+import com.xhkjedu.smarking.model.scan.MsScanbatchPaper;
9
+import com.xhkjedu.utils.N_Utils;
5 10
 import org.springframework.stereotype.Service;
6 11
 
7 12
 import javax.annotation.Resource;
13
+import java.util.HashMap;
8 14
 import java.util.List;
15
+import java.util.Map;
9 16
 
10 17
 /**
11 18
  * @Description 阅卷答题卡扫描批次表 服务实现类
@@ -16,26 +23,79 @@ import java.util.List;
16 23
 public class MsScanbatchService {
17 24
     @Resource
18 25
     private MsScanbatchMapper msScanbatchMapper;
26
+    @Resource
27
+    private MsPaperMapper msPaperMapper;
28
+    @Resource
29
+    private MsScanbatchPaperMapper msScanbatchPaperMapper;
30
+    @Resource
31
+    private MsClassMapper msClassMapper;
19 32
 
20 33
     /**
21
-     * @Description 新增
34
+     * @Description 新增扫描批次
22 35
      * @Param [msScanbatch]
23 36
      * @Author auto
24 37
      * @Date 2024-10-15
25 38
      * @return void
26 39
      **/
27
-    public void add(MsScanbatch msScanbatch){
28
-        msScanbatchMapper.insert(msScanbatch);
40
+    public Map<String,Object> save(MsScanbatch msScanbatch){
41
+        String batchname = msScanbatch.getDevice() + "-" + msScanbatch.getMpid() + "-";
42
+        Integer batchnum = msScanbatchMapper.getBatchNumByBatchname(batchname);
43
+        if(!N_Utils.isTrueInteger(batchnum)){
44
+            batchnum = 1;
45
+        }else{
46
+            batchnum ++;
47
+        }
48
+        batchname += batchnum;
49
+        Integer examid = msPaperMapper.getExamidByMpid(msScanbatch.getMpid());
50
+        msScanbatch.setBatchname(batchname);
51
+        msScanbatch.setExamid(examid);
52
+        msScanbatch.setCreatetime(N_Utils.getSecondTimestamp());
53
+        msScanbatch.setBatchnum(0);
54
+        msScanbatch.setScannum(0);
55
+        msScanbatch.setUploadnum(0);
56
+        msScanbatch.setIdentifynum(0);
57
+        msScanbatchMapper.insertUseGeneratedKeys(msScanbatch);
58
+
59
+        Map<String,Object> map = new HashMap<>();
60
+        map.put("batchname",batchname);
61
+        map.put("batchid",msScanbatch.getId());
62
+        return map;
29 63
     }
30 64
 
31
-    /**
32
-     * @Description 列表
33
-     * @Param [msScanbatch]
34
-     * @Author auto
35
-     * @Date 2024-10-15
36
-     * @return java.util.List<com.xhkjedu.smarking.model.scan.MsScanbatch>
65
+    /*
66
+     * @Description 获取批次下所有试卷
67
+     * @Date 2024/10/24 16:25:47
68
+     * @Author WN
69
+     * @Param [batchid]
70
+     * @Return java.util.List<com.xhkjedu.smarking.model.scan.MsScanbatchPaper>
37 71
      **/
38
-    public List<MsScanbatch> queryList(MsScanbatch msScanbatch){
39
-        return msScanbatchMapper.selectAll();
72
+    public List<MsScanbatchPaper> listPaperByBatchid(Integer batchid){
73
+        return msScanbatchPaperMapper.listPaperByBatchid(batchid);
40 74
     }
75
+
76
+    /*
77
+     * @Description 扫描答题卡
78
+     * @Date 2024/10/24 15:09:33
79
+     * @Author WN
80
+     * @Param [mpid]
81
+     * @Return java.util.Map<java.lang.String,java.lang.Object>
82
+     **/
83
+    public Map<String,Object> getExamPaperScanInfo(Integer mpid){
84
+        Map<String,Object> map = msScanbatchMapper.getExamPaperScanInfo(mpid);
85
+        Map<String,Object> rtnMap = new HashMap<>();
86
+        rtnMap.put("paper",map);
87
+        rtnMap.put("scans",msScanbatchMapper.listScanBatchForPaper(mpid));
88
+        return rtnMap;
89
+    }
90
+
91
+    public Map<String,Object> getScanRecordAndClass(Integer mpid){
92
+        Map<String,Object> map = null;
93
+
94
+        //试卷扫描批次集合
95
+        List<Map<String,Object>> scans = msScanbatchMapper.listScanBatchByMpidForSel(mpid);
96
+        //参加考试的班级
97
+
98
+        return map;
99
+    }
100
+
41 101
 }

+ 4
- 0
smarking/src/main/resources/mapper/paper/MsPaperMapper.xml View File

@@ -86,4 +86,8 @@
86 86
         from ms_paper where examid=#{examid} and subjectid=#{subjectid}
87 87
     </select>
88 88
 
89
+    <!--根据试卷ID获取考试ID-->
90
+    <select id="getExamidByMpid" resultType="java.lang.Integer">
91
+        select examid from ms_paper where mpid=#{mpid}
92
+    </select>
89 93
 </mapper>

+ 26
- 0
smarking/src/main/resources/mapper/scan/MsScanbatchMapper.xml View File

@@ -1,4 +1,30 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.smarking.mapper.scan.MsScanbatchMapper">
4
+
5
+    <!--扫描答卷-考试试卷信息-->
6
+    <select id="getExamPaperScanInfo" resultType="java.util.Map">
7
+        select e.examid,e.examname,e.exammode,e.gradeid,s.msid,s.subjectid,s.subjectname,p.mpid,
8
+        (select sum(bqnum) from ms_paper_block where mpid=p.mpid and blocktype=1) objnum,
9
+        (select sum(bqnum) from ms_paper_block where mpid=p.mpid and blocktype=2) subnum,
10
+        (select count(mcsid) from ms_class_student where examid=e.examid and subjectid=s.subjectid) stunum
11
+        from ms_subject s left join ms_exam e on s.examid=e.examid
12
+        left join ms_paper p on s.msid=p.msid where p.mpid=#{mpid}
13
+    </select>
14
+
15
+    <!--扫描答卷-扫描信息-->
16
+    <select id="listScanBatchForPaper" resultType="java.util.Map">
17
+        select s.* from ms_scanbatch s where s.mpid=#{mpid} order by s.batchid
18
+    </select>
19
+
20
+    <!--获取批次名称模糊数量-->
21
+    <select id="getBatchNumByBatchname" resultType="java.lang.Integer">
22
+        select count(*) from ms_scanbatch where batchname like concat(#{batchname,jdbcType=VARCHAR},'%')
23
+    </select>
24
+
25
+    <!--获取试卷所有扫描批次-->
26
+    <select id="listScanBatchByMpidForSel" resultType="java.util.Map">
27
+        select batchid,batchname from ms_scanbatch where mpid=#{mpid} order by batchid
28
+    </select>
29
+
4 30
 </mapper>

+ 4
- 0
smarking/src/main/resources/mapper/scan/MsScanbatchPaperMapper.xml View File

@@ -1,4 +1,8 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.smarking.mapper.scan.MsScanbatchPaperMapper">
4
+    <!--获取批次下所有试卷-->
5
+    <select id="listPaperByBatchid" resultType="com.xhkjedu.smarking.model.scan.MsScanbatchPaper">
6
+        select * from ms_scanbatch_paper where batchid = #{batchid} order by mspid
7
+    </select>
4 8
 </mapper>

Loading…
Cancel
Save