Browse Source

答题卡pdfmq

tags/正式版本
王宁 2 years ago
parent
commit
be02f69e6e

+ 2
- 2
sexam/src/main/java/com/xhkjedu/sexam/listener/MessageConsumer.java View File

61
      * @Date 2022/8/2 14:00
61
      * @Date 2022/8/2 14:00
62
      **/
62
      **/
63
     @RabbitHandler
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
         try {
66
         try {
67
             String msg = new String(message.getBody(), "UTF-8");
67
             String msg = new String(message.getBody(), "UTF-8");
68
             System.out.println(LocalDateTime.now() + "答题卡图片合并接收消息内容:" + msg);
68
             System.out.println(LocalDateTime.now() + "答题卡图片合并接收消息内容:" + msg);

+ 6
- 4
sexam/src/main/java/com/xhkjedu/sexam/listener/MessageSender.java View File

23
 
23
 
24
     @Value("${rabbitmq.examImgMergeQueue}")
24
     @Value("${rabbitmq.examImgMergeQueue}")
25
     private String examImgMergeQueue;
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
      * @Author wn
49
      * @Author wn
50
      * @Date 2022/8/2 13:57
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
         Map map = new HashMap();
53
         Map map = new HashMap();
54
         map.put("epid", epid);
54
         map.put("epid", epid);
55
+        map.put("examid", examid);
55
         map.put("imgs", imgs);
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 View File

58
 
58
 
59
     //保存答题卡pdf
59
     //保存答题卡pdf
60
     void updatePaperScantronpdf(@Param("paper") EPaper paper);
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 View File

8
 import com.xhkjedu.sexam.mapper.system.UserBasketMapper;
8
 import com.xhkjedu.sexam.mapper.system.UserBasketMapper;
9
 import com.xhkjedu.sexam.model.paper.*;
9
 import com.xhkjedu.sexam.model.paper.*;
10
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
10
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
11
+import com.xhkjedu.sexam.utils.ConvertUtil;
11
 import com.xhkjedu.sexam.utils.ExamUtil;
12
 import com.xhkjedu.sexam.utils.ExamUtil;
12
 import com.xhkjedu.sexam.vo.paper.*;
13
 import com.xhkjedu.sexam.vo.paper.*;
13
 import com.xhkjedu.utils.N_Utils;
14
 import com.xhkjedu.utils.N_Utils;
14
 import com.xhkjedu.vo.ResultVo;
15
 import com.xhkjedu.vo.ResultVo;
15
 import lombok.extern.slf4j.Slf4j;
16
 import lombok.extern.slf4j.Slf4j;
16
 import org.springframework.beans.BeanUtils;
17
 import org.springframework.beans.BeanUtils;
18
+import org.springframework.beans.factory.annotation.Autowired;
17
 import org.springframework.stereotype.Service;
19
 import org.springframework.stereotype.Service;
18
 import org.springframework.transaction.annotation.Transactional;
20
 import org.springframework.transaction.annotation.Transactional;
19
 
21
 
20
 import javax.annotation.Resource;
22
 import javax.annotation.Resource;
23
+import java.io.File;
21
 import java.util.*;
24
 import java.util.*;
22
 import java.util.List;
25
 import java.util.List;
23
 import java.util.stream.Collectors;
26
 import java.util.stream.Collectors;
48
     private EPaperStudentQuestionMapper ePaperStudentQuestionMapper;
51
     private EPaperStudentQuestionMapper ePaperStudentQuestionMapper;
49
     @Resource
52
     @Resource
50
     private EPaperStudentMapper ePaperStudentMapper;
53
     private EPaperStudentMapper ePaperStudentMapper;
54
+    @Autowired
55
+    private ConvertUtil convertUtil;
51
 
56
 
52
 
57
 
53
     /**
58
     /**
621
         ePaperQtypeMapper.updateBatchQuestionForScan(questions);
626
         ePaperQtypeMapper.updateBatchQuestionForScan(questions);
622
         if(paper.getPstate() == 1){
627
         if(paper.getPstate() == 1){
623
             eSubjectMapper.updateEsubjectStateByEpid(1,paper.getEpid());
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 View File

28
         messageSender.imgMerge(psqid, userAnswers, device);
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 View File

54
 
54
 
55
 rabbitmq.examImgMergeQueue=xhkjedu.xhschool.examImgMergeQueue_dev
55
 rabbitmq.examImgMergeQueue=xhkjedu.xhschool.examImgMergeQueue_dev
56
 rabbitmq.examImgMergeHandleQueue=xhkjedu.xhschool.examImgMergeHandleQueue_dev
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
 spring.rabbitmq.host=116.63.199.166
59
 spring.rabbitmq.host=116.63.199.166
60
 spring.rabbitmq.port=5672
60
 spring.rabbitmq.port=5672
61
 spring.rabbitmq.username=xhkjedu
61
 spring.rabbitmq.username=xhkjedu

+ 8
- 0
sexam/src/main/resources/mapper/paper/EPaperMapper.xml View File

117
         update e_paper set scantronpdf=#{paper.scantronpdf} where epid=#{paper.epid}
117
         update e_paper set scantronpdf=#{paper.scantronpdf} where epid=#{paper.epid}
118
     </update>
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
 </mapper>
128
 </mapper>

Loading…
Cancel
Save