Browse Source

扫描保存单张试卷信息

wn
王宁 2 months ago
parent
commit
7f5c1b9409
31 changed files with 681 additions and 201 deletions
  1. 5
    0
      sapi/src/main/java/com/xhkjedu/sapi/service/scantron/ScantronService.java
  2. 1
    1
      smarking/src/main/java/com/xhkjedu/smarking/controller/scan/MsScanbatchController.java
  3. 1
    3
      smarking/src/main/java/com/xhkjedu/smarking/controller/scan/MsScanbatchPaperController.java
  4. 142
    174
      smarking/src/main/java/com/xhkjedu/smarking/listener/MessageConsumer.java
  5. 3
    2
      smarking/src/main/java/com/xhkjedu/smarking/listener/MessageSender.java
  6. 6
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/scan/MsScanbatchMapper.java
  7. 6
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/scan/MsScanbatchPaperMapper.java
  8. 12
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/stupaper/MsPaperStudentBlockMapper.java
  9. 3
    1
      smarking/src/main/java/com/xhkjedu/smarking/mapper/stupaper/MsPaperStudentMapper.java
  10. 6
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/stupaper/MsPaperStudentQuestionMergeMapper.java
  11. 2
    0
      smarking/src/main/java/com/xhkjedu/smarking/mapper/system/UserMapper.java
  12. 1
    1
      smarking/src/main/java/com/xhkjedu/smarking/model/paper/MsPaperQtypeQuestion.java
  13. 0
    2
      smarking/src/main/java/com/xhkjedu/smarking/model/scan/MsScanbatch.java
  14. 6
    0
      smarking/src/main/java/com/xhkjedu/smarking/model/scan/MsScanbatchPaper.java
  15. 1
    1
      smarking/src/main/java/com/xhkjedu/smarking/model/scan/MsScanbatchPaperBlock.java
  16. 2
    2
      smarking/src/main/java/com/xhkjedu/smarking/model/scan/MsScanbatchPaperBlockQuestion.java
  17. 5
    4
      smarking/src/main/java/com/xhkjedu/smarking/model/stupaper/MsPaperStudent.java
  18. 14
    1
      smarking/src/main/java/com/xhkjedu/smarking/model/stupaper/MsPaperStudentBlock.java
  19. 15
    0
      smarking/src/main/java/com/xhkjedu/smarking/model/stupaper/MsPaperStudentQuestionMerge.java
  20. 1
    1
      smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperQtypeService.java
  21. 247
    3
      smarking/src/main/java/com/xhkjedu/smarking/service/scan/MsScanbatchPaperService.java
  22. 0
    1
      smarking/src/main/java/com/xhkjedu/smarking/service/scan/MsScanbatchService.java
  23. 2
    2
      smarking/src/main/java/com/xhkjedu/smarking/utils/ConvertUtil.java
  24. 108
    0
      smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java
  25. 9
    0
      smarking/src/main/resources/mapper/scan/MsScanbatchMapper.xml
  26. 2
    2
      smarking/src/main/resources/mapper/scan/MsScanbatchPaperBlockMapper.xml
  27. 1
    0
      smarking/src/main/resources/mapper/scan/MsScanbatchPaperBlockQuestionMapper.xml
  28. 12
    0
      smarking/src/main/resources/mapper/scan/MsScanbatchPaperMapper.xml
  29. 54
    0
      smarking/src/main/resources/mapper/stupaper/MsPaperStudentBlockMapper.xml
  30. 5
    0
      smarking/src/main/resources/mapper/stupaper/MsPaperStudentMapper.xml
  31. 9
    0
      smarking/src/main/resources/mapper/stupaper/MsPaperStudentQuestionMergeMapper.xml

+ 5
- 0
sapi/src/main/java/com/xhkjedu/sapi/service/scantron/ScantronService.java View File

@@ -42,6 +42,11 @@ public class ScantronService {
42 42
     }
43 43
     //答题卡-修改
44 44
     public void update(TScantron tScantron){
45
+        if(N_Utils.isTrueInteger(tScantron.getSlayout()) && tScantron.getSlayout() > 1){
46
+            tScantron.setPapertype(1);
47
+        }else{
48
+            tScantron.setPapertype(2);
49
+        }
45 50
         scantronMapper.updateByPrimaryKeySelective(tScantron);
46 51
     }
47 52
 

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

@@ -31,7 +31,7 @@ public class MsScanbatchController {
31 31
     private MsScanbatchService msScanbatchService;
32 32
 
33 33
     /**
34
-     * @Description 新增扫描试卷
34
+     * @Description 新增试卷扫描批次
35 35
      * @Param [msScanbatch]
36 36
      * @Author auto
37 37
      * @Date 2024-10-15

+ 1
- 3
smarking/src/main/java/com/xhkjedu/smarking/controller/scan/MsScanbatchPaperController.java View File

@@ -22,9 +22,7 @@ import java.util.Map;
22 22
 public class MsScanbatchPaperController {
23 23
     @Resource
24 24
     private MsScanbatchPaperService msScanbatchPaperService;
25
-
26
-
27
-
25
+    
28 26
 
29 27
     /*
30 28
      * @Description 扫描记录-查看原卷

+ 142
- 174
smarking/src/main/java/com/xhkjedu/smarking/listener/MessageConsumer.java View File

@@ -1,174 +1,142 @@
1
-// package com.xhkjedu.smarking.listener;
2
-//
3
-// import com.alibaba.fastjson.JSON;
4
-// import com.xhkjedu.sexam.mapper.exam.EBaseMapper;
5
-// import com.xhkjedu.sexam.mapper.paper.EPaperFileMapper;
6
-// import com.xhkjedu.sexam.mapper.paper.EPaperMapper;
7
-// import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentQuestionMapper;
8
-// import com.xhkjedu.sexam.mapper.paperstudent.EScanerrorMapper;
9
-// import com.xhkjedu.sexam.mapper.report.EReportGenerateMapper;
10
-// import com.xhkjedu.sexam.model.paper.EPaper;
11
-// import com.xhkjedu.sexam.model.paper.EPaperFile;
12
-// import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
13
-// import com.xhkjedu.sexam.model.paperstudent.EScanerror;
14
-// import com.xhkjedu.sexam.utils.ConvertUtil;
15
-// import com.xhkjedu.sexam.vo.report.EReportVo;
16
-// import lombok.extern.slf4j.Slf4j;
17
-// import org.springframework.amqp.core.Message;
18
-// import org.springframework.amqp.rabbit.annotation.RabbitHandler;
19
-// import org.springframework.amqp.rabbit.annotation.RabbitListener;
20
-// import org.springframework.beans.factory.annotation.Autowired;
21
-// import org.springframework.stereotype.Component;
22
-//
23
-// import javax.annotation.Resource;
24
-// import java.time.LocalDateTime;
25
-// import java.util.HashMap;
26
-// import java.util.Map;
27
-//
28
-// /**
29
-//  * 消息到达消费者监听类
30
-//  */
31
-// @Component
32
-// @Slf4j
33
-// public class MessageConsumer {
34
-//
35
-//     @Resource
36
-//     private EPaperStudentQuestionMapper ePaperStudentQuestionMapper;
37
-//     @Resource
38
-//     private EPaperMapper ePaperMapper;
39
-//     @Resource
40
-//     private EScanerrorMapper eScanerrorMapper;
41
-//     @Resource
42
-//     private EPaperFileMapper ePaperFileMapper;
43
-//     @Resource
44
-//     private EReportGenerateMapper eReportGenerateMapper;
45
-//     @Resource
46
-//     private EBaseMapper eBaseMapper;
47
-//     @Autowired
48
-//     private ConvertUtil convertUtil;
49
-//
50
-//
51
-//     /*
52
-//      * 学生答案图片合并完处理转换状态
53
-//      *
54
-//      * @param [message]
55
-//      * @return void
56
-//      * @author ywx
57
-//      * @date 2022/5/9 13:44
58
-//      */
59
-//     @RabbitHandler
60
-//     @RabbitListener(queues = "${rabbitmq.examImgMergeHandleQueue}")
61
-//     public void imgMergeHandleQueue(Message message) {
62
-//         try {
63
-//             String msg = new String(message.getBody(), "UTF-8");
64
-//             System.out.println(LocalDateTime.now() + "学生试题答案合并接收消息内容:" + msg);
65
-//             EPaperStudentQuestion psq = JSON.parseObject(msg, EPaperStudentQuestion.class);
66
-//             if (psq.getConverted() != 1) {//合并失败不修改学生答案
67
-//                 psq.setStuanswer(null);
68
-//             } else {
69
-//                 psq.setStuanswer(JSON.toJSONString(new String[]{psq.getStuanswer()}));
70
-//             }
71
-//             ePaperStudentQuestionMapper.updateByPrimaryKeySelective(psq);
72
-//         } catch (Exception e) {
73
-//             log.error("学生试题答案合并失败:" + e.getMessage());
74
-//         }
75
-//     }
76
-//
77
-//     /**
78
-//      * @Description 修改试卷答题卡pdf
79
-//      * @Param [message]
80
-//      * @Return void
81
-//      * @Author wn
82
-//      * @Date 2022/8/2 14:00
83
-//      **/
84
-//     @RabbitHandler
85
-//     @RabbitListener(queues = "${rabbitmq.examBaseToPdfHandleQueue}")
86
-//     public void baseToPdfHandleQueue(Message message) {
87
-//         try {
88
-//             String msg = new String(message.getBody(), "UTF-8");
89
-//             System.out.println(LocalDateTime.now() + "答题卡图片合并接收消息内容:" + msg);
90
-//             EPaper paper = JSON.parseObject(msg, EPaper.class);
91
-//             ePaperMapper.updatePaperScantronpdf(paper);
92
-//         } catch (Exception e) {
93
-//             log.error("答题卡图片合并失败:" + e.getMessage());
94
-//         }
95
-//     }
96
-//
97
-//     /**
98
-//      * @Description 扫码出错答题卡base64转图片
99
-//      * @Param [message]
100
-//      * @Return void
101
-//      * @Author wn
102
-//      * @Date 2022/9/19 9:46
103
-//      **/
104
-//     @RabbitHandler
105
-//     @RabbitListener(queues = "${rabbitmq.examBaseToScanImgHandleQueue}")
106
-//     public void baseToScanImgHandleQueue(Message message) {
107
-//         try {
108
-//             String msg = new String(message.getBody(), "UTF-8");
109
-//             System.out.println(LocalDateTime.now() + "扫码出错答题卡base64转图片接收消息内容:" + msg);
110
-//             EScanerror eScanerror = JSON.parseObject(msg, EScanerror.class);
111
-//             if (eScanerror.getConverted() != null && eScanerror.getConverted() == 1) {
112
-//                 eScanerrorMapper.updateErrorStupic(eScanerror.getSerrorid(), eScanerror.getStupic());
113
-//             }
114
-//         } catch (Exception e) {
115
-//             log.error("扫码出错答题卡base64转图片失败:" + e.getMessage());
116
-//         }
117
-//     }
118
-//
119
-//     /**
120
-//      * @Description 考试附件试卷图片转pdf
121
-//      * @Param [message]
122
-//      * @Return void
123
-//      * @Author wn
124
-//      * @Date 2022/11/1 10:45
125
-//      **/
126
-//     @RabbitHandler
127
-//     @RabbitListener(queues = "${rabbitmq.examImgToPdfHandleQueue}")
128
-//     public void examImageToPdfHandleQueue(Message message) {
129
-//         try {
130
-//             String msg = new String(message.getBody(), "UTF-8");
131
-//             System.out.println(LocalDateTime.now() + "考试附件试卷图片转pdf接收消息内容:" + msg);
132
-//             EPaperFile paperFile = JSON.parseObject(msg, EPaperFile.class);
133
-//             if (paperFile.getConverted() != null && paperFile.getConverted() == 1) {
134
-//                 ePaperFileMapper.updateSourcepathByEpid(paperFile.getEpid(),paperFile.getSourcepath());
135
-//             }
136
-//         } catch (Exception e) {
137
-//             log.error("考试附件试卷图片转pdf失败:" + e.getMessage());
138
-//         }
139
-//     }
140
-//
141
-//     @RabbitHandler
142
-//     @RabbitListener(queues = "${rabbitmq.examHtmlToPdfHandleQueue}")
143
-//     public void examHtmlToPdfHandleQueue(Message message) {
144
-//         try {
145
-//             String msg = new String(message.getBody(), "UTF-8");
146
-//             System.out.println(LocalDateTime.now() + "考试报告html转pdf接收消息内容:" + msg);
147
-//             EReportVo report = JSON.parseObject(msg, EReportVo.class);
148
-//             if (report.getConverted() != null && report.getConverted() != 1) return;
149
-//             eReportGenerateMapper.updatePdf(report);//修改考试pdf地址
150
-//             Integer examid = report.getExamid();
151
-//             Integer type = report.getType();
152
-//             if (3 == type) {
153
-//                 Integer classid = report.getClassid();
154
-//                 Integer num = eReportGenerateMapper.getNoPdfNumByExamAndClassId(examid, classid);//考试班级未生成pdf的数量
155
-//                 if (0 == num) {
156
-//                     Map map = new HashMap();
157
-//                     String savefolder = eReportGenerateMapper.getSaveFolder(examid);
158
-//                     map.put("savefolder", savefolder + "/" +  + classid);
159
-//                     map.put("examid", examid);
160
-//                     map.put("classid", classid);
161
-//                     map.put("type", 4);
162
-//                     convertUtil.htmlToPdf(map);
163
-//                 }
164
-//             } else if (4 == type) {
165
-//                 Integer num = eReportGenerateMapper.getNoPdfNumByExamId(examid);//考试未生成pdf的数量
166
-//                 if (0 == num) {
167
-//                     eBaseMapper.updateExamReportState(examid, 2);
168
-//                 }
169
-//             }
170
-//         } catch (Exception e) {
171
-//             log.error("考试报告html转pdf失败:" + e.getMessage());
172
-//         }
173
-//     }
174
-// }
1
+package com.xhkjedu.smarking.listener;
2
+
3
+import com.xhkjedu.smarking.utils.ConvertUtil;
4
+import lombok.extern.slf4j.Slf4j;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.stereotype.Component;
7
+
8
+/**
9
+ * 消息到达消费者监听类
10
+ */
11
+@Component
12
+@Slf4j
13
+public class MessageConsumer {
14
+
15
+
16
+    @Autowired
17
+    private ConvertUtil convertUtil;
18
+
19
+
20
+    /*
21
+     * @Description 学生题块、试题答案图片合并完处理转换状态
22
+     * @Date 2024/10/29 14:43:39
23
+     * @Author WN
24
+     * @Param [message]
25
+     * @Return void
26
+     **/
27
+    // @RabbitHandler
28
+    // @RabbitListener(queues = "${rabbitmq.markingImgMergeHandleQueue}")
29
+    // public void imgMergeHandleQueue(Message message) {
30
+    //     try {
31
+    //         String msg = new String(message.getBody(), "UTF-8");
32
+    //         System.out.println(LocalDateTime.now() + "学生题块、试题答案合并接收消息内容:" + msg);
33
+    //         EPaperStudentQuestion psq = JSON.parseObject(msg, EPaperStudentQuestion.class);
34
+    //         if (psq.getConverted() != 1) {//合并失败不修改学生答案
35
+    //             psq.setStuanswer(null);
36
+    //         } else {
37
+    //             psq.setStuanswer(JSON.toJSONString(new String[]{psq.getStuanswer()}));
38
+    //         }
39
+    //         ePaperStudentQuestionMapper.updateByPrimaryKeySelective(psq);
40
+    //     } catch (Exception e) {
41
+    //         log.error("学生试题答案合并失败:" + e.getMessage());
42
+    //     }
43
+    // }
44
+
45
+    /**
46
+     * @Description 修改试卷答题卡pdf
47
+     * @Param [message]
48
+     * @Return void
49
+     * @Author wn
50
+     * @Date 2022/8/2 14:00
51
+     **/
52
+    // @RabbitHandler
53
+    // @RabbitListener(queues = "${rabbitmq.markingBaseToPdfHandleQueue}")
54
+    // public void baseToPdfHandleQueue(Message message) {
55
+    //     try {
56
+    //         String msg = new String(message.getBody(), "UTF-8");
57
+    //         System.out.println(LocalDateTime.now() + "答题卡图片合并接收消息内容:" + msg);
58
+    //         EPaper paper = JSON.parseObject(msg, EPaper.class);
59
+    //         ePaperMapper.updatePaperScantronpdf(paper);
60
+    //     } catch (Exception e) {
61
+    //         log.error("答题卡图片合并失败:" + e.getMessage());
62
+    //     }
63
+    // }
64
+
65
+    /**
66
+     * @Description 扫码出错答题卡base64转图片
67
+     * @Param [message]
68
+     * @Return void
69
+     * @Author wn
70
+     * @Date 2022/9/19 9:46
71
+     **/
72
+    // @RabbitHandler
73
+    // @RabbitListener(queues = "${rabbitmq.markingBaseToScanImgHandleQueue}")
74
+    // public void baseToScanImgHandleQueue(Message message) {
75
+    //     try {
76
+    //         String msg = new String(message.getBody(), "UTF-8");
77
+    //         System.out.println(LocalDateTime.now() + "扫码出错答题卡base64转图片接收消息内容:" + msg);
78
+    //         EScanerror eScanerror = JSON.parseObject(msg, EScanerror.class);
79
+    //         if (eScanerror.getConverted() != null && eScanerror.getConverted() == 1) {
80
+    //             eScanerrorMapper.updateErrorStupic(eScanerror.getSerrorid(), eScanerror.getStupic());
81
+    //         }
82
+    //     } catch (Exception e) {
83
+    //         log.error("扫码出错答题卡base64转图片失败:" + e.getMessage());
84
+    //     }
85
+    // }
86
+
87
+    /**
88
+     * @Description 考试附件试卷图片转pdf
89
+     * @Param [message]
90
+     * @Return void
91
+     * @Author wn
92
+     * @Date 2022/11/1 10:45
93
+     **/
94
+    // @RabbitHandler
95
+    // @RabbitListener(queues = "${rabbitmq.markingImgToPdfHandleQueue}")
96
+    // public void examImageToPdfHandleQueue(Message message) {
97
+    //     try {
98
+    //         String msg = new String(message.getBody(), "UTF-8");
99
+    //         System.out.println(LocalDateTime.now() + "考试附件试卷图片转pdf接收消息内容:" + msg);
100
+    //         EPaperFile paperFile = JSON.parseObject(msg, EPaperFile.class);
101
+    //         if (paperFile.getConverted() != null && paperFile.getConverted() == 1) {
102
+    //             ePaperFileMapper.updateSourcepathByEpid(paperFile.getEpid(),paperFile.getSourcepath());
103
+    //         }
104
+    //     } catch (Exception e) {
105
+    //         log.error("考试附件试卷图片转pdf失败:" + e.getMessage());
106
+    //     }
107
+    // }
108
+
109
+    // @RabbitHandler
110
+    // @RabbitListener(queues = "${rabbitmq.markingHtmlToPdfHandleQueue}")
111
+    // public void examHtmlToPdfHandleQueue(Message message) {
112
+    //     try {
113
+    //         String msg = new String(message.getBody(), "UTF-8");
114
+    //         System.out.println(LocalDateTime.now() + "考试报告html转pdf接收消息内容:" + msg);
115
+    //         EReportVo report = JSON.parseObject(msg, EReportVo.class);
116
+    //         if (report.getConverted() != null && report.getConverted() != 1) return;
117
+    //         eReportGenerateMapper.updatePdf(report);//修改考试pdf地址
118
+    //         Integer examid = report.getExamid();
119
+    //         Integer type = report.getType();
120
+    //         if (3 == type) {
121
+    //             Integer classid = report.getClassid();
122
+    //             Integer num = eReportGenerateMapper.getNoPdfNumByExamAndClassId(examid, classid);//考试班级未生成pdf的数量
123
+    //             if (0 == num) {
124
+    //                 Map map = new HashMap();
125
+    //                 String savefolder = eReportGenerateMapper.getSaveFolder(examid);
126
+    //                 map.put("savefolder", savefolder + "/" +  + classid);
127
+    //                 map.put("examid", examid);
128
+    //                 map.put("classid", classid);
129
+    //                 map.put("type", 4);
130
+    //                 convertUtil.htmlToPdf(map);
131
+    //             }
132
+    //         } else if (4 == type) {
133
+    //             Integer num = eReportGenerateMapper.getNoPdfNumByExamId(examid);//考试未生成pdf的数量
134
+    //             if (0 == num) {
135
+    //                 eBaseMapper.updateExamReportState(examid, 2);
136
+    //             }
137
+    //         }
138
+    //     } catch (Exception e) {
139
+    //         log.error("考试报告html转pdf失败:" + e.getMessage());
140
+    //     }
141
+    // }
142
+}

+ 3
- 2
smarking/src/main/java/com/xhkjedu/smarking/listener/MessageSender.java View File

@@ -52,11 +52,12 @@ public class MessageSender {
52 52
      * @Author wn
53 53
      * @Date 2022/7/28 16:46
54 54
      **/
55
-    public void imgMerge(Integer epsqid, List<String> userAnswers, Integer device) {
55
+    public void imgMerge(Integer mpsbid, List<String> userAnswers, Integer device) {
56 56
         Map map = new HashMap();
57
-        map.put("epsqid", epsqid);
57
+        map.put("mpsbid", mpsbid);
58 58
         map.put("stuanswers", userAnswers);
59 59
         map.put("device", device);
60
+        map.put("device", device);
60 61
         if (userAnswers.toString().contains(node2)) {
61 62
             rabbitTemplate.convertAndSend(markingImgMergeQueue2, JSON.toJSONString(map));
62 63
         } else {

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

@@ -35,4 +35,10 @@ public interface MsScanbatchMapper extends TkMapper<MsScanbatch> {
35 35
 
36 36
     //扫描记录-按批次
37 37
     List<Map<String,Object>> listRecordBatchStudents(@Param("params")ScanParams params);
38
+
39
+    //修改扫描数量
40
+    int updateScannum(@Param("batchid")Integer batchid);
41
+
42
+    //修改识别数量
43
+    int updateIdentifynum(@Param("batchid")Integer batchid);
38 44
 }

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

@@ -19,4 +19,10 @@ public interface MsScanbatchPaperMapper extends TkMapper<MsScanbatchPaper> {
19 19
 
20 20
     //查看原卷-试卷信息
21 21
     Map<String,Object> getScanPaperByMspid(@Param("mspid") Integer mspid);
22
+
23
+    //试卷标记为异常
24
+    Integer updatePaperErrortype(@Param("mspid") Integer mspid, @Param("errortype") Integer errortype);
25
+
26
+    //指定试卷和考号下未处理异常数量
27
+    Integer getErrorNumByMpidAndExamno(@Param("mpid") Integer mpid, @Param("examno") String examno);
22 28
 }

+ 12
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/stupaper/MsPaperStudentBlockMapper.java View File

@@ -2,6 +2,9 @@ package com.xhkjedu.smarking.mapper.stupaper;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.stupaper.MsPaperStudentBlock;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
5 8
 
6 9
 /**
7 10
  * @Description 阅卷试卷学生题块 Mapper 接口
@@ -9,4 +12,13 @@ import com.xhkjedu.smarking.model.stupaper.MsPaperStudentBlock;
9 12
  * @Date 2024-10-15
10 13
  */
11 14
 public interface MsPaperStudentBlockMapper extends TkMapper<MsPaperStudentBlock> {
15
+
16
+    //根据学生试卷ID清空作答及批阅信息
17
+    int updateStudentBlockQuestionByMpsid(@Param("mpsid")Integer mpsid);
18
+
19
+    //获取学生题块试题
20
+    List<MsPaperStudentBlock> listPaperStuBlockQuestions(@Param("mpsid")Integer mpsid);
21
+
22
+    //批量更改学生题块
23
+    int updateBatchStuBlock(@Param("list")List<MsPaperStudentBlock> list);
12 24
 }

+ 3
- 1
smarking/src/main/java/com/xhkjedu/smarking/mapper/stupaper/MsPaperStudentMapper.java View File

@@ -1,7 +1,6 @@
1 1
 package com.xhkjedu.smarking.mapper.stupaper;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4
-import com.xhkjedu.smarking.model.exam.MsClassStudent;
5 4
 import com.xhkjedu.smarking.model.stupaper.MsPaperStudent;
6 5
 import com.xhkjedu.smarking.vo.exam.CStudentVo;
7 6
 import org.apache.ibatis.annotations.Param;
@@ -19,4 +18,7 @@ public interface MsPaperStudentMapper extends TkMapper<MsPaperStudent> {
19 18
 
20 19
     //获取学生科目试卷状态
21 20
     Integer getStateByStudentIdAndSubjectId(@Param("cs") CStudentVo cs);
21
+
22
+    //获取试卷学生信息
23
+    MsPaperStudent getPaperStudentByStudentidAndMpid(@Param("studentId") Integer studentId, @Param("mpId") Integer mpId);
22 24
 }

+ 6
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/stupaper/MsPaperStudentQuestionMergeMapper.java View File

@@ -2,6 +2,9 @@ package com.xhkjedu.smarking.mapper.stupaper;
2 2
 
3 3
 import com.xhkjedu.base.TkMapper;
4 4
 import com.xhkjedu.smarking.model.stupaper.MsPaperStudentQuestionMerge;
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.stupaper.MsPaperStudentQuestionMerge;
9 12
  * @Date 2024-10-15
10 13
  */
11 14
 public interface MsPaperStudentQuestionMergeMapper extends TkMapper<MsPaperStudentQuestionMerge> {
15
+
16
+    //批量修改学生试题
17
+    int updateBatchStuQues(@Param("list") List<MsPaperStudentQuestionMerge> list);
12 18
 }

+ 2
- 0
smarking/src/main/java/com/xhkjedu/smarking/mapper/system/UserMapper.java View File

@@ -39,4 +39,6 @@ public interface UserMapper {
39 39
 
40 40
     //获取用户信息用户操作日志
41 41
     UserVo getUserInfoForHandleLog(@Param("userid") Integer userid);
42
+
43
+
42 44
 }

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/model/paper/MsPaperQtypeQuestion.java View File

@@ -42,7 +42,7 @@ public class MsPaperQtypeQuestion extends BaseBean {
42 42
     //正确答案
43 43
     private String qanswer;
44 44
     //少选分值
45
-    private Integer loseoption;
45
+    private Double loseoption;
46 46
     //分值设置0默认1送分题 20分题
47 47
     private Integer scoreset;
48 48
     //试题难易度

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

@@ -24,8 +24,6 @@ public class MsScanbatch extends BaseBean {
24 24
     private Integer examid;
25 25
     //试卷id
26 26
     private Integer mpid;
27
-    //批次应扫张数
28
-    private Integer batchnum;
29 27
     //扫描总数量
30 28
     private Integer scannum;
31 29
     //上传数量

+ 6
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/scan/MsScanbatchPaper.java View File

@@ -27,6 +27,9 @@ public class MsScanbatchPaper extends BaseBean {
27 27
     private String paperfront;
28 28
     //试卷反面
29 29
     private String paperback;
30
+
31
+    //扫描时第几张
32
+    private Integer pagenum;
30 33
     //是否识别0未识别1已识别
31 34
     private Integer identified;
32 35
     //考号
@@ -49,4 +52,7 @@ public class MsScanbatchPaper extends BaseBean {
49 52
     //扫描试卷块表
50 53
     @Transient
51 54
     private List<MsScanbatchPaperBlock> spblocks;
55
+
56
+    @Transient
57
+    private Integer mpid;//试卷ID
52 58
 }

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/model/scan/MsScanbatchPaperBlock.java View File

@@ -24,7 +24,7 @@ public class MsScanbatchPaperBlock extends BaseBean {
24 24
     //扫描试卷ID
25 25
     private Integer mspid;
26 26
     //题块ID
27
-    private Integer mpblockid;
27
+    private Integer mblockid;
28 28
     //图片
29 29
     private String picpath;
30 30
     //扩展图片

+ 2
- 2
smarking/src/main/java/com/xhkjedu/smarking/model/scan/MsScanbatchPaperBlockQuestion.java View File

@@ -19,8 +19,8 @@ public class MsScanbatchPaperBlockQuestion extends BaseBean {
19 19
     private Integer mspbqid;
20 20
     //扫描题块ID
21 21
     private Integer mspbid;
22
-    //合并试题ID
23
-    private Integer mpsqmid;
22
+    //题块试题ID
23
+    private Integer mbqid;
24 24
     //识别结果
25 25
     private String identifycont;
26 26
 }

+ 5
- 4
smarking/src/main/java/com/xhkjedu/smarking/model/stupaper/MsPaperStudent.java View File

@@ -55,14 +55,15 @@ public class MsPaperStudent extends BaseBean {
55 55
     private Integer batchid;
56 56
     //扫描批次下试卷ID
57 57
     private Integer mspid;
58
-    //学生答题卡图片
59
-    private String stupic;
58
+    //学生答题卡正面图片
59
+    private String paperfront;
60
+    //学生答题卡反面图片
61
+    private String paperback;
60 62
     //扫码时第几张
61 63
     private Integer pagenum;
62 64
     //设备web、pad
63 65
     private String device;
64 66
     //提交方式:1主动提交2自动提交3返回提交
65 67
     private Integer submittype;
66
-    //是否验证0待验证1验证通过2验证不通过
67
-    private Integer verified;
68
+
68 69
 }

+ 14
- 1
smarking/src/main/java/com/xhkjedu/smarking/model/stupaper/MsPaperStudentBlock.java View File

@@ -5,6 +5,8 @@ import lombok.Data;
5 5
 
6 6
 import javax.persistence.Id;
7 7
 import javax.persistence.Table;
8
+import javax.persistence.Transient;
9
+import java.util.List;
8 10
 
9 11
 /**
10 12
  * @Description 阅卷试卷学生题块
@@ -25,8 +27,12 @@ public class MsPaperStudentBlock extends BaseBean {
25 27
     private Integer mblockid;
26 28
     //学生ID
27 29
     private Integer studentid;
30
+    //试卷学生ID
31
+    private Integer mpsid;
28 32
     //学生答案图片
29 33
     private String stuanswer;
34
+    //是否转换0未转换1已转换2转换失败
35
+    private Integer converted;
30 36
     //是否疑难卷0默认1是
31 37
     private Integer hasproblem;
32 38
     //疑难类型1图形模糊2答题错位3没有图像4图像颠倒5其他问题
@@ -37,10 +43,17 @@ public class MsPaperStudentBlock extends BaseBean {
37 43
     private Integer hasgood;
38 44
     //是否违规试卷0默认1是
39 45
     private Integer hasbad;
40
-    //是否最终批改结果
46
+    //是否最终批改结果0否1是
41 47
     private Integer hasfinal;
42 48
     //最终批改原因1仲裁2学科组成批
43 49
     private Integer finalreason;
44 50
     //创建时间
45 51
     private Integer createtime;
52
+
53
+    //学生题块下试题
54
+    @Transient
55
+    private List<MsPaperStudentQuestionMerge> questions;
56
+    //题块类型1客观题2主观题
57
+    @Transient
58
+    private Integer blocktype;
46 59
 }

+ 15
- 0
smarking/src/main/java/com/xhkjedu/smarking/model/stupaper/MsPaperStudentQuestionMerge.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 阅卷试卷学生合并后试题表
@@ -29,6 +30,8 @@ public class MsPaperStudentQuestionMerge extends BaseBean {
29 30
     private Integer mpsid;
30 31
     //题块试题ID
31 32
     private Integer mbqid;
33
+    //试卷学生题块ID
34
+    private Integer mpsbid;
32 35
     //处理题型
33 36
     private Integer ctype;
34 37
     //试题id
@@ -83,4 +86,16 @@ public class MsPaperStudentQuestionMerge extends BaseBean {
83 86
     private Integer problemtype;
84 87
     //疑难备注
85 88
     private String problemcomm;
89
+
90
+    @Transient
91
+    private String qanswer;//试题答案
92
+    @Transient
93
+    private Integer hasanswer;//是否设置正确答案0未设置1已设置
94
+    //少选分值
95
+    @Transient
96
+    private Double loseoption;
97
+
98
+    //分值设置0默认1送分题 20分题
99
+    @Transient
100
+    private Integer scoreset;
86 101
 }

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/service/paper/MsPaperQtypeService.java View File

@@ -160,7 +160,7 @@ public class MsPaperQtypeService {
160 160
                     q.setOptionnum(0);
161 161
                 }
162 162
                 if (q.getLoseoption() == null) {
163
-                    q.setLoseoption(0);
163
+                    q.setLoseoption(0.0);
164 164
                 }
165 165
                 if (q.getScoreset() == null) {
166 166
                     q.setScoreset(0);

+ 247
- 3
smarking/src/main/java/com/xhkjedu/smarking/service/scan/MsScanbatchPaperService.java View File

@@ -1,11 +1,22 @@
1 1
 package com.xhkjedu.smarking.service.scan;
2 2
 
3
+import com.alibaba.fastjson.JSON;
4
+import com.xhkjedu.smarking.mapper.scan.MsScanbatchMapper;
3 5
 import com.xhkjedu.smarking.mapper.scan.MsScanbatchPaperBlockMapper;
4 6
 import com.xhkjedu.smarking.mapper.scan.MsScanbatchPaperBlockQuestionMapper;
5 7
 import com.xhkjedu.smarking.mapper.scan.MsScanbatchPaperMapper;
8
+import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentBlockMapper;
9
+import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentMapper;
10
+import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentQuestionMergeMapper;
11
+import com.xhkjedu.smarking.mapper.system.UserMapper;
6 12
 import com.xhkjedu.smarking.model.scan.MsScanbatchPaper;
7 13
 import com.xhkjedu.smarking.model.scan.MsScanbatchPaperBlock;
8 14
 import com.xhkjedu.smarking.model.scan.MsScanbatchPaperBlockQuestion;
15
+import com.xhkjedu.smarking.model.stupaper.MsPaperStudent;
16
+import com.xhkjedu.smarking.model.stupaper.MsPaperStudentBlock;
17
+import com.xhkjedu.smarking.model.stupaper.MsPaperStudentQuestionMerge;
18
+import com.xhkjedu.smarking.utils.ConvertUtil;
19
+import com.xhkjedu.smarking.utils.MarkingUtil;
9 20
 import com.xhkjedu.utils.N_Utils;
10 21
 import org.springframework.stereotype.Service;
11 22
 import org.springframework.transaction.annotation.Transactional;
@@ -28,20 +39,99 @@ public class MsScanbatchPaperService {
28 39
     private MsScanbatchPaperBlockMapper msScanbatchPaperBlockMapper;
29 40
     @Resource
30 41
     private MsScanbatchPaperBlockQuestionMapper msScanbatchPaperBlockQuestionMapper;
42
+    @Resource
43
+    private MsScanbatchMapper msScanbatchMapper;
44
+    @Resource
45
+    private UserMapper userMapper;
46
+    @Resource
47
+    private MsPaperStudentMapper msPaperStudentMapper;
48
+    @Resource
49
+    private MsPaperStudentQuestionMergeMapper msPaperStudentQuestionMergeMapper;
50
+    @Resource
51
+    private MsPaperStudentBlockMapper msPaperStudentBlockMapper;
52
+    @Resource
53
+    private ConvertUtil convertUtil;
31 54
 
32 55
     /**
33 56
      * @Description 新增
34 57
      * @Param [msScanbatchPaper]
35 58
      * @Author auto
36 59
      * @Date 2024-10-15
37
-     * @return void
38 60
      **/
39 61
     @Transactional(rollbackFor = Exception.class)
40 62
     public void add(MsScanbatchPaper msScanbatchPaper){
63
+        //保存一次,扫描次数加1
64
+        msScanbatchMapper.updateScannum(msScanbatchPaper.getBatchid());
65
+
66
+        Integer timestamp = N_Utils.getSecondTimestamp();
67
+        msScanbatchPaper.setCreatetime(timestamp);
68
+
69
+        //获取考号
70
+        String examno = msScanbatchPaper.getExamno();
71
+        //考号不存在,异常信息2考号有误(异常类型1扫描出错 2考号有误 3考号重复 4缺考异常)
72
+        if(N_Utils.isEmpty(examno)){
73
+            msScanbatchPaper.setHaserror(1);
74
+            msScanbatchPaper.setErrortype(2);
75
+            savePaperBlockQuestions(msScanbatchPaper);
76
+            return;
77
+        }
78
+
79
+        //考号存在,获取对应的试卷信息是否有异常,如果有则该条数据也标识为异常,异常信息3考号重复
80
+        Integer errorNum = msScanbatchPaperMapper.getErrorNumByMpidAndExamno(msScanbatchPaper.getMpid(),examno);
81
+        if(errorNum > 0){
82
+            msScanbatchPaper.setHaserror(1);
83
+            msScanbatchPaper.setErrortype(3);
84
+            savePaperBlockQuestions(msScanbatchPaper);
85
+        }
86
+
87
+        //根据考号获取学生
88
+        Integer userid = userMapper.getUseridByExamno(examno);
89
+        //用户不存在,异常信息2考号有误
90
+        if(!N_Utils.isTrueInteger(userid)){
91
+            msScanbatchPaper.setHaserror(1);
92
+            msScanbatchPaper.setErrortype(2);
93
+            savePaperBlockQuestions(msScanbatchPaper);
94
+            return;
95
+        }
96
+        //用户存在,获取用户试卷信息
97
+        MsPaperStudent msPaperStudent = msPaperStudentMapper.getPaperStudentByStudentidAndMpid(userid,msScanbatchPaper.getMpid());
98
+        //试卷不存在,异常信息1扫描出错
99
+        if(msPaperStudent == null){
100
+            msScanbatchPaper.setHaserror(1);
101
+            msScanbatchPaper.setErrortype(1);
102
+            savePaperBlockQuestions(msScanbatchPaper);
103
+            return;
104
+        }
105
+        //试卷存在,判断学生是否已绑定扫描试卷信息,已有保存扫描信息本次异常,异常信息3考号重复
106
+        if(N_Utils.isTrueInteger(msPaperStudent.getMspid())){
107
+            msScanbatchPaper.setHaserror(1);
108
+            msScanbatchPaper.setErrortype(3);
109
+            savePaperBlockQuestions(msScanbatchPaper);
110
+            //处理上一次对应扫描试卷为3考号重复,并清空学生试卷试题信息
111
+            msScanbatchPaperMapper.updatePaperErrortype(msPaperStudent.getMspid(),3);
112
+            updatePaperStudentQuestion(msPaperStudent);
113
+            return;
114
+        }
41 115
 
42
-        msScanbatchPaper.setCreatetime(N_Utils.getSecondTimestamp());
116
+
117
+        //保存扫描信息
118
+        savePaperBlockQuestions(msScanbatchPaper);
119
+        //学生试卷信息
120
+        int answernum = saveStudentBlockQuestions(msScanbatchPaper,msPaperStudent.getMpsid());
121
+        if (!N_Utils.isEmptyInteger(msScanbatchPaper.getMissexam()) && msScanbatchPaper.getMissexam() == 1 && answernum>0) {//缺考
122
+            //如果标记考试缺考,且答题数量大于0属于异常,异常信息4缺考异常
123
+            msScanbatchPaper.setHaserror(1);
124
+            msScanbatchPaper.setErrortype(4);
125
+            //修改扫描信息
126
+            msScanbatchPaperMapper.updatePaperErrortype(msPaperStudent.getMspid(),4);
127
+        }
128
+    }
129
+
130
+    //保存扫描试卷-保存扫描题块试题信息
131
+    private void savePaperBlockQuestions(MsScanbatchPaper msScanbatchPaper){
43 132
         msScanbatchPaperMapper.insertUseGeneratedKeys(msScanbatchPaper);
44 133
         Integer mspid = msScanbatchPaper.getId();
134
+        msScanbatchPaper.setMspid(mspid);
45 135
 
46 136
         //保存试题
47 137
         List<MsScanbatchPaperBlock> spblocks = msScanbatchPaper.getSpblocks();
@@ -60,7 +150,161 @@ public class MsScanbatchPaperService {
60 150
                 saveQuestions.add(spbquestion);
61 151
             }
62 152
         }
63
-        msScanbatchPaperBlockQuestionMapper.insertList(saveQuestions);
153
+        if(N_Utils.isListNotEmpty(saveQuestions)){
154
+            msScanbatchPaperBlockQuestionMapper.insertList(saveQuestions);
155
+        }
156
+        //更改识别数量
157
+        msScanbatchMapper.updateIdentifynum(msScanbatchPaper.getBatchid());
158
+
159
+    }
160
+
161
+    //保存扫描试卷-清空学生试卷题块试题信息
162
+    private void updatePaperStudentQuestion(MsPaperStudent msPaperStudent){
163
+        Integer mspid = msPaperStudent.getMspid();
164
+        //清空学生题块、试题 作答信息及批阅信息
165
+        msPaperStudentBlockMapper.updateStudentBlockQuestionByMpsid(mspid);
166
+
167
+        //清空学生试卷信息
168
+        MsPaperStudent ps = new MsPaperStudent();
169
+        ps.setBatchid(null);
170
+        ps.setMspid(null);
171
+        ps.setSstate(0);
172
+        ps.setChecked(0);
173
+        ps.setStuscore(0.0);
174
+        ps.setStuscoretype(0);
175
+        ps.setHasbad(0);
176
+        ps.setPaperfront(null);
177
+        ps.setPaperback(null);
178
+        ps.setPagenum(0);
179
+        ps.setMpsid(msPaperStudent.getMpsid());
180
+
181
+        msPaperStudentMapper.updateByPrimaryKeySelective(ps);
182
+    }
183
+
184
+    //保存扫描试卷-保存学生试卷题块信息
185
+    private int saveStudentBlockQuestions(MsScanbatchPaper msScanbatchPaper,Integer mpsid){
186
+        int rtnanswernum = 0;//试题数量
187
+
188
+        //扫描试卷中切割题块
189
+        List<MsScanbatchPaperBlock> spblocks = msScanbatchPaper.getSpblocks();
190
+
191
+        //学生题块试题信息
192
+        List<MsPaperStudentBlock> paperQuestions =msPaperStudentBlockMapper.listPaperStuBlockQuestions(mpsid);
193
+        //扫描的题块数量和学生试题题块数量不一致
194
+        if(spblocks.size() != paperQuestions.size()){
195
+            return -1;
196
+        }
197
+
198
+        Integer checknum = 0;//记录试卷中已批改题块数量
199
+        Double stuPaperScore = 0.0;//学生试卷得分
200
+        List<MsPaperStudentBlock>  saveBlockList = new ArrayList<>();// 保存学生题块信息
201
+        List<MsPaperStudentQuestionMerge> saveQuesList = new ArrayList<>();//保存学生提交试题
202
+        List<MsPaperStudentBlock> needConvertList = new ArrayList<>();//需要合并图片的题块
203
+        Integer timestamp = N_Utils.getSecondTimestamp();
204
+
205
+        for(MsScanbatchPaperBlock spblock : spblocks){
206
+            String picPath = spblock.getPicpath();
207
+            MsPaperStudentBlock studentBlock = paperQuestions.stream().filter(b -> b.getMblockid().equals(spblock.getMblockid())).findFirst().orElse(null);
208
+            studentBlock.setStuanswer(picPath);
209
+            List<String> stuPicList = JSON.parseArray(picPath, String.class);//判断有几张图片
210
+            Integer converted = 1;
211
+            if(stuPicList!= null && stuPicList.size() > 1){
212
+                converted = 0;
213
+            }
214
+            studentBlock.setConverted(0);
215
+            saveBlockList.add(studentBlock);
216
+            needConvertList.add(studentBlock);
217
+
218
+            List<MsPaperStudentQuestionMerge> stuQuestions = studentBlock.getQuestions();//学生试题
219
+            List<MsScanbatchPaperBlockQuestion> spbquestions = spblock.getSpbquestions();//扫描题块下试题
220
+            if(studentBlock.getBlocktype() == 1){
221
+                //说明是客观题题块,需要自动批改
222
+
223
+                for(MsScanbatchPaperBlockQuestion spbquestion : spbquestions) {
224
+                    //试题答案
225
+                    MsPaperStudentQuestionMerge queAnswer = stuQuestions.stream().filter(q -> q.getMbqid().equals(spbquestion.getMbqid())).findFirst().orElse(null);
226
+
227
+                    //扫描结果
228
+                    MsPaperStudentQuestionMerge stuQuestion = new MsPaperStudentQuestionMerge();
229
+                    stuQuestion.setStuanswer(spbquestion.getIdentifycont());
230
+                    stuQuestion.setMbqid(spbquestion.getMbqid());
231
+                    stuQuestion.setMpsqmid(queAnswer.getMpsqmid());
232
+                    stuQuestion.setAnswertime(timestamp);
233
+                    stuQuestion.setConverted(1);
234
+                    stuQuestion.setAnswertype(1);
235
+                    MarkingUtil.checkObjectiveQuestion(stuQuestion, queAnswer);
236
+                    if(stuQuestion.getChecked() == 2){
237
+                        checknum++;
238
+                    }
239
+                    stuPaperScore = MarkingUtil.add(stuPaperScore, stuQuestion.getStuscore());
240
+
241
+                    saveQuesList.add(stuQuestion);
242
+                }
243
+            }else{
244
+                //主观题
245
+                for(MsScanbatchPaperBlockQuestion spbquestion : spbquestions){
246
+                    //试题答案
247
+                    MsPaperStudentQuestionMerge queAnswer = stuQuestions.stream().filter(q -> q.getMbqid().equals(spbquestion.getMbqid())).findFirst().orElse(null);
248
+                    MsPaperStudentQuestionMerge stuQuestion = new MsPaperStudentQuestionMerge();
249
+                    stuQuestion.setMpsqmid(queAnswer.getMpsqmid());
250
+                    stuQuestion.setStuanswer(picPath);
251
+                    stuQuestion.setAnswertype(2);
252
+                    stuQuestion.setAnswered(1);
253
+                    stuQuestion.setAnswertime(timestamp);
254
+                    stuQuestion.setConverted(converted);
255
+                    //如果多图,需要合并
256
+                    saveQuesList.add(stuQuestion);
257
+                }
258
+            }
259
+            //保存需要合并的试题信息,合并后保存
260
+        }
261
+
262
+        //处理试卷信息
263
+        MsPaperStudent msPaperStudent = new MsPaperStudent();
264
+        msPaperStudent.setMpsid(mpsid);
265
+        msPaperStudent.setEndtime(timestamp);
266
+        msPaperStudent.setBatchid(msScanbatchPaper.getBatchid());
267
+        msPaperStudent.setMspid(msScanbatchPaper.getMspid());
268
+        msPaperStudent.setCosttime(0);
269
+        msPaperStudent.setPaperfront(msScanbatchPaper.getPaperfront());
270
+        msPaperStudent.setPaperback(msScanbatchPaper.getPaperback());
271
+        msPaperStudent.setPagenum(msScanbatchPaper.getPagenum());
272
+        msPaperStudent.setStuscore(stuPaperScore);
273
+        msPaperStudent.setStuscoretype(1);
274
+        if(msScanbatchPaper.getMissexam() == 1){
275
+            //缺考
276
+            msPaperStudent.setSstate(3);//状态0未进场1已进场2已交卷3缺考
277
+        }else{
278
+            msPaperStudent.setSstate(2);//状态0未进场1已进场2已交卷3缺考
279
+        }
280
+        if(msScanbatchPaper.getViolated() == 1){
281
+            msPaperStudent.setHasbad(1);
282
+        }
283
+        if(checknum == saveQuesList.size()){
284
+            msPaperStudent.setChecked(2);
285
+        }
286
+
287
+        //批量修改试卷题块、试题信息
288
+        msPaperStudentBlockMapper.updateBatchStuBlock(saveBlockList);
289
+        msPaperStudentQuestionMergeMapper.updateBatchStuQues(saveQuesList);
290
+        msPaperStudentMapper.updateByPrimaryKeySelective(msPaperStudent);
291
+        handleStudentNeedConvert(needConvertList);
292
+
293
+        rtnanswernum = saveQuesList.size();
294
+
295
+        return rtnanswernum;
296
+    }
297
+
298
+    private void handleStudentNeedConvert(List<MsPaperStudentBlock> needConvertList){
299
+        if(needConvertList.size() > 0){
300
+            for(MsPaperStudentBlock studentBlock : needConvertList){
301
+                String stuAnswer = studentBlock.getStuanswer();
302
+                List<String> stuPicList = JSON.parseArray(stuAnswer, String.class);
303
+                if(stuPicList != null && stuPicList.size() > 1){
304
+                    convertUtil.imgMerge(studentBlock.getMpsbid(),stuPicList,2);
305
+                }
306
+            }
307
+        }
64 308
     }
65 309
 
66 310
 

+ 0
- 1
smarking/src/main/java/com/xhkjedu/smarking/service/scan/MsScanbatchService.java View File

@@ -51,7 +51,6 @@ public class MsScanbatchService {
51 51
         msScanbatch.setBatchname(batchname);
52 52
         msScanbatch.setExamid(examid);
53 53
         msScanbatch.setCreatetime(N_Utils.getSecondTimestamp());
54
-        msScanbatch.setBatchnum(0);
55 54
         msScanbatch.setScannum(0);
56 55
         msScanbatch.setUploadnum(0);
57 56
         msScanbatch.setIdentifynum(0);

+ 2
- 2
smarking/src/main/java/com/xhkjedu/smarking/utils/ConvertUtil.java View File

@@ -26,8 +26,8 @@ public class ConvertUtil {
26 26
      * @author ywx
27 27
      * @date 2022/5/9 14:57
28 28
      */
29
-    public void imgMerge(Integer psqid, List<String> userAnswers, Integer device) {
30
-        messageSender.imgMerge(psqid, userAnswers, device);
29
+    public void imgMerge(Integer mpsbid, List<String> userAnswers, Integer device) {
30
+        messageSender.imgMerge(mpsbid, userAnswers, device);
31 31
     }
32 32
 
33 33
     /**

+ 108
- 0
smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java View File

@@ -1,5 +1,11 @@
1 1
 package com.xhkjedu.smarking.utils;
2 2
 
3
+import com.alibaba.fastjson.JSON;
4
+import com.xhkjedu.smarking.model.stupaper.MsPaperStudentQuestionMerge;
5
+import com.xhkjedu.utils.N_Utils;
6
+
7
+import java.math.BigDecimal;
8
+import java.util.Arrays;
3 9
 import java.util.Map;
4 10
 import java.util.concurrent.ConcurrentHashMap;
5 11
 import java.util.regex.Pattern;
@@ -51,4 +57,106 @@ public class MarkingUtil {
51 57
         }
52 58
         return textStr;// 返回文本字符串
53 59
     }
60
+
61
+    /*
62
+     * @Description 判断两个字符串的关系
63
+     * @Date 2024/10/29 10:23:58
64
+     * @Author WN
65
+     * @Param [str1, str2]
66
+     * @Return int
67
+     **/
68
+    public static int isEqualStringCheck(String str1,String str2){
69
+        char[] charArray1 = str1.toCharArray();
70
+        char[] charArray2 = str2.toCharArray();
71
+        Arrays.sort(charArray1);
72
+        Arrays.sort(charArray2);
73
+        int eqResult = 0;//0代表不相等 1表示两个字符串相等 2代表字符串1包含字符串2
74
+        if(Arrays.equals(charArray1, charArray2)){
75
+            eqResult = 1;
76
+        }
77
+
78
+        if(Arrays.asList(charArray1).containsAll(Arrays.asList(charArray2))){
79
+            eqResult = 2;
80
+        }
81
+
82
+        return eqResult;
83
+    }
84
+
85
+    /*
86
+     * @Description 客观题自动批阅(扫描)
87
+     * @Date 2024/10/29 10:34:54
88
+     * @Author WN
89
+     * @Param [stuQuestion 学生作答, queAnswer 试题答案]
90
+     * @Return void
91
+     **/
92
+    public static void checkObjectiveQuestion(MsPaperStudentQuestionMerge stuQuestion,MsPaperStudentQuestionMerge queAnswer){
93
+        String stuAnswer = stuQuestion.getStuanswer();
94
+        Double stuScore = 0D;
95
+        Integer timestamp = N_Utils.getSecondTimestamp();
96
+
97
+        //学生答案为空时
98
+        if(N_Utils.isEmpty(stuAnswer)){
99
+            stuQuestion.setAnswered(0);
100
+            stuQuestion.setStuanswer(null);
101
+            stuQuestion.setStuscore(stuScore);
102
+            stuQuestion.setChecked(2);
103
+            stuQuestion.setFirstcime(timestamp);
104
+            stuQuestion.setFirstccore(stuScore);
105
+        }else{
106
+            //如果试题进行了得分设置,则直接进行分值处理(分值设置0默认1送分题 20分题)
107
+            Integer scoreset = queAnswer.getScoreset();
108
+            if(N_Utils.isTrueInteger(scoreset)){
109
+                if(scoreset == 1){
110
+                    stuScore = queAnswer.getQscore();
111
+                }
112
+            }else{
113
+                //未进行分值设置
114
+                //学生答案不为空,试卷设置了正确答案
115
+                if(queAnswer.getHasanswer()!=null && queAnswer.getHasanswer() == 1){
116
+                    String qanswer = JSON.parseArray(queAnswer.getQanswer(), String.class).get(0);//试题正确答案
117
+                    int ctype = queAnswer.getCtype();
118
+                    Double qscore = queAnswer.getQscore();
119
+                    if(N_Utils.isObjectiveQuestion(ctype)){
120
+                        //客观题进行批阅
121
+                        if(ctype == 1 || ctype == 4 || ctype == 5 || ctype == 6){
122
+                            //单选题、判断题进行判断
123
+                            if(stuAnswer.equalsIgnoreCase(qanswer)){
124
+                                stuScore = qscore;
125
+                            }
126
+                        }else if(ctype == 2){
127
+                            //多选题进行判断,
128
+                            Double lostoption = queAnswer.getLoseoption();//少选分值
129
+                            int isEqualStr = isEqualStringCheck(qanswer, stuAnswer);
130
+                            if(isEqualStr == 1){
131
+                                stuScore = qscore;
132
+                            }else if(isEqualStr == 2){
133
+                                stuScore = lostoption;//少选得分
134
+                            }
135
+
136
+                        }
137
+                        stuQuestion.setChecked(2);
138
+                        stuQuestion.setFirstcime(timestamp);
139
+                    }
140
+
141
+                }else{
142
+                    stuQuestion.setChecked(0);
143
+                }
144
+            }
145
+            stuQuestion.setStuscore(stuScore);
146
+            stuQuestion.setAnswered(1);
147
+        }
148
+    }
149
+
150
+    /**
151
+     * 提供精确的加法运算。
152
+     *
153
+     * @param v1 被加数
154
+     * @param v2 加数
155
+     * @return 两个参数的和
156
+     */
157
+    public static double add(double v1, double v2) {
158
+        BigDecimal b1 = new BigDecimal(Double.toString(v1));
159
+        BigDecimal b2 = new BigDecimal(Double.toString(v2));
160
+        return b1.add(b2).doubleValue();
161
+    }
54 162
 }

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

@@ -80,4 +80,13 @@
80 80
         order by b.batchid,sp.mspid
81 81
     </select>
82 82
 
83
+    <!--修改扫描数量-->
84
+    <update id="updateScannum">
85
+        update ms_scanbatch set scannum=scannum+1 where batchid=#{batchid}
86
+    </update>
87
+    <!--修改识别数量-->
88
+    <update id="updateIdentifynum">
89
+        update ms_scanbatch_paper set identified=(select count(*) from ms_scanbatch_paper where batchid=#{batchid} and identified=1) where batchid=#{batchid} and mspid=#{mspid}
90
+    </update>
91
+
83 92
 </mapper>

+ 2
- 2
smarking/src/main/resources/mapper/scan/MsScanbatchPaperBlockMapper.xml View File

@@ -12,13 +12,13 @@
12 12
         <result property="msptype" column="msptype"/>
13 13
         <collection property="questions" ofType="java.util.Map" javaType="java.util.ArrayList">
14 14
             <result property="mspbqid" column="mspbqid"/>
15
-            <result property="mpsqmid" column="mpsqmid"/>
15
+            <result property="mbqid" column="mbqid"/>
16 16
             <result property="identifycont" column="identifycont"/>
17 17
         </collection>
18 18
     </resultMap>
19 19
     <select id="listObjectiveQuestions" resultMap="objectiveQuestions">
20 20
         select b.mspbid,b.mpblockid,b.picpath,b.extendpath,b.identifycont,b.msptype
21
-        ,q.mspbqid,q.mpsqmid,q.identifycont
21
+        ,q.mspbqid,q.mbqid,q.identifycont
22 22
         from ms_scanbatch_paper_block b
23 23
         left join ms_scanbatch_paper_block_question q on b.mspbid=q.mspbid
24 24
         where b.mspid=#{mspid} and b.msptype=1 order by b.mspbid,q.mspbqid

+ 1
- 0
smarking/src/main/resources/mapper/scan/MsScanbatchPaperBlockQuestionMapper.xml View File

@@ -2,3 +2,4 @@
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.MsScanbatchPaperBlockQuestionMapper">
4 4
 </mapper>
5
+

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

@@ -10,4 +10,16 @@
10 10
     <select id="getScanPaperByMspid" resultType="java.util.Map">
11 11
         select * from ms_scanbatch_paper where mspid = #{mspid}
12 12
     </select>
13
+
14
+    <!--试卷标记为异常-->
15
+    <update id="updatePaperErrortype">
16
+        update ms_scanbatch_paper set errortype = #{errortype} and haserror=1 where mspid = #{mspid}
17
+    </update>
18
+
19
+    <!--指定试卷和考号下未处理异常数量-->
20
+    <select id="getErrorNumByMpidAndExamno" resultType="java.lang.Integer">
21
+        select count(p.mspid) from ms_scanbatch_paper p left join ms_scanbatch b on p.batchid=b.batchid
22
+        where b.mpid=#{mpid} and p.examno=#{examno} and p.haserror=1 and p.mspstate=0
23
+    </select>
24
+
13 25
 </mapper>

+ 54
- 0
smarking/src/main/resources/mapper/stupaper/MsPaperStudentBlockMapper.xml View File

@@ -1,4 +1,58 @@
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.stupaper.MsPaperStudentBlockMapper">
4
+
5
+    <!--根据学生试卷ID清空作答及批阅信息-->
6
+    <update id="updateStudentBlockQuestionByMpsid">
7
+        update ms_paper_student_block b join ms_paper_student_question_merge q
8
+        on b.mpsid=q.mpsid and b.mpsbid=q.mpsbid
9
+        set b.stuanswer=null,b.hasproblem=0,b.problemtype=0,b.problemcomm=null,b.hasgood=0,
10
+        b.hasbad=0,b.hasfinal=0,b.finalreason=0,
11
+        q.answered=0,q.answertype=0,q.stuanswer=null,q.converted=0,q.answertime=0,q.stuscore=0,
12
+        q.checked=0,q.firstcid=null,q.firstcime=null,q.firstccore=0,q.secondcid=null,q.secondctime=null,q.secondcscore=0,q.arbitrateid=null,q.arbitratetime=null,q.arbitratescore=0,q.hasgood=0,
13
+        q.hasbad=0,q.hasproblem=0,q.problemtype=0,q.problemcomm=null
14
+        where b.mpsid = #{mpsid}
15
+    </update>
16
+
17
+    <!--获取学生题块试题-->
18
+    <resultMap id="stuBlockQuestions" type="com.xhkjedu.smarking.model.stupaper.MsPaperStudentBlock">
19
+        <result property="mpsbid" column="mpsbid"/>
20
+        <result property="mpsid" column="mpsid"/>
21
+        <result property="mpid" column="mpid"/>
22
+        <result property="mblockid" column="mblockid"/>
23
+        <result property="stuanswer" column="stuanswer"/>
24
+        <result property="blocktype" column="blocktype"/>
25
+        <collection property="questions" ofType="com.xhkjedu.smarking.model.stupaper.MsPaperStudentQuestionMerge" javaType="java.util.List">
26
+            <result property="mpsqmid" column="mpsqmid"/>
27
+            <result property="mbqid" column="mbqid"/>
28
+            <result property="mpsbid" column="mpsbid"/>
29
+            <result property="qn" column="qn"/>
30
+            <result property="qorder" column="qorder"/>
31
+            <result property="qscore" column="qscore"/>
32
+            <result property="ctype" column="ctype"/>
33
+            <result property="qanswer" column="qanswer"/>
34
+            <result property="loseoption" column="loseoption"/>
35
+            <result property="scoreset" column="scoreset"/>
36
+            <result property="hasanswer" column="answered"/>
37
+
38
+        </collection>
39
+    </resultMap>
40
+    <select id="listPaperStuBlockQuestions" resultMap="stuBlockQuestions">
41
+        select distinct b.mpsbid,b.mpsid,b.mpid,b.mblockid,b.stuanswer,pb.blocktype,q.mpsqmid,q.mbqid,q.mpsbid,q.qn,q.qorder,
42
+                        q.qscore,q.ctype,tq.qanswer,tq.loseoption,tq.scoreset,p.answered
43
+        from ms_paper_student_question_merge q leftjoin ms_paper_student_block b
44
+        on b.mpsid=q.mpsid and b.mpsbid=q.mpsbid
45
+        left join ms_paper_block pb on pb.mblockid=b.mblockid
46
+        left join ms_paper_block_question pbq on q.mbqid=pbq.mbqid
47
+        left join ms_paper_qtype_question tq on pbq.mptqid=tq.mptqid
48
+        left join ms_paper p on p.mpid=b.mpid
49
+        where b.mpsid = #{mpsid}
50
+    </select>
51
+
52
+    <!--批量更改学生题块-->
53
+    <update id="updateBatchStuBlock">
54
+        <foreach collection="list" separator=";" item="b">
55
+            update ms_paper_student_block set stuanswer=#{b.stuanswer},converted=#{b.converted} where mpsbid=#{b.mpsbid}
56
+        </foreach>
57
+    </update>
4 58
 </mapper>

+ 5
- 0
smarking/src/main/resources/mapper/stupaper/MsPaperStudentMapper.xml View File

@@ -14,4 +14,9 @@
14 14
         select sstate
15 15
         from ms_paper_student where examid=#{cs.examid} and subjectid=#{cs.subjectid} and studentid=#{cs.studentid}
16 16
     </select>
17
+
18
+    <!--获取试卷学生信息-->
19
+    <select id="getPaperStudentByStudentidAndMpid" resultType="com.xhkjedu.smarking.model.stupaper.MsPaperStudent">
20
+        select * from ms_paper_student where studentid=#{studentid} and mpid=#{mpid} order by mpsid limit 1
21
+    </select>
17 22
 </mapper>

+ 9
- 0
smarking/src/main/resources/mapper/stupaper/MsPaperStudentQuestionMergeMapper.xml View File

@@ -1,4 +1,13 @@
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.stupaper.MsPaperStudentQuestionMergeMapper">
4
+
5
+    <!--批量修改学生试题-->
6
+    <update id="updateBatchStuQues">
7
+        <foreach collection="list" item="q" separator="; ">
8
+            update ms_paper_student_question set answered = #{q.answered},answertype = #{q.answertype},stuanswer = #{q.stuanswer},
9
+            converted= #{q.converted},answertime = #{q.answertime},costtime = #{q.costtime},stuscore = #{q.stuscore},
10
+            checked = #{q.checked},firstcime = #{q.firstcime},firstccore = #{q.firstccore} where mpsqmid = #{q.mpsqmid}
11
+        </foreach>
12
+    </update>
4 13
 </mapper>

Loading…
Cancel
Save