From 717abbe819892d3cded73b12772b216b48d7e357 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 29 七月 2026 14:55:14 +0800
Subject: [PATCH] 【丽水】宣教超链接跳转调整
---
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java | 469 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 428 insertions(+), 41 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 46958c5..dffe37f 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -13,9 +13,12 @@
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.core.service.IConfigService;
+import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper;
+import com.ruoyi.system.service.ISysConfigService;
+import com.smartor.common.DeepSeekApi;
import com.smartor.common.FtpService;
import com.smartor.common.MtSubmitSmUtil;
import com.smartor.config.PhoneUtils;
@@ -31,6 +34,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;
@@ -38,17 +42,17 @@
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;
import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.ZoneId;
+import java.time.*;
import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
@@ -144,6 +148,9 @@
@Value("${ASRCallBackPath}")
private String ASRCallBackPath;
+
+ @Autowired
+ private ISysConfigService configService;
@Autowired
private MtSubmitSmUtil mtSubmitSmUtil;
@@ -417,9 +424,74 @@
serviceSubtaskRes.setCurrentPreachform(serviceSubtask.getPreachform().split(",")[0]);
}
}
+ PatMedInhosp inhosp = patMedInhospMapper.selectPatMedInhospByInhospid(serviceSubtask.getInhospid());
+ if (ObjectUtils.isNotEmpty(inhosp)) {
+ PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(inhosp.getPatid());
+ if (ObjectUtils.isNotEmpty(patArchive)) {
+ Map<String, String> stringStringMap = calculateAge(patArchive.getBirthdate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now());
+ serviceSubtaskRes.setAge(StringUtils.isNotEmpty(stringStringMap.get("age")) ? Long.valueOf(stringStringMap.get("age")) : null);
+ serviceSubtaskRes.setSex(patArchive.getSex());
+ serviceSubtaskRes.setSexName(patArchive.getSex() != null ? (patArchive.getSex() == 1 ? "鐢�" : "濂�") : null);
+ }
+ serviceSubtaskRes.setHospno(inhosp.getInhospno());
+ serviceSubtaskRes.setPatno(inhosp.getPatno());
+ }
+
serviceSubtaskResList.add(serviceSubtaskRes);
}
return serviceSubtaskResList;
+ }
+
+ public Map<String, String> calculateAge(LocalDate birthdate, LocalDate today) {
+ if (birthdate == null || today.isBefore(birthdate)) {
+ return null;
+ }
+ Map<String, String> ageMap = new HashMap<>();
+
+ Period period = Period.between(birthdate, today);
+ long totalDays = ChronoUnit.DAYS.between(birthdate, today);
+ long totalMonths = ChronoUnit.MONTHS.between(birthdate, today);
+
+ int years = period.getYears();
+ int months = period.getMonths();
+ int days = period.getDays();
+
+ String ageUnit;
+ Integer age;
+ String ageUnit2 = null;
+ Integer age2 = null;
+
+ if (totalDays < 90) {
+ // 灏忎簬 1 涓湀锛屾寜澶╄绠�
+ ageUnit = "澶�";
+ age = (int) totalDays;
+ ageMap.put("age", age != null ? age.toString() : null);
+ ageMap.put("ageUnit", ageUnit);
+ ageMap.put("age2", null);
+ ageMap.put("ageUnit2", null);
+ } else if (totalMonths < 36) {
+ // 灏忎簬 1 骞达紝鎸夋湀 + 澶╄绠�
+ ageUnit = "鏈�";
+ age = (int) totalMonths;
+ ageUnit2 = "澶�";
+ age2 = days;
+ ageMap.put("age", age != null ? age.toString() : null);
+ ageMap.put("ageUnit", ageUnit);
+ ageMap.put("age2", age2 != null ? age2.toString() : null);
+ ageMap.put("ageUnit2", ageUnit2);
+ } else {
+ // 澶т簬 1 骞达紝鎸夊勾 + 鏈堣绠�
+ ageUnit = "宀�";
+ age = years;
+ ageUnit2 = "鏈�";
+ age2 = months;
+ ageMap.put("age", age != null ? age.toString() : null);
+ ageMap.put("ageUnit", ageUnit);
+ ageMap.put("age2", age2 != null ? age2.toString() : null);
+ ageMap.put("ageUnit2", ageUnit2);
+ }
+
+ return ageMap;
}
@Override
@@ -591,9 +663,16 @@
ServiceSubtask serviceSubtask = serviceSubtaskMapper.selectServiceSubtaskById(serviceSubtaskTemplateVO.getSubId());
if (serviceSubtask == null || serviceSubtask.getSendstate() != 2L)
throw new BaseException("璇ヤ换鍔″凡鍙戦�佺粰鎮h�咃紝涓嶈兘鍐嶈繘琛屼慨鏀规ā鏉�");
-
+ serviceSubtaskTemplateVO.getSvyTaskTemplateVO().setIntroduce("璇ラ棶鍗锋槸鏇挎崲鍚庣殑闂锛屾浛鎹㈠墠鐨勯棶棰樻槸锛�" + serviceSubtask.getTemplateid());
Integer taskTempid = svyTaskTemplateService.saveOrUpdateTemplate(serviceSubtaskTemplateVO.getSvyTaskTemplateVO());
if (taskTempid == null) return false;
+
+ //姣忔閮芥柊寤轰竴涓篃鍙互锛屼絾鏂板缓涔嬪悗瑕佹妸涔嬪墠鐨勫垹闄�
+ if (serviceSubtask.getType().equals("2")) {
+ svyTaskTemplateService.deleteSvyTaskTemplateBySvyid(serviceSubtask.getTemplateid());
+ } else if (serviceSubtask.getType().equals("1"))
+ ivrTaskTemplateService.deleteIvrTaskTemplateByID(serviceSubtask.getTemplateid());
+
String tempName = svyTaskTemplateService.selectSvyTaskTemplateBySvyid(Long.valueOf(taskTempid)).getSvyname();
serviceSubtask.setTemplateid(taskTempid.longValue());
@@ -1660,12 +1739,28 @@
if (ivrTaskTemplateScriptVO.getScriptType().equals("1")) {
//鐢ㄦ潵鏍囪锛屾槸鍚︽湁鍖归厤涓婄殑
Integer flag = 0;
+ //1-AI璇嗗埆
+ SysConfig configVoiceMatchAi = new SysConfig();
+ configVoiceMatchAi.setOrgid(phoneCallReqYQVO.getOrgid());
+ configVoiceMatchAi.setConfigKey("sys.voice.match.ai");
+ SysConfig matchAi = sysConfigMapper.selectConfig(configVoiceMatchAi);
+
+ if (ObjectUtils.isNotEmpty(matchAi) && StringUtils.isNotEmpty(matchAi.getConfigValue())
+ && matchAi.getConfigValue().equals("1")) {
+ PhoneCallBackYQVO aiMatchResult = AiMatch(phoneCallReqYQVO, phoneCallBackYQVO,
+ ivrTaskTemplateScriptVO, serviceSubtask, ivrTaskTemplate,
+ ivrTaskTemplateScripts, scriptId, flag, phoneCallReqYQVO.getUuid());
+ 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;
}
+ boolean matchedFlag = false;
//鍖呭惈
Matcher matcher = null;
if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex())) {
@@ -1678,8 +1773,12 @@
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()) {
- //璇存槑鍖归厤姝g‘浜�
+ matchedFlag = true;
+ }
+ //璇存槑鍖归厤姝g‘浜�
+ if(matchedFlag){
//杩欓噷搴旇鍏堝垽鏂被鍨嬶紝鍘诲啀淇敼锛岃缃甀sUserOperation鏄崟閫夐鐨勬敼娉�
log.info("鍖归厤姝g‘浜嗗悧--------------");
ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).setIsUserOperation(1);
@@ -1896,6 +1995,7 @@
continue;
}
}
+ }
//閮芥病鏈夊尮閰嶅埌
if (StringUtils.isEmpty(phoneCallBackYQVO.getValue())) {
log.info("閮芥病鏈夊尮閰嶅埌-------------------------");
@@ -2517,16 +2617,21 @@
@Cacheable(value = "sfStatistics", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#serviceSubtaskCountReq.toString().getBytes())", unless = "#result == null or #result.isEmpty()")
public List<ServiceSubtaskStatistic> getSfStatistics(ServiceSubtaskCountReq serviceSubtaskCountReq) {
log.info("getSfStatistics鐨勫叆鍙備负锛歿}", serviceSubtaskCountReq);
- String groupKey = "drcode";
+ String drcode = "drcode";
+ //缂欎簯浜烘皯 鏍规嵁缁忕鍖荤敓鍒嗙粍
+ if(serviceSubtaskCountReq.getOrgid().equals("47246116333112211A1001")){
+ drcode = "management_doctor_code";
+ }
+ String groupKey = drcode;
if (serviceSubtaskCountReq.getStatisticaltype() != null && serviceSubtaskCountReq.getStatisticaltype() == 1) {
if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
- groupKey = "drcode";
+ groupKey = drcode;
} else {
groupKey = "leavehospitaldistrictcode";
}
} else if (serviceSubtaskCountReq.getStatisticaltype() != null && serviceSubtaskCountReq.getStatisticaltype() == 2) {
if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) {
- groupKey = "drcode";
+ groupKey = drcode;
} else {
groupKey = "deptcode";
}
@@ -2539,11 +2644,14 @@
serviceSubtaskCountReq.setGroupKeyList(groupKeyList);
List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq);
switch (groupKey) {
- case "deptcode":
- collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptcode()).orElse("Unknown")));
- break;
case "drcode":
collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDrcode()).orElse("Unknown")));
+ break;
+ case "management_doctor_code":
+ collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getManagementDoctorCode()).orElse("Unknown")));
+ break;
+ case "deptcode":
+ collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getDeptcode()).orElse("Unknown")));
break;
case "leavehospitaldistrictcode":
collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeavehospitaldistrictcode()).orElse("Unknown")));
@@ -4544,9 +4652,9 @@
}
@Override
- public List<ServiceSubtask> gethelibraryCountHyperlink(HeLibraryCountVO heLibraryCountVO){
+ public List<ServiceSubtask> gethelibraryCountHyperlink(HeLibraryCountVO heLibraryCountVO) {
String hyperLinkInfoType = heLibraryCountVO.getHyperLinkInfoType();
- if(StringUtils.isNotEmpty(hyperLinkInfoType)){
+ if (StringUtils.isNotEmpty(hyperLinkInfoType)) {
heLibraryCountVO.setSendstate(null);
heLibraryCountVO.setIsFinished(null);
switch (hyperLinkInfoType) {
@@ -4769,19 +4877,19 @@
}
}
- public String scanGenerateSubtask(ServiceTask serviceTaskVo){
+ public String scanGenerateSubtask(ServiceTask serviceTaskVo) {
String content = "";
String ip = localIP;
ServiceTask serviceTask = new ServiceTask();
serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceTaskVo.getTaskid());
- if(ObjectUtils.isNotEmpty(serviceTask)){
+ if (ObjectUtils.isNotEmpty(serviceTask)) {
try {
ServiceTaskdept serviceTaskdept = new ServiceTaskdept();
- if(ObjectUtils.isNotEmpty(serviceTaskVo.getDeptcode())){
+ if (ObjectUtils.isNotEmpty(serviceTaskVo.getDeptcode())) {
serviceTaskdept.setDeptType("1");
- serviceTaskdept.setDeptCode(serviceTask.getDeptcode());
+ serviceTaskdept.setDeptCode(serviceTaskVo.getDeptcode());
}
- if(ObjectUtils.isNotEmpty(serviceTaskVo.getLeavehospitaldistrictcode())){
+ if (ObjectUtils.isNotEmpty(serviceTaskVo.getLeavehospitaldistrictcode())) {
serviceTaskdept.setDeptType("2");
serviceTaskdept.setDeptCode(serviceTaskVo.getLeavehospitaldistrictcode());
}
@@ -4791,27 +4899,14 @@
List<ServiceTaskdept> serviceTaskdepts = serviceTaskdeptService.selectServiceTaskdeptList(serviceTaskdept);
if (!CollectionUtils.isEmpty(serviceTaskdepts)) {
- ServiceTaskdept serviceTaskdept1 = serviceTaskdepts.get(0);
- PatArchive patArchiveVo = new PatArchive();
- patArchiveVo.setViptype("-1");
- List<PatArchive> patArchives = patArchiveMapper.selectPatArchiveList(patArchiveVo);
PatArchive patArchive = new PatArchive();
- if(!ObjectUtils.isNotEmpty(patArchives)){
- PatArchive newPatArchive = new PatArchive();
- newPatArchive.setPatientno("00000000");
- newPatArchive.setName("铏氭嫙鎮h��");
- patArchiveMapper.insertPatArchiveSingle(newPatArchive);
- patArchive = newPatArchive;
- }else {
- patArchive = patArchives.get(0);
- }
+ patArchive.setId(999999999L);
+ patArchive.setName("铏氭嫙鎮h��");
//灏佽serviceSubtask
- ServiceSubtask serviceSubtask = boxedServiceSubtask(serviceTask, patArchive);
+ ServiceSubtask serviceSubtask = boxedServiceSubtask(serviceTask, serviceTaskdepts.get(0), patArchive);
int i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
//鏍规嵁鐢熸垚澶栭摼
- if (ObjectUtils.isNotEmpty(serviceSubtask.getTaskid()) &&
- ObjectUtils.isNotEmpty(serviceSubtask.getPatid())
- && ObjectUtils.isNotEmpty(serviceSubtask.getId())) {
+ if (ObjectUtils.isNotEmpty(serviceSubtask.getTaskid()) && ObjectUtils.isNotEmpty(serviceSubtask.getPatid()) && ObjectUtils.isNotEmpty(serviceSubtask.getId())) {
RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
String taskId = rsaPublicKeyExample.encryptedData(serviceSubtask.getTaskid().toString(), pub_key);
String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key);
@@ -4842,7 +4937,7 @@
return content;
}
- public ServiceSubtask boxedServiceSubtask(ServiceTask serviceTask, PatArchive patArchive) {
+ public ServiceSubtask boxedServiceSubtask(ServiceTask serviceTask, ServiceTaskdept serviceTaskdept, PatArchive patArchive) {
ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTask, ServiceSubtask.class);
serviceSubtask.setTaskid(serviceTask.getTaskid());
if (StringUtils.isNotEmpty(serviceTask.getLibtemplateid()))
@@ -4851,10 +4946,13 @@
// serviceSubtask.setNurseName(patMedInhosp1.getNurseName());
// serviceSubtask.setDrcode(patMedInhosp1.getDrcode());
// serviceSubtask.setDrname(patMedInhosp1.getDrname());
- serviceSubtask.setDeptcode(serviceTask.getDeptcode());
- serviceSubtask.setDeptname(serviceTask.getDeptname());
- serviceSubtask.setLeavehospitaldistrictcode(serviceTask.getLeavehospitaldistrictcode());
- serviceSubtask.setLeavehospitaldistrictname(serviceTask.getLeavehospitaldistrictname());
+ if(StringUtils.isNotEmpty(serviceTaskdept.getDeptType()) && serviceTaskdept.getDeptType().equals("1")){
+ serviceSubtask.setDeptcode(serviceTaskdept.getDeptCode());
+ serviceSubtask.setDeptname(serviceTaskdept.getDeptName());
+ }else {
+ serviceSubtask.setLeavehospitaldistrictcode(serviceTaskdept.getDeptCode());
+ serviceSubtask.setLeavehospitaldistrictname(serviceTaskdept.getDeptName());
+ }
serviceSubtask.setTemplateid(serviceTask.getTemplateid());
serviceSubtask.setTemplatename(serviceTask.getTemplatename());
serviceSubtask.setPatid(patArchive.getId());
@@ -4883,4 +4981,293 @@
serviceSubtask.setVisitTime(newDate);
return serviceSubtask;
}
+
+ /**
+ * Ai 鍖归厤閫夐」
+ * @param questionText
+ * @param voiceText
+ * @param options
+ * @return
+ */
+ public Integer matchOptionIndex(String questionText, String voiceText, List<IvrTaskTemplateTargetoption> options, String uuid){
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("userQuestion",questionText);
+ jsonObject.put("userAnswer",voiceText);
+ jsonObject.put("options", options);
+ jsonObject.put("uuid", uuid);
+ String jsonString = jsonObject.toJSONString();
+ String result = null;
+
+ String url = "http://localhost:8099/matchOptionIndex";
+// String url = configService.selectConfigByKey("sys.voice.match.ai.url");
+ if(StringUtils.isNotEmpty(url)){
+ try {
+ Map<String, String> headers = new HashMap<>();
+ headers.put("Content-Type", "application/json");
+
+ result = HttpUtils.sendPostByHeader(url, jsonString, headers);
+ } catch (Exception e) {
+ log.error("AI璇嗗埆澶辫触", e);
+ }
+ }
+ if(StringUtils.isNotEmpty(result) && result.matches("^-?\\d+$")){
+ return Integer.parseInt(result);
+ }else {
+ return -1;
+ }
+ }
+
+ public PhoneCallBackYQVO AiMatch(PhoneCallReqYQVO phoneCallReqYQVO, PhoneCallBackYQVO phoneCallBackYQVO,
+ IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO, ServiceSubtask serviceSubtask, IvrTaskTemplate ivrTaskTemplate,
+ List<IvrTaskTemplateScript> ivrTaskTemplateScripts, String scriptId, Integer flag, String uuid){
+ PhoneCallBackYQVO back = null;
+ List<IvrTaskTemplateTargetoption> options = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList();
+ String voiceText = phoneCallReqYQVO.getAsrtext();
+ String questionText = StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrtext()) ? ivrTaskTemplateScriptVO.getIvrtext() : ivrTaskTemplateScriptVO.getScriptContent();
+ Integer matched = -1;
+ matched = matchOptionIndex(questionText, voiceText, options, uuid);
+ //璇存槑鍖归厤姝g‘浜�
+ if(matched != null && matched >= 0){
+ IvrTaskTemplateTargetoption chosenOption = options.get(matched);
+ //杩欓噷搴旇鍏堝垽鏂被鍨嬶紝鍘诲啀淇敼锛岃缃甀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 = "鎴戣嚜宸�";
+ String matchedText = "";
+ 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);
+
+ Integer matched = matchOptionIndex(questionText,voiceText,options,"1");
+ if(ObjectUtils.isNotEmpty(matched)){
+ if(matched >= 0){
+ matchedText = options.get(matched).getTargetvalue();
+ }
+ }
+ log.info("ai鍖归厤鎴愬姛锛屽尮閰嶇粨鏋滄槸:" + matchedText);
+ }
}
--
Gitblit v1.9.3