Browse Source

Merge remote-tracking branch 'origin/wn' into ywx

ywx
雍文秀 3 days ago
parent
commit
4a740ee218

+ 1
- 1
gateway/src/main/resources/application.properties View File

@@ -129,7 +129,7 @@ whitelistAPI=/user/login,user/loginstu,/class_student/stu_class,/user/detail,/st
129 129
   ,/class_student/import_user,/user/import_teacher,/user/autologin\
130 130
   ,/get_new,/stype/list,/cloud/detail,/auser/import,/pdf,/epsb/import,\
131 131
   ,/section/get_zjr,/csw/add,/xz/import,/agora_token/rtc_token,/epqt/pqs,/eb/get_mn,/scan/save,/eps/sca,/eps/scaer\
132
-  ,/module/treelst,/std/td_num,/bk/list_client,/user/check_login
132
+  ,/module/treelst,/std/td_num,/bk/list_client,/user/check_login,/smarking/mscan/save,/smarking/mscanp/save,/smarking/mscanp/paper_temps
133 133
 
134 134
 #\u53C2\u6570\u5927\u5C0F\u9650\u523650M
135 135
 paramsize=52428800

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

@@ -1,6 +1,5 @@
1 1
 package com.xhkjedu.smarking.controller.scan;
2 2
 
3
-import com.xhkjedu.smarking.model.paper.MsTemplate;
4 3
 import com.xhkjedu.smarking.model.scan.MsScanbatchPaper;
5 4
 import com.xhkjedu.smarking.model.scan.MsScanbatchPaperBlock;
6 5
 import com.xhkjedu.smarking.service.scan.MsScanbatchPaperService;
@@ -56,8 +55,7 @@ public class MsScanbatchPaperController {
56 55
     public ResultVo listTemplates(@RequestBody MsScanbatchPaper msScanbatchPaper) {
57 56
         Integer mpid = msScanbatchPaper.getMpid();
58 57
         N_Utils.validation(new Object[]{mpid, "试卷id", 1});
59
-        List<MsTemplate> temps = msScanbatchPaperService.listTemplates(mpid);
60
-        return new ResultVo(0, "获取成功", temps);
58
+        return new ResultVo(0, "获取成功", msScanbatchPaperService.listTemplates(mpid));
61 59
     }
62 60
 
63 61
     /*

+ 4
- 1
smarking/src/main/java/com/xhkjedu/smarking/controller/stupaper/MsPaperStudentScoreController.java View File

@@ -173,11 +173,14 @@ public class MsPaperStudentScoreController {
173 173
     @PostMapping("/save_import")
174 174
     public ResultVo saveBatchForImport(MsPaperStudentScore stuScoreVo, MultipartFile file) {
175 175
         N_Utils.validation(new Object[]{stuScoreVo.getExamid(), "考试id", 1});
176
+        if(file == null){
177
+            return new ResultVo(1, "上传文件不能为空");
178
+        }
176 179
 
177 180
         try {
178 181
             return msPaperStudentScoreService.saveBatch(stuScoreVo, file);
179 182
         }catch (Exception e){
180
-            log.error("补录成绩导入失败", e.getMessage());
183
+            log.error("补录成绩导入失败" + e.getMessage());
181 184
             return new ResultVo(1, "保存失败");
182 185
         }
183 186
     }

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

@@ -30,7 +30,7 @@ public interface MsTemplateMapper extends TkMapper<MsTemplate> {
30 30
     int getUnSelTemplateCount(@Param("mpid")Integer mpid);
31 31
 
32 32
     //试卷所有模板信息
33
-    List<MsTemplate> listTemplateBlockQueByMpid(@Param("mpid") Integer mpid);
33
+    List<Map<String,Object>> listTemplateBlockQueByMpid(@Param("mpid") Integer mpid);
34 34
 
35 35
     //获取模版详情和考试id
36 36
     MsTemplate getTemplateAndExamidByMtid(@Param("mtid") Integer mtid);

+ 4
- 2
smarking/src/main/java/com/xhkjedu/smarking/mapper/scan/MsScanbatchPaperMapper.java View File

@@ -44,8 +44,10 @@ public interface MsScanbatchPaperMapper extends TkMapper<MsScanbatchPaper> {
44 44
 
45 45
     //扫描异常-缺考异常-异常处理
46 46
     int updateBatchScanPaperMspstate(@Param("list") List<PaperStudentWebVo> list);
47
-    //获取重新识别数据
47
+    //重新识别-获取重新识别数据
48 48
     List<MsScanbatchPaper> listScanPapersForReidentify(@Param("param") ScanParams param);
49
-    //删除需要重新识别试卷识别数据
49
+    //重新识别-删除需要重新识别试卷识别数据
50 50
     int deleteScanPaperForReidentify(@Param("param") ScanParams param);
51
+    //重新识别-修改识别试卷数据
52
+    int updateScanPaperForReidentified(@Param("p")MsScanbatchPaper p);
51 53
 }

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

@@ -23,6 +23,8 @@ public class MsScanbatchPaper extends BaseBean {
23 23
     private Integer batchid;
24 24
     //当前批次第几张
25 25
     private Integer batchorder;
26
+    //试卷扫描图片
27
+    private String paperpic;
26 28
     //试卷正面
27 29
     private String paperfront;
28 30
     //试卷反面

+ 40
- 11
smarking/src/main/java/com/xhkjedu/smarking/service/scan/MsScanbatchPaperService.java View File

@@ -1,5 +1,6 @@
1 1
 package com.xhkjedu.smarking.service.scan;
2 2
 
3
+import com.alibaba.fastjson.JSON;
3 4
 import com.xhkjedu.exception.ServiceException;
4 5
 import com.xhkjedu.smarking.mapper.exam.MsExamMapper;
5 6
 import com.xhkjedu.smarking.mapper.paper.MsPaperBlockQuestionMapper;
@@ -94,7 +95,7 @@ public class MsScanbatchPaperService {
94 95
     }
95 96
 
96 97
     //获取试卷的所有模版信息
97
-    public List<MsTemplate> listTemplates(Integer mpid){
98
+    public List<Map<String,Object>> listTemplates(Integer mpid){
98 99
         return msTemplateMapper.listTemplateBlockQueByMpid(mpid);
99 100
     }
100 101
 
@@ -184,17 +185,41 @@ public class MsScanbatchPaperService {
184 185
         SchoolCloudVo schoolCloudVo = schoolMapper.getSchoolCloudcode(msScanbatchPaper.getMpid());
185 186
         String saveFloder = schoolCloudVo.getCloudcode() + "/" + schoolCloudVo.getSchoolid() + "/marking/scan";
186 187
 
187
-        String paperfront = MarkingUtil.uploadBase64Img(msScanbatchPaper.getPaperfront(),1,saveFloder);
188
-        if(N_Utils.isNotEmpty(paperfront)){
189
-            msScanbatchPaper.setPaperfront(paperfront);
188
+        //扫描的图片
189
+        if(N_Utils.isNotEmpty(msScanbatchPaper.getPaperpic())){
190
+            List<String> paperpics = JSON.parseArray(msScanbatchPaper.getPaperpic(), String.class);
191
+            List<String> rtnPics = new ArrayList<>();
192
+            for(String pic : paperpics){
193
+                if(N_Utils.isNotEmpty(pic)){
194
+                    String paperpic = MarkingUtil.uploadBase64Img(pic,1,saveFloder);
195
+                    if(N_Utils.isNotEmpty(paperpic)){
196
+                        rtnPics.add(paperpic);
197
+                    }
198
+                }
199
+            }
200
+            if(!rtnPics.isEmpty()){
201
+                msScanbatchPaper.setPaperpic(JSON.toJSONString(rtnPics));
202
+            }
203
+        }
204
+
205
+        if(N_Utils.isNotEmpty(msScanbatchPaper.getPaperfront())){
206
+            String paperfront = MarkingUtil.uploadBase64Img(msScanbatchPaper.getPaperfront(),1,saveFloder);
207
+            if(N_Utils.isNotEmpty(paperfront)){
208
+                msScanbatchPaper.setPaperfront(paperfront);
209
+            }
190 210
         }
191
-        String paperback = MarkingUtil.uploadBase64Img(msScanbatchPaper.getPaperback(),1,saveFloder);
192
-        if(N_Utils.isNotEmpty(paperback)){
193
-            msScanbatchPaper.setPaperback(paperback);
211
+        if(N_Utils.isNotEmpty(msScanbatchPaper.getPaperback())){
212
+            String paperback = MarkingUtil.uploadBase64Img(msScanbatchPaper.getPaperback(),1,saveFloder);
213
+            if(N_Utils.isNotEmpty(paperback)){
214
+                msScanbatchPaper.setPaperback(paperback);
215
+            }
194 216
         }
195
-        String examnopic = MarkingUtil.uploadBase64Img(msScanbatchPaper.getExamnopic(),1,saveFloder);
196
-        if(N_Utils.isNotEmpty(examnopic)){
197
-            msScanbatchPaper.setExamnopic(examnopic);
217
+
218
+        if(N_Utils.isNotEmpty(msScanbatchPaper.getExamnopic())){
219
+            String examnopic = MarkingUtil.uploadBase64Img(msScanbatchPaper.getExamnopic(),1,saveFloder);
220
+            if(N_Utils.isNotEmpty(examnopic)){
221
+                msScanbatchPaper.setExamnopic(examnopic);
222
+            }
198 223
         }
199 224
 
200 225
         msScanbatchPaperMapper.insertUseGeneratedKeys(msScanbatchPaper);
@@ -650,7 +675,7 @@ public class MsScanbatchPaperService {
650 675
         if(scanbatchPapers.isEmpty()) return;
651 676
 
652 677
         //获取考试对应的试卷模板及坐标信息
653
-        List<MsTemplate> templates = msTemplateMapper.listTemplateBlockQueByMpid(mpid);
678
+        List<Map<String,Object>> templates = msTemplateMapper.listTemplateBlockQueByMpid(mpid);
654 679
         if(templates.isEmpty()) throw new ServiceException("该考试未设置试卷模板");
655 680
 
656 681
         //清空学生题块试题信息和学生试卷扫描识别信息
@@ -684,6 +709,10 @@ public class MsScanbatchPaperService {
684 709
         return template;
685 710
     }
686 711
 
712
+    //重新识别-获取试卷正反面图片
713
+    private void settPaperFrontAndBack(MsScanbatchPaper scanbatchPaper,MsTemplate template){
714
+
715
+    }
687 716
 
688 717
 
689 718
 }

+ 78
- 1
smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java View File

@@ -13,11 +13,17 @@ import com.xhkjedu.utils.N_Utils;
13 13
 import com.xhkjedu.vo.PageResult;
14 14
 import com.xhkjedu.vo.ResultVo;
15 15
 import lombok.extern.slf4j.Slf4j;
16
+import org.opencv.core.Mat;
17
+import org.opencv.core.MatOfByte;
18
+import org.opencv.imgcodecs.Imgcodecs;
16 19
 
17
-import java.io.UnsupportedEncodingException;
20
+import java.io.*;
18 21
 import java.math.BigDecimal;
19 22
 import java.math.BigInteger;
23
+import java.net.HttpURLConnection;
24
+import java.net.URL;
20 25
 import java.net.URLEncoder;
26
+import java.nio.charset.StandardCharsets;
21 27
 import java.text.SimpleDateFormat;
22 28
 import java.time.LocalDateTime;
23 29
 import java.time.ZoneId;
@@ -350,6 +356,77 @@ public class MarkingUtil {
350 356
         }
351 357
     }
352 358
 
359
+    private static final String BOUNDARY = UUID.randomUUID().toString();
360
+
361
+    //上传Mat图片
362
+    public static String sendPostForMat(Mat matImage, String param) {
363
+        // 将 Mat 转换为字节数组
364
+        MatOfByte matOfByte = new MatOfByte();
365
+        Imgcodecs.imencode(".jpg", matImage, matOfByte);
366
+        byte[] byteArray = matOfByte.toArray();
367
+
368
+        // 是否重命名0不重名1重命名
369
+        Integer isrename = 1;
370
+        Integer iscompress = 1;//是否压缩0压缩1不压缩
371
+        BufferedOutputStream bufferedOutputStream = null;
372
+        BufferedReader bufferedReader = null;
373
+        String result = "";
374
+
375
+        try {
376
+            // 创建 URL 对象
377
+            URL url = new URL("http://127.0.0.1:8908/up/upfile");
378
+            // 打开连接
379
+            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
380
+            // 设置请求方法为 POST
381
+            connection.setRequestMethod("POST");
382
+            connection.setDoOutput(true);
383
+            // 生成唯一的边界字符串
384
+            String boundary = UUID.randomUUID().toString();
385
+            // 设置为 multipart/form-data 以便发送多部分数据
386
+            connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
387
+
388
+            // 获取输出流
389
+            OutputStream outputStream = connection.getOutputStream();
390
+            bufferedOutputStream = new BufferedOutputStream(outputStream);
391
+
392
+            // 写入图片数据
393
+            bufferedOutputStream.write(("--" + boundary + "\r\n" +
394
+                    "Content-Disposition: form-data; name=\"file\"; filename=\"image.jpg\"\r\n" +
395
+                    "Content-Type: image/jpeg\r\n\r\n").getBytes(StandardCharsets.UTF_8));
396
+            bufferedOutputStream.write(byteArray);
397
+            bufferedOutputStream.write(("\r\n--" + boundary + "\r\n" +
398
+                    "Content-Disposition: form-data; name=\"savefolder\"\r\n\r\n" + param +
399
+                    "\r\n--" + boundary + "\r\n" +
400
+                    "Content-Disposition: form-data; name=\"isrename\"\r\n\r\n" + isrename +
401
+                    "\r\n--" + boundary + "\r\n" +
402
+                    "Content-Disposition: form-data; name=\"iscompress\"\r\n\r\n" + iscompress +
403
+                    "\r\n--" + boundary + "--\r\n").getBytes(StandardCharsets.UTF_8));
404
+
405
+            bufferedOutputStream.flush();
406
+            bufferedOutputStream.close();
407
+
408
+            bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
409
+            String line;
410
+            while ((line = bufferedReader.readLine())!= null) {
411
+                result += line;
412
+            }
413
+        } catch (Exception e) {
414
+            log.error("发送 POST 请求出现异常!" + e.getMessage());
415
+        }finally {
416
+            try {
417
+                if(bufferedOutputStream!= null){
418
+                    bufferedOutputStream.close();
419
+                }
420
+                if (bufferedReader != null) {
421
+                    bufferedReader.close();
422
+                }
423
+            } catch (IOException ex) {
424
+                log.error("关闭输入输出流异常", ex.getMessage());
425
+            }
426
+        }
427
+        return result;
428
+    }
429
+
353 430
     /*
354 431
      * @Description 识别客观题题块单题结果
355 432
      * @Date 2024/11/7 14:58:44

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

@@ -8,6 +8,14 @@ import java.util.Base64;
8 8
 import java.util.List;
9 9
 
10 10
 public class CvCommonUtils {
11
+
12
+    static {
13
+        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
14
+        String libraryPath = System.getProperty("java.library.path");
15
+        // 输出java.library.path的值,用于查看当前系统的库搜索路径。
16
+        System.out.println("java.library.path:" + libraryPath);
17
+    }
18
+
11 19
     /**
12 20
      * 逆时针旋转90度
13 21
      *

+ 33
- 0
smarking/src/main/java/com/xhkjedu/smarking/utils/opencv/TestMain.java View File

@@ -0,0 +1,33 @@
1
+package com.xhkjedu.smarking.utils.opencv;
2
+
3
+import com.alibaba.fastjson.JSON;
4
+import com.xhkjedu.smarking.utils.MarkingUtil;
5
+import com.xhkjedu.vo.ResultVo;
6
+import org.opencv.core.Core;
7
+import org.opencv.core.Mat;
8
+import org.opencv.imgcodecs.Imgcodecs;
9
+
10
+/**
11
+ * @Description:
12
+ * @Author: WN
13
+ * @Date: 2025/1/10 14:56:28
14
+ **/
15
+public class TestMain {
16
+    static {
17
+        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
18
+    }
19
+    public static void main(String[] args) {
20
+
21
+        // String libraryPath = System.getProperty("java.library.path");
22
+        // // 输出java.library.path的值,用于查看当前系统的库搜索路径。
23
+        // System.out.println("java.library.path:" + libraryPath);
24
+
25
+
26
+        String imgPath= "D:\\school\\images\\tr2.jpg";
27
+        String param = "AAA/0110";
28
+        Mat img =  Imgcodecs.imread(imgPath, Imgcodecs.IMREAD_GRAYSCALE);
29
+        String resultVo = MarkingUtil.sendPostForMat(img, param);
30
+        ResultVo result = JSON.parseObject(resultVo, ResultVo.class);
31
+        System.out.println(result.getObj());
32
+    }
33
+}

+ 5
- 1
smarking/src/main/resources/application.properties View File

@@ -93,7 +93,11 @@ cron.questionCheckState=0 0/10 * * * ?
93 93
 marking.socket=wss://wsexam.xhkjedu.com/ws
94 94
 marking.face=https://face.xhkjedu.com/
95 95
 #\u6587\u4EF6\u670D\u52A1\u5730\u5740
96
-fileapi=https://schoolfiletest.xhkjedu.com/
96
+#fileapi=https://schoolfiletest.xhkjedu.com/
97
+fileapi=http://127.0.0.1:8908/
98
+#\u6587\u4EF6\u670D\u52A1\u8BBF\u95EE\u6587\u4EF6\u5730\u5740
99
+file.showurl=http://schoolstatictest.xhkjedu.com/static/
100
+
97 101
 
98 102
 #\u914D\u7F6E\u8003\u8BD5\u7ED3\u675F\u65F6\u95F4\u8303\u56F4
99 103
 marking.endtime=30

+ 4
- 5
smarking/src/main/resources/mapper/paper/MsTemplateMapper.xml View File

@@ -51,7 +51,7 @@
51 51
     </select>
52 52
 
53 53
     <!--试卷所有模板信息-->
54
-    <resultMap id="paperTemplate" type="com.xhkjedu.smarking.model.paper.MsTemplate">
54
+    <resultMap id="paperTemplate" type="java.util.Map">
55 55
         <result property="mtid" column="mtid"/>
56 56
         <result property="mpid" column="mpid"/>
57 57
         <result property="tsize" column="tsize"/>
@@ -68,16 +68,15 @@
68 68
         <result property="violatecoor" column="violatecoor"/>
69 69
         <result property="examnocoor" column="examnocoor"/>
70 70
         <result property="cardcoor" column="cardcoor"/>
71
-        <collection property="tblocks" ofType="com.xhkjedu.smarking.model.paper.MsTemplateBlock" javaType="java.util.ArrayList">
71
+        <collection property="tblocks" ofType="java.util.Map" javaType="java.util.ArrayList">
72 72
             <result property="mtbid" column="mtbid"/>
73 73
             <result property="mblockid" column="mblockid"/>
74 74
             <result property="mttype" column="mttype"/>
75 75
             <result property="mtborder" column="mtborder"/>
76 76
             <result property="localcoor" column="localcoor"/>
77
-            <result property="pagenum" column="pagenum"/>
78 77
             <result property="extendcoor" column="extendcoor"/>
79 78
             <result property="scorecoor" column="scorecoor"/>
80
-            <collection property="tbquestions" ofType="com.xhkjedu.smarking.model.paper.MsTemplateBlockQuestion" javaType="java.util.ArrayList">
79
+            <collection property="tbquestions" ofType="java.util.Map" javaType="java.util.ArrayList">
81 80
                 <result property="mtbqid" column="mtbqid"/>
82 81
                 <result property="qn" column="qn"/>
83 82
                 <result property="mptqid" column="mptqid"/>
@@ -89,7 +88,7 @@
89 88
     <select id="listTemplateBlockQueByMpid" resultMap="paperTemplate">
90 89
         select t.mtid,t.mpid,t.tsize,t.twidth,t.theight,t.blankindex,t.anglefront,t.angleback,t.coorfront,t.coorback,
91 90
         t.dwtfront,t.dwtback,t.misscoor,t.violatecoor,t.examnocoor,t.cardcoor
92
-        ,tb.mtbid,tb.mblockid,tb.mttype,tb.mtborder,tb.localcoor,tb.pagenum,tb.extendcoor,tb.scorecoor
91
+        ,tb.mtbid,tb.mblockid,tb.mttype,tb.mtborder,tb.localcoor,tb.extendcoor,tb.scorecoor
93 92
         ,q.mtbqid,q.qn,q.mptqid,q.qlocalcoor,q.mtbqorder
94 93
         from ms_template t left join ms_template_block tb on t.mtid=tb.mtid
95 94
         left join ms_template_block_question q on tb.mtbid=q.mtbid

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

@@ -71,7 +71,7 @@
71 71
         </foreach>
72 72
     </update>
73 73
 
74
-    <!--获取重新识别数据-->
74
+    <!--重新识别-获取重新识别数据-->
75 75
     <select id="listScanPapersForReidentify" resultType="com.xhkjedu.smarking.model.scan.MsScanbatchPaper">
76 76
         select * from ms_scanbatch_paper where mpid=#{param.mpid}
77 77
         <if test="param.batchid!=null and param.batchid!=0"> and batchid=#{param.batchid}</if>
@@ -79,7 +79,7 @@
79 79
         <if test="param.hasidentify!=null and param.hasidentify==2"> and identified=0</if>
80 80
         order by mspid
81 81
     </select>
82
-    <!--删除需要重新识别试卷识别数据-->
82
+    <!--重新识别-删除需要重新识别试卷识别数据-->
83 83
     <delete id="deleteScanPaperForReidentify">
84 84
         delete b from ms_scanbatch_paper_block b left join ms_scanbatch_paper p on b.mspid=p.mspid
85 85
         where p.mpid=#{param.mpid}
@@ -88,4 +88,11 @@
88 88
         <if test="param.hasidentify!=null and param.hasidentify==2"> and p.identified=0</if>
89 89
     </delete>
90 90
 
91
+    <!--重新识别-修改识别试卷数据-->
92
+    <update id="updateScanPaperForReidentified">
93
+        update ms_scanbatch_paper set paperfront=#{p.paperfront},paperback=#{p.paperback},identified=#{p.identified},examno=#{p.examno},
94
+        examnopic=#{p.examnopic},missexam=#{p.missexam},violated=#{p.violated},haserror=#{p.haserror},errortype=#{p.errortype},mspstate=#{p.mspstate}
95
+        where mspid=#{p.mspid}
96
+    </update>
97
+
91 98
 </mapper>

+ 7
- 0
sstudy/src/main/java/com/xhkjedu/sstudy/config/ConfigKey.java View File

@@ -75,4 +75,11 @@ public class ConfigKey {
75 75
     public void setIpregiondb(String ipregiondb){
76 76
         ConfigKey.ipregiondb = ipregiondb;
77 77
     }
78
+
79
+    public static String fileShowurl;//解析ip地址归属地
80
+
81
+    @Value("${file.showurl}")
82
+    public void setFileShowurl(String fileShowurl){
83
+        ConfigKey.fileShowurl = fileShowurl;
84
+    }
78 85
 }

Loading…
Cancel
Save