Kaynağa Gözat

试卷合并

tags/正式版本
王宁 2 yıl önce
ebeveyn
işleme
f4b69ee841

+ 46
- 0
sexam/src/main/java/com/xhkjedu/sexam/config/RabbitConfig.java Dosyayı Görüntüle

@@ -0,0 +1,46 @@
1
+package com.xhkjedu.sexam.config;
2
+
3
+import org.springframework.amqp.core.Queue;
4
+import org.springframework.beans.factory.annotation.Value;
5
+import org.springframework.context.annotation.Bean;
6
+import org.springframework.context.annotation.Configuration;
7
+
8
+/**
9
+ * @author ywx
10
+ * @classname RabbitConfig
11
+ * @description
12
+ * @date 2021/6/18 12:51
13
+ **/
14
+@Configuration
15
+public class RabbitConfig {
16
+
17
+    @Value("${rabbitmq.examImgMergeQueue}")
18
+    private String examImgMergeQueue;
19
+    @Value("${rabbitmq.examImgMergeHandleQueue}")
20
+    private String examImgMergeHandleQueue;
21
+    @Value("${rabbitmq.examBaseToPdfQueue}")
22
+    private String examBaseToPdfQueue;
23
+    @Value("${rabbitmq.examBaseToPdfHandleQueue}")
24
+    private String examBaseToPdfHandleQueue;
25
+
26
+    @Bean
27
+    public Queue examImgMergeQueue() {
28
+        return new Queue(examImgMergeQueue);
29
+    }
30
+
31
+    @Bean
32
+    public Queue examImgMergeHandleQueue() {
33
+        return new Queue(examImgMergeHandleQueue);
34
+    }
35
+
36
+    @Bean
37
+    public Queue examBaseToPdfQueue() {
38
+        return new Queue(examBaseToPdfQueue);
39
+    }
40
+
41
+    @Bean
42
+    public Queue examBaseToPdfHandleQueue() {
43
+        return new Queue(examBaseToPdfHandleQueue);
44
+    }
45
+
46
+}

+ 13
- 1
sexam/src/main/java/com/xhkjedu/sexam/controller/paperstudent/EPaperStudentController.java Dosyayı Görüntüle

@@ -113,7 +113,7 @@ public class EPaperStudentController {
113 113
             N_Utils.validation(new Object[]{ps.getEpsid(), "试卷id", 1});
114 114
             List<EPaperStudentQuestion> qlist = ps.getQuestions();
115 115
             if (N_Utils.isListEmpty(qlist)) {
116
-                return new ResultVo(1, "试题");
116
+                return new ResultVo(1, "试题不能为空");
117 117
             }
118 118
             ePaperStudentService.saveCommitPaperForWeb(ps);
119 119
             return new ResultVo(0, "成功提交试卷");
@@ -123,5 +123,17 @@ public class EPaperStudentController {
123 123
         }
124 124
     }
125 125
 
126
+    @PostMapping("/sca")
127
+    public ResultVo saveCommitPaperScantron(@RequestBody PaperStudentWebVo ps) {
128
+        try {
129
+            N_Utils.validation(new Object[]{ps.getEpid(), "试卷id", 1});
130
+            ePaperStudentService.saveCommitPaperForScantron(ps);
131
+            return new ResultVo(0, "成功提交试卷");
132
+        } catch (Exception e) {
133
+            log.error("提交试卷(web)失败:" + e.getMessage());
134
+            return new ResultVo(1, "提交失败");
135
+        }
136
+    }
137
+
126 138
 
127 139
 }

+ 6
- 2
sexam/src/main/java/com/xhkjedu/sexam/listener/MessageSender.java Dosyayı Görüntüle

@@ -1,6 +1,7 @@
1 1
 package com.xhkjedu.sexam.listener;
2 2
 
3 3
 import com.alibaba.fastjson.JSON;
4
+import lombok.extern.slf4j.Slf4j;
4 5
 import org.springframework.amqp.core.AmqpTemplate;
5 6
 import org.springframework.beans.factory.annotation.Autowired;
6 7
 import org.springframework.beans.factory.annotation.Value;
@@ -17,6 +18,7 @@ import java.util.Map;
17 18
  * @date 2021/10/25 14:28
18 19
  **/
19 20
 @Component
21
+@Slf4j
20 22
 public class MessageSender {
21 23
     @Autowired
22 24
     private AmqpTemplate rabbitTemplate;
@@ -49,12 +51,14 @@ public class MessageSender {
49 51
      * @Author wn
50 52
      * @Date 2022/8/2 13:57
51 53
      **/
52
-    public void base64ToPdf(Integer epid,Integer examid, List<String> imgs,String savefolder) {
54
+    public void base64ToPdf(Integer epid,Integer examid, List<String> imgs,String savefolder,Integer scantroncol) {
53 55
         Map map = new HashMap();
54 56
         map.put("epid", epid);
55 57
         map.put("examid", examid);
56 58
         map.put("imgs", imgs);
57
-        map.put("savefolder","");
59
+        map.put("scantroncol", scantroncol);
60
+        map.put("savefolder",savefolder);
61
+
58 62
         rabbitTemplate.convertAndSend(examBaseToPdfQueue, JSON.toJSONString(map));
59 63
     }
60 64
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paperstudent/EPaperStudentMapper.java Dosyayı Görüntüle

@@ -46,6 +46,9 @@ public interface EPaperStudentMapper extends TkMapper<EPaperStudent> {
46 46
     //学生提交试卷
47 47
     int updateStudentPaper(@Param("ps")EPaperStudent ps);
48 48
 
49
+    //更新缺考字段
50
+    void updateStudentPaperState(@Param("ps")EPaperStudent ps);
51
+
49 52
     //根据试卷id批量修改该试卷学生得分
50 53
     void updateBathStudentPaperScoreByEpid(@Param("epid")Integer epid);
51 54
 }

+ 6
- 6
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperQtypeService.java Dosyayı Görüntüle

@@ -627,12 +627,12 @@ public class EPaperQtypeService {
627 627
         if(paper.getPstate() == 1){
628 628
             eSubjectMapper.updateEsubjectStateByEpid(1,paper.getEpid());
629 629
             //提交之后把答题卡base图片转成pdf
630
-//            chandleScantronFile(paper.getEpid());
630
+            chandleScantronFile(paper.getEpid());
631 631
         }
632 632
     }
633 633
 
634
-    //答题卡图片处理
635
-    private void chandleScantronFile(Integer epid){
634
+    //答题卡图片处理
635
+    public void chandleScantronFile(Integer epid){
636 636
         //获取试卷中答题卡文件,
637 637
         Map map = ePaperMapper.getPaperScantronfile(epid);
638 638
         if(map.get("scantronfile")!=null){
@@ -641,9 +641,9 @@ public class EPaperQtypeService {
641 641
                 Integer examid = Integer.parseInt(map.get("examid").toString());
642 642
                 Integer schoolid = Integer.parseInt(map.get("schoolid").toString());
643 643
                 String cloudcode =  map.get("cloudcode").toString();
644
-                String path = cloudcode + File.separator + schoolid + File.separator + "exam" +
645
-                        File.separator;
646
-                convertUtil.baseToPdf(epid,examid,scantronfiles,path);
644
+                String path = cloudcode + File.separator + schoolid + File.separator + "exam";
645
+                Integer scantroncol = Integer.parseInt(map.get("scantroncol").toString());
646
+                convertUtil.baseToPdf(epid,examid,scantronfiles,path,scantroncol);
647 647
             }
648 648
         }
649 649
     }

+ 59
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/paperstudent/EPaperStudentService.java Dosyayı Görüntüle

@@ -381,4 +381,63 @@ public class EPaperStudentService {
381 381
         ePaperStudentMapper.updateStudentPaper(paperStudent);
382 382
     }
383 383
 
384
+    /**
385
+     * @Description 答题卡扫描时保存
386
+     * @Param [pswvo]
387
+     * @Return void
388
+     * @Author wn
389
+     * @Date 2022/8/3 9:17
390
+     **/
391
+    public void saveCommitPaperForScantron(PaperStudentWebVo pswvo){
392
+        //更加学生姓名和准考证号找到对应学生
393
+
394
+        int epsid = 0;
395
+        pswvo.setEpsid(epsid);
396
+        EPaperStudent ps = ePaperStudentMapper.selectByPrimaryKey(pswvo.getEpsid());
397
+        //试卷不存在或者已提交
398
+        if(ps == null || ps.getSstate() == 1){
399
+            return;
400
+        }
401
+
402
+        if(pswvo.getSstate() == 3){
403
+            //说明学生缺考仅更新状态和
404
+            EPaperStudent paperStudent = new EPaperStudent();
405
+            paperStudent.setEpsid(pswvo.getEpsid());
406
+            paperStudent.setStupic(JSON.toJSONString(pswvo.getStupic()));
407
+            paperStudent.setSstate(3);
408
+            ePaperStudentMapper.updateStudentPaperState(paperStudent);
409
+        }else{
410
+            List<EPaperStudentQuestion> sqlist = pswvo.getQuestions();//学生提交试卷中试题
411
+
412
+            //获取试卷中所有试题答案及分值
413
+            List<PsqAnswerVo> anvolist = ePaperStudentQuestionMapper.listPaperQuestionsAnswer(pswvo.getEpsid());
414
+            Integer checknum = 0;//记录试卷中试题批阅数量
415
+            Double paperscore = 0D;//学生试卷得分
416
+            for(EPaperStudentQuestion q : sqlist){
417
+
418
+                //获取该试题正确答案
419
+                PsqAnswerVo anvo = anvolist.stream().filter(a -> a.getEptqid().equals(q.getEptqid())).findFirst().orElse(null);
420
+
421
+                setCommitQuestion(q,anvo,2);
422
+                if(q.getChecked() == 2){
423
+                    checknum ++;
424
+                }
425
+                paperscore = ExamUtil.add(paperscore, q.getStuscore());
426
+            }
427
+            EPaperStudent paperStudent = new EPaperStudent();
428
+            paperStudent.setEpsid(pswvo.getEpsid());
429
+            paperStudent.setStupic(JSON.toJSONString(pswvo.getStupic()));
430
+            paperStudent.setSstate(2);
431
+            paperStudent.setStuscore(paperscore);
432
+            int checked = 0;
433
+            if(checknum == sqlist.size()){
434
+                checked = 1;
435
+            }
436
+            paperStudent.setChecked(checked);
437
+
438
+            ePaperStudentQuestionMapper.updateBatchStuQuestion(sqlist);
439
+            ePaperStudentMapper.updateStudentPaper(paperStudent);
440
+        }
441
+    }
442
+
384 443
 }

+ 3
- 2
sexam/src/main/java/com/xhkjedu/sexam/utils/ConvertUtil.java Dosyayı Görüntüle

@@ -1,5 +1,6 @@
1 1
 package com.xhkjedu.sexam.utils;
2 2
 
3
+import ch.qos.logback.core.net.SyslogOutputStream;
3 4
 import com.xhkjedu.sexam.listener.MessageSender;
4 5
 import org.springframework.beans.factory.annotation.Autowired;
5 6
 import org.springframework.stereotype.Component;
@@ -35,8 +36,8 @@ public class ConvertUtil {
35 36
      * @Author wn
36 37
      * @Date 2022/8/2 17:20
37 38
      **/
38
-    public void baseToPdf(Integer epid,Integer examid, List<String> imgs, String savefolder) {
39
-        messageSender.base64ToPdf(epid, examid,imgs, savefolder);
39
+    public void baseToPdf(Integer epid,Integer examid, List<String> imgs, String savefolder,Integer scantroncol) {
40
+        messageSender.base64ToPdf(epid, examid,imgs, savefolder,scantroncol);
40 41
     }
41 42
 
42 43
 }

+ 12
- 0
sexam/src/main/java/com/xhkjedu/sexam/vo/paperstudent/PaperStudentWebVo.java Dosyayı Görüntüle

@@ -20,4 +20,16 @@ public class PaperStudentWebVo {
20 20
 
21 21
     //试卷中试题
22 22
     private List<EPaperStudentQuestion> questions;
23
+
24
+    //学生答题卡图片
25
+    private List<String> stupic;
26
+
27
+    private Integer epid;//试卷id
28
+
29
+    private String stuname;//学生姓名
30
+
31
+    private String examno;//学生准考证号
32
+
33
+    private Integer sstate;//状态0未进场1已进场2已交卷3缺考
34
+
23 35
 }

+ 0
- 1
sexam/src/main/resources/application.properties Dosyayı Görüntüle

@@ -51,7 +51,6 @@ spring.redis.jedis.pool.max-active=60000
51 51
 #缓存访问数据有效时长60*60*24*7
52 52
 redisdatatime=604800
53 53
 
54
-
55 54
 rabbitmq.examImgMergeQueue=xhkjedu.xhschool.examImgMergeQueue_dev
56 55
 rabbitmq.examImgMergeHandleQueue=xhkjedu.xhschool.examImgMergeHandleQueue_dev
57 56
 rabbitmq.examBaseToPdfQueue=xhkjedu.xhschool.examBaseToPdfQueue_dev

+ 1
- 1
sexam/src/main/resources/mapper/paper/EPaperMapper.xml Dosyayı Görüntüle

@@ -119,7 +119,7 @@
119 119
 
120 120
     <!--获取试卷中答题卡文件-->
121 121
     <select id="getPaperScantronfile" resultType="java.util.Map">
122
-        select p.epid,p.examid,p.scantronfile,e.schoolid,
122
+        select p.epid,p.examid,p.scantronfile,p.scantroncol,e.schoolid,
123 123
         (select cloudcode from t_cloud limit 1) cloudcode
124 124
         from e_paper p left join e_base e on p.examid=e.examid
125 125
         where p.epid=#{epid}

+ 6
- 1
sexam/src/main/resources/mapper/paperstudent/EPaperStudentMapper.xml Dosyayı Görüntüle

@@ -162,10 +162,15 @@
162 162
     <!--学生提交试卷-->
163 163
     <update id="updateStudentPaper">
164 164
         update e_paper_student set endtime=#{endtime},costtime=#{ps.costtime}
165
-         ,sstate=#{ps.sstate},checked=#{ps.checked}
165
+         ,sstate=#{ps.sstate},checked=#{ps.checked},stupic=#{ps.stupic}
166 166
          ,stuscore=(SELECT SUM(IFNULL(q.stuscore,0)) FROM e_paper_student_question q WHERE q.epsid=#{ps.epsid})
167 167
         where epsid=#{ps.epsid}
168 168
     </update>
169
+    <!--更新缺考状态-->
170
+    <update id="updateStudentPaperState">
171
+        update e_paper_student set sstate=#{ps.sstate},checked=#{ps.checked},stupic=#{ps.stupic}
172
+        where epsid=#{ps.epsid}
173
+    </update>
169 174
 
170 175
     <!--批量更新学生试卷分值-->
171 176
     <update id="updateBathStudentPaperScoreByEpid">

+ 5
- 0
sexam/src/main/resources/mapper/paperstudent/EPaperStudentQuestionMapper.xml Dosyayı Görüntüle

@@ -90,6 +90,11 @@
90 90
                     when epsqid=#{q.epsqid} then #{q.checktime}
91 91
                 </foreach>
92 92
             </trim>
93
+            <trim prefix="stupic = case" suffix="end,">
94
+                <foreach collection="list" item="q">
95
+                    when epsqid=#{q.epsqid} then #{q.stupic}
96
+                </foreach>
97
+            </trim>
93 98
         </trim>
94 99
         <where>
95 100
             <foreach collection="list" item="q" separator="or">

+ 2
- 1
sexam/src/test/java/com/xhkjedu/sexam/SexamApplicationTests.java Dosyayı Görüntüle

@@ -23,7 +23,8 @@ class SexamApplicationTests {
23 23
         ePaper.setEpid(68);
24 24
         ePaper.setPnum(15);
25 25
         ePaper.setPscore(172.0);
26
-//        ePaperQtypeService.savePaperAnalyzeForQuestion(ePaper);
26
+
27
+        ePaperQtypeService.chandleScantronFile(156);
27 28
     }
28 29
 
29 30
 }

Loading…
İptal
Kaydet