From 0ef7bb2a442c039b01599010fa3370f7c59ef0c4 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 05 六月 2024 18:32:45 +0800
Subject: [PATCH] 代码修改

---
 ruoyi-admin/src/main/java/com/ruoyi/web/component/RabbitMqReceiver.java |   90 ++++++++++++++++++++++++++++++++++++---------
 1 files changed, 72 insertions(+), 18 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RabbitMqReceiver.java b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RabbitMqReceiver.java
index 61396f7..a179d19 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RabbitMqReceiver.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RabbitMqReceiver.java
@@ -1,10 +1,12 @@
 package com.ruoyi.web.component;
 
+import com.alibaba.fastjson2.JSON;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.rabbitmq.client.Channel;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.enums.ServiceFromEnum;
+import com.ruoyi.common.utils.RSAPublicKeyExample;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.web.task.PhoneTask;
 import com.smartor.common.SendService;
@@ -27,9 +29,12 @@
 import org.springframework.stereotype.Component;
 
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 @Slf4j
 @Component//鐩戝惉姝ら槦鍒�
@@ -37,6 +42,12 @@
 
     @Value("${phonePath}")
     private String phonePath;
+
+    @Value("${pub_key}")
+    private String pub_key;
+
+    @Value("${req_path}")
+    private String req_path;
 
     private static IIvrTaskTemplateService ivrTaskTemplateService;
 
@@ -51,6 +62,7 @@
     private static RabbitMqCallPhoneConfig rabbitMqCallPhoneConfig;
 
     private static RobotPhoneUtils robotPhoneUtils;
+
 
     // 鍒涘缓鍥哄畾澶у皬鐨勭嚎绋嬫睜
     private static final ExecutorService executorService = Executors.newFixedThreadPool(10);
@@ -96,13 +108,12 @@
      */
     @RabbitListener(queues = "task_queue", concurrency = "50")
     public void phoneVisit(String content, Message message, Channel channel) throws IOException {
-
+        log.error("娑堟伅杩涙潵浜�--------------");
+        IvrTaskcallMQ ivrTaskcallMQ = null;
         try {
-            IvrTaskcallMQ ivrTaskcallMQ = null;
-
             ObjectMapper mapper = new ObjectMapper();
             try {
-                if (!content.contains("{")) {
+                if (!content.startsWith("{")) {
                     ivrTaskcallMQ = mapper.readValue("{" + content + "}", IvrTaskcallMQ.class);
                 } else {
                     ivrTaskcallMQ = mapper.readValue(content, IvrTaskcallMQ.class);
@@ -118,40 +129,83 @@
                 return;
             }
 
-            if (StringUtils.isNotEmpty(ivrTaskcallMQ.getServicefrom())) {
+            if (StringUtils.isNotEmpty(ivrTaskcallMQ.getPreachform())) {
                 //濡備綍浠诲姟鍙戦�佹柟寮忎笉涓虹┖
-                String[] split = ivrTaskcallMQ.getServicefrom().split(",");
+                String[] split = ivrTaskcallMQ.getPreachform().split(",");
                 for (String serviceFrom : split) {
                     String descByCode = ServiceFromEnum.getDescByCode(Integer.valueOf(serviceFrom));
                     //杩欓噷鍙互鑰冭檻鐢ㄧ瓥鐣ユā寮忎紭鍖栦竴涓嬶紝涓嶇劧澶毦鐪嬩簡
+
+                    //閫氳繃妯℃澘ID鑾峰彇妯℃澘闂
+                    IvrTaskTemplateVO ivrTaskTemplateVO = new IvrTaskTemplateVO();
+                    ivrTaskTemplateVO.setID(Long.valueOf(ivrTaskcallMQ.getTemplateid()));
+                    IvrTaskTemplateVO ivrTaskTemplateVO1 = ivrTaskTemplateService.selectInfoByCondition(ivrTaskTemplateVO);
+
+                    //閫氳繃浠诲姟ID鎷垮埌鎮h�呬俊鎭�
+                    IvrTaskSingle ivrTaskcall = new IvrTaskSingle();
+                    ivrTaskcall.setTaskid(ivrTaskcallMQ.getTaskid());
+                    List<IvrTaskSingle> ivrTaskcalls = ivrTaskcallMapper.selectIvrTaskcallList(ivrTaskcall);
                     if (descByCode.equals("鐢佃瘽")) {
-                        //閫氳繃妯℃澘ID鑾峰彇妯℃澘闂
-                        IvrTaskTemplateVO ivrTaskTemplateVO = new IvrTaskTemplateVO();
-                        ivrTaskTemplateVO.setID(Long.valueOf(ivrTaskcallMQ.getTemplateid()));
-                        IvrTaskTemplateVO ivrTaskTemplateVO1 = ivrTaskTemplateService.selectInfoByCondition(ivrTaskTemplateVO);
-
-                        //閫氳繃浠诲姟ID鎷垮埌鎮h�呬俊鎭�
-                        IvrTaskSingle ivrTaskcall = new IvrTaskSingle();
-                        ivrTaskcall.setTaskid(ivrTaskcallMQ.getTaskid());
-                        List<IvrTaskSingle> ivrTaskcalls = ivrTaskcallMapper.selectIvrTaskcallList(ivrTaskcall);
-
                         for (IvrTaskSingle ivrTaskcall1 : ivrTaskcalls) {
                             IvrTask ivrTask = ivrTaskMapper.selectIvrTaskByTaskid(ivrTaskcall1.getTaskid());
-                            if (StringUtils.isNotEmpty(ivrTask.getSendState()) && ivrTask.getSendState().equals(3) || StringUtils.isNotEmpty(ivrTask.getSendState()) && ivrTask.getSendState().equals(4)) {
+                            if (ivrTask.getSendState() != null && ivrTask.getSendState() == 3 || ivrTask.getSendState() != null && ivrTask.getSendState() == 4) {
                                 //濡備綍浠诲姟琚�滄殏鍋溾�濇垨鈥滅粓姝⑩��
                                 break;
                             }
                             //閫氳繃澶氱嚎绋嬬殑鏂瑰紡鍘绘墦鐢佃瘽
                             executorService.submit(new PhoneTask(ivrTaskcall1, ivrTaskTemplateVO1, redisCache, rabbitMqCallPhoneConfig, message, sendService, phonePath, robotPhoneUtils));
                         }
-                    } else if (descByCode.equals("鍏紬鍙�")) {
+                    } else if (descByCode.equals("澶氬獟浣�")) {
+                        //澶氬獟浣�
+                    } else if (descByCode.equals("绾歌川")) {
+                        //绾歌川
+                    } else if (descByCode.equals("鐭俊")) {
+                        //鐭俊
+//                        http://localhost:8099/followvisit/particty?param1=3&param2=348
+                        //瀵箄rl涓袱涓弬鏁板姞瀵�
+                        RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
+                        String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key);
 
+
+                        for (IvrTaskSingle ivrTaskSingle : ivrTaskcalls) {
+                            String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key);
+                            SendMagParam sendMagParam = new SendMagParam();
+                            sendMagParam.setType("4");
+                            sendMagParam.setUrl("192.168.2.10:8099/followvisit/particty?param1=" + taskId + "&param2=" + patid);
+                            sendService.sendMsg(sendMagParam);
+                        }
+                    } else if (descByCode.equals("鍏紬鍙�")) {
+                        //鍏紬鍙�
+                        RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
+                        String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key);
+                        for (IvrTaskSingle ivrTaskSingle : ivrTaskcalls) {
+                            String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key);
+                            SendMagParam sendMagParam = new SendMagParam();
+                            sendMagParam.setType("5");
+                            sendMagParam.setUrl(req_path + "/outsideChain?param1=" + taskId + "&param2=" + patid + "&param3=" + ivrTask1.getTaskName());
+                            log.info("閾炬帴瀹屾暣璺緞锛歿}", req_path + "/outsideChain?param1=" + taskId + "&param2=" + patid + "&param3=" + ivrTask1.getTaskName());
+                            //杩欎釜妯℃澘ID鍏堝啓姝伙紝鍚庨潰鍋氭垚鍙��
+                            sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4");
+                            Map map = new HashMap();
+                            map.put("first", ivrTask1.getTaskName());
+                            sendMagParam.setContent(JSON.toJSONString(map));
+                            sendService.sendMsg(sendMagParam);
+                        }
                     }
                     //閫氱煡 MQ 娑堟伅宸茶鎺ユ敹,鍙互ACK(浠庨槦鍒椾腑鍒犻櫎)浜�   锛堣繖涓渶瑕佹牴鎹笟鍔″啀鍘诲鐞咥CK锛�
                     channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
                 }
             }
         } catch (Exception e) {
+            Integer integer = redisCache.getCacheObject(ivrTaskcallMQ.getTaskid().toString());
+            if (integer != null && integer == 2) {
+                channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+            } else if (integer == null) {
+                redisCache.setCacheObject(ivrTaskcallMQ.getTaskid().toString(), 1, 120, TimeUnit.MINUTES);
+            } else {
+                redisCache.setCacheObject(ivrTaskcallMQ.getTaskid().toString(), integer + 1, 120, TimeUnit.MINUTES);
+            }
+
             log.error("============娑堣垂澶辫触,灏濊瘯娑堟伅琛ュ彂鍐嶆娑堣垂!==============");
             log.error(e.getMessage());
             channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);

--
Gitblit v1.9.3