From 21c27eaa5280713b0ec39423bbe6e3d7541f1da7 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 28 七月 2026 11:33:24 +0800
Subject: [PATCH] 【省立同德】AI识别
---
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java | 333 ++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 304 insertions(+), 29 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 d211e97..1201841 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -32,6 +32,7 @@
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.annotations.Param;
+import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
@@ -39,8 +40,10 @@
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
+import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
@@ -1731,43 +1734,44 @@
if (ivrTaskTemplateScriptVO.getScriptType().equals("1")) {
//鐢ㄦ潵鏍囪锛屾槸鍚︽湁鍖归厤涓婄殑
Integer flag = 0;
+// //2-AI璇嗗埆
+// SysConfig configVoiceMatchType = new SysConfig();
+// configVoiceMatchType.setOrgid(phoneCallReqYQVO.getOrgid());
+// configVoiceMatchType.setConfigKey("sys.voice.match.type");
+// SysConfig matchType = sysConfigMapper.selectConfig(configVoiceMatchType);
+//
+// if (ObjectUtils.isNotEmpty(matchType) && StringUtils.isNotEmpty(matchType.getConfigValue())
+// && matchType.getConfigValue().equals("2")) {
+// PhoneCallBackYQVO aiMatchResult = AiMatch(phoneCallReqYQVO, phoneCallBackYQVO,
+// ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate,
+// ivrTaskTemplateScripts, scriptId, flag);
+// if(aiMatchResult != null){
+// return aiMatchResult;
+// }
+// } else {
//鏄�夋嫨棰�
for (int j = 0; j < ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().size(); j++) {
log.error("phoneCallReqYQVO.getAsrtext()鐨勫�间负锛歿}", phoneCallReqYQVO.getAsrtext());
if (StringUtils.isEmpty(phoneCallReqYQVO.getAsrtext())) {
continue;
}
- //2-AI璇嗗埆
-// SysConfig configVoiceMatchType = new SysConfig();
-// configVoiceMatchType.setOrgid(phoneCallReqYQVO.getOrgid());
-// configVoiceMatchType.setConfigKey("sys.voice.match.type");
-// SysConfig matchType = sysConfigMapper.selectConfig(configVoiceMatchType);
boolean matchedFlag = false;
-// if (ObjectUtils.isNotEmpty(matchType) && StringUtils.isNotEmpty(matchType.getConfigValue()) && matchType.getConfigValue().equals("2")) {
-// int checkFlag = DeepSeekApi.matchQuestionAnswer(ivrTaskTemplateScriptVO.getScriptContent(),
-// phoneCallReqYQVO.getAsrtext(),
-// ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetvalue());
-// if (checkFlag == 1) {
-// matchedFlag = true;
-// }
-// } else {
- //鍖呭惈
- Matcher matcher = null;
- if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex())) {
- Pattern pattern = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex());
- matcher = pattern.matcher(phoneCallReqYQVO.getAsrtext());
- }
- //涓嶅寘鍚�
- Matcher matcher2 = null;
- if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2())) {
- Pattern pattern2 = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2());
- matcher2 = pattern2.matcher(phoneCallReqYQVO.getAsrtext());
- }
+ //鍖呭惈
+ Matcher matcher = null;
+ if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex())) {
+ Pattern pattern = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex());
+ matcher = pattern.matcher(phoneCallReqYQVO.getAsrtext());
+ }
+ //涓嶅寘鍚�
+ Matcher matcher2 = null;
+ if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2())) {
+ Pattern pattern2 = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2());
+ matcher2 = pattern2.matcher(phoneCallReqYQVO.getAsrtext());
+ }
- if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
- matchedFlag = true;
- }
-// }
+ if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
+ matchedFlag = true;
+ }
//璇存槑鍖归厤姝g‘浜�
if(matchedFlag){
//杩欓噷搴旇鍏堝垽鏂被鍨嬶紝鍘诲啀淇敼锛岃缃甀sUserOperation鏄崟閫夐鐨勬敼娉�
@@ -1986,6 +1990,7 @@
continue;
}
}
+// }
//閮芥病鏈夊尮閰嶅埌
if (StringUtils.isEmpty(phoneCallBackYQVO.getValue())) {
log.info("閮芥病鏈夊尮閰嶅埌-------------------------");
@@ -4963,4 +4968,274 @@
serviceSubtask.setVisitTime(newDate);
return serviceSubtask;
}
+
+ /**
+ * Ai 鍖归厤閫夐」
+ * @param questionText
+ * @param voiceText
+ * @param options
+ * @return
+ */
+ public String matchOptionIndex(String questionText, String voiceText, List<IvrTaskTemplateTargetoption> options) {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("userQuestion",questionText);
+ jsonObject.put("userAnswer",voiceText);
+ jsonObject.put("options", options);
+ String jsonString = jsonObject.toJSONString();
+ String result = null;
+ try {
+ result = OkHttpExample.post("http://localhost:8099/matchOptionIndex", jsonString);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return result;
+ }
+
+ public PhoneCallBackYQVO AiMatch(PhoneCallReqYQVO phoneCallReqYQVO, PhoneCallBackYQVO phoneCallBackYQVO,
+ IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO, ServiceSubtask serviceSubtask, IvrTaskTemplate ivrTaskTemplate,
+ List<IvrTaskTemplateScript> ivrTaskTemplateScripts, String scriptId, Integer flag){
+ PhoneCallBackYQVO back = null;
+ String result = "0";
+ List<IvrTaskTemplateTargetoption> options = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList();
+ String voiceText = phoneCallReqYQVO.getAsrtext();
+ String questionText = StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrtext()) ? ivrTaskTemplateScriptVO.getIvrtext() : ivrTaskTemplateScriptVO.getScriptContent();
+ result = matchOptionIndex(questionText, voiceText, options);
+ Integer matched = Integer.valueOf(result);
+ IvrTaskTemplateTargetoption chosenOption = options.get(matched);
+ //璇存槑鍖归厤姝g‘浜�
+ if(matched != null && matched != 0){
+ //杩欓噷搴旇鍏堝垽鏂被鍨嬶紝鍘诲啀淇敼锛岃缃甀sUserOperation鏄崟閫夐鐨勬敼娉�
+ log.info("鍖归厤姝g‘浜嗗悧--------------");
+ chosenOption.setIsUserOperation(1);
+ serviceTaskScriptTargetoptionMapper.updateIvrTaskTemplateTargetoption(chosenOption);
+
+ //灏嗘偅鑰呯殑鍥炵鍐欒繘service_subtask_detail涓�
+ ServiceSubTaskDetailReq serviceSubTaskDetailReq = new ServiceSubTaskDetailReq();
+ List<ServiceSubtaskDetail> serviceSubtaskDetailList = new ArrayList<>();
+ ivrTaskTemplateScriptVO.setQuestionResult(chosenOption.getOptiondesc());
+ ServiceSubtaskDetail serviceSubtaskDetail = getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate);
+ //淇敼涓�涓嬭闊宠矾寰勶紙鏀规垚鍓嶇鍙互璁块棶鐨勶紝瀛樺埌鏁版嵁搴撲腑锛�
+ if (StringUtils.isNotEmpty(serviceSubtaskDetail.getQuestionvoice())) {
+ String questionvoice = serviceSubtaskDetail.getQuestionvoice();
+ String[] split = questionvoice.split("\\\\");
+ if (split.length > 0) {
+ String lastPart = split[split.length - 1];
+ serviceSubtaskDetail.setQuestionvoice(voicePathPrefix + lastPart);
+ }
+ }
+ serviceSubtaskDetailList.add(serviceSubtaskDetail);
+ serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList);
+ serviceSubTaskDetailReq.setGuid(phoneCallReqYQVO.getGuid());
+ serviceSubTaskDetailReq.setOrgid(phoneCallReqYQVO.getOrgid());
+ saveQuestionAnswerPhone(serviceSubTaskDetailReq);
+
+ //鍒ゆ柇涓�涓嬪綋鍓嶇殑闂鏄笉鏄弧鎰忓害闂锛屽苟涓攄utyDeptCode鏄惁鏈夊�硷紝骞朵笖閫夐」鏄笉鏄紓甯搁�夐」锛屽鏋滃叏绗﹀悎锛屽垯寰�婊℃剰搴﹂棶棰樺紓甯歌〃鏂板
+ if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getDutyDeptCode()) && 1 == chosenOption.getIsabnormal()) {
+ ServiceSubtaskDetailTrace subtaskDetailTrace = new ServiceSubtaskDetailTrace();
+ //鐢╰askid銆乻ubid鍜宻criptid鍘昏幏鍙杁etailid
+ ServiceSubtaskDetail ssd = new ServiceSubtaskDetail();
+ ssd.setSubId(serviceSubtask.getId());
+ ssd.setTaskid(serviceSubtask.getTaskid());
+ ssd.setScriptid(StringUtils.isNotEmpty(scriptId) ? Long.valueOf(scriptId) : null);
+ List<ServiceSubtaskDetail> serviceSubtaskDetails = serviceSubtaskDetailMapper.selectServiceSubtaskDetailList(ssd);
+ subtaskDetailTrace.setDetailId(CollectionUtils.isNotEmpty(serviceSubtaskDetails) ? serviceSubtaskDetails.get(0).getId() : null);
+
+ subtaskDetailTrace.setSubId(serviceSubtask.getId());
+ subtaskDetailTrace.setTaskid(serviceSubtask.getTaskid());
+ subtaskDetailTrace.setTemplateid(ivrTaskTemplateScriptVO.getId());
+ subtaskDetailTrace.setTemplatequestionnum(ivrTaskTemplateScriptVO.getScriptno());
+ subtaskDetailTrace.setSwitchid(chosenOption.getId());
+ subtaskDetailTrace.setQuestiontext(ivrTaskTemplateScriptVO.getScriptContent());
+ subtaskDetailTrace.setQuestionvoice(null);
+ subtaskDetailTrace.setCategoryname(ivrTaskTemplateScriptVO.getScriptAssortname());
+ subtaskDetailTrace.setCategoryid(ivrTaskTemplateScriptVO.getScriptAssortid());
+ //鑾峰彇鎵�鏈夐�夐」
+ String optionDescStr = Optional.ofNullable(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList()).filter(list -> !list.isEmpty()).map(list -> list.stream().map(IvrTaskTemplateTargetoption::getOptiondesc).filter(Objects::nonNull).collect(Collectors.joining("&"))).orElse("");
+ subtaskDetailTrace.setTargetid(chosenOption.getId());
+ subtaskDetailTrace.setTargetvalue(optionDescStr);
+ subtaskDetailTrace.setMatchedtext(chosenOption.getOptiondesc());
+ subtaskDetailTrace.setValueType(serviceSubtaskDetails.get(0).getValueType());
+ subtaskDetailTrace.setTemplateType(1);
+
+ SvyLibScriptCategory svyLibScriptCategory = svyLibScriptCategoryMapper.selectSvyLibScriptCategoryById(ivrTaskTemplateScriptVO.getScriptAssortid());
+ subtaskDetailTrace.setType(svyLibScriptCategory.getType());
+ subtaskDetailTrace.setScriptid(ivrTaskTemplateScriptVO.getId());
+ subtaskDetailTrace.setAsrtext(phoneCallReqYQVO.getAsrtext());
+ subtaskDetailTrace.setRecordpath(phoneCallReqYQVO.getRecordpath());
+ subtaskDetailTrace.setPatid(serviceSubtask.getPatid());
+ JSONObject patdescJson = new JSONObject();
+ patdescJson.put("sendname", serviceSubtask.getSendname());
+ patdescJson.put("phone", serviceSubtask.getPhone());
+ patdescJson.put("age", serviceSubtask.getAge());
+ patdescJson.put("sex", serviceSubtask.getSex() != null ? serviceSubtask.getSex() == 1 ? "鐢�" : "濂�" : null);
+ subtaskDetailTrace.setPatdesc(patdescJson.toJSONString());
+ subtaskDetailTrace.setTodeptcode(ivrTaskTemplateScriptVO.getDutyDeptCode());
+ subtaskDetailTrace.setTodeptname(ivrTaskTemplateScriptVO.getDutyDeptName());
+ subtaskDetailTrace.setOrgid(serviceSubtask.getOrgid());
+ subtaskDetailTrace.setHandleFlag("0");
+ subtaskDetailTrace.setGuid(phoneCallReqYQVO.getGuid());
+ subtaskDetailTrace.setCreateTime(new Date());
+ subtaskDetailTrace.setUpdateTime(new Date());
+ subtaskDetailTrace.setOrgid(phoneCallReqYQVO.getOrgid());
+ traceService.insertServiceSubtaskDetailTtrace(subtaskDetailTrace);
+ }
+
+ //鍒ゆ柇涓�涓嬶紝杩欎釜閫夐」缁撴灉鏄笉鏄繕鏈夌户缁棶涓嬪幓鐨勫繀瑕侊紝渚嬪閫夐」缁撴灉鏄埆浜轰笉鎯崇户缁洖绛旈棶棰橈紝灏辫缁撴潫鎺�
+ if (chosenOption.getIsEnd() == 1) {
+ redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone());
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "noVoice");
+ //鍦╮edis涓繚瀛樹竴涓嬬粨鏉熻锛屽湪璋冪敤鎸傜數璇濈殑鏂规硶鏃跺垹闄�
+ ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+ redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", serviceTask.getJsy(), 120, TimeUnit.MINUTES);
+ phoneCallBackYQVO.setType("text");
+ phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + serviceTask.getJsy());
+ //璁板綍鐘舵��
+ setFailPreachForm(serviceSubtask, "3", "鐢佃瘽鎷ㄦ墦宸插畬鎴�", "9");
+ return phoneCallBackYQVO;
+ }
+
+ flag = 1;
+ //灏嗗綋鍓嶅墠鐨勬挱鎶ョ姸鎬佸垹闄わ紝缁欎笅涓�棰樿浣�
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
+// //鑾峰彇涓嬩竴棰�
+ 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 = chosenOption.getNextQuestion();
+ //鏇存柊鍒嗘暟
+ double score = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
+ score = BigDecimal.valueOf(score).add(chosenOption.getScore()).doubleValue();
+ redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score);
+ } else {
+ nextQuestion = ivrTaskTemplateScriptVO.getNextScriptno();
+ //鏇存柊鍒嗘暟
+ 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(chosenOption.getScore()).doubleValue();
+ redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "SCORE", score, 120, TimeUnit.MINUTES);
+ }
+ if (nextQuestion == null || nextQuestion == 0L) {
+ //濡傛灉涓嬩竴棰樹负绌猴紝鎴栬�呬负0锛屽垯鎸傛満
+ ServiceSubtask ss = new ServiceSubtask();
+ ss.setId(serviceSubtask.getId());
+ ss.setSendstate(6L);
+ ss.setRemark("鐢佃瘽鎷ㄦ墦宸插畬鎴�");
+ serviceSubtaskMapper.updateServiceSubtask(ss);
+ //璁板綍鐘舵��
+ setFailPreachForm(serviceSubtask, "3", "鐢佃瘽鎷ㄦ墦宸插畬鎴�", "9");
+
+ redisCache.deleteObject(serviceSubtask.getId() + "-" + serviceSubtask.getPhone());
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "SCORE");
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "PlayEventCallbackPlaystop");
+ redisCache.deleteObject(phoneCallReqYQVO.getUuid() + "noVoice");
+ //鍦╮edis涓繚瀛樹竴涓嬬粨鏉熻锛屽湪璋冪敤鎸傜數璇濈殑鏂规硶鏃跺垹闄�
+ ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+ redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", serviceTask.getJsy(), 120, TimeUnit.MINUTES);
+ phoneCallBackYQVO.setType("text");
+ phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + serviceTask.getJsy());
+ //灏嗙粨鏋滃啓杩沝etail琛�
+ ServiceSubTaskDetailReq ssdReq = new ServiceSubTaskDetailReq();
+ List<ServiceSubtaskDetail> serviceSubtaskDetailList2 = new ArrayList<>();
+ serviceSubtaskDetailList.add(getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate));
+ serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList2);
+ ssdReq.setGuid(phoneCallReqYQVO.getGuid());
+ ssdReq.setOrgid(phoneCallReqYQVO.getOrgid());
+ saveQuestionAnswerPhone(ssdReq);
+ return phoneCallBackYQVO;
+ }
+
+ for (IvrTaskTemplateScript script : ivrTaskTemplateScripts) {
+ if (script.getSort() == nextQuestion.intValue()) {
+ phoneCallBackYQVO.setType("text");
+ phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
+ String scriptContent = StringUtils.isNotEmpty(script.getIvrtext()) ? script.getIvrtext() : script.getScriptContent();
+ log.error("涓嬩竴棰橀棶棰橈細{}", scriptContent);
+ log.error("涓嬩竴棰樼殑瀛愪换鍔℃槸锛歿}", serviceSubtask);
+ phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + getObject(serviceSubtask, scriptContent));
+ //灏嗚鎮h�呯殑Redis涓殑棰樼洰ID锛岃繘琛屼慨鏀�
+ redisCache.setCacheObject(phoneCallReqYQVO.getTaskid().trim() + "-" + phoneCallReqYQVO.getPhone().trim(), script.getId().toString(), 120, TimeUnit.MINUTES);
+ //鍒犻櫎鏃犲搷搴�
+ redisCache.deleteObject(phoneCallReqYQVO.getTaskid().trim() + "&&" + "mate" + "&&" + phoneCallReqYQVO.getUuid());
+ }
+ }
+ } else if (ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getNextScriptno() == 0) {
+ ServiceTask serviceTask1 = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+ phoneCallBackYQVO.setType("text");
+ phoneCallBackYQVO.setSilent_interval(ivrTaskTemplate.getSilencetime().intValue());
+ //鏇存柊涓�涓嬪垎鏁�
+ double score = 0.0;
+ Object scoreObj = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "SCORE");
+ if (ObjectUtils.isNotEmpty(scoreObj)) score = (double) scoreObj;
+ serviceSubtask.setScore(BigDecimal.valueOf(score));
+ serviceSubtask.setFinishtime(new Date());
+ serviceSubtask.setSendstate(6L);
+ serviceSubtask.setRemark("鐢佃瘽鎷ㄦ墦宸插畬鎴�");
+ serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
+ //璁板綍鐘舵��
+ setFailPreachForm(serviceSubtask, "3", "鐢佃瘽鎷ㄦ墦宸插畬鎴�", "9");
+ //璁剧疆缁撴潫璇�
+ phoneCallBackYQVO.setValue(phoneCallBackYQVO.getCommonValue() + serviceTask1.getJsy());
+ Long id = serviceSubtask.getId();
+ Map<String, String> map = delRedisValue(null, id.toString());
+ log.error("map鐨勫�间负锛歿}", map);
+ if (ObjectUtils.isNotEmpty(map))
+ redisCache.setCacheObject(map.get("cacheName"), map.get("val"));
+ 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涓繚瀛樹竴涓嬬粨鏉熻锛屽湪璋冪敤鎸傜數璇濈殑鏂规硶鏃跺垹闄�
+ ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+ redisCache.setCacheObject(phoneCallReqYQVO.getUuid() + "- jsy", serviceTask.getJsy(), 120, TimeUnit.MINUTES);
+// return phoneCallBackYQVO;
+
+ }
+ } else {
+ log.info("娌℃湁鍖归厤涓�----------------------------");
+ //flag=0,璇存槑娌� 鍖归厤涓婏紝涔熻鎶婃偅鑰呰鐨勮瘽璁板綍涓嬫潵
+ if (matched == ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().size() - 1 && flag == 0) {
+ ServiceSubTaskDetailReq serviceSubTaskDetailReq = new ServiceSubTaskDetailReq();
+ List<ServiceSubtaskDetail> serviceSubtaskDetailList = new ArrayList<>();
+ ServiceSubtaskDetail serviceSubtaskDetail = getServiceSubtaskDetail(phoneCallReqYQVO, ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate);
+ //淇敼涓�涓嬭闊宠矾寰勶紙鏀规垚鍓嶇鍙互璁块棶鐨勶紝瀛樺埌鏁版嵁搴撲腑锛�
+ if (StringUtils.isNotEmpty(serviceSubtaskDetail.getQuestionvoice())) {
+ String questionvoice = serviceSubtaskDetail.getQuestionvoice();
+ String[] split = questionvoice.split("\\\\");
+ if (split.length > 0) {
+ String lastPart = split[split.length - 1];
+ serviceSubtaskDetail.setQuestionvoice(voicePathPrefix + lastPart);
+ }
+ }
+ serviceSubtaskDetailList.add(serviceSubtaskDetail);
+ //濡傛灉娌℃湁 鍖归厤涓婏紝杩欎釜蹇呴』涓簄ull
+ serviceSubtaskDetailList.get(0).setMatchedtext("");
+ serviceSubTaskDetailReq.setServiceSubtaskDetailList(serviceSubtaskDetailList);
+ serviceSubTaskDetailReq.setGuid(phoneCallReqYQVO.getGuid());
+ serviceSubTaskDetailReq.setOrgid(phoneCallReqYQVO.getOrgid());
+ saveQuestionAnswerPhone(serviceSubTaskDetailReq);
+ }
+ }
+ return back;
+ }
+
+ @Test
+ public void TestMatch(){
+ String questionText = "鎮ㄥソ,璇烽棶鎮ㄦ槸鎮h�呮湰浜鸿繕鏄灞烇紵\n";
+ String voiceText = "鎴戣嚜宸�";
+ Long scriptid = 31231L;
+ List<IvrTaskTemplateTargetoption> options = new ArrayList<>();
+ IvrTaskTemplateTargetoption ivrTaskTemplateTargetoption1 = new IvrTaskTemplateTargetoption();
+ ivrTaskTemplateTargetoption1.setTargetvalue("鏈汉");
+ options.add(ivrTaskTemplateTargetoption1);
+ IvrTaskTemplateTargetoption ivrTaskTemplateTargetoption2 = new IvrTaskTemplateTargetoption();
+ ivrTaskTemplateTargetoption2.setTargetvalue("瀹跺睘");
+ options.add(ivrTaskTemplateTargetoption2);
+ IvrTaskTemplateTargetoption ivrTaskTemplateTargetoption3 = new IvrTaskTemplateTargetoption();
+ ivrTaskTemplateTargetoption3.setTargetvalue("鍏朵粬");
+ options.add(ivrTaskTemplateTargetoption3);
+ matchOptionIndex(questionText,voiceText,options);
+ }
}
--
Gitblit v1.9.3