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/domain/IvrTaskcallPhoneMQ.java | 33 +
smartor/src/main/java/com/smartor/domain/TestVo.java | 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/IvrLibaTemplateController.java | 42 -
smartor/src/main/java/com/smartor/config/RabbitMqCallPhoneConfig.java | 113 ++++++
ruoyi-admin/src/main/java/com/ruoyi/web/task/PhoneTask.java | 131 ++++---
smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java | 412 +++++++++++------------
ruoyi-admin/src/main/java/com/ruoyi/web/component/RabbitMqReceiver.java | 96 +++--
smartor/src/main/java/com/smartor/config/RabbitMqConfig.java | 134 ++----
ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java | 4
9 files changed, 544 insertions(+), 423 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 13df8de..db62ae9 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
@@ -2,16 +2,14 @@
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.utils.StringUtils;
import com.ruoyi.web.task.PhoneTask;
-import com.ruoyi.web.task.PhoneTask2;
import com.smartor.common.SendService;
-import com.smartor.config.RabbitMqConfig;
-import com.smartor.domain.IvrLibaTemplateVO;
-import com.smartor.domain.IvrTask;
-import com.smartor.domain.IvrTaskSingle;
-import com.smartor.domain.IvrTaskcallMQ;
+import com.smartor.config.PhoneUtils;
+import com.smartor.config.RabbitMqCallPhoneConfig;
+import com.smartor.domain.*;
import com.smartor.mapper.IvrTaskMapper;
import com.smartor.mapper.IvrTaskSingleMapper;
import com.smartor.service.IIvrLibaTemplateService;
@@ -19,12 +17,11 @@
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
+import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
-import com.rabbitmq.client.Channel;
-import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import java.io.IOException;
import java.util.List;
@@ -35,6 +32,7 @@
@Component//鐩戝惉姝ら槦鍒�
public class RabbitMqReceiver {
+
private static IIvrLibaTemplateService ivrLibaTemplateService;
private static IvrTaskSingleMapper ivrTaskcallMapper;
@@ -44,6 +42,8 @@
private static SendService sendService;
private static RedisCache redisCache;
+
+ private static RabbitMqCallPhoneConfig rabbitMqCallPhoneConfig;
// 鍒涘缓鍥哄畾澶у皬鐨勭嚎绋嬫睜
private static final ExecutorService executorService = Executors.newFixedThreadPool(10);
@@ -57,6 +57,11 @@
@Autowired
public void setSendService(SendService sendService) {
RabbitMqReceiver.sendService = sendService;
+ }
+
+ @Autowired
+ public void setRabbitMqCallPhoneConfig(RabbitMqCallPhoneConfig rabbitMqCallPhoneConfig) {
+ RabbitMqReceiver.rabbitMqCallPhoneConfig = rabbitMqCallPhoneConfig;
}
@Autowired
@@ -74,37 +79,22 @@
RabbitMqReceiver.redisCache = redisCache;
}
-// @RabbitListener(queues = RabbitMqConfig.delay_queue)
-// public void consultReceiveDealy(String content, Message message, Channel channel) throws IOException {
-// log.info("----------------鎺ユ敹寤惰繜闃熷垪娑堟伅--------------------");
-// //閫氱煡 MQ 娑堟伅宸茶鎺ユ敹,鍙互ACK(浠庨槦鍒椾腑鍒犻櫎)浜�
-// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-// try {
-// log.info("=============Do Something==============");
-// } catch (Exception e) {
-// log.error("============娑堣垂澶辫触,灏濊瘯娑堟伅琛ュ彂鍐嶆娑堣垂!==============");
-// log.error(e.getMessage());
-// /**
-// * basicRecover鏂规硶鏄繘琛岃ˉ鍙戞搷浣滐紝
-// * 鍏朵腑鐨勫弬鏁板鏋滀负true鏄妸娑堟伅閫�鍥炲埌queue浣嗘槸鏈夊彲鑳借鍏跺畠鐨刢onsumer(闆嗙兢)鎺ユ敹鍒帮紝
-// * 璁剧疆涓篺alse鏄彧琛ュ彂缁欏綋鍓嶇殑consumer
-// */
-// channel.basicRecover(false);
-// }
-// }
-
/**
* 鐢佃瘽闅忚
* concurrency = "50" 骞跺彂鏁颁负50
*/
- @RabbitListener(queues = RabbitMqConfig.phone_queue, concurrency = "50")
+ @RabbitListener(queues = "phone_queue", concurrency = "50")
public void phoneVisit(String content, Message message, Channel channel) throws IOException {
try {
IvrTaskcallMQ ivrTaskcallMQ = null;
ObjectMapper mapper = new ObjectMapper();
try {
- ivrTaskcallMQ = mapper.readValue("{" + content + "}", IvrTaskcallMQ.class);
+ if (!content.contains("{")) {
+ ivrTaskcallMQ = mapper.readValue("{" + content + "}", IvrTaskcallMQ.class);
+ } else {
+ ivrTaskcallMQ = mapper.readValue(content, IvrTaskcallMQ.class);
+ }
} catch (JsonProcessingException e) {
e.printStackTrace();
}
@@ -125,22 +115,50 @@
break;
}
// //閫氳繃澶氱嚎绋嬬殑鏂瑰紡鍘绘墦鐢佃瘽
-// executorService.submit(new PhoneTask(ivrTaskcall1, ivrLibaTemplateVO1, redisCache, channel, message, sendService));
- new PhoneTask2().runPhone(ivrTaskcall1, ivrLibaTemplateVO1, redisCache, channel, message, sendService);
+ executorService.submit(new PhoneTask(ivrTaskcall1, ivrLibaTemplateVO1, redisCache, rabbitMqCallPhoneConfig, message, sendService));
}
//閫氱煡 MQ 娑堟伅宸茶鎺ユ敹,鍙互ACK(浠庨槦鍒椾腑鍒犻櫎)浜� 锛堣繖涓渶瑕佹牴鎹笟鍔″啀鍘诲鐞咥CK锛�
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
-
- log.info("=============Do Something==============");
} catch (Exception e) {
log.error("============娑堣垂澶辫触,灏濊瘯娑堟伅琛ュ彂鍐嶆娑堣垂!==============");
log.error(e.getMessage());
- /**
- * basicRecover鏂规硶鏄繘琛岃ˉ鍙戞搷浣滐紝
- * 鍏朵腑鐨勫弬鏁板鏋滀负true鏄妸娑堟伅閫�鍥炲埌queue浣嗘槸鏈夊彲鑳借鍏跺畠鐨刢onsumer(闆嗙兢)鎺ユ敹鍒帮紝
- * 璁剧疆涓篺alse鏄彧琛ュ彂缁欏綋鍓嶇殑consumer
- */
- channel.basicRecover(false);
+ channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
+ }
+ }
+
+ /**
+ * 鏈哄櫒浜虹涓�鍙ヨ瘽璇煶
+ * concurrency = "50" 骞跺彂鏁颁负50
+ */
+ @RabbitListener(queues = "ob_queue", concurrency = "50")
+ public void obVisit(String content, Message message, Channel channel) throws IOException {
+ try {
+ IvrTaskcallPhoneMQ ivrTaskcallMQ = null;
+ ObjectMapper mapper = new ObjectMapper();
+ ivrTaskcallMQ = mapper.readValue(content, IvrTaskcallPhoneMQ.class);
+ //鍒ゆ柇鎮h�呮槸鍚﹀凡缁忔帴鐢佃瘽
+ String str = redisCache.getCacheObject(ivrTaskcallMQ.getUuid() + "state_id");
+ System.out.println("-----------------" + str);
+ if (StringUtils.isNotEmpty(str) && str.equals("0")) {
+ //鎮h�呭凡缁忔帴鍚簡鐢佃瘽
+ new PhoneUtils().ttsPlayback(ivrTaskcallMQ.getScript(), ivrTaskcallMQ.getUuid());
+ } else if (StringUtils.isNotEmpty(str) && str.equals("-10")) {
+ //杩欎釜璇存槑,宸茬粡鎵撲簡鎸囧畾閬嶆暟杩樻槸娌℃湁浜烘帴锛屽彲浠ュ皢娑堟伅浠庨槦鍒椾腑绉婚櫎浜�
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+ return;
+ } else {
+ //杩涜闃熷垪灏鹃儴锛岃繘琛屼笅涓�娆℃牎楠�
+// channel.basicRecover(false);
+ channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
+ System.out.println("++++++++++++++++++++++" + str);
+ return;
+ }
+ //閫氱煡 MQ 娑堟伅宸茶鎺ユ敹,鍙互ACK(浠庨槦鍒椾腑鍒犻櫎)浜� 锛堣繖涓渶瑕佹牴鎹笟鍔″啀鍘诲鐞咥CK锛�
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+ } catch (Exception e) {
+ log.error("============娑堣垂澶辫触,灏濊瘯娑堟伅琛ュ彂鍐嶆娑堣垂!==============");
+ log.error(e.getMessage());
+ channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
}
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/IvrLibaTemplateController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/IvrLibaTemplateController.java
index e94b150..60a4739 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/IvrLibaTemplateController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/IvrLibaTemplateController.java
@@ -1,7 +1,6 @@
package com.ruoyi.web.controller.smartor;
import com.alibaba.fastjson2.JSON;
-import com.google.gson.Gson;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
@@ -10,7 +9,7 @@
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.smartor.config.PhoneUtils;
-import com.smartor.config.RabbitMqConfig;
+import com.smartor.config.RabbitMqCallPhoneConfig;
import com.smartor.domain.IvrLibaTemplate;
import com.smartor.domain.IvrLibaTemplateVO;
import com.smartor.domain.Test1Vo;
@@ -19,19 +18,12 @@
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
-import org.springframework.amqp.AmqpException;
-import org.springframework.amqp.core.Message;
-import org.springframework.amqp.core.MessageBuilder;
-import org.springframework.amqp.core.MessagePostProcessor;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
/**
* 闅忚妯℃澘搴揅ontroller
@@ -47,11 +39,14 @@
@Autowired
private IIvrLibaTemplateService ivrLibaTemplateService;
- @Autowired
- private RabbitTemplate rabbitTemplate;
+// @Autowired
+// private RabbitTemplate rabbitTemplate;
@Autowired
private PhoneUtils phoneUtils;
+
+ @Autowired
+ private RabbitMqCallPhoneConfig rabbitMqCallPhoneConfig;
/**
* 鏌ヨ妯℃澘搴撳垪琛�
@@ -152,30 +147,19 @@
@PostMapping("/queryRabbitmq")
public AjaxResult queryRabbitmq(@RequestBody Test1Vo test1Vo) {
-// rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, "phone.001", "娴嬭瘯鏁版嵁001");
-// rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, "phone.002", "娴嬭瘯鏁版嵁002");
-// rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, "phone.003", "娴嬭瘯鏁版嵁003");
-// rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, routintKey, message, new MessagePostProcessor() {
-// @Override
-// public Message postProcessMessage(Message message) throws AmqpException {
-//// message.getMessageProperties().setDelay(times);
-// message.getMessageProperties().getHeaders().put("x-delay", times);
-////message.getMessageProperties().setExpiration();
-// return message;
-// }
-// });
-
log.info("-------------鍚姩鍜ㄨ搴旂瓟瓒呮椂鎻愰啋寤惰繜闃熷垪-------------");
String data = JSON.toJSONString(test1Vo.getTestVo());
String substring = data.substring(1, data.length() - 1);
+ rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.123", substring, test1Vo.getTimes());
- this.rabbitTemplate.convertAndSend(RabbitMqConfig.phone_exchange, RabbitMqConfig.routing_key, substring, message -> {
- //娉ㄦ剰杩欓噷鏃堕棿鍙互浣縧ong锛岃�屼笖鏄缃甴eader
- message.getMessageProperties().setHeader("x-delay", test1Vo.getTimes());
- return message;
- });
log.info("-------------寤惰繜闃熷垪{}ms鍚庢墽琛�.-------------", test1Vo.getTimes());
return success();
}
+ @GetMapping("/tts")
+ public AjaxResult tts(@RequestParam("fileText") String fileText, @RequestParam("uuid") String uuid) {
+ new PhoneUtils().ttsPlayback(fileText, uuid);
+ return success();
+ }
+
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/task/PhoneTask.java b/ruoyi-admin/src/main/java/com/ruoyi/web/task/PhoneTask.java
index d719abf..771d92a 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/task/PhoneTask.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/task/PhoneTask.java
@@ -1,15 +1,16 @@
package com.ruoyi.web.task;
+import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.rabbitmq.client.Channel;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DtoConversionUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.smartor.common.SendService;
import com.smartor.config.PhoneUtils;
+import com.smartor.config.RabbitMqCallPhoneConfig;
import com.smartor.domain.*;
import org.springframework.amqp.core.Message;
-import org.springframework.data.convert.Jsr310Converters;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
import java.util.*;
import java.util.concurrent.TimeUnit;
@@ -19,79 +20,95 @@
private List<IvrLibaTemplateScriptVO> ivrLibaTemplateScriptVO;
private RedisCache redisCache;
private IvrLibaTemplateVO ivrLibaTemplateVO;
- private Channel channel;
+ private RabbitMqCallPhoneConfig rabbitMqCallPhoneConfig;
private Message message;
private SendService sendService;
- public PhoneTask(IvrTaskSingle ivrTaskSingle, IvrLibaTemplateVO ivrLibaTemplateVO, RedisCache redisCache, Channel channel, Message message, SendService sendService) {
+ public PhoneTask(IvrTaskSingle ivrTaskSingle, IvrLibaTemplateVO ivrLibaTemplateVO, RedisCache redisCache, RabbitMqCallPhoneConfig rabbitMqCallPhoneConfig, Message message, SendService sendService) {
this.ivrTaskSingle = DtoConversionUtils.sourceToTarget(ivrTaskSingle, IvrTaskSingle.class);
this.ivrLibaTemplateScriptVO = DtoConversionUtils.sourceToTarget(ivrLibaTemplateVO.getIvrLibaTemplateScriptVOList(), IvrLibaTemplateScriptVO.class);
this.ivrLibaTemplateVO = DtoConversionUtils.sourceToTarget(ivrLibaTemplateVO, IvrLibaTemplateVO.class);
this.redisCache = redisCache;
- this.channel = channel;
+ this.rabbitMqCallPhoneConfig = rabbitMqCallPhoneConfig;
this.message = message;
this.sendService = sendService;
}
@Override
public void run() {
- synchronized (PhoneTask.class) {
- try {
- //鑾峰彇鐢佃瘽缁勶紝鏌ョ湅鍝簺鐢佃瘽鍙互浣跨敤
- PhoneUtils phoneUtils = new PhoneUtils();
- final String uuid = IdUtils.randomUUID();
- //鑾峰彇鎵�鏈夌殑鈥滈�氶厤绗︹�濋敭鍊煎
- ObjectMapper objectMapper = new ObjectMapper();
- Map<String, Map<String, String>> ivrTaskSingleMmap = objectMapper.readValue(ivrTaskSingle.getTextParam(), Map.class);
- List<Map<String, String>> mapList = new ArrayList<>();
- if (!Objects.isNull(ivrTaskSingleMmap)) {
- for (Map<String, String> map : ivrTaskSingleMmap.values()) {
- mapList.add(map);
- }
- //灏嗘ā鏉块棶棰樿瘽鏈噷鐨勯�氶厤绗︽浛鎹�
- for (IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO : ivrLibaTemplateScriptVO) {
- for (Map<String, String> map : mapList) {
- for (String key : map.keySet()) {
- ivrLibaTemplateScriptVO.setQuestionText(ivrLibaTemplateScriptVO.getQuestionText().replace(key, map.get(key)));
- }
+ try {
+ //鑾峰彇鐢佃瘽缁勶紝鏌ョ湅鍝簺鐢佃瘽鍙互浣跨敤
+ PhoneUtils phoneUtils = new PhoneUtils();
+ final String uuid = IdUtils.randomUUID();
+ //鑾峰彇鎵�鏈夌殑鈥滈�氶厤绗︹�濋敭鍊煎
+ ObjectMapper objectMapper = new ObjectMapper();
+ Map<String, Map<String, String>> ivrTaskSingleMmap = objectMapper.readValue(ivrTaskSingle.getTextParam(), Map.class);
+ List<Map<String, String>> mapList = new ArrayList<>();
+ if (!Objects.isNull(ivrTaskSingleMmap)) {
+ for (Map<String, String> map : ivrTaskSingleMmap.values()) {
+ mapList.add(map);
+ }
+ //灏嗘ā鏉块棶棰樿瘽鏈噷鐨勯�氶厤绗︽浛鎹�
+ for (IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO : ivrLibaTemplateScriptVO) {
+ for (Map<String, String> map : mapList) {
+ for (String key : map.keySet()) {
+ ivrLibaTemplateScriptVO.setQuestionText(ivrLibaTemplateScriptVO.getQuestionText().replace(key, map.get(key)));
}
}
}
- Map<String, Object> objectMap = new HashMap<>();
- objectMap.put("ivrTaskSingle", ivrTaskSingle);
- objectMap.put("ivrLibaTemplateScriptVO", ivrLibaTemplateScriptVO);
- //灏嗘暟鎹斁鍒皉edis涓紝鏂逛究鍦ㄥ洖璋冩柟娉曢噷鑾峰彇
- redisCache.setCacheObject(uuid, objectMap, 120, TimeUnit.MINUTES);
-
- //璁板綍棣栨闂
- QuestionMessage returnQues = new QuestionMessage();
- returnQues.setKcb(ivrLibaTemplateVO.getRevisitBefore());
- for (IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO : ivrLibaTemplateScriptVO) {
- if (ivrLibaTemplateScriptVO.getTargetid() == ivrLibaTemplateVO.getFirstQuestionNum().intValue()) {
- returnQues.setNowQuestion(ivrLibaTemplateScriptVO);
- }
- }
- returnQues.setQuestionList(ivrLibaTemplateScriptVO);
- //灏嗛棶棰橈紝鍜屾ā鏉夸俊鎭斁鍒皉edis涓�
- redisCache.setCacheObject(uuid + "returnQues", returnQues, 120, TimeUnit.MINUTES);
- redisCache.setCacheObject(uuid + "ivrLibaTemplateVO", ivrLibaTemplateVO, 120, TimeUnit.MINUTES);
-
- System.out.println("----------------uuID涓� 锛�" + uuid + " " + ivrTaskSingle.getSendname() + " " + returnQues.getNowQuestion().getQuestionText() + " " + ivrTaskSingle.getPhone());
-
- //璋冪敤鏈哄櫒浜虹數璇濓紝寮�濮嬬數璇濓紙闇�瑕佸皢鍥炶皟鏂规硶浼犲叆锛岃繖涓瓑鈥濈數璇濇柟鈥滃憡璇夋�庝箞浼狅紝鐜板湪鍏堢┖鐫�,杩樻湁绗竴鍙ラ棶棰樿瘽鏈級
- String ob = phoneUtils.ob("", "", "", "", "", "", "", ivrTaskSingle.getPhone(), uuid, true);
- System.out.println("OB鐨勫�间负锛�" + ob);
- //閫氫簡涔嬪悗锛岀珛椹幓璋冨紑鍦虹櫧
- System.out.println("闂鐨勫�间负锛�" + returnQues.getNowQuestion().getQuestionText() + " " + uuid);
- phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitBefore() + returnQues.getNowQuestion().getQuestionText(), uuid);
-
-// //閫氱煡 MQ 娑堟伅宸茶鎺ユ敹,鍙互ACK(浠庨槦鍒椾腑鍒犻櫎)浜� 锛堣繖涓渶瑕佹牴鎹笟鍔″啀鍘诲鐞咥CK锛�
-// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
- } catch (Exception e) {
- e.printStackTrace();
}
- }
+ Map<String, Object> objectMap = new HashMap<>();
+ objectMap.put("ivrTaskSingle", ivrTaskSingle);
+ objectMap.put("ivrLibaTemplateScriptVO", ivrLibaTemplateScriptVO);
+ //灏嗘暟鎹斁鍒皉edis涓紝鏂逛究鍦ㄥ洖璋冩柟娉曢噷鑾峰彇
+ redisCache.setCacheObject(uuid, objectMap, 120, TimeUnit.MINUTES);
+ //璁板綍棣栨闂
+ QuestionMessage returnQues = new QuestionMessage();
+ returnQues.setKcb(ivrLibaTemplateVO.getRevisitBefore());
+ for (IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO : ivrLibaTemplateScriptVO) {
+ if (ivrLibaTemplateScriptVO.getTargetid() == ivrLibaTemplateVO.getFirstQuestionNum().intValue()) {
+ returnQues.setNowQuestion(ivrLibaTemplateScriptVO);
+ }
+ }
+ returnQues.setQuestionList(ivrLibaTemplateScriptVO);
+ //灏嗛棶棰橈紝鍜屾ā鏉夸俊鎭斁鍒皉edis涓�
+ redisCache.setCacheObject(uuid + "returnQues", returnQues, 120, TimeUnit.MINUTES);
+ redisCache.setCacheObject(uuid + "ivrLibaTemplateVO", ivrLibaTemplateVO, 120, TimeUnit.MINUTES);
+
+ System.out.println("----------------uuID涓� 锛�" + uuid + " " + ivrTaskSingle.getSendname() + " " + returnQues.getNowQuestion().getQuestionText() + " " + ivrTaskSingle.getPhone());
+
+ //鍏堝皢璇濇湳鏀惧埌ob_queue闃熷垪涓�
+ IvrTaskcallPhoneMQ ivrTaskcallPhoneMQ = new IvrTaskcallPhoneMQ();
+ ivrTaskcallPhoneMQ.setScript(ivrLibaTemplateVO.getRevisitBefore() + returnQues.getNowQuestion().getQuestionText());
+ ivrTaskcallPhoneMQ.setType("1");
+ ivrTaskcallPhoneMQ.setUuid(uuid);
+ String data = JSON.toJSONString(ivrTaskcallPhoneMQ);
+ rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.ob1", data, 0L);
+
+ //璋冪敤鏈哄櫒浜虹數璇濓紝寮�濮嬬數璇�
+ String ob = phoneUtils.ob("", "", "", "", "", "", "", ivrTaskSingle.getPhone(), uuid, true);
+ System.out.println("----------------uuID涓� 锛�" + uuid + " " + ivrTaskSingle.getSendname() + " " + returnQues.getNowQuestion().getQuestionText() + " " + ivrTaskSingle.getPhone() + "----------宸茬粡鎷ㄦ墦");
+ Map<String, String> obMap = objectMapper.readValue(ob, Map.class);
+ Thread.sleep(1000);
+ redisCache.setCacheObject(uuid + "state_id", "0", 10, TimeUnit.MINUTES);
+//杩欓噷鍏堟敞閲婏紝state_id,鐢佃瘽閭h竟锛屽彧鑳借繑鍥�6锛屼笉鑳借繑鍥�0锛岃繕闇�瑕佺數璇濋偅杈硅繘琛屼慨鏀癸紝閭h竟淇敼涔嬪悗锛屼笂闈袱琛屽彲鍒犻櫎锛屽皢涓嬮潰鐨勮В寮�娉ㄩ噴
+// if (obMap.get("state_id").equals("0")) {
+// // 璇存槑鎵撻�氫簡
+// redisCache.setCacheObject(uuid + "state_id", "0", 10, TimeUnit.MINUTES);
+// } else {
+// while (true) {
+// Thread.sleep(2000);
+// redisCache.setCacheObject(uuid + "state_id", "0", 10, TimeUnit.MINUTES);
+// }
+// }
+
+
+ System.out.println("OB鐨勫�间负锛�" + ob);
+ } catch (Exception e) {
+ e.printStackTrace();
+
+ }
}
}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
index c3c5cdb..262f747 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/HttpUtil.java
@@ -77,9 +77,9 @@
// 璁惧畾鍙傛暟锛氬鎴风鐨勬�昏繛鎺ユ暟
manager.getParams().setMaxTotalConnections(400);
// 璁剧疆杩炴帴瓒呮椂鏃堕棿,鍗曚綅锛氭绉�
- manager.getParams().setConnectionTimeout(8000);
+ manager.getParams().setConnectionTimeout(30000);
// 璁剧疆璇锋眰璇诲彇瓒呮椂鏃堕棿锛屽崟浣嶏細姣
- manager.getParams().setSoTimeout(8000);
+ manager.getParams().setSoTimeout(30000);
// 璁剧疆浠庤繛鎺ユ睜涓幏鍙栭摼鎺ユ椂闂达紝 鍗曚綅锛氭绉�
manager.getParams().setParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT, 8000);
// 浣跨敤杩炴帴姹犳妧鏈垱寤篐ttpClient瀵硅薄
diff --git a/smartor/src/main/java/com/smartor/config/RabbitMqCallPhoneConfig.java b/smartor/src/main/java/com/smartor/config/RabbitMqCallPhoneConfig.java
new file mode 100644
index 0000000..de3d53a
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/config/RabbitMqCallPhoneConfig.java
@@ -0,0 +1,113 @@
+package com.smartor.config;
+
+import org.springframework.amqp.core.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Component
+public class RabbitMqCallPhoneConfig {
+
+ @Autowired
+ private AmqpAdmin amqpAdmin;
+
+ @Autowired
+ private AmqpTemplate rabbitTemplate;
+
+ /**
+ * 鍒涘缓浜ゆ崲鏈�
+ *
+ * @param exchangeName 浜ゆ崲鏈哄悕绉�
+ */
+ public void createExchange(String exchangeName) {
+ Map<String, Object> args = new HashMap<>();
+ args.put("x-delayed-type", "topic");
+ CustomExchange exchange = new CustomExchange(exchangeName, "x-delayed-message", true, false, args);
+ amqpAdmin.declareExchange(exchange);
+ }
+
+ /**
+ * 鍒涘缓闃熷垪
+ *
+ * @param queueName 闃熷垪鍚嶇О
+ */
+ public void createQueue(String queueName) {
+ Queue queue = new Queue(queueName, true, false, false);
+ amqpAdmin.declareQueue(queue);
+ }
+
+ /**
+ * 浜ゆ崲鏈虹粦瀹�
+ *
+ * @param changeName 浜ゆ崲鏈哄悕绉�
+ * @param routingKey 璺敱key
+ * @param queueName 闃熷垪鍚嶇О
+ */
+ public void bindExchange(String changeName, String routingKey, String queueName) {
+ Binding binding = new Binding(queueName, Binding.DestinationType.QUEUE, changeName, routingKey, null);
+ amqpAdmin.declareBinding(binding);
+ }
+
+ /**
+ * 鍙戦�佷俊鎭埌浜ゆ崲鏈�
+ *
+ * @param changeName 浜ゆ崲鏈哄悕绉�
+ * @param routingKey 璺敱key
+ * @param data 娑堟伅
+ */
+ public void sendMessage(String changeName, String routingKey, String data, Long times) {
+
+ this.rabbitTemplate.convertAndSend(changeName, routingKey, data, message -> {
+ //娉ㄦ剰杩欓噷鏃堕棿鍙互浣縧ong锛岃�屼笖鏄缃甴eader
+ message.getMessageProperties().setHeader("x-delay", times);
+ return message;
+ });
+// rabbitTemplate.convertAndSend(changeName, routingKey, message);
+ }
+
+ /**
+ * 鍒犻櫎浜ゆ崲鏈�
+ *
+ * @param changeName 浜ゆ崲鏈哄悕绉�
+ */
+ public void deleteExchange(String changeName) {
+ amqpAdmin.deleteExchange(changeName);
+ }
+
+ /**
+ * 鍒犻櫎闃熷垪
+ *
+ * @param queueName 闃熷垪鍚嶇О
+ */
+ public void deleteQueue(String queueName) {
+ amqpAdmin.deleteQueue(queueName);
+ }
+
+ /**
+ * 鍒涘缓MQ
+ *
+ * @param exchangName
+ * @param queueName
+ * @param routingKey
+ * @return
+ */
+ public Boolean createRabbitMq(String exchangName, String queueName, String routingKey) {
+ this.createExchange(exchangName);
+ this.createQueue(queueName);
+ this.bindExchange(exchangName, routingKey, queueName);
+ return true;
+ }
+
+ /**
+ * 鍏堝皢闇�瑕佸垱寤虹殑闃熷垪寤哄ソ
+ */
+ @Bean
+ public void createMq() {
+ createRabbitMq("phone_exchange", "ob_queue", "phone.ob1");
+ createRabbitMq("phone_exchange", "phone_queue", "phone.123");
+ }
+
+}
diff --git a/smartor/src/main/java/com/smartor/config/RabbitMqConfig.java b/smartor/src/main/java/com/smartor/config/RabbitMqConfig.java
index aab306a..e621e62 100644
--- a/smartor/src/main/java/com/smartor/config/RabbitMqConfig.java
+++ b/smartor/src/main/java/com/smartor/config/RabbitMqConfig.java
@@ -1,91 +1,57 @@
-package com.smartor.config;
-
-import org.springframework.amqp.core.*;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.HashMap;
-import java.util.Map;
-
-@Configuration
-public class RabbitMqConfig {
-// public static final String EXCHANGE_NAME = "phone_topic_exchange2";
-// public static final String QUEUE_NAME = "phone_queue";
- //
-// /**
-// * topic浜ゆ崲鏈�,骞舵寔涔呭寲
-// */
-// @Bean(EXCHANGE_NAME)
-// public Exchange phoneExchange() {
-// Map<String, Object> arguments = new HashMap<>();
-// //鎸囧畾閫氫俊鏂瑰紡涓簍opic
-// arguments.put("x-delayed-type", "topic");
-// //浣跨敤CustomExchange绫诲垱寤猴紝绫诲瀷瑕佹寚瀹氫负鈥渪-delayed-message鈥濈被鍨�
-// Exchange exchange = new CustomExchange(EXCHANGE_NAME, "x-delayed-message", true, false, arguments);
-// return exchange;
+//package com.smartor.config;
//
-////
-//// return ExchangeBuilder.topicExchange(EXCHANGE_NAME).durable(true).build();
-// }
+//import org.springframework.amqp.core.*;
+//import org.springframework.beans.factory.annotation.Qualifier;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//
+//import java.util.HashMap;
+//import java.util.Map;
+//
+////@Configuration
+//public class RabbitMqConfig {
+//
+////瀹氫箟寤惰繜闃熷垪
+// public static final String phone_queue = "phone_queue";
+// //瀹氫箟寤惰繜浜ゆ崲鏈�
+// public static final String phone_exchange = "phone_exchange";
+// //瀹氫箟璺敱閿�
+// public static final String routing_key = "phone.123";
//
//
// /**
-// * 闃熷垪
-// */
-// @Bean(QUEUE_NAME)
-// public Queue phoneQueue() {
-// return QueueBuilder.durable(QUEUE_NAME).build();
-// }
-//
-// /**
-// * 浜ゆ崲鏈轰笌闃熷垪鐨勭粦瀹�
+// * 瀹氫箟寤惰繜闃熷垪
+// *
+// * @return
// */
// @Bean
-// public Binding bindQueueExchange(@Qualifier(QUEUE_NAME) Queue phoneQueue, @Qualifier(EXCHANGE_NAME) Exchange phoneExchange) {
-// return BindingBuilder.bind(phoneQueue).to(phoneExchange).with(" phone.#").noargs();
+// public Queue delayQueue() {
+// return new Queue(phone_queue, true);
// }
-//瀹氫箟寤惰繜闃熷垪
- public static final String phone_queue = "phone_queue";
- //瀹氫箟寤惰繜浜ゆ崲鏈�
- public static final String phone_exchange = "phone_exchange";
- //瀹氫箟璺敱閿�
- public static final String routing_key = "phone.123";
-
-
- /**
- * 瀹氫箟寤惰繜闃熷垪
- *
- * @return
- */
- @Bean
- public Queue delayQueue() {
- return new Queue(phone_queue, true);
- }
-
- /**
- * 寤舵椂闃熷垪浜ゆ崲鏈�
- * 浜ゆ崲鏈虹被鍨嬶細CustomExchange
- *
- * @return
- */
- @Bean
- public CustomExchange delayExchange() {
- Map<String, Object> args = new HashMap<>();
- args.put("x-delayed-type", "topic");
- return new CustomExchange(phone_exchange, "x-delayed-message", true, false, args);
- }
-
- /**
- * 涓哄欢杩熼槦鍒楃粦瀹氫氦鎹㈡満
- *
- * @param queue
- * @param exchange
- * @return
- */
- @Bean
- public Binding delayBinding(Queue queue, CustomExchange exchange) {
- return BindingBuilder.bind(queue).to(exchange).with(routing_key).noargs();
- }
-
-}
+//
+// /**
+// * 寤舵椂闃熷垪浜ゆ崲鏈�
+// * 浜ゆ崲鏈虹被鍨嬶細CustomExchange
+// *
+// * @return
+// */
+// @Bean
+// public CustomExchange delayExchange() {
+// Map<String, Object> args = new HashMap<>();
+// args.put("x-delayed-type", "topic");
+// return new CustomExchange(phone_exchange, "x-delayed-message", true, false, args);
+// }
+//
+// /**
+// * 涓哄欢杩熼槦鍒楃粦瀹氫氦鎹㈡満
+// *
+// * @param queue
+// * @param exchange
+// * @return
+// */
+// @Bean
+// public Binding delayBinding(Queue queue, CustomExchange exchange) {
+// return BindingBuilder.bind(queue).to(exchange).with(routing_key).noargs();
+// }
+//
+//}
diff --git a/smartor/src/main/java/com/smartor/domain/IvrTaskcallPhoneMQ.java b/smartor/src/main/java/com/smartor/domain/IvrTaskcallPhoneMQ.java
new file mode 100644
index 0000000..75a577d
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/IvrTaskcallPhoneMQ.java
@@ -0,0 +1,33 @@
+package com.smartor.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * MQ浠诲姟
+ *
+ * @author ruoyi
+ * @date 2024-02-02
+ */
+@Data
+public class IvrTaskcallPhoneMQ extends BaseEntity {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 绫诲瀷: 1 鐢佃瘽 2鍏跺畠
+ */
+ @ApiModelProperty(value = "绫诲瀷: 1 鐢佃瘽 2鍏跺畠")
+ private String type;
+
+ @ApiModelProperty(value = "闂")
+ private String script;
+
+ @ApiModelProperty(value = "闂")
+ private String uuid;
+
+
+}
diff --git a/smartor/src/main/java/com/smartor/domain/TestVo.java b/smartor/src/main/java/com/smartor/domain/TestVo.java
index ea0a5ce..25ef06d 100644
--- a/smartor/src/main/java/com/smartor/domain/TestVo.java
+++ b/smartor/src/main/java/com/smartor/domain/TestVo.java
@@ -28,5 +28,7 @@
@ApiModelProperty(value = "鍙戦�佺被鍨�: 1 鏃堕棿娈� 2 鍗冲埢鍙戦��")
private String sendType;
+ private String type;
+
}
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 5a9142d..1520c85 100644
--- a/smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java
@@ -4,15 +4,12 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
-import com.ruoyi.common.core.domain.entity.SysUser;
-import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.redis.RedisCache;
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;
@@ -21,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;
@@ -63,7 +59,7 @@
private IvrLibaExtemplatescriptMapper ivrLibaExtemplatescriptMapper;
@Autowired
- private RabbitTemplate rabbitTemplate;
+ private RabbitMqCallPhoneConfig rabbitMqCallPhoneConfig;
/**
@@ -280,11 +276,8 @@
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;
- });
+ rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.123", ivrTaskcallMQJson, 0L);
+
} else if (ivrTaskcallVO.getSendType().equals("1")) {
//鏃堕棿娈靛彂閫�
if (CollectionUtils.isNotEmpty(ivrTaskcallVO.getSendTimeslot())) {
@@ -314,11 +307,7 @@
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();
@@ -333,168 +322,127 @@
@Override
public void phoneCallBack(PhoneCallBackVO phoneCallBackVO) {
- synchronized (new IvrTaskSingleServiceImpl()) {
- 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());
- if (!aBoolean) {
- throw new BaseException("璇uid涓嶅瓨鍦�");
- }
- Integer hangupValue = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "hangup");
- PhoneUtils phoneUtils = new PhoneUtils();
- if (hangupValue != null && hangupValue == 1) {
+ 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());
+ if (!aBoolean) {
+ throw new BaseException("璇uid涓嶅瓨鍦�");
+ }
+ Integer hangupValue = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "hangup");
+ PhoneUtils phoneUtils = new PhoneUtils();
+ if (hangupValue != null && hangupValue == 1) {
+ 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("ivrTaskSingle");
+ List<IvrLibaTemplateScriptVO> ivrLibaTemplateScriptVOs = (List<IvrLibaTemplateScriptVO>) map.get("ivrLibaTemplateScriptVO");
+ //灏唘uid鏇存柊鍒版暟鎹簱涓�
+ ivrTaskcall.setSenduuid(phoneCallBackVO.getUuid());
+ ivrTaskSingleMapper.updateIvrTaskcall(ivrTaskcall);
+
+ //鑾峰彇妯℃澘淇℃伅
+ IvrLibaTemplateVO ivrLibaTemplateVO = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "ivrLibaTemplateVO");
+
+ //璇煶璇嗗埆缁撴灉涓婃姤鎺ュ彛: 3
+ Integer noVoice = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "noVoice");
+ QuestionMessage returnQues = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "returnQues");
+ //灏嗕紶鍥炵殑缁撴灉鏀惧埌鍥炲瀵硅薄涓�
+ returnQues.setContent(phoneCallBackVO.getTextResult());
+
+ IvrLibaTemplateScriptVO nowQuestion = returnQues.getNowQuestion();
+
+ if (StringUtils.isEmpty(returnQues.getContent())) {
+ //鏃犲洖璇�
+ //鍒ゆ柇noVoice鏄惁宸茬粡鍒颁簡鏈�澶у��
+ if (noVoice == ivrLibaTemplateVO.getNoVoiceNum().intValue()) {
+ //宸茬粡闂簡瀵瑰簲鐨勯亶鏁帮紝灏卞垽鏂槸鍚﹁繕鏈変笅涓�棰�
+ if (nowQuestion.getTargetid() == ivrLibaTemplateScriptVOs.size()) {
+ //娌℃湁涓嬩竴棰樹簡锛屽氨鎸傛柇鐢佃瘽锛屾挱鏀剧粨鏉熻
+ redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES);
+ phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid());
+ return;
+ } else {
+ //鏈変笅涓�棰�
+ 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 {
+ redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", noVoice + 1, 120, TimeUnit.MINUTES);
+ //璋冪敤ivrLibaTemplateScriptVO涓殑slienceText(闈欓粯璇濇湳)
+ String slienceText = nowQuestion.getSlienceText();
+ //闈欓粯璇濇湳 + 闂锛� 鍘昏皟鐢ㄢ�渢ts鍚堟垚鍜屾挱鏀锯�濇帴鍙�
String date = simpleDateFormat1.format(new Date());
- log.info("鐢佃瘽瑕佹寕鏂簡: {}", date);
- //hangupValue == 1 闅忚缁撴潫锛岀洿鎺ュ彲浠ユ寕鐢佃瘽
- phoneUtils.hangup("", "", "", "", "", "", "", phoneCallBackVO.getUuid());
+ log.info("闈欓粯璇濇湳 + 闂,鍘昏皟鐢╰ts鍚堟垚鍜屾挱鏀炬帴鍙�: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
+ phoneUtils.ttsPlayback(slienceText + nowQuestion.getQuestionText(), phoneCallBackVO.getUuid());
return;
}
- Map<String, Object> map = redisCache.getCacheObject(phoneCallBackVO.getUuid());
- IvrTaskSingle ivrTaskcall = (IvrTaskSingle) map.get("ivrTaskSingle");
- List<IvrLibaTemplateScriptVO> ivrLibaTemplateScriptVOs = (List<IvrLibaTemplateScriptVO>) map.get("ivrLibaTemplateScriptVO");
- //灏唘uid鏇存柊鍒版暟鎹簱涓�
- ivrTaskcall.setSenduuid(phoneCallBackVO.getUuid());
- ivrTaskSingleMapper.updateIvrTaskcall(ivrTaskcall);
-
- //鑾峰彇妯℃澘淇℃伅
- IvrLibaTemplateVO ivrLibaTemplateVO = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "ivrLibaTemplateVO");
-
- //璇煶璇嗗埆缁撴灉涓婃姤鎺ュ彛: 3
- Integer noVoice = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "noVoice");
- QuestionMessage returnQues = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "returnQues");
- //灏嗕紶鍥炵殑缁撴灉鏀惧埌鍥炲瀵硅薄涓�
- returnQues.setContent(phoneCallBackVO.getTextResult());
-
- IvrLibaTemplateScriptVO nowQuestion = returnQues.getNowQuestion();
-
- if (StringUtils.isEmpty(returnQues.getContent())) {
- //鏃犲洖璇�
- //鍒ゆ柇noVoice鏄惁宸茬粡鍒颁簡鏈�澶у��
- if (noVoice == ivrLibaTemplateVO.getNoVoiceNum().intValue()) {
- //宸茬粡闂簡瀵瑰簲鐨勯亶鏁帮紝灏卞垽鏂槸鍚﹁繕鏈変笅涓�棰�
- if (nowQuestion.getTargetid() == ivrLibaTemplateScriptVOs.size()) {
- //娌℃湁涓嬩竴棰樹簡锛屽氨鎸傛柇鐢佃瘽锛屾挱鏀剧粨鏉熻
- redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES);
- phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid());
- return;
- } else {
- //鏈変笅涓�棰�
- 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 {
- redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", noVoice + 1, 120, TimeUnit.MINUTES);
- //璋冪敤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;
+ } else {
+ //isppd鐢ㄦ潵璁板綍鏄惁鍖归厤鍒�
+ Boolean isppd = false;
+ //鏈夊洖璇濓紝瀵瑰洖绛旂殑闂,杩涜姝e垯鍖归厤锛堣繖閲屽彧閽堝閫夋嫨棰橈紝鍏跺畠棰樺瀷涓嶈锛�
+ for (int j = 0; j < nowQuestion.getIvrLibaScriptTargetoptionList().size(); j++) {
+ //鍖呭惈
+ Matcher matcher = null;
+ if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex())) {
+ Pattern pattern = Pattern.compile(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex());
+ matcher = pattern.matcher(phoneCallBackVO.getTextResult());
}
-
- } else {
- //isppd鐢ㄦ潵璁板綍鏄惁鍖归厤鍒�
- Boolean isppd = false;
- //鏈夊洖璇濓紝瀵瑰洖绛旂殑闂,杩涜姝e垯鍖归厤锛堣繖閲屽彧閽堝閫夋嫨棰橈紝鍏跺畠棰樺瀷涓嶈锛�
- for (int j = 0; j < nowQuestion.getIvrLibaScriptTargetoptionList().size(); j++) {
- //鍖呭惈
- Matcher matcher = null;
- if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex())) {
- Pattern pattern = Pattern.compile(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex());
- matcher = pattern.matcher(phoneCallBackVO.getTextResult());
- }
- //涓嶅寘鍚�
- Matcher matcher2 = null;
- if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2())) {
- Pattern pattern2 = Pattern.compile(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2());
- matcher2 = pattern2.matcher(phoneCallBackVO.getTextResult());
- }
- 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);
- ivrLibaScriptTargetoptionMapper.updateIvrLibaTemplateTargetoption(nowQuestion.getIvrLibaScriptTargetoptionList().get(j));
-
- //灏嗛潤榛樼疆涓�0
- redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES);
- redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", 0, 120, TimeUnit.MINUTES);
-
- //灏嗘偅鑰呯殑鍥炵鍐欒繘琛ㄩ噷
- IvrTaskVisitResult ivrTaskVisitResult = DtoConversionUtils.sourceToTarget(ivrTaskcall, IvrTaskVisitResult.class);
- ivrTaskVisitResult.setId(null);
- ivrTaskVisitResult.setQuestion(nowQuestion.getQuestionText());
- ivrTaskVisitResult.setPatientAnswer(phoneCallBackVO.getTextResult());
- ivrTaskVisitResult.setCreateTime(new Date());
- ivrTaskVisitResult.setOptionResult(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetvalue());
- ivrTaskVisitResultMapper.insertIvrTaskVisitResult(ivrTaskVisitResult);
-
- //灏嗗尮閰嶅埌鐨勬爣璇嗘敼鎴恡rue
- isppd = true;
-
- //鑾峰彇涓嬩竴棰�
- Integer nextQuestion = nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getNextQuestion();
- for (IvrLibaTemplateScriptVO script : ivrLibaTemplateScriptVOs) {
- if (script.getTargetid() == nextQuestion) {
- QuestionMessage questionMessage = new QuestionMessage();
- questionMessage.setNowQuestion(script);
- questionMessage.setQuestionList(ivrLibaTemplateScriptVOs);
- redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES);
- phoneUtils.ttsPlayback(script.getQuestionText(), phoneCallBackVO.getUuid());
- 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 {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- phoneUtils.hangup("", "", ivrLibaTemplateVO.getRevisitAfter(), "", "", "", "", phoneCallBackVO.getUuid());
- return;
- }
- }
- return;
- } else {
- //娌℃湁鍖归厤涓婂綋鍓峯ption
- //Targetregex2 涓篺alse锛岃〃绀哄湪Targetregex2涓瓨鍦� 璇彞涓殑鍏抽敭瀛楋紝杩欎釜option灏变笉鐢ㄥ啀缁х画鍖归厤浜嗭紝鐩存帴鍖归厤涓嬩竴涓猳ption
- continue;
- }
+ //涓嶅寘鍚�
+ Matcher matcher2 = null;
+ if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2())) {
+ Pattern pattern2 = Pattern.compile(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2());
+ matcher2 = pattern2.matcher(phoneCallBackVO.getTextResult());
}
+ 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);
+ ivrLibaScriptTargetoptionMapper.updateIvrLibaTemplateTargetoption(nowQuestion.getIvrLibaScriptTargetoptionList().get(j));
- if (isppd != true) {
- //娌℃湁鍖归厤鍒�
- Integer mateNum = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "mateNum");
- if (mateNum == null) mateNum = 0;
- //鏃犲尮閰嶆鏁板幓鍒ゆ柇鏄惁鍒版渶澶ц闂鏁帮紝骞朵笖鎵�鏈夌殑閫夐」閮藉尮閰嶅畬浜�
- if (mateNum == ivrLibaTemplateVO.getMateNum().intValue()) {
- //濡傛灉涓嬩竴棰樹负绌�.鍒欐柊鐨勬暟鎹繑鍥�,骞跺姞涓婃劅璋㈣
- if (nowQuestion.getTargetid() < ivrLibaTemplateScriptVOs.size()) {
+ //灏嗛潤榛樼疆涓�0
+ redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES);
+ redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", 0, 120, TimeUnit.MINUTES);
+
+ //灏嗘偅鑰呯殑鍥炵鍐欒繘琛ㄩ噷
+ IvrTaskVisitResult ivrTaskVisitResult = DtoConversionUtils.sourceToTarget(ivrTaskcall, IvrTaskVisitResult.class);
+ ivrTaskVisitResult.setId(null);
+ ivrTaskVisitResult.setQuestion(nowQuestion.getQuestionText());
+ ivrTaskVisitResult.setPatientAnswer(phoneCallBackVO.getTextResult());
+ ivrTaskVisitResult.setCreateTime(new Date());
+ ivrTaskVisitResult.setOptionResult(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetvalue());
+ ivrTaskVisitResultMapper.insertIvrTaskVisitResult(ivrTaskVisitResult);
+
+ //灏嗗尮閰嶅埌鐨勬爣璇嗘敼鎴恡rue
+ isppd = true;
+
+ //鑾峰彇涓嬩竴棰�
+ Integer nextQuestion = nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getNextQuestion();
+ for (IvrLibaTemplateScriptVO script : ivrLibaTemplateScriptVOs) {
+ if (script.getTargetid() == nextQuestion) {
QuestionMessage questionMessage = new QuestionMessage();
- IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion);
+ questionMessage.setNowQuestion(script);
questionMessage.setQuestionList(ivrLibaTemplateScriptVOs);
- 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());
+ phoneUtils.ttsPlayback(script.getQuestionText(), phoneCallBackVO.getUuid());
return;
- } else {
- //灏卞彲浠ユ寕鏂數璇濅簡
+ } else if (nextQuestion > ivrLibaTemplateScriptVOs.size()) {
+ //娌℃湁涓嬩竴棰樹簡锛屽氨缁撴潫浜�
String date = simpleDateFormat1.format(new Date());
- log.info("灏卞彲浠ユ寕鏂數璇濅簡------: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
+ log.error("娌℃湁涓嬩竴棰樹簡锛屽氨缁撴潫浜�: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES);
phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid());
try {
@@ -505,62 +453,102 @@
phoneUtils.hangup("", "", ivrLibaTemplateVO.getRevisitAfter(), "", "", "", "", phoneCallBackVO.getUuid());
return;
}
- } else if (mateNum < ivrLibaTemplateVO.getMateNum().intValue()) {
- //娌℃湁闂埌瑙勫畾娆℃暟
- mateNum = mateNum + 1;
- redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", mateNum, 120, TimeUnit.MINUTES);
}
+ return;
+ } else {
+ //娌℃湁鍖归厤涓婂綋鍓峯ption
+ //Targetregex2 涓篺alse锛岃〃绀哄湪Targetregex2涓瓨鍦� 璇彞涓殑鍏抽敭瀛楋紝杩欎釜option灏变笉鐢ㄥ啀缁х画鍖归厤浜嗭紝鐩存帴鍖归厤涓嬩竴涓猳ption
+ continue;
}
- //閫夐」鍖归厤瀹屾垚鍚庯紝闇�瑕佸啀鍘婚�氳繃搴撳啀杩涜鍖归厤涓�娆�
- String extemplateID = ivrLibaTemplateVO.getSubmoduleID();
- String[] split = extemplateID.split(",");
- List<String> list = Arrays.asList(split);
- List<Long> list1 = new ArrayList<>();
- if (StringUtils.isNotEmpty(extemplateID)) {
- for (String str : list) {
- list1.add(Long.valueOf(str));
- }
- List<IvrLibaExtemplatescript> ivrLibaExtemplatescripts = ivrLibaExtemplatescriptMapper.queryIvrLibaExtemplatescriptList(list1);
- for (IvrLibaExtemplatescript ivrLibaExtemplatescript : ivrLibaExtemplatescripts) {
- Matcher matcher = null;
- if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex())) {
- Pattern pattern = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex());
- matcher = pattern.matcher(returnQues.getContent());
- }
+ }
- Matcher matcher2 = null;
- if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2())) {
- Pattern pattern2 = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex2());
- matcher2 = pattern2.matcher(returnQues.getContent());
+ if (isppd != true) {
+ //娌℃湁鍖归厤鍒�
+ Integer mateNum = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "mateNum");
+ if (mateNum == null) mateNum = 0;
+ //鏃犲尮閰嶆鏁板幓鍒ゆ柇鏄惁鍒版渶澶ц闂鏁帮紝骞朵笖鎵�鏈夌殑閫夐」閮藉尮閰嶅畬浜�
+ if (mateNum == ivrLibaTemplateVO.getMateNum().intValue()) {
+ //濡傛灉涓嬩竴棰樹负绌�.鍒欐柊鐨勬暟鎹繑鍥�,骞跺姞涓婃劅璋㈣
+ if (nowQuestion.getTargetid() < ivrLibaTemplateScriptVOs.size()) {
+ QuestionMessage questionMessage = new QuestionMessage();
+ IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion);
+ questionMessage.setQuestionList(ivrLibaTemplateScriptVOs);
+ 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 {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
- log.info("++++++++++++++++++++++++++閫氱敤搴撴槸鍚︿负绌猴細selfRegex : {} , selfRegex2 : {}", ivrLibaExtemplatescript.getSelfRegex(), ivrLibaExtemplatescript.getSelfRegex2());
- if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches() && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches()) {
- QuestionMessage questionMessage = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "returnQues");
- IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO = returnQues.getNowQuestion();
- ivrLibaTemplateScriptVO.setSubmoduleText(ivrLibaExtemplatescript.getSwitchText());
- ivrLibaTemplateScriptVO.setSubmoduleVoice(ivrLibaExtemplatescript.getSwitchWav());
+ phoneUtils.hangup("", "", ivrLibaTemplateVO.getRevisitAfter(), "", "", "", "", phoneCallBackVO.getUuid());
+ return;
+ }
+ } else if (mateNum < ivrLibaTemplateVO.getMateNum().intValue()) {
+ //娌℃湁闂埌瑙勫畾娆℃暟
+ mateNum = mateNum + 1;
+ redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", mateNum, 120, TimeUnit.MINUTES);
+ }
+ }
+ //閫夐」鍖归厤瀹屾垚鍚庯紝闇�瑕佸啀鍘婚�氳繃搴撳啀杩涜鍖归厤涓�娆�
+ String extemplateID = ivrLibaTemplateVO.getSubmoduleID();
+ String[] split = extemplateID.split(",");
+ List<String> list = Arrays.asList(split);
+ List<Long> list1 = new ArrayList<>();
+ if (StringUtils.isNotEmpty(extemplateID)) {
+ for (String str : list) {
+ list1.add(Long.valueOf(str));
+ }
+ List<IvrLibaExtemplatescript> ivrLibaExtemplatescripts = ivrLibaExtemplatescriptMapper.queryIvrLibaExtemplatescriptList(list1);
+ for (IvrLibaExtemplatescript ivrLibaExtemplatescript : ivrLibaExtemplatescripts) {
+ Matcher matcher = null;
+ if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex())) {
+ Pattern pattern = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex());
+ matcher = pattern.matcher(returnQues.getContent());
+ }
+
+ Matcher matcher2 = null;
+ if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2())) {
+ Pattern pattern2 = Pattern.compile(ivrLibaExtemplatescript.getSelfRegex2());
+ matcher2 = pattern2.matcher(returnQues.getContent());
+ }
+ log.info("++++++++++++++++++++++++++閫氱敤搴撴槸鍚︿负绌猴細selfRegex : {} , selfRegex2 : {}", ivrLibaExtemplatescript.getSelfRegex(), ivrLibaExtemplatescript.getSelfRegex2());
+ if (StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches() && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && matcher2.matches() || StringUtils.isEmpty(ivrLibaExtemplatescript.getSelfRegex2()) && StringUtils.isNotEmpty(ivrLibaExtemplatescript.getSelfRegex()) && matcher.matches()) {
+ QuestionMessage questionMessage = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "returnQues");
+ IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO = returnQues.getNowQuestion();
+ ivrLibaTemplateScriptVO.setSubmoduleText(ivrLibaExtemplatescript.getSwitchText());
+ ivrLibaTemplateScriptVO.setSubmoduleVoice(ivrLibaExtemplatescript.getSwitchWav());
+ redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES);
+ if (ivrLibaExtemplatescript.getIsEnd() == 1) {
+ //灏嗛棶棰樼疆绌�
+ IvrLibaTemplateScriptVO nowQuestion1 = questionMessage.getNowQuestion();
+ nowQuestion1.setQuestionText(null);
+ nowQuestion1.setQuestionVoice(null);
+ questionMessage.setNowQuestion(nowQuestion1);
redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES);
- if (ivrLibaExtemplatescript.getIsEnd() == 1) {
- //灏嗛棶棰樼疆绌�
- IvrLibaTemplateScriptVO nowQuestion1 = questionMessage.getNowQuestion();
- nowQuestion1.setQuestionText(null);
- nowQuestion1.setQuestionVoice(null);
- questionMessage.setNowQuestion(nowQuestion1);
- redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES);
- 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());
+ redisCache.setCacheObject(phoneCallBackVO.getUuid() + "isOver", 1, 120, TimeUnit.MINUTES);
}
- break;
+ //璋冪敤鈥�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());
}
- String date = simpleDateFormat1.format(new Date());
- log.info("鏈�鍚庣殑淇℃伅鍥炲-: {},uuid涓猴細{}", date, phoneCallBackVO.getUuid());
- phoneUtils.ttsPlayback(nowQuestion.getQuestionText(), 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