From 723d38375c45d24737bfef6f33a9686254abf99b Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 17 十月 2024 13:42:27 +0800
Subject: [PATCH] 代码提交
---
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java | 132 +++++++++++++++++++++++++++++++++++---------
1 files changed, 105 insertions(+), 27 deletions(-)
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
index fa93511..100d45c 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -7,10 +7,8 @@
import com.google.gson.Gson;
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.ruoyi.common.utils.RSAPublicKeyExample;
-import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.*;
+import com.ruoyi.common.utils.http.HttpUtils;
import com.smartor.config.PhoneUtils;
import com.smartor.domain.*;
import com.smartor.mapper.*;
@@ -24,6 +22,7 @@
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -76,6 +75,12 @@
@Value("${pri_key}")
private String pri_key;
+
+ @Value("${ASRCallBackPath}")
+ private String ASRCallBackPath;
+
+ @Value("${hangup}")
+ private String hangup;
/**
@@ -200,8 +205,8 @@
public List<ServiceSubtask> patItem(ServiceSubtaskVO serviceSubtaskVO) {
List<ServiceSubtask> selectServiceSubtaskList = this.selectServiceSubtaskList(serviceSubtaskVO);
//鏍规嵁鍑洪櫌 鏃堕棿鍊掑簭
- List<ServiceSubtask> sortedServiceSubtaskList = selectServiceSubtaskList.stream().sorted(Comparator.comparing(ServiceSubtask::getEndtime).reversed()).collect(Collectors.toList());
- return sortedServiceSubtaskList;
+// List<ServiceSubtask> sortedServiceSubtaskList = selectServiceSubtaskList.stream().sorted(Comparator.comparing(ServiceSubtask::getEndtime).reversed()).collect(Collectors.toList());
+ return selectServiceSubtaskList;
}
@Override
@@ -642,12 +647,43 @@
public PhoneCallBackYQVO phoneCallBackYQ(PhoneCallReqYQVO phoneCallReqYQVO) {
//瀹氫箟涓�涓垎鏁扮殑鍙橀噺
Boolean aBoolean1 = redisCache.hasKey(phoneCallReqYQVO.getUuid() + "SCORE");
- if (!aBoolean1) redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", 0);
+ if (!aBoolean1) redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", 0.0, 120, TimeUnit.MINUTES);
PhoneCallBackYQVO phoneCallBackYQVO = new PhoneCallBackYQVO();
//channel_create 閫氶亾鍒涘缓鐨勬椂鍊欙紝鍙互鎵ц涓�浜涘叾瀹冩搷浣滐紝璀鍙戜釜鐭俊涔嬬被鐨�; 鎴戜滑鐨勪笟鍔″彲浠ヤ笉鐢ㄧ PlayEventCallback 杩欎釜鏄挱鏀捐闊崇殑,鏆傛椂鐢ㄤ笉鍒� End_time()= -1鎴杗ull琛ㄧず褰撳墠鐨刟srtext涓嶆槸涓�鍙ュ畬鏁寸殑璇�
- if (phoneCallReqYQVO.getOperate().equals("channel_create") || phoneCallReqYQVO.getOperate().equals("PlayEventCallback") || phoneCallReqYQVO.getEnd_time() == null || phoneCallReqYQVO.getEnd_time() == -1) {
+ if (phoneCallReqYQVO.getOperate().equals("channel_create")) {
return phoneCallBackYQVO;
}
+ //PlayEventCallback 杩欎釜鏄挱鏀捐闊崇殑 playstart锛氭斁闊冲紑濮嬶紙闂鎾姤寮�濮嬶級 playstop锛� 鏀鹃煶缁撴潫锛堥棶棰樻挱鎶ョ粨鏉燂級
+ if (phoneCallReqYQVO.getOperate().equals("PlayEventCallback")) {
+ String cacheJSY = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "- jsy");
+ if (phoneCallReqYQVO.getOperate().equals("PlayEventCallback") && phoneCallReqYQVO.getPlaystop() == false) {
+ //鍒ゆ柇redis涓槸鍚︽湁缁撴潫璇�
+ if (StringUtils.isEmpty(cacheJSY)) {
+ redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop", false, 120, TimeUnit.MINUTES);
+ log.error("PlayEventCallbackPlaystop鐨勫�间负-------锛歿}", false);
+ }
+ } else {
+ //濡傛灉缁撴潫璇笉涓虹┖锛屽垯瑕佹寕鐢佃瘽浜�
+ if (StringUtils.isNotEmpty(cacheJSY)) {
+ Map<String, String> req = new HashMap<>();
+ req.put("uuid", phoneCallReqYQVO.getUuid());
+ req.put("caller", phoneCallReqYQVO.getPhone());
+ HttpUtils.sendPost(hangup, new Gson().toJson(req));
+ //鍒犻櫎缁撴潫璇殑鎮e瓨
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "- jsy");
+ } else {
+ redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop", true, 120, TimeUnit.MINUTES);
+ log.error("-------PlayEventCallbackPlaystop鐨勫�间负锛歿}", true);
+ }
+ }
+ return phoneCallBackYQVO;
+ }
+ //鑾峰彇鏀鹃煶鏄惁缁撴潫
+ boolean isPlayEventOver = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
+ if (!isPlayEventOver) {
+ return phoneCallBackYQVO;
+ }
+
//閫氳繃瀛愪换鍔D鑾峰彇鍒版ā鏉夸俊鎭�
ServiceSubtask serviceSubtask = serviceSubtaskMapper.selectServiceSubtaskById(Long.valueOf(phoneCallReqYQVO.getTaskid()));
IvrTaskTemplate ivrTaskTemplate = ivrTaskTemplateService.selectIvrTaskTemplateByID(serviceSubtask.getTemplateid());
@@ -678,14 +714,16 @@
phoneCallBackYQVO.setType("text");
phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
String scriptContent = ivrTaskTemplateScriptVO.getScriptContent();
+ log.error("SilentCallback鐨勯棶棰樺唴瀹箂criptContent锛歿}", scriptContent);
phoneCallBackYQVO.setValue(getObject(serviceSubtask, scriptContent));
//灏嗛潤榛樻鏁板姞1
Integer noVoiceNum = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "noVoice");
redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "noVoice", noVoiceNum + 1, 120, TimeUnit.MINUTES);
+ return phoneCallBackYQVO;
} else {
log.error("闈欓粯娆℃暟杈惧埌,鎸傛帀鐢佃瘽锛歿}", num);
//澶т笌绛変簬鐨勮瘽,鐩存帴鎸傛柇
- phoneCallBackYQVO.setType("hangup");
+ phoneCallBackYQVO.setType("text");
phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
phoneCallBackYQVO.setValue(ivrTaskTemplate.getRevisitAfter());
//灏嗙粨鏋滃啓鍒癲etail涓�
@@ -705,9 +743,28 @@
redisCache.setCacheObject(map.get("cacheName"), map.get("val"));
redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone());
redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
+ //鍦╮edis涓繚瀛樹竴涓嬬粨鏉熻锛屽湪璋冪敤鎸傜數璇濈殑鏂规硶鏃跺垹闄�
+ redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", ivrTaskTemplate.getRevisitAfter(), 120, TimeUnit.MINUTES);
}
return phoneCallBackYQVO;
- } else if ("AsrCallback".equals(phoneCallReqYQVO.getOperate())) {
+ } else if ("AsrCallback".equals(phoneCallReqYQVO.getOperate()) && phoneCallReqYQVO.getEnd_time() != null && phoneCallReqYQVO.getEnd_time() != -1) {
+ //鎾姤绗竴棰�
+ Integer integer = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim() + "-firstSort");
+// if(integer==0){
+// //integer==0,琛ㄧず寮�鍦虹櫧鍒氭挱鎶ュ畬锛岄渶瑕佸仠椤夸竴涓嬶紝绛夋偅鑰呰璇�
+// redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim() + "-firstSort", 1, 120, TimeUnit.MINUTES);
+// return phoneCallBackYQVO;
+// }
+ if (ivrTaskTemplateScriptVO.getSort() == 1 && integer == 1) {
+ phoneCallBackYQVO.setType("text");
+ phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
+ String scriptContent = ivrTaskTemplateScriptVO.getScriptContent();
+ phoneCallBackYQVO.setValue(getObject(serviceSubtask, scriptContent));
+ redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim() + "-firstSort", 2, 120, TimeUnit.MINUTES);
+ return phoneCallBackYQVO;
+ }
+
//濡傛灉鏄枃鏈洖璋�
//鏍规嵁闂ID鑾峰彇璇ラ棶棰樼殑绫诲瀷
if (ivrTaskTemplateScriptVO.getScriptType().equals("1")) {
@@ -742,9 +799,11 @@
serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate));
serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList);
saveQuestionAnswerPhone(serviceSubTaskDetailReq);
-//
+ //灏嗗綋鍓嶅墠鐨勬挱鎶ョ姸鎬佸垹闄わ紝缁欎笅涓�棰樿浣�
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
// //鑾峰彇涓嬩竴棰�
- if (ivrTaskTemplateScriptVO.getBranchFlag().equals("1") || ivrTaskTemplateScriptVO.getBranchFlag().equals("0") && ivrTaskTemplateScriptVO.getNextScriptno() != 0) {
+ log.error("鑾峰彇涓嬩竴棰樼殑淇℃伅锛歿}", ivrTaskTemplateScriptVO);
+ if (ivrTaskTemplateScriptVO.getBranchFlag().equals("1") || ivrTaskTemplateScriptVO.getBranchFlag().equals("0") && ivrTaskTemplateScriptVO.getNextScriptno() != null && ivrTaskTemplateScriptVO.getNextScriptno() != 0) {
Long nextQuestion = null;
if (ivrTaskTemplateScriptVO.getBranchFlag().equals("1")) {
nextQuestion = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getNextQuestion();
@@ -755,7 +814,8 @@
} else {
nextQuestion = ivrTaskTemplateScriptVO.getNextScriptno();
//鏇存柊鍒嗘暟
- double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
+ Object obj = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
+ Double score = (obj == null ? new Double(0.00) : new Double(((Double) obj).doubleValue()));
score = BigDecimal.valueOf(score).add(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getScore()).doubleValue();
redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score);
}
@@ -765,6 +825,7 @@
phoneCallBackYQVO.setType("text");
phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
String scriptContent = script.getScriptContent();
+ log.error("涓嬩竴棰橀棶棰橈細{}", scriptContent);
phoneCallBackYQVO.setValue(getObject(serviceSubtask, scriptContent));
//灏嗚鎮h�呯殑Redis涓殑棰樼洰ID锛岃繘琛屼慨鏀�
redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim(), script.getId().toString(), 120, TimeUnit.MINUTES);
@@ -773,8 +834,8 @@
}
}
} else if (ivrTaskTemplateScriptVO.getBranchFlag().equals("0")) {
- if (ivrTaskTemplateScriptVO.getNextScriptno() == 0 || ivrTaskTemplateScriptVO.getNextScriptno() == null) {
- phoneCallBackYQVO.setType("hangup");
+ if (ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getNextScriptno() == 0) {
+ phoneCallBackYQVO.setType("text");
phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
//鏇存柊涓�涓嬪垎鏁�
double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
@@ -789,6 +850,9 @@
redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone());
redisCache.deleteObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid());
redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
+ //鍦╮edis涓繚瀛樹竴涓嬬粨鏉熻锛屽湪璋冪敤鎸傜數璇濈殑鏂规硶鏃跺垹闄�
+ redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", ivrTaskTemplate.getRevisitAfter(), 120, TimeUnit.MINUTES);
// return phoneCallBackYQVO;
}
}
@@ -803,7 +867,7 @@
//濡傛灉count宸茬粡澶т簬鎴栫瓑浜庢病鏈夊尮閰嶆鏁�
if (ivrTaskTemplateScriptVO.getBranchFlag().equals("0") && ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getBranchFlag().equals("0") && ivrTaskTemplateScriptVO.getNextScriptno() == 0 || ivrTaskTemplateScriptVO.getBranchFlag().equals("1") && ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getBranchFlag().equals("1") && ivrTaskTemplateScriptVO.getNextScriptno() == 0) {
//濡傛灉鏄渶鍚庝竴閬撻锛屾垨鑰呮病鏈変笅涓�棰樹簡锛屽氨鐩存帴鎸傛満
- phoneCallBackYQVO.setType("hangup");
+ phoneCallBackYQVO.setType("text");
phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
if (StringUtils.isNotEmpty(phoneCallBackYQVO.getValue()))
phoneCallBackYQVO.setValue(phoneCallBackYQVO.getValue() + ivrTaskTemplate.getRevisitAfter());
@@ -815,6 +879,8 @@
serviceSubtask.setFinishtime(new Date());
serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+ //鍦╮edis涓繚瀛樹竴涓嬬粨鏉熻锛屽湪璋冪敤鎸傜數璇濈殑鏂规硶鏃跺垹闄�
+ redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", ivrTaskTemplate.getRevisitAfter(), 120, TimeUnit.MINUTES);
//鍘籸edis涓紝鎶婅瀛愪换鍔D鍒犻櫎
Long id = serviceSubtask.getId();
Map<String, String> map = delRedisValue(null, id.toString());
@@ -863,7 +929,7 @@
//濡傛灉閫夐」鍒嗘敮涓�1鐨勮瘽锛屽垯闇�瑕佹牴鎹棶棰樹笂鐨刵extScriptno杩涜璺宠浆
//闂瓟棰樻病鏈夎烦杞�
- if (ivrTaskTemplateScriptVO.getNextScriptno() != null || ivrTaskTemplateScriptVO.getNextScriptno() != 0) {
+ if (ivrTaskTemplateScriptVO.getNextScriptno() != null && ivrTaskTemplateScriptVO.getNextScriptno() != 0) {
for (IvrTaskTemplateScript ivrTaskTemplateScript1 : ivrTaskTemplateScripts) {
if (ivrTaskTemplateScriptVO.getNextScriptno().intValue() == ivrTaskTemplateScript1.getSort()) {
phoneCallBackYQVO.setType("text");
@@ -881,9 +947,9 @@
// return phoneCallBackYQVO;
}
}
- } else if (ivrTaskTemplateScriptVO.getNextScriptno() == null) {
+ } else if (ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getNextScriptno() == 0) {
//娌℃湁涓嬩竴棰樹簡锛屽氨缁撴潫浜�
- phoneCallBackYQVO.setType("hangup");
+ phoneCallBackYQVO.setType("text");
phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
phoneCallBackYQVO.setValue(ivrTaskTemplate.getRevisitAfter());
@@ -897,16 +963,18 @@
Long id = serviceSubtask.getId();
Map<String, String> map = delRedisValue(null, id.toString());
redisCache.setCacheObject(map.get("cacheName"), map.get("val"));
+ //鍦╮edis涓繚瀛樹竴涓嬬粨鏉熻锛屽湪璋冪敤鎸傜數璇濈殑鏂规硶鏃跺垹闄�
+ redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", ivrTaskTemplate.getRevisitAfter(), 120, TimeUnit.MINUTES);
redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone());
redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
}
//閫夐」鍖归厤瀹屾垚鍚庯紝闇�瑕佸啀鍘婚�氳繃搴撳啀杩涜鍖归厤涓�娆�
String extemplateID = ivrTaskTemplate.getSubmoduleID();
- String[] split = extemplateID.split(",");
- List<String> list = Arrays.asList(split);
- List<Long> list1 = new ArrayList<>();
if (StringUtils.isNotEmpty(extemplateID)) {
+ String[] split = extemplateID.split(",");
+ List<String> list = Arrays.asList(split);
+ List<Long> list1 = new ArrayList<>();
for (String str : list) {
list1.add(Long.valueOf(str));
}
@@ -934,6 +1002,7 @@
}
return phoneCallBackYQVO;
}
+
private String getObject(ServiceSubtask serviceSubtask, String scriptContent) {
Map<String, Map<String, String>> param = getParam(serviceSubtask.getTaskid());
@@ -1014,9 +1083,11 @@
if (!StringUtils.isEmpty(value0)) {
pullTaskVOList = getPullTaskList(value0, "cache-0");
//灏哻ache-0鐨勬暟鎹紝杞Щ涓嶅鍔瞔ache-00涓�
+ redisCache.deleteObject("cache-00");
String cache00 = redisCache.getCacheObject("cache-00");
- if (!StringUtils.isEmpty(cache00)) redisCache.setCacheObject("cache-00", cache00 + "," + value0);
- else redisCache.setCacheObject("cache-00", value0);
+ if (!StringUtils.isEmpty(cache00))
+ redisCache.setCacheObject("cache-00", cache00 + "," + value0, 120, TimeUnit.MINUTES);
+ else redisCache.setCacheObject("cache-00", value0, 120, TimeUnit.MINUTES);
redisCache.deleteObject("cache-0");
} else {
for (int i = 1; i < 6; i++) {
@@ -1034,7 +1105,12 @@
redisCache.deleteObject("cache-" + i);
}
}
-
+ if (CollectionUtils.isNotEmpty(pullTaskVOList)) {
+ //缁欏洖璋冨弬鏁拌祴鍊�
+ for (PullTaskVO pullTaskVO : pullTaskVOList) {
+ pullTaskVO.setAsrcallback(ASRCallBackPath);
+ }
+ }
return pullTaskVOList;
}
@@ -1068,8 +1144,9 @@
//濡傛灉ivrTaskTemplateScript涓虹┖锛屼篃灏辨病鏈夊線涓嬫墽琛岀殑蹇呰浜�
if (ObjectUtils.isEmpty(ivrTaskTemplateScript)) return null;
//鑾峰彇閫氶厤绗﹀尮閰嶈繃鍚庣殑闂
- String scrContent = getObject(serviceSubtask, ivrTaskTemplateScript.getScriptContent());
- String kcb = ivrTaskTemplate.getRevisitBefore() + "," + scrContent;
+// String scrContent = getObject(serviceSubtask, ivrTaskTemplateScript.getScriptContent());
+// String kcb = ivrTaskTemplate.getRevisitBefore() + "," + scrContent;
+ String kcb = ivrTaskTemplate.getRevisitBefore();
//灏佽杩斿洖鏁版嵁
//taskId = 瀛愪换鍔D + 闂ID +闂搴忓彿
@@ -1081,6 +1158,7 @@
pullTaskVO.setDisplayNo("85129866");
pullTaskVOList.add(pullTaskVO);
redisCache.setCacheObject(subId.trim() + "-" + serviceSubtask.getPhone().trim(), ivrTaskTemplateScript.getId().toString());
+ redisCache.setCacheObject(subId.trim() + "-" + serviceSubtask.getPhone().trim() + "-firstSort", 1, 120, TimeUnit.MINUTES);
} else {
if (StringUtils.isEmpty(newValue0)) {
newValue0 = "," + split[i].trim() + ",";
--
Gitblit v1.9.3