ソースを参照

答题卡pdfmq

tags/正式版本
王宁 2年前
コミット
be02f69e6e

+ 2
- 2
sexam/src/main/java/com/xhkjedu/sexam/listener/MessageConsumer.java ファイルの表示

@@ -61,8 +61,8 @@ public class MessageConsumer {
61 61
      * @Date 2022/8/2 14:00
62 62
      **/
63 63
     @RabbitHandler
64
-    @RabbitListener(queues = "${rabbitmq.examImgToPdfHandleQueue}")
65
-    public void imgToPdfHandleQueue(Message message) {
64
+    @RabbitListener(queues = "${rabbitmq.examBaseToPdfHandleQueue}")
65
+    public void baseToPdfHandleQueue(Message message) {
66 66
         try {
67 67
             String msg = new String(message.getBody(), "UTF-8");
68 68
             System.out.println(LocalDateTime.now() + "答题卡图片合并接收消息内容:" + msg);

+ 6
- 4
sexam/src/main/java/com/xhkjedu/sexam/listener/MessageSender.java ファイルの表示

@@ -23,8 +23,8 @@ public class MessageSender {
23 23
 
24 24
     @Value("${rabbitmq.examImgMergeQueue}")
25 25
     private String examImgMergeQueue;
26
-    @Value("${rabbitmq.examImgToPdfQueue}")
27
-    private String examImgToPdfQueue;
26
+    @Value("${rabbitmq.examBaseToPdfQueue}")
27
+    private String examBaseToPdfQueue;
28 28
 
29 29
 
30 30
     /**
@@ -49,10 +49,12 @@ public class MessageSender {
49 49
      * @Author wn
50 50
      * @Date 2022/8/2 13:57
51 51
      **/
52
-    public void imgToPdf(Integer epid, List<String> imgs) {
52
+    public void base64ToPdf(Integer epid,Integer examid, List<String> imgs,String savefolder) {
53 53
         Map map = new HashMap();
54 54
         map.put("epid", epid);
55
+        map.put("examid", examid);
55 56
         map.put("imgs", imgs);
56
-        rabbitTemplate.convertAndSend(examImgToPdfQueue, JSON.toJSONString(map));
57
+        map.put("savefolder","");
58
+        rabbitTemplate.convertAndSend(examBaseToPdfQueue, JSON.toJSONString(map));
57 59
     }
58 60
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paper/EPaperMapper.java ファイルの表示

@@ -58,4 +58,7 @@ public interface EPaperMapper extends TkMapper<EPaper> {
58 58
 
59 59
     //保存答题卡pdf
60 60
     void updatePaperScantronpdf(@Param("paper") EPaper paper);
61
+
62
+    //获取试卷中答题卡文件
63
+    Map getPaperScantronfile(@Param("epid") Integer epid);
61 64
 }

+ 23
- 1
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperQtypeService.java ファイルの表示

@@ -8,16 +8,19 @@ import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentQuestionMapper;
8 8
 import com.xhkjedu.sexam.mapper.system.UserBasketMapper;
9 9
 import com.xhkjedu.sexam.model.paper.*;
10 10
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
11
+import com.xhkjedu.sexam.utils.ConvertUtil;
11 12
 import com.xhkjedu.sexam.utils.ExamUtil;
12 13
 import com.xhkjedu.sexam.vo.paper.*;
13 14
 import com.xhkjedu.utils.N_Utils;
14 15
 import com.xhkjedu.vo.ResultVo;
15 16
 import lombok.extern.slf4j.Slf4j;
16 17
 import org.springframework.beans.BeanUtils;
18
+import org.springframework.beans.factory.annotation.Autowired;
17 19
 import org.springframework.stereotype.Service;
18 20
 import org.springframework.transaction.annotation.Transactional;
19 21
 
20 22
 import javax.annotation.Resource;
23
+import java.io.File;
21 24
 import java.util.*;
22 25
 import java.util.List;
23 26
 import java.util.stream.Collectors;
@@ -48,6 +51,8 @@ public class EPaperQtypeService {
48 51
     private EPaperStudentQuestionMapper ePaperStudentQuestionMapper;
49 52
     @Resource
50 53
     private EPaperStudentMapper ePaperStudentMapper;
54
+    @Autowired
55
+    private ConvertUtil convertUtil;
51 56
 
52 57
 
53 58
     /**
@@ -621,8 +626,25 @@ public class EPaperQtypeService {
621 626
         ePaperQtypeMapper.updateBatchQuestionForScan(questions);
622 627
         if(paper.getPstate() == 1){
623 628
             eSubjectMapper.updateEsubjectStateByEpid(1,paper.getEpid());
629
+            //提交之后把答题卡base图片转成pdf
630
+//            chandleScantronFile(paper.getEpid());
631
+        }
632
+    }
624 633
 
625
-
634
+    //答题卡种图片处理
635
+    private void chandleScantronFile(Integer epid){
636
+        //获取试卷中答题卡文件,
637
+        Map map = ePaperMapper.getPaperScantronfile(epid);
638
+        if(map.get("scantronfile")!=null){
639
+            List<String> scantronfiles = JSON.parseArray(map.get("scantronfile").toString(),String.class);
640
+            if(N_Utils.isNotEmpty(scantronfiles)){
641
+                Integer examid = Integer.parseInt(map.get("examid").toString());
642
+                Integer schoolid = Integer.parseInt(map.get("schoolid").toString());
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);
647
+            }
626 648
         }
627 649
     }
628 650
 }

+ 11
- 0
sexam/src/main/java/com/xhkjedu/sexam/utils/ConvertUtil.java ファイルの表示

@@ -28,4 +28,15 @@ public class ConvertUtil {
28 28
         messageSender.imgMerge(psqid, userAnswers, device);
29 29
     }
30 30
 
31
+    /**
32
+     * @Description  答题卡base64转pdf
33
+     * @Param [epid, examid, imgs, savefolder]
34
+     * @Return void
35
+     * @Author wn
36
+     * @Date 2022/8/2 17:20
37
+     **/
38
+    public void baseToPdf(Integer epid,Integer examid, List<String> imgs, String savefolder) {
39
+        messageSender.base64ToPdf(epid, examid,imgs, savefolder);
40
+    }
41
+
31 42
 }

+ 2
- 2
sexam/src/main/resources/application.properties ファイルの表示

@@ -54,8 +54,8 @@ redisdatatime=604800
54 54
 
55 55
 rabbitmq.examImgMergeQueue=xhkjedu.xhschool.examImgMergeQueue_dev
56 56
 rabbitmq.examImgMergeHandleQueue=xhkjedu.xhschool.examImgMergeHandleQueue_dev
57
-rabbitmq.examImgToPdfQueue=xhkjedu.xhschool.examImgToPdfQueue_dev
58
-rabbitmq.examImgToPdfHandleQueue=xhkjedu.xhschool.examImgToPdfHandleQueue_dev
57
+rabbitmq.examBaseToPdfQueue=xhkjedu.xhschool.examBaseToPdfQueue_dev
58
+rabbitmq.examBaseToPdfHandleQueue=xhkjedu.xhschool.examBaseToPdfHandleQueue_dev
59 59
 spring.rabbitmq.host=116.63.199.166
60 60
 spring.rabbitmq.port=5672
61 61
 spring.rabbitmq.username=xhkjedu

+ 8
- 0
sexam/src/main/resources/mapper/paper/EPaperMapper.xml ファイルの表示

@@ -117,4 +117,12 @@
117 117
         update e_paper set scantronpdf=#{paper.scantronpdf} where epid=#{paper.epid}
118 118
     </update>
119 119
 
120
+    <!--获取试卷中答题卡文件-->
121
+    <select id="getPaperScantronfile" resultType="java.util.Map">
122
+        select p.epid,p.examid,p.scantronfile,e.schoolid,
123
+        (select cloudcode from t_cloud limit 1) cloudcode
124
+        from e_paper p left join e_base e on p.examid=e.examid
125
+        where p.epid=#{epid}
126
+    </select>
127
+
120 128
 </mapper>

読み込み中…
キャンセル
保存