From f243bb8af00a2464d16536d42150a4107f87b4ae Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期日, 12 五月 2024 21:32:57 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java |   71 +++++++++++++++++++----------------
 1 files changed, 39 insertions(+), 32 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java
index 1d5c720..1520c85 100644
--- a/smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java
@@ -8,9 +8,8 @@
 import com.ruoyi.common.exception.base.BaseException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.DtoConversionUtils;
-//import com.smartor.config.PhoneUtils;
 import com.smartor.config.PhoneUtils;
-import com.smartor.config.RabbitMqConfig;
+import com.smartor.config.RabbitMqCallPhoneConfig;
 import com.smartor.domain.*;
 import com.smartor.mapper.*;
 import com.smartor.service.IIvrTaskService;
@@ -19,7 +18,6 @@
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -49,6 +47,9 @@
     private IvrLibaTemplateTargetoptionMapper ivrLibaScriptTargetoptionMapper;
 
     @Autowired
+    private IvrLibaTemplateScriptMapper ivrLibaTemplateScriptMapper;
+
+    @Autowired
     private IvrTaskVisitResultMapper ivrTaskVisitResultMapper;
 
     @Autowired
@@ -58,14 +59,7 @@
     private IvrLibaExtemplatescriptMapper ivrLibaExtemplatescriptMapper;
 
     @Autowired
-    private RabbitTemplate rabbitTemplate;
-
-
-    @Autowired
-    private PatMedOuthospMapper patMedOuthospMapper;
-
-    @Autowired
-    private PatMedInhospMapper patMedInhospMapper;
+    private RabbitMqCallPhoneConfig rabbitMqCallPhoneConfig;
 
 
     /**
@@ -138,7 +132,7 @@
                 patTaskRelevance.setPhone(ivrTaskcall1.getPhone());
                 patTaskRelevance.setAddr(ivrTaskcall1.getAddr());
                 patTaskRelevance.setDeptName(ivrTaskcall1.getDeptname());
-                patTaskRelevance.setBedNo(ivrTaskcall1.getBadNo());
+                patTaskRelevance.setBedNo(ivrTaskcall1.getBedNo());
                 patTaskRelevance.setDiagname(ivrTaskcall1.getDiagname());
                 patTaskRelevances.add(patTaskRelevance);
             }
@@ -209,7 +203,7 @@
         if (ivrTaskcallVO.getIsoperation() != null && ivrTaskcallVO.getIsoperation() == 1) {
             //寰�浠诲姟琛ㄤ腑锛屾柊澧炰换鍔�
             IvrTask ivrTask = DtoConversionUtils.sourceToTarget(ivrTaskcallVO, IvrTask.class);
-            Integer taskId = ivrTaskService.insertIvrTask(ivrTask);
+            ivrTaskService.insertIvrTask(ivrTask);
 
             ivrTaskcallVO.setTaskid(ivrTask.getTaskid().longValue());
             //鏂板
@@ -223,7 +217,7 @@
                     ivrTaskcall.setPhone(patTaskRelevance.getPhone());
                     ivrTaskcall.setAddr(patTaskRelevance.getAddr());
                     ivrTaskcall.setCreateTime(DateUtils.getNowDate());
-                    ivrTaskcall.setTextParam(new Gson().toJson(ivrTaskcallVO.getTextParam()));
+                    ivrTaskcall.setTextParam(new Gson().toJson(patTaskRelevance.getTextParam()));
                     if (CollectionUtils.isNotEmpty(ivrTaskcallVO.getSendTimeslot())) {
                         ivrTaskcall.setSendTimeSlot(ivrTaskcallVO.getSendTimeslot().toString());
                     }
@@ -273,7 +267,7 @@
     @Override
     public int heTaskSend(IvrTaskSingleVO ivrTaskcallVO) {
         //鍒ゆ柇浠诲姟鏄惁鏄珛鍗冲彂閫�
-        if (ivrTaskcallVO.getSendType().equals("2") && ivrTaskcallVO.getSendstate() == 1) {
+        if (ivrTaskcallVO.getSendType().equals("2")) {
             IvrTaskcallMQ ivrTaskcallMQ = new IvrTaskcallMQ();
             ivrTaskcallMQ.setTaskid(ivrTaskcallVO.getTaskid());
             ivrTaskcallMQ.setSendType("1");
@@ -282,12 +276,9 @@
             String ivrTaskcallMQJson = JSON.toJSONString(ivrTaskcallMQ);
             ivrTaskcallMQJson = ivrTaskcallMQJson.substring(1, ivrTaskcallMQJson.length() - 1);
             //绔嬪嵆鍙戦��
-            rabbitTemplate.convertAndSend(RabbitMqConfig.phone_exchange, RabbitMqConfig.routing_key, ivrTaskcallMQJson, message -> {
-                //娉ㄦ剰杩欓噷鏃堕棿鍙互浣縧ong锛岃�屼笖鏄缃甴eader
-                message.getMessageProperties().setHeader("x-delay", 0);
-                return message;
-            });
-        } else if (ivrTaskcallVO.getSendType().equals("1") && ivrTaskcallVO.getSendstate() == 1) {
+            rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.123", ivrTaskcallMQJson, 0L);
+
+        } else if (ivrTaskcallVO.getSendType().equals("1")) {
             //鏃堕棿娈靛彂閫�
             if (CollectionUtils.isNotEmpty(ivrTaskcallVO.getSendTimeslot())) {
                 for (TaskSendTimeVO taskSendTimeVO : ivrTaskcallVO.getSendTimeslot()) {
@@ -316,12 +307,13 @@
                     Long finalMilliseconds = milliseconds;
                     String ivrTaskcallMQJson = JSON.toJSONString(ivrTaskcallMQ);
                     ivrTaskcallMQJson = ivrTaskcallMQJson.substring(1, ivrTaskcallMQJson.length() - 1);
-                    rabbitTemplate.convertAndSend(RabbitMqConfig.phone_exchange, RabbitMqConfig.routing_key, ivrTaskcallMQJson, message -> {
-                        //娉ㄦ剰杩欓噷鏃堕棿鍙互浣縧ong锛岃�屼笖鏄缃甴eader
-                        message.getMessageProperties().setHeader("x-delay", finalMilliseconds);
-                        return message;
-                    });
+                    rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.123", ivrTaskcallMQJson, 0L);
                 }
+                //灏嗕换鍔$姸鎬佷慨鏀规垚鎵ц涓�
+                IvrTask ivrTask = new IvrTask();
+                ivrTask.setTaskid(ivrTaskcallVO.getTaskid());
+                ivrTask.setSendState("2");
+                ivrTaskService.updateIvrTask(ivrTask);
             }
         }
 
@@ -330,7 +322,9 @@
 
     @Override
     public void phoneCallBack(PhoneCallBackVO phoneCallBackVO) {
+
         phoneCallBackVO.setTextResult(phoneCallBackVO.getTextResult().substring(0, phoneCallBackVO.getTextResult().length() - 1));
+        SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
 
         //鑾峰彇鏁版嵁
         Boolean aBoolean = redisCache.hasKey(phoneCallBackVO.getUuid());
@@ -340,14 +334,15 @@
         Integer hangupValue = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "hangup");
         PhoneUtils phoneUtils = new PhoneUtils();
         if (hangupValue != null && hangupValue == 1) {
-            log.info("鐢佃瘽瑕佹寕鏂簡");
+            String date = simpleDateFormat1.format(new Date());
+            log.info("鐢佃瘽瑕佹寕鏂簡: {}", date);
             //hangupValue == 1  闅忚缁撴潫锛岀洿鎺ュ彲浠ユ寕鐢佃瘽
             phoneUtils.hangup("", "", "", "", "", "", "", phoneCallBackVO.getUuid());
             return;
         }
 
         Map<String, Object> map = redisCache.getCacheObject(phoneCallBackVO.getUuid());
-        IvrTaskSingle ivrTaskcall = (IvrTaskSingle) map.get("ivrTaskcall");
+        IvrTaskSingle ivrTaskcall = (IvrTaskSingle) map.get("ivrTaskSingle");
         List<IvrLibaTemplateScriptVO> ivrLibaTemplateScriptVOs = (List<IvrLibaTemplateScriptVO>) map.get("ivrLibaTemplateScriptVO");
         //灏唘uid鏇存柊鍒版暟鎹簱涓�
         ivrTaskcall.setSenduuid(phoneCallBackVO.getUuid());
@@ -379,6 +374,8 @@
                     redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES);
                     IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion);
                     // 闂锛�  鍘昏皟鐢ㄢ�渢ts鍚堟垚鍜屾挱鏀锯�濇帴鍙�
+                    String date = simpleDateFormat1.format(new Date());
+                    log.info("鍘昏皟鐢╰ts鍚堟垚鍜屾挱鏀炬帴鍙�: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
                     phoneUtils.ttsPlayback(nowQuestion.getQuestionText(), phoneCallBackVO.getUuid());
                 }
             } else {
@@ -386,6 +383,8 @@
                 //璋冪敤ivrLibaTemplateScriptVO涓殑slienceText(闈欓粯璇濇湳)
                 String slienceText = nowQuestion.getSlienceText();
                 //闈欓粯璇濇湳  + 闂锛�  鍘昏皟鐢ㄢ�渢ts鍚堟垚鍜屾挱鏀锯�濇帴鍙�
+                String date = simpleDateFormat1.format(new Date());
+                log.info("闈欓粯璇濇湳  + 闂,鍘昏皟鐢╰ts鍚堟垚鍜屾挱鏀炬帴鍙�: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
                 phoneUtils.ttsPlayback(slienceText + nowQuestion.getQuestionText(), phoneCallBackVO.getUuid());
                 return;
             }
@@ -407,10 +406,8 @@
                     Pattern pattern2 = Pattern.compile(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2());
                     matcher2 = pattern2.matcher(phoneCallBackVO.getTextResult());
                 }
-                log.info("phoneCallBack--Targetregex鐨勫�间负锛歿}, phoneCallBack--Targetregex2鐨勫�间负锛歿}", nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex(), nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2());
-                if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()
-                        || StringUtils.isEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches()
-                        || StringUtils.isEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
+                log.error("PCB--getQuestionText闂涓猴細{},UUID锛歿}", nowQuestion.getQuestionText(), phoneCallBackVO.getUuid());
+                if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
                     //璇存槑鍖归厤姝g‘浜�
                     //杩欓噷搴旇鍏堝垽鏂被鍨嬶紝鍘诲啀淇敼锛岃缃甀sUserOperation鏄崟閫夐鐨勬敼娉�
                     nowQuestion.getIvrLibaScriptTargetoptionList().get(j).setIsUserOperation(true);
@@ -444,6 +441,8 @@
                             return;
                         } else if (nextQuestion > ivrLibaTemplateScriptVOs.size()) {
                             //娌℃湁涓嬩竴棰樹簡锛屽氨缁撴潫浜�
+                            String date = simpleDateFormat1.format(new Date());
+                            log.error("娌℃湁涓嬩竴棰樹簡锛屽氨缁撴潫浜�: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
                             redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES);
                             phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid());
                             try {
@@ -477,10 +476,14 @@
                         questionMessage.setNowQuestion(nextQuestion);
                         redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES);
                         redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", 0, 120, TimeUnit.MINUTES);
+                        String date = simpleDateFormat1.format(new Date());
+                        log.info("濡傛灉涓嬩竴棰樹负绌�.鍒欐柊鐨勬暟鎹繑鍥�,骞跺姞涓婃劅璋㈣: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
                         phoneUtils.ttsPlayback(nextQuestion.getQuestionText(), phoneCallBackVO.getUuid());
                         return;
                     } else {
                         //灏卞彲浠ユ寕鏂數璇濅簡
+                        String date = simpleDateFormat1.format(new Date());
+                        log.info("灏卞彲浠ユ寕鏂數璇濅簡------: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
                         redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES);
                         phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid());
                         try {
@@ -537,10 +540,14 @@
                             redisCache.setCacheObject(phoneCallBackVO.getUuid() + "isOver", 1, 120, TimeUnit.MINUTES);
                         }
                         //璋冪敤鈥�15銆乼ts鍚堟垚鍜屾挱鏀撅紝 tts_playback鈥濆皢缁撴灉浼犲洖
+                        String date = simpleDateFormat1.format(new Date());
+                        log.info("璋冪敤鈥�15銆乼ts鍚堟垚鍜屾挱鏀�------: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
                         phoneUtils.ttsPlayback(nowQuestion.getQuestionText() + ivrLibaTemplateScriptVO.getSubmoduleText(), phoneCallBackVO.getUuid());
                     }
                     break;
                 }
+                String date = simpleDateFormat1.format(new Date());
+                log.info("鏈�鍚庣殑淇℃伅鍥炲-: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
                 phoneUtils.ttsPlayback(nowQuestion.getQuestionText(), phoneCallBackVO.getUuid());
             }
         }

--
Gitblit v1.9.3