|
@@ -1,6 +1,8 @@
|
1
|
1
|
package com.xhkjedu.smarking.service.scan;
|
2
|
2
|
|
3
|
3
|
import com.alibaba.fastjson.JSON;
|
|
4
|
+import com.alibaba.fastjson.JSONArray;
|
|
5
|
+import com.xhkjedu.smarking.config.ConfigKey;
|
4
|
6
|
import com.xhkjedu.smarking.mapper.scan.MsScanbatchMapper;
|
5
|
7
|
import com.xhkjedu.smarking.mapper.scan.MsScanbatchPaperBlockMapper;
|
6
|
8
|
import com.xhkjedu.smarking.mapper.scan.MsScanbatchPaperBlockQuestionMapper;
|
|
@@ -8,6 +10,7 @@ import com.xhkjedu.smarking.mapper.scan.MsScanbatchPaperMapper;
|
8
|
10
|
import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentBlockMapper;
|
9
|
11
|
import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentMapper;
|
10
|
12
|
import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentQuestionMergeMapper;
|
|
13
|
+import com.xhkjedu.smarking.mapper.system.SchoolMapper;
|
11
|
14
|
import com.xhkjedu.smarking.mapper.system.UserMapper;
|
12
|
15
|
import com.xhkjedu.smarking.model.scan.MsScanbatchPaper;
|
13
|
16
|
import com.xhkjedu.smarking.model.scan.MsScanbatchPaperBlock;
|
|
@@ -17,7 +20,9 @@ import com.xhkjedu.smarking.model.stupaper.MsPaperStudentBlock;
|
17
|
20
|
import com.xhkjedu.smarking.model.stupaper.MsPaperStudentQuestionMerge;
|
18
|
21
|
import com.xhkjedu.smarking.utils.ConvertUtil;
|
19
|
22
|
import com.xhkjedu.smarking.utils.MarkingUtil;
|
|
23
|
+import com.xhkjedu.smarking.vo.system.SchoolCloudVo;
|
20
|
24
|
import com.xhkjedu.utils.N_Utils;
|
|
25
|
+import com.xhkjedu.vo.ResultVo;
|
21
|
26
|
import org.springframework.stereotype.Service;
|
22
|
27
|
import org.springframework.transaction.annotation.Transactional;
|
23
|
28
|
|
|
@@ -51,6 +56,8 @@ public class MsScanbatchPaperService {
|
51
|
56
|
private MsPaperStudentBlockMapper msPaperStudentBlockMapper;
|
52
|
57
|
@Resource
|
53
|
58
|
private ConvertUtil convertUtil;
|
|
59
|
+ @Resource
|
|
60
|
+ private SchoolMapper schoolMapper;
|
54
|
61
|
|
55
|
62
|
/**
|
56
|
63
|
* @Description 新增
|
|
@@ -113,7 +120,6 @@ public class MsScanbatchPaperService {
|
113
|
120
|
return;
|
114
|
121
|
}
|
115
|
122
|
|
116
|
|
-
|
117
|
123
|
//保存扫描信息
|
118
|
124
|
savePaperBlockQuestions(msScanbatchPaper);
|
119
|
125
|
//学生试卷信息
|
|
@@ -129,6 +135,23 @@ public class MsScanbatchPaperService {
|
129
|
135
|
|
130
|
136
|
//保存扫描试卷-保存扫描题块试题信息
|
131
|
137
|
private void savePaperBlockQuestions(MsScanbatchPaper msScanbatchPaper){
|
|
138
|
+ //获取学校对应区域码,
|
|
139
|
+ SchoolCloudVo schoolCloudVo = schoolMapper.getSchoolCloudcode(msScanbatchPaper.getMpid());
|
|
140
|
+ String saveFloder = schoolCloudVo.getCloudcode() + "/" + schoolCloudVo.getSchoolid() + "/";
|
|
141
|
+
|
|
142
|
+ String paperfront = uploadBase64Img(msScanbatchPaper.getPaperfront(),1,saveFloder);
|
|
143
|
+ if(N_Utils.isNotEmpty(paperfront)){
|
|
144
|
+ msScanbatchPaper.setPaperfront(paperfront);
|
|
145
|
+ }
|
|
146
|
+ String paperback = uploadBase64Img(msScanbatchPaper.getPaperback(),1,saveFloder);
|
|
147
|
+ if(N_Utils.isNotEmpty(paperback)){
|
|
148
|
+ msScanbatchPaper.setPaperback(paperback);
|
|
149
|
+ }
|
|
150
|
+ String examnopic = uploadBase64Img(msScanbatchPaper.getExamnopic(),1,saveFloder);
|
|
151
|
+ if(N_Utils.isNotEmpty(examnopic)){
|
|
152
|
+ msScanbatchPaper.setExamnopic(examnopic);
|
|
153
|
+ }
|
|
154
|
+
|
132
|
155
|
msScanbatchPaperMapper.insertUseGeneratedKeys(msScanbatchPaper);
|
133
|
156
|
Integer mspid = msScanbatchPaper.getId();
|
134
|
157
|
msScanbatchPaper.setMspid(mspid);
|
|
@@ -138,6 +161,14 @@ public class MsScanbatchPaperService {
|
138
|
161
|
for (MsScanbatchPaperBlock spblock : spblocks) {
|
139
|
162
|
spblock.setMspid(mspid);
|
140
|
163
|
spblock.setBatchid(msScanbatchPaper.getBatchid());
|
|
164
|
+
|
|
165
|
+ //题块多图片合并比一张图片
|
|
166
|
+ String rtnBlock = uploadBase64Img(spblock.getPicpath(),2,saveFloder);
|
|
167
|
+ spblock.setPicpath(rtnBlock);
|
|
168
|
+
|
|
169
|
+ //题块多图片合并比一张图片
|
|
170
|
+ String extendBlock = uploadBase64Img(spblock.getExtendpath(),2,saveFloder);
|
|
171
|
+ spblock.setExtendpath(extendBlock);
|
141
|
172
|
}
|
142
|
173
|
|
143
|
174
|
msScanbatchPaperBlockMapper.insertList(spblocks);
|
|
@@ -155,7 +186,31 @@ public class MsScanbatchPaperService {
|
155
|
186
|
}
|
156
|
187
|
//更改识别数量
|
157
|
188
|
msScanbatchMapper.updateIdentifynum(msScanbatchPaper.getBatchid());
|
|
189
|
+ }
|
158
|
190
|
|
|
191
|
+ //图片base上传
|
|
192
|
+ private String uploadBase64Img(String stupic,Integer merged,String saveFloder){
|
|
193
|
+ String apiMethod = "";
|
|
194
|
+ String params = "";
|
|
195
|
+ if(merged == 1){
|
|
196
|
+ //说明上传的图片为单张保存
|
|
197
|
+ params = "base64path=" + stupic;
|
|
198
|
+ apiMethod = "bs/base";
|
|
199
|
+ }else{
|
|
200
|
+ //上传的多张图片需要合并为一张
|
|
201
|
+ List<String> imgList =JSONArray.parseArray(stupic, String.class);
|
|
202
|
+ params = "filepaths=" + imgList;
|
|
203
|
+ apiMethod = "bs/mbase_merge";
|
|
204
|
+ }
|
|
205
|
+ //处理字段那种图片路径,base64转图片
|
|
206
|
+ params = params + "&savefolder=" + saveFloder + "marking/scan/";
|
|
207
|
+ String fileInfoStr = N_Utils.sendPost(ConfigKey.fileapi + apiMethod, params);
|
|
208
|
+ ResultVo fileResult = JSON.parseObject(fileInfoStr, ResultVo.class);
|
|
209
|
+ if (fileResult.getCode() == 0 && N_Utils.isNotEmpty(fileResult.getObj())) {
|
|
210
|
+ return fileResult.getObj().toString();
|
|
211
|
+ }else{
|
|
212
|
+ return "";
|
|
213
|
+ }
|
159
|
214
|
}
|
160
|
215
|
|
161
|
216
|
//保存扫描试卷-清空学生试卷题块试题信息
|
|
@@ -199,7 +254,6 @@ public class MsScanbatchPaperService {
|
199
|
254
|
Double stuPaperScore = 0.0;//学生试卷得分
|
200
|
255
|
List<MsPaperStudentBlock> saveBlockList = new ArrayList<>();// 保存学生题块信息
|
201
|
256
|
List<MsPaperStudentQuestionMerge> saveQuesList = new ArrayList<>();//保存学生提交试题
|
202
|
|
- List<MsPaperStudentBlock> needConvertList = new ArrayList<>();//需要合并图片的题块
|
203
|
257
|
Integer timestamp = N_Utils.getSecondTimestamp();
|
204
|
258
|
|
205
|
259
|
for(MsScanbatchPaperBlock spblock : spblocks){
|
|
@@ -213,7 +267,6 @@ public class MsScanbatchPaperService {
|
213
|
267
|
}
|
214
|
268
|
studentBlock.setConverted(0);
|
215
|
269
|
saveBlockList.add(studentBlock);
|
216
|
|
- needConvertList.add(studentBlock);
|
217
|
270
|
|
218
|
271
|
List<MsPaperStudentQuestionMerge> stuQuestions = studentBlock.getQuestions();//学生试题
|
219
|
272
|
List<MsScanbatchPaperBlockQuestion> spbquestions = spblock.getSpbquestions();//扫描题块下试题
|
|
@@ -288,26 +341,12 @@ public class MsScanbatchPaperService {
|
288
|
341
|
msPaperStudentBlockMapper.updateBatchStuBlock(saveBlockList);
|
289
|
342
|
msPaperStudentQuestionMergeMapper.updateBatchStuQues(saveQuesList);
|
290
|
343
|
msPaperStudentMapper.updateByPrimaryKeySelective(msPaperStudent);
|
291
|
|
- handleStudentNeedConvert(needConvertList);
|
292
|
344
|
|
293
|
345
|
rtnanswernum = saveQuesList.size();
|
294
|
346
|
|
295
|
347
|
return rtnanswernum;
|
296
|
348
|
}
|
297
|
349
|
|
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
|
|
- }
|
308
|
|
- }
|
309
|
|
-
|
310
|
|
-
|
311
|
350
|
/*
|
312
|
351
|
* @Description 扫描记录-查看原卷
|
313
|
352
|
* @Date 2024/10/25 17:22:45
|