Browse Source

试卷切割

wn
王宁 17 hours ago
parent
commit
43573db7df

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

70
     public ResultVo saveScanPaper(@RequestBody MsScanbatchPaper msScanbatchPaper) {
70
     public ResultVo saveScanPaper(@RequestBody MsScanbatchPaper msScanbatchPaper) {
71
         N_Utils.validation(new Object[]{msScanbatchPaper.getBatchid(), "扫描批次id", 1,msScanbatchPaper.getMpid(), "试卷id", 1});
71
         N_Utils.validation(new Object[]{msScanbatchPaper.getBatchid(), "扫描批次id", 1,msScanbatchPaper.getMpid(), "试卷id", 1});
72
         try{
72
         try{
73
-            msScanbatchPaperService.savePaperIdentify(msScanbatchPaper);
73
+            msScanbatchPaperService.savePaperIdentify(msScanbatchPaper,1);
74
             return new ResultVo(0, "保存成功");
74
             return new ResultVo(0, "保存成功");
75
         }catch (Exception e){
75
         }catch (Exception e){
76
             String message = e.getMessage();
76
             String message = e.getMessage();

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

63
     //获取试卷类型
63
     //获取试卷类型
64
     Integer getPaperTypeByMpsid(@Param("mpsid") Integer mpsid);
64
     Integer getPaperTypeByMpsid(@Param("mpsid") Integer mpsid);
65
     //修改试卷切割状态
65
     //修改试卷切割状态
66
-    int updatePaperCutState(@Param("mpid") Integer mpid, @Param("cutstate") Integer cutstate);
66
+    int updatePaperCutState(@Param("mpid") Integer mpid, @Param("yjstate") Integer yjstate);
67
     //获取试卷切割状态
67
     //获取试卷切割状态
68
     Integer getPaperCutStateByMpid(@Param("mpid") Integer mpid);
68
     Integer getPaperCutStateByMpid(@Param("mpid") Integer mpid);
69
     //根据试卷ID获取科目名称和考试名称
69
     //根据试卷ID获取科目名称和考试名称

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

116
         // 保存试题切割信息
116
         // 保存试题切割信息
117
         msPaperQtypeQuestionMapper.updateBatchQuestionCoor(params.getQuestions());
117
         msPaperQtypeQuestionMapper.updateBatchQuestionCoor(params.getQuestions());
118
         // 保存试卷切割状态
118
         // 保存试卷切割状态
119
-        msPaperMapper.updatePaperCutState(params.getMpid(), 1);
119
+        msPaperMapper.updatePaperCutState(params.getMpid(), 2);
120
     }
120
     }
121
 
121
 
122
     /*
122
     /*

+ 35
- 27
smarking/src/main/java/com/xhkjedu/smarking/service/scan/MsScanbatchPaperService.java View File

113
 
113
 
114
     /**
114
     /**
115
      * @Description 新增
115
      * @Description 新增
116
-     * @Param [msScanbatchPaper]
116
+     * @Param [msScanbatchPaper, stype:1代表是客户端调用接口保存,2代表服务端自己识别调用]
117
      * @Author auto
117
      * @Author auto
118
      * @Date 2024-10-15
118
      * @Date 2024-10-15
119
      **/
119
      **/
120
     @Transactional(rollbackFor = Exception.class)
120
     @Transactional(rollbackFor = Exception.class)
121
-    public void savePaperIdentify(MsScanbatchPaper msScanbatchPaper){
121
+    public void savePaperIdentify(MsScanbatchPaper msScanbatchPaper,Integer stype){
122
 
122
 
123
         Integer examstate  = msScanbatchMapper.getExamStateByBatchid(msScanbatchPaper.getBatchid());
123
         Integer examstate  = msScanbatchMapper.getExamStateByBatchid(msScanbatchPaper.getBatchid());
124
         if(examstate == 3){
124
         if(examstate == 3){
127
 
127
 
128
         //更改扫描、识别次数
128
         //更改扫描、识别次数
129
         if(N_Utils.isTrueInteger(msScanbatchPaper.getIdentified()) && msScanbatchPaper.getIdentified() == 1){
129
         if(N_Utils.isTrueInteger(msScanbatchPaper.getIdentified()) && msScanbatchPaper.getIdentified() == 1){
130
-            msScanbatchMapper.updateScannumAndIdentifynum(msScanbatchPaper.getBatchid());
130
+            if(stype == 1){
131
+                msScanbatchMapper.updateScannumAndIdentifynum(msScanbatchPaper.getBatchid());
132
+            }else{
133
+                msScanbatchMapper.updateIdentifynum(msScanbatchPaper.getBatchid());
134
+            }
135
+
131
         }else{
136
         }else{
132
             //保存一次,扫描次数加1
137
             //保存一次,扫描次数加1
133
             msScanbatchMapper.updateScannum(msScanbatchPaper.getBatchid());
138
             msScanbatchMapper.updateScannum(msScanbatchPaper.getBatchid());
134
             //识别出错
139
             //识别出错
135
             msScanbatchPaper.setErrortype(1);
140
             msScanbatchPaper.setErrortype(1);
136
-            savePaperBlockQuestions(msScanbatchPaper);
141
+            savePaperBlockQuestions(msScanbatchPaper, stype);
137
             return;
142
             return;
138
         }
143
         }
139
 
144
 
145
         //考号不存在,异常信息2考号有误(异常类型1扫描出错 2考号有误 3考号重复 4缺考异常)
150
         //考号不存在,异常信息2考号有误(异常类型1扫描出错 2考号有误 3考号重复 4缺考异常)
146
         if(N_Utils.isEmpty(examno)){
151
         if(N_Utils.isEmpty(examno)){
147
             msScanbatchPaper.setErrortype(2);
152
             msScanbatchPaper.setErrortype(2);
148
-            savePaperBlockQuestions(msScanbatchPaper);
153
+            savePaperBlockQuestions(msScanbatchPaper, stype);
149
             return;
154
             return;
150
         }
155
         }
151
 
156
 
153
         Integer errorNum = msScanbatchPaperMapper.getErrorNumByMpidAndExamno(msScanbatchPaper.getMpid(),examno);
158
         Integer errorNum = msScanbatchPaperMapper.getErrorNumByMpidAndExamno(msScanbatchPaper.getMpid(),examno);
154
         if(errorNum > 0){
159
         if(errorNum > 0){
155
             msScanbatchPaper.setErrortype(3);
160
             msScanbatchPaper.setErrortype(3);
156
-            savePaperBlockQuestions(msScanbatchPaper);
161
+            savePaperBlockQuestions(msScanbatchPaper, stype);
157
             return;
162
             return;
158
         }
163
         }
159
 
164
 
162
         //用户不存在,异常信息2考号有误
167
         //用户不存在,异常信息2考号有误
163
         if(!N_Utils.isTrueInteger(userid)){
168
         if(!N_Utils.isTrueInteger(userid)){
164
             msScanbatchPaper.setErrortype(2);
169
             msScanbatchPaper.setErrortype(2);
165
-            savePaperBlockQuestions(msScanbatchPaper);
170
+            savePaperBlockQuestions(msScanbatchPaper, stype);
166
             return;
171
             return;
167
         }
172
         }
168
         //用户存在,获取用户试卷信息
173
         //用户存在,获取用户试卷信息
170
         //试卷不存在,异常信息1扫描出错
175
         //试卷不存在,异常信息1扫描出错
171
         if(msPaperStudent == null){
176
         if(msPaperStudent == null){
172
             msScanbatchPaper.setErrortype(1);
177
             msScanbatchPaper.setErrortype(1);
173
-            savePaperBlockQuestions(msScanbatchPaper);
178
+            savePaperBlockQuestions(msScanbatchPaper, stype);
174
             return;
179
             return;
175
         }
180
         }
176
         //试卷存在,判断学生是否已绑定扫描试卷信息,已有保存扫描信息本次异常,异常信息3考号重复
181
         //试卷存在,判断学生是否已绑定扫描试卷信息,已有保存扫描信息本次异常,异常信息3考号重复
177
         if(N_Utils.isTrueInteger(msPaperStudent.getMspid())){
182
         if(N_Utils.isTrueInteger(msPaperStudent.getMspid())){
178
             msScanbatchPaper.setErrortype(3);
183
             msScanbatchPaper.setErrortype(3);
179
-            savePaperBlockQuestions(msScanbatchPaper);
184
+            savePaperBlockQuestions(msScanbatchPaper, stype);
180
             //处理上一次对应扫描试卷为3考号重复,并清空学生试卷试题信息
185
             //处理上一次对应扫描试卷为3考号重复,并清空学生试卷试题信息
181
             msScanbatchPaperMapper.updatePaperErrortype(msPaperStudent.getMspid(),3);
186
             msScanbatchPaperMapper.updatePaperErrortype(msPaperStudent.getMspid(),3);
182
             updatePaperStudentQuestion(msPaperStudent);
187
             updatePaperStudentQuestion(msPaperStudent);
184
         }
189
         }
185
 
190
 
186
         //保存扫描信息
191
         //保存扫描信息
187
-        savePaperBlockQuestions(msScanbatchPaper);
192
+        savePaperBlockQuestions(msScanbatchPaper, stype);
188
         //学生试卷信息
193
         //学生试卷信息
189
         int answernum = saveStudentBlockQuestions(msScanbatchPaper,msPaperStudent.getMpsid());
194
         int answernum = saveStudentBlockQuestions(msScanbatchPaper,msPaperStudent.getMpsid());
190
         if (!N_Utils.isEmptyInteger(msScanbatchPaper.getMissexam()) && msScanbatchPaper.getMissexam() == 1 && answernum>0) {//缺考
195
         if (!N_Utils.isEmptyInteger(msScanbatchPaper.getMissexam()) && msScanbatchPaper.getMissexam() == 1 && answernum>0) {//缺考
196
     }
201
     }
197
 
202
 
198
     //保存扫描试卷-保存扫描题块试题信息
203
     //保存扫描试卷-保存扫描题块试题信息
199
-    private void savePaperBlockQuestions(MsScanbatchPaper msScanbatchPaper){
200
-
204
+    private void savePaperBlockQuestions(MsScanbatchPaper msScanbatchPaper,Integer stype){
201
         if(msScanbatchPaper.getErrortype() == null){
205
         if(msScanbatchPaper.getErrortype() == null){
202
             msScanbatchPaper.setErrortype(0);
206
             msScanbatchPaper.setErrortype(0);
203
             msScanbatchPaper.setMspstate(0);
207
             msScanbatchPaper.setMspstate(0);
205
             msScanbatchPaper.setMspstate(1);
209
             msScanbatchPaper.setMspstate(1);
206
         }
210
         }
207
 
211
 
208
-        msScanbatchPaperMapper.insertUseGeneratedKeys(msScanbatchPaper);
212
+        Integer mspid = msScanbatchPaper.getMspid();
213
+        if(stype == 1 || msScanbatchPaper.getMspid() == null){
214
+            msScanbatchPaperMapper.insertUseGeneratedKeys(msScanbatchPaper);
215
+            mspid = msScanbatchPaper.getId();
216
+        }else{
217
+            msScanbatchPaperMapper.updateScanPaperForReidentified(msScanbatchPaper);
218
+        }
219
+
209
         //如果识别出错则不再进行后续保存
220
         //如果识别出错则不再进行后续保存
210
         if(msScanbatchPaper.getErrortype() == 1) return;
221
         if(msScanbatchPaper.getErrortype() == 1) return;
211
 
222
 
212
-        Integer mspid = msScanbatchPaper.getId();
213
         msScanbatchPaper.setMspid(mspid);
223
         msScanbatchPaper.setMspid(mspid);
214
 
224
 
215
         //保存试题
225
         //保存试题
707
         }
717
         }
708
         if(templates.isEmpty()) throw new ServiceException("该考试未设置试卷模板");
718
         if(templates.isEmpty()) throw new ServiceException("该考试未设置试卷模板");
709
 
719
 
720
+        //处理之前扫描识别结果,把需要重新识别的试卷按批次进行分组
721
+        // Map<Integer,List<MsScanbatchPaper>> batchMap = scanbatchPapers.stream().collect(Collectors.groupingBy(MsScanbatchPaper::getBatchid));
722
+        // for(Integer batchid : batchMap.keySet()){
723
+        //     List<MsScanbatchPaper> papers = batchMap.get(batchid);
724
+        //     //把识别数量、违规数量、缺考数量 减去
725
+        //
726
+        // }
727
+
710
         //清空学生题块试题信息和学生试卷扫描识别信息
728
         //清空学生题块试题信息和学生试卷扫描识别信息
711
         // msPaperStudentMapper.updateStudentBlockQuestionForReIdentify(param);
729
         // msPaperStudentMapper.updateStudentBlockQuestionForReIdentify(param);
712
         //清空符合条件的需要从新识别的试卷的识别信息
730
         //清空符合条件的需要从新识别的试卷的识别信息
718
         System.out.println("saveFloder:" + saveFloder);
736
         System.out.println("saveFloder:" + saveFloder);
719
         for(MsScanbatchPaper paper : scanbatchPapers){
737
         for(MsScanbatchPaper paper : scanbatchPapers){
720
             chandleIdentifyPaper(paper,stps,saveFloder);
738
             chandleIdentifyPaper(paper,stps,saveFloder);
739
+            System.out.println("识别完成!");
721
 
740
 
722
-            //修改扫描试卷信息
723
-            // msScanbatchPaperMapper.updateScanPaperForReidentified(paper);
724
-            List<MsScanbatchPaperBlock> blocks = paper.getSpblocks();
725
-            // msScanbatchPaperBlockMapper.insertList(blocks);
726
-            List<MsScanbatchPaperBlockQuestion> allQuestions = new ArrayList<>();
727
-            for(MsScanbatchPaperBlock block : blocks){
728
-                int mspbid = block.getId();
729
-                for(MsScanbatchPaperBlockQuestion question : block.getSpbquestions()){
730
-                    question.setMspbid(mspbid);
731
-                    allQuestions.add(question);
732
-                }
733
-            }
734
-            // if(!allQuestions.isEmpty()) msScanbatchPaperBlockQuestionMapper.insertList(allQuestions);
741
+            //保存扫描试卷信息,和客户端扫描保存调用同一个接口
742
+            // savePaperIdentify(paper, 2);
735
         }
743
         }
736
     }
744
     }
737
 
745
 

+ 1
- 1
smarking/src/main/java/com/xhkjedu/smarking/utils/opencv/CvCommonUtils.java View File

645
     }
645
     }
646
 
646
 
647
     /**
647
     /**
648
-     * 保存图片
648
+     * 读取网络图片
649
      *
649
      *
650
      * @param imageUrl 图片地址
650
      * @param imageUrl 图片地址
651
      * @return 读取的图像矩阵
651
      * @return 读取的图像矩阵

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

112
 
112
 
113
     <!--修改试卷切割状态-->
113
     <!--修改试卷切割状态-->
114
     <update id="updatePaperCutState">
114
     <update id="updatePaperCutState">
115
-        update ms_paper set cutstate=#{cutstate} where mpid=#{mpid}
115
+        update ms_paper set yjstate=#{yjstate} where mpid=#{mpid}
116
     </update>
116
     </update>
117
     <!--获取试卷切割状态-->
117
     <!--获取试卷切割状态-->
118
     <select id="getPaperCutStateByMpid" resultType="java.lang.Integer">
118
     <select id="getPaperCutStateByMpid" resultType="java.lang.Integer">
119
-        select cutstate from ms_paper where mpid=#{mpid}
119
+        select yjstate from ms_paper where mpid=#{mpid}
120
     </select>
120
     </select>
121
     <!--根据试卷ID获取科目名称和考试名称-->
121
     <!--根据试卷ID获取科目名称和考试名称-->
122
     <select id="getSubjectAndExamByMpid" resultType="java.util.Map">
122
     <select id="getSubjectAndExamByMpid" resultType="java.util.Map">

Loading…
Cancel
Save