From 035108ae9d6ea2c2daa860921f296fda02a8e410 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 02 九月 2026 10:42:25 +0800
Subject: [PATCH] 1.满意度导出BUG处理 2.三汇电话接口部分 3.外链可以通过subid查询到
---
smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java | 233 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 215 insertions(+), 18 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 8dbae00..0588017 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -8,10 +8,10 @@
import com.google.gson.Gson;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.core.service.IConfigService;
import com.ruoyi.common.dx.MessageSend;
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;
@@ -33,6 +33,7 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
+import org.checkerframework.checker.nullness.qual.NonNull;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -41,10 +42,8 @@
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;
@@ -204,6 +203,8 @@
@Value("${spring.profiles.active}")
private String active;
+ @Autowired
+ private ServiceOutPathMapper serviceOutPathMapper;
/**
* 鏌ヨ鍗曚竴浠诲姟锛堥殢璁匡級
@@ -628,9 +629,42 @@
*/
@Override
public Map<String, Object> insertServiceSubtask(ServiceSubtask serviceSubtask) {
- serviceSubtask.setCreateTime(DateUtils.getNowDate());
- serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
+ //鍏堟煡璇竴涓嬭鎮h�呮槸鍚﹀凡缁忓垱寤烘牴鎹畇erviceType,sendstate,inhospid,patid,orgid
+ ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity();
+ serviceSubtaskVO.setServiceType(serviceSubtask.getServiceType());
+ serviceSubtaskVO.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 5L, 7L)));
+ serviceSubtaskVO.setPatid(serviceSubtask.getPatid());
+ serviceSubtaskVO.setOrgid(serviceSubtask.getOrgid());
+ serviceSubtaskVO.setCampusid(serviceSubtask.getCampusid());
+ List<ServiceSubtask> serviceSubtasks = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO);
RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
+ String format = null;
+ if (CollectionUtils.isNotEmpty(serviceSubtasks)) {
+ ServiceSubtask serviceSubtask1 = serviceSubtasks.get(0);
+ ServiceOutPath serviceOutPath = new ServiceOutPath();
+ serviceOutPath.setSubId(serviceSubtask1.getId());
+ List<ServiceOutPath> serviceOutPaths = serviceOutPathMapper.selectServiceOutPathList(serviceOutPath);
+ if (CollectionUtils.isNotEmpty(serviceOutPaths))
+ format = String.format("%03X", serviceOutPaths.get(0).getId());
+ else format = getOutPath(serviceSubtask1, rsaPublicKeyExample);
+ serviceSubtask = serviceSubtask1;
+ } else {
+ //濡傛灉涓嶅瓨鍦紝鍒欐柊澧�
+ serviceSubtask.setCreateTime(DateUtils.getNowDate());
+ serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
+ format = getOutPath(serviceSubtask, rsaPublicKeyExample);
+ }
+
+ Map<String, Object> result = new HashMap<>();
+ if (StringUtils.isNotEmpty(format))
+ result.put("url", StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/wt?p=" + format : localIP + "/wt?p=" + format);
+ else result.put("url", null);
+ result.put("subId", serviceSubtask.getId());
+ return result;
+ }
+
+ private String getOutPath(ServiceSubtask serviceSubtask, RSAPublicKeyExample rsaPublicKeyExample) {
+ String format;
String taskId = rsaPublicKeyExample.encryptedData(serviceSubtask.getTaskid().toString(), pub_key);
String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key);
String subId = rsaPublicKeyExample.encryptedData(serviceSubtask.getId().toString(), pub_key);
@@ -640,17 +674,15 @@
serviceOutPath.setCreateTime(new Date());
serviceOutPath.setParam6(subId);
serviceOutPath.setOrgid(serviceSubtask.getOrgid());
+ serviceOutPath.setTaskId(serviceSubtask.getTaskid());
+ serviceOutPath.setSubId(serviceSubtask.getId());
iServiceOutPathService.insertServiceOutPath(serviceOutPath);
//杞垚16杩涘埗
- String format = String.format("%03X", serviceOutPath.getId());
+ format = String.format("%03X", serviceOutPath.getId());
serviceOutPath.setRadix(format);
serviceOutPath.setUpdateTime(new Date());
iServiceOutPathService.updateServiceOutPath(serviceOutPath);
-
- Map<String, Object> result = new HashMap<>();
- result.put("url", StringUtils.isNotEmpty(req_path) ? localIP + ":" + req_path + "/wt?p=" + format : localIP + "/wt?p=" + format);
- result.put("subId", serviceSubtask.getId());
- return result;
+ return format;
}
/**
@@ -1071,8 +1103,7 @@
}
}
- }
- else if (serviceTaskVO.getIsoperation() != null && serviceTaskVO.getIsoperation() == 2) {
+ } else if (serviceTaskVO.getIsoperation() != null && serviceTaskVO.getIsoperation() == 2) {
//浠诲姟淇敼
if (ObjectUtils.isNotEmpty(serviceTaskVO.getSendTimeslot()))
serviceTask.setSendTimeSlot(JSON.toJSONString(serviceTaskVO.getSendTimeslot()));
@@ -4941,6 +4972,16 @@
return serviceSubtaskMapper.statQuestionOption(taskIds, startOutHospTime, endOutHospTime);
}
+ @Override
+ public List<ServiceSubtaskDetailRatioExport> statQuestionOptionBySubtaskIds(List<Long> subtaskIds, Date startOutHospTime, Date endOutHospTime) {
+ //鍏堟竻鐞嗕竴涓嬮噸澶嶆暟鎹�
+ List<Long> repeatIds = serviceSubtaskDetailMapper.selectRepeatDetailIds();
+ if (!CollectionUtils.isEmpty(repeatIds)) {
+ serviceSubtaskDetailMapper.deleteRepeatDetailByIds(repeatIds);
+ }
+ return serviceSubtaskMapper.statQuestionOptionBySubtaskIds(subtaskIds, startOutHospTime, endOutHospTime);
+ }
+
/**
* 鏍囧噯鍖栭棶鍗风瓟妗堟枃鏈細鍘绘帀 A/B/C/D 鍗曞瓧姣嶅墠缂�鍜屽悗缁┖鏍�
* 渚嬪 "A 鏄�" -> "鏄�"锛�"B 鍚�" -> "鍚�"
@@ -5225,7 +5266,7 @@
String jsonString = jsonObject.toJSONString();
String result = null;
-// String url = "http://localhost:8099/matchOptionIndex";
+// String url = "cc";
if (StringUtils.isNotEmpty(url)) {
try {
Map<String, String> headers = new HashMap<>();
@@ -5242,6 +5283,163 @@
return -1;
}
}
+
+
+ public PhoneCallBackSHVO getFirstQues(PhoneCallReqYQVO phoneCallReqYQVO) {
+ //鐢ㄤ簬杩斿洖
+ PhoneCallBackSHVO phoneCallBackSHVO = new PhoneCallBackSHVO();
+
+ //鏍规嵁鎵嬫満鍙疯幏鍙栫敤鎴风殑鐨勫瓙浠诲姟淇℃伅
+ ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity();
+ serviceSubtaskVO.setPhone(phoneCallReqYQVO.getPhone());
+ serviceSubtaskVO.setType("1");
+ serviceSubtaskVO.setSendstate(2L);
+ List<ServiceSubtask> serviceSubtasks = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO);
+ if (CollectionUtils.isNotEmpty(serviceSubtasks)) {
+ ServiceSubtask serviceSubtask = serviceSubtasks.get(0);
+ IvrTaskTemplate ivrTaskTemplate = ivrTaskTemplateService.selectIvrTaskTemplateByID(serviceSubtask.getTemplateid());
+
+ //閫氳繃浠诲姟妯℃澘涓殑"绗竴娆¢棶棰樼紪鍙�"鑾峰彇绗竴涓棶棰�;
+ IvrTaskTemplateScript ivrTaskTemplateScript = null;
+ IvrTaskTemplateScript ivrTaskTemplateScript1 = new IvrTaskTemplateScript();
+ ivrTaskTemplateScript1.setTemplateID(ivrTaskTemplate.getId());
+ List<IvrTaskTemplateScript> ivrTaskTemplateScripts = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptList(ivrTaskTemplateScript1);
+
+ for (IvrTaskTemplateScript ivrTaskTemplateScript2 : ivrTaskTemplateScripts) {
+ if (ivrTaskTemplate.getFirstQuestionNum() == Long.valueOf(ivrTaskTemplateScript2.getSort())) {
+ ivrTaskTemplateScript = ivrTaskTemplateScript2;
+ break;
+ }
+ }
+ //鑾峰彇寮�鍦虹櫧
+ ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+
+ phoneCallBackSHVO.setSubId(serviceSubtask.getId());
+ phoneCallBackSHVO.setScriptId(ivrTaskTemplateScript.getId());
+ phoneCallBackSHVO.setSort(ivrTaskTemplateScript.getSort());
+ phoneCallBackSHVO.setTaskTemplateid(ivrTaskTemplateScript.getTemplateID());
+ phoneCallBackSHVO.setScriptContent(serviceTask.getKcb() + "," + ivrTaskTemplateScript.getScriptContent());
+ }
+ return phoneCallBackSHVO;
+ }
+
+
+ /**
+ * 涓夋眹ASR缁撴灉澶勭悊
+ *
+ * @param phoneCallResultYQVO
+ * @return
+ */
+ public PhoneCallBackSHVO processResust(PhoneCallResultYQVO phoneCallResultYQVO) {
+ PhoneCallBackSHVO phoneCallBackSHVO = new PhoneCallBackSHVO();
+ //閫氳繃scriptid锛岃幏鍙栨墍鏈夌殑缁撴灉
+ String url = configService.selectConfigByKey("sys.voice.match.ai.url", phoneCallResultYQVO.getOrgid());
+ ServiceSubtask serviceSubtask = serviceSubtaskMapper.selectServiceSubtaskById(phoneCallResultYQVO.getSubId());
+ IvrTaskTemplate ivrTaskTemplate = ivrTaskTemplateService.selectIvrTaskTemplateByID(serviceSubtask.getTemplateid());
+ IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO = iIvrTaskTemplateScriptService.getTaskTempScriptInfoByid(Long.valueOf(phoneCallResultYQVO.getScriptId()));
+ Integer i = matchOptionIndex(url, phoneCallResultYQVO.getScriptContent(), phoneCallResultYQVO.getAsrResult(), ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList(), phoneCallResultYQVO.getUuid());
+ if (i >= 0) {
+ String optiondesc = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(i).getOptiondesc();
+ //灏嗘偅鑰呯殑鍥炵瓟鍐欒繘service_subtask_detail涓�
+ ServiceSubTaskDetailReq serviceSubTaskDetailReq = new ServiceSubTaskDetailReq();
+ List<ServiceSubtaskDetail> serviceSubtaskDetailList = new ArrayList<>();
+ ivrTaskTemplateScriptVO.setQuestionResult(optiondesc);
+
+ PhoneCallReqYQVO phoneCallReqYQVO = new PhoneCallReqYQVO();
+ phoneCallReqYQVO.setTaskid("" + serviceSubtask.getId());
+ phoneCallReqYQVO.setPhone(phoneCallResultYQVO.getPhone());
+ phoneCallReqYQVO.setAsrtext(phoneCallResultYQVO.getAsrResult());
+ 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(phoneCallResultYQVO.getGuid());
+ serviceSubTaskDetailReq.setOrgid(phoneCallResultYQVO.getOrgid());
+ saveQuestionAnswerPhone(serviceSubTaskDetailReq);
+
+ IvrTaskTemplateScript ivrTaskTemplateScript = new IvrTaskTemplateScript();
+ ivrTaskTemplateScript.setTemplateID(ivrTaskTemplateScriptVO.getTemplateID());
+ List<IvrTaskTemplateScript> ivrTaskTemplateScripts = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptList(ivrTaskTemplateScript);
+
+ //鑾峰彇涓嬩竴棰�
+ for (IvrTaskTemplateScript script : ivrTaskTemplateScripts) {
+ if (ivrTaskTemplateScriptVO.getNextScriptno() == null || ivrTaskTemplateScriptVO.getNextScriptno() == 0) {
+ ServiceTask serviceTask = serviceTaskService.selectServiceTaskByTaskid(serviceSubtask.getTaskid());
+ phoneCallBackSHVO.setScriptContent(serviceTask.getJsy());
+ phoneCallBackSHVO.setTaskTemplateid(script.getTemplateID());
+ phoneCallBackSHVO.setSort(script.getSort());
+ phoneCallBackSHVO.setScriptId(script.getId());
+ phoneCallBackSHVO.setSubId(serviceSubtask.getId());
+ phoneCallBackSHVO.setStatus("0");
+ } else if (script.getSort() == ivrTaskTemplateScriptVO.getNextScriptno().intValue()) {
+ phoneCallBackSHVO.setScriptContent(script.getScriptContent());
+ phoneCallBackSHVO.setTaskTemplateid(script.getTemplateID());
+ phoneCallBackSHVO.setSort(script.getSort());
+ phoneCallBackSHVO.setScriptId(script.getId());
+ phoneCallBackSHVO.setSubId(serviceSubtask.getId());
+ break;
+ }
+ }
+ //鎶婄紦瀛樻竻闄�
+ redisCache.deleteObject(phoneCallResultYQVO.getSubId() + "-" + phoneCallResultYQVO.getScriptId());
+ } else {
+ //鍐嶅皢閲嶅璇㈤棶
+ //璁板綍涓�涓嬭繖涓棶棰樿闂鐨勬鏁�
+ Object cacheObject = redisCache.getCacheObject(phoneCallResultYQVO.getSubId() + "-" + phoneCallResultYQVO.getScriptId());
+ if (cacheObject == null || (Integer) cacheObject < ivrTaskTemplate.getMateNum()) {
+
+
+ // 鑾峰彇閫夐」闆嗗悎涓殑 optiondesc 鐢ㄤ簬寮曞鎮h��
+ List<IvrTaskTemplateTargetoption> optionList = ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList();
+ String optionDescStr = "";
+ if (optionList != null && !optionList.isEmpty()) {
+ optionDescStr = optionList.stream().map(IvrTaskTemplateTargetoption::getTargetvalue).filter(StringUtils::isNotEmpty).collect(Collectors.joining("鎴�"));
+ }
+
+ String scriptContent = "璇烽棶" + phoneCallResultYQVO.getScriptContent();
+ if (StringUtils.isNotEmpty(optionDescStr)) {
+ scriptContent += "锛屼綘鍙互鍥炵瓟锛�" + optionDescStr;
+ }
+ phoneCallBackSHVO.setScriptContent(scriptContent);
+ phoneCallBackSHVO.setTaskTemplateid(phoneCallResultYQVO.getTaskTemplateid());
+ phoneCallBackSHVO.setSort(phoneCallResultYQVO.getSort());
+ phoneCallBackSHVO.setScriptId(phoneCallResultYQVO.getScriptId());
+ phoneCallBackSHVO.setSubId(phoneCallResultYQVO.getSubId());
+ if (cacheObject == null)
+ redisCache.setCacheObject(phoneCallResultYQVO.getSubId() + "-" + phoneCallResultYQVO.getScriptId(), 1, 120, TimeUnit.MINUTES);
+ else
+ redisCache.setCacheObject(phoneCallResultYQVO.getSubId() + "-" + phoneCallResultYQVO.getScriptId(), (Integer) cacheObject + 1, 120, TimeUnit.MINUTES);
+ } else if ((Integer) cacheObject >= ivrTaskTemplate.getMateNum()) {
+ //濡傛灉宸茬粡闂簡瑙勫畾娆℃暟锛屽氨涓嶉棶浜嗭紝缁х画闂笅涓�棰橈紙杩欎釜瑕佸晢閲忎竴涓嬶紝鏄户缁棶涓嬩竴棰橈紝杩樻槸鍋滀簡锛屾槸涓嶆槸瑕佸仛涓紑鍏筹級
+ IvrTaskTemplateScript ivrTaskTemplateScript = new IvrTaskTemplateScript();
+ ivrTaskTemplateScript.setTemplateID(ivrTaskTemplateScriptVO.getTemplateID());
+ List<IvrTaskTemplateScript> ivrTaskTemplateScripts = iIvrTaskTemplateScriptService.selectIvrTaskTemplateScriptList(ivrTaskTemplateScript);
+ //鑾峰彇涓嬩竴棰�
+ for (IvrTaskTemplateScript script : ivrTaskTemplateScripts) {
+ if (script.getSort() == ivrTaskTemplateScriptVO.getNextScriptno().intValue()) {
+ phoneCallBackSHVO.setScriptContent(script.getScriptContent());
+ phoneCallBackSHVO.setTaskTemplateid(script.getTemplateID());
+ phoneCallBackSHVO.setSort(script.getSort());
+ phoneCallBackSHVO.setScriptId(script.getId());
+ phoneCallBackSHVO.setSubId(serviceSubtask.getId());
+ break;
+ }
+ }
+ //鎶婄紦瀛樻竻闄�
+ redisCache.deleteObject(phoneCallResultYQVO.getSubId() + "-" + phoneCallResultYQVO.getScriptId());
+ }
+ }
+ return phoneCallBackSHVO;
+ }
+
public PhoneCallBackYQVO AiMatch(String url, PhoneCallReqYQVO phoneCallReqYQVO, PhoneCallBackYQVO phoneCallBackYQVO, IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO, ServiceSubtask serviceSubtask, IvrTaskTemplate ivrTaskTemplate, List<IvrTaskTemplateScript> ivrTaskTemplateScripts, String scriptId, Integer flag, String uuid) {
PhoneCallBackYQVO back = null;
@@ -5470,14 +5668,13 @@
}
//鑾峰彇浠诲姟缁勪俊鎭�
- private void findServiceTaskScheduleVO(ServiceTaskVO serviceTaskVO){
- if(StringUtils.isNotEmpty(serviceTaskVO.getAppltype()) && serviceTaskVO.getAppltype().equals("5")){
+ private void findServiceTaskScheduleVO(ServiceTaskVO serviceTaskVO) {
+ if (StringUtils.isNotEmpty(serviceTaskVO.getAppltype()) && serviceTaskVO.getAppltype().equals("5")) {
//浠诲姟缁勪俊鎭�
ServiceTaskSchedule schedule = serviceTaskScheduleService.selectByTaskid(serviceTaskVO.getTaskid());
if (ObjectUtils.isNotEmpty(schedule)) {
ServiceTaskScheduleVO serviceTaskScheduleVO = DtoConversionUtils.sourceToTarget(schedule, ServiceTaskScheduleVO.class);
- List<ServiceTaskScheduleDetail> scheduleDetailList =
- serviceTaskScheduleService.selectDetailByScheduleid(schedule.getId());
+ List<ServiceTaskScheduleDetail> scheduleDetailList = serviceTaskScheduleService.selectDetailByScheduleid(schedule.getId());
serviceTaskScheduleVO.setDetailList(scheduleDetailList);
serviceTaskVO.setServiceTaskScheduleVO(serviceTaskScheduleVO);
}
--
Gitblit v1.9.3