百度智能外呼对接。
This commit is contained in:
parent
ec4fb23e75
commit
bfe64372fc
@ -0,0 +1,34 @@
|
||||
package com.xinelu.manage.dto.aibo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description: 通话记录
|
||||
* @author: haown
|
||||
* @create: 2024-09-10 16:06
|
||||
**/
|
||||
@Data
|
||||
public class AiboRecord {
|
||||
|
||||
/**
|
||||
* 会话角色,分为机器人侧(speech)和客户侧(voice)
|
||||
*/
|
||||
private String role;
|
||||
|
||||
/**
|
||||
* 会话时间戳,微秒
|
||||
*/
|
||||
private Long timestamp;
|
||||
|
||||
/**
|
||||
* 会话文本
|
||||
*/
|
||||
private String contextText;
|
||||
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 意图
|
||||
*/
|
||||
private String intent;
|
||||
}
|
||||
@ -13,17 +13,25 @@ import com.xinelu.common.core.redis.RedisCache;
|
||||
import com.xinelu.common.enums.ErrorStatusEnum;
|
||||
import com.xinelu.common.enums.NodeExecuteResultStatusEnum;
|
||||
import com.xinelu.common.enums.NodeExecuteStatusEnum;
|
||||
import com.xinelu.common.enums.PhoneDialMethodEnum;
|
||||
import com.xinelu.common.enums.PhoneRedialTimesEnum;
|
||||
import com.xinelu.common.enums.TaskNodeTypeEnum;
|
||||
import com.xinelu.common.exception.ServiceException;
|
||||
import com.xinelu.common.utils.StringUtils;
|
||||
import com.xinelu.manage.domain.patientinfo.PatientInfo;
|
||||
import com.xinelu.manage.domain.patientquestionoptionresult.PatientQuestionOptionResult;
|
||||
import com.xinelu.manage.domain.patientquestionsubjectresult.PatientQuestionSubjectResult;
|
||||
import com.xinelu.manage.domain.patientquestionsubmitresult.PatientQuestionSubmitResult;
|
||||
import com.xinelu.manage.domain.patienttaskexecuterecord.PatientTaskExecuteRecord;
|
||||
import com.xinelu.manage.domain.phonedialrecord.PhoneDialRecord;
|
||||
import com.xinelu.manage.domain.questioninfo.QuestionInfo;
|
||||
import com.xinelu.manage.domain.questionsubjectoption.QuestionSubjectOption;
|
||||
import com.xinelu.manage.domain.scriptInfo.ScriptInfo;
|
||||
import com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute;
|
||||
import com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode;
|
||||
import com.xinelu.manage.domain.signpatientrecord.SignPatientRecord;
|
||||
import com.xinelu.manage.domain.textmessage.TextMessage;
|
||||
import com.xinelu.manage.dto.aibo.AiboRecord;
|
||||
import com.xinelu.manage.dto.aibo.CreateTaskDto;
|
||||
import com.xinelu.manage.dto.aibo.CustomerInfoDto;
|
||||
import com.xinelu.manage.dto.aibo.ImportTaskDto;
|
||||
@ -32,8 +40,14 @@ import com.xinelu.manage.dto.patientquestionsubmitresult.PatientQuestionSubmitRe
|
||||
import com.xinelu.manage.dto.smssend.SmsInfoDTO;
|
||||
import com.xinelu.manage.mapper.labelfieldcontent.LabelFieldContentMapper;
|
||||
import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper;
|
||||
import com.xinelu.manage.mapper.patientquestionoptionresult.PatientQuestionOptionResultMapper;
|
||||
import com.xinelu.manage.mapper.patientquestionsubjectresult.PatientQuestionSubjectResultMapper;
|
||||
import com.xinelu.manage.mapper.patientquestionsubmitresult.PatientQuestionSubmitResultMapper;
|
||||
import com.xinelu.manage.mapper.patienttaskexecuterecord.PatientTaskExecuteRecordMapper;
|
||||
import com.xinelu.manage.mapper.phonedialrecord.PhoneDialRecordMapper;
|
||||
import com.xinelu.manage.mapper.questioninfo.QuestionInfoMapper;
|
||||
import com.xinelu.manage.mapper.questionsubject.QuestionSubjectMapper;
|
||||
import com.xinelu.manage.mapper.questionsubjectoption.QuestionSubjectOptionMapper;
|
||||
import com.xinelu.manage.mapper.scriptInfo.ScriptInfoMapper;
|
||||
import com.xinelu.manage.mapper.signpatientmanageroute.SignPatientManageRouteMapper;
|
||||
import com.xinelu.manage.mapper.signpatientmanageroutenode.SignPatientManageRouteNodeMapper;
|
||||
@ -44,12 +58,19 @@ import com.xinelu.manage.service.patienttaskstatistics.IPatientTaskStatisticsSer
|
||||
import com.xinelu.manage.service.signpatientmanageroute.ISignPatientManageRouteService;
|
||||
import com.xinelu.manage.vo.aibo.ImportTaskVo;
|
||||
import com.xinelu.manage.vo.labelfieldcontent.LabelFieldInfoContentVo;
|
||||
import com.xinelu.manage.vo.questionsubject.QuestionSubjectVO;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@ -108,6 +129,19 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
private LabelFieldContentMapper labelFieldContentMapper;
|
||||
@Resource
|
||||
private ScriptInfoMapper scriptInfoMapper;
|
||||
@Resource
|
||||
private QuestionInfoMapper questionInfoMapper;
|
||||
|
||||
@Resource
|
||||
private PatientQuestionSubmitResultMapper questionSubmitResultMapper;
|
||||
@Resource
|
||||
private QuestionSubjectMapper questionSubjectMapper;
|
||||
@Resource
|
||||
private PatientQuestionSubjectResultMapper patientQuestionSubjectResultMapper;
|
||||
@Resource
|
||||
private QuestionSubjectOptionMapper questionSubjectOptionMapper;
|
||||
@Resource
|
||||
private PatientQuestionOptionResultMapper patientQuestionOptionResultMapper;
|
||||
|
||||
/**
|
||||
* @description 获取外呼平台accessToken
|
||||
@ -282,22 +316,6 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
*/
|
||||
@Override
|
||||
public JSONObject taskCallBack(Integer callbackType, TaskCallbackDataDto data) throws ClientException {
|
||||
//{"extJson":"623","taskId":"3892402966495232","tenantId":3849515568332800}
|
||||
//TaskCallbackDataDto(sessionId=3874887150206976_2e1ae4e5ee0a4513b61d2411523f7b9b, tenantId=3849515568332800,
|
||||
// taskId=3874887150206976, taskName=测试20240829, robotId=11a05202-12a4-437a-b989-43235b920a2f,
|
||||
// robotName=慢病用药回访, memberId=3875110220070912, mobile=15166940975, callTimes=1,
|
||||
// callerNum=02110001062, endType=1, callType=0, endTypeReason=null, contactUUID=1724917686303674_278162,
|
||||
// field=null, collectInfo={},
|
||||
// record=[{"role":"speech","timestamp":1724917698521,"contextText":"您好,我是山东省立医院的电话客服,请问您是李四本人或家属吗?", "sn":"19a09431-1ac6-43a1-8f9f-4b6f617bed73","intent":"NOINTENT","start":"00:00.033","stop":"00:06.974","timeLen":6941,"interrupted":false,"silent":false,"nodeInfo":"eyJwcm9jZXNzTmFtZSI6IuaFoueXheeUqOiNr+Wbnuiuv+ivneacryIsIm5vZGVOYW1lIjoi5byA5Zy655m96IqC54K5X3RwcnZtc2g4IiwiaW50ZW50IjoiIiwiZW50aXR5IjpbXSwic3lzdGVtRXZlbnQiOiIiLCJmYXEiOiIifQ=="},
|
||||
// {"role":"voice","timestamp":1724917707542,"content":"是的","contextText":"是的","sn":"0e5c9c4e65db11ef_2_1","start":"00:06.930","stop":"00:08.330","timeLen":1400,"interrupted":false,"silent":false},
|
||||
// {"role":"speech","timestamp":1724917708359,"content":"是的","contextText":"好的,您之前在我们医院住过院,想了解一下您近期的健康状况。","sn":"0e5c9c4e65db11ef_2_1","intent":"patient_self","start":"00:09.871","stop":"00:15.793","timeLen":5922,"interrupted":false,"silent":false,"nodeInfo":"eyJwcm9jZXNzTmFtZSI6IuaFoueXheeUqOiNr+Wbnuiuv+ivneacryIsIm5vZGVOYW1lIjoi5pys5Lq66IqC54K5X3Nyd2Q5MTR3IiwiaW50ZW50Ijoi5piv5pys5Lq6IiwiZW50aXR5IjpbXSwic3lzdGVtRXZlbnQiOiIiLCJmYXEiOiIifQ=="},
|
||||
// {"role":"voice","timestamp":1724917718191,"content":"好的嗯","contextText":"好的嗯","sn":"0e5c9c4e65db11ef_4_1","start":"00:16.650","stop":"00:18.970","timeLen":2320,"interrupted":false,"silent":false},
|
||||
// {"role":"speech","timestamp":1724917718873,"content":"好的嗯","contextText":"您是否正常按时服药呢?","sn":"0e5c9c4e65db11ef_4_1","intent":"NOINTENT","start":"00:20.385","stop":"00:22.917","timeLen":2532,"interrupted":false,"silent":false,"nodeInfo":"eyJwcm9jZXNzTmFtZSI6IuaFoueXheeUqOiNr+Wbnuiuv+ivneacryIsIm5vZGVOYW1lIjoi6IKv5a6a6IqC54K5X3F6aWpzb2g2IiwiaW50ZW50IjoiIiwiZW50aXR5IjpbXSwic3lzdGVtRXZlbnQiOiIiLCJmYXEiOiIifQ=="},
|
||||
// {"role":"voice","timestamp":1724917725425,"content":"是的","contextText":"是的","sn":"0e5c9c4e65db11ef_6_1","start":"00:24.810","stop":"00:26.210","timeLen":1400,"interrupted":false,"silent":false},
|
||||
// {"role":"speech","timestamp":1724917725993,"content":"是的","contextText":"祝您早日康复。","sn":"0e5c9c4e65db11ef_6_1","intent":"sys_yes","start":"00:27.505","stop":"00:29.637","timeLen":2132,"interrupted":false,"silent":false,"nodeInfo":"eyJwcm9jZXNzTmFtZSI6IuaFoueXheeUqOiNr+Wbnuiuv+ivneacryIsIm5vZGVOYW1lIjoi5oyJ5pe25pyN6I2v6IqC54K5X3Bxd2RkcDBpIiwiaW50ZW50Ijoi6IKv5a6a5oSP5Zu+IiwiZW50aXR5IjpbXSwic3lzdGVtRXZlbnQiOiIiLCJmYXEiOiIifQ=="}],
|
||||
// durationTimeLen=42, ringingTimeLen=9, talkingTimeLen=29, startTime=1724917686000, ringStartTime=1724917688000, talkingStartTime=1724917698000, endTime=1724917728000, intent=null, action=[HANGUP], isRobotHangup=true,
|
||||
// dialogVar={"departmentName":"山东省立医院","patientName":"李四"}, smsVar=null, extJson=测试2, transResult=0)
|
||||
|
||||
JSONObject retObj = new JSONObject();
|
||||
retObj.fluentPut("code", 200).fluentPut("msg", "success");
|
||||
if (callbackType == 0) {
|
||||
@ -323,7 +341,7 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
// 不需要重拨,设置电话拨通情况
|
||||
signPatientManageRouteNode.setPhoneNodeExecuteResultStatus(NodeExecuteResultStatusEnum.FAILURE.getInfo());
|
||||
}
|
||||
//电话短信提醒
|
||||
// 电话短信提醒
|
||||
if (StringUtils.equals(PhoneMessageRemindConstants.NOT_CONNECTED_SEND_MESSAGE, signPatientManageRouteNode.getPhoneMessageRemind())) {
|
||||
// 发送短信
|
||||
needSendSms = true;
|
||||
@ -347,7 +365,7 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
if (ObjectUtils.isNotEmpty(signPatientManageRoute)) {
|
||||
patientTaskExecuteRecord.setPatientId(signPatientManageRoute.getPatientId());
|
||||
patientTaskExecuteRecord.setPatientName(signPatientManageRoute.getPatientName());
|
||||
// 就诊记录
|
||||
// 签约记录
|
||||
SignPatientRecord signPatientRecord = signPatientRecordMapper.selectByPrimaryKey(signPatientManageRoute.getSignPatientRecordId());
|
||||
if (ObjectUtils.isNotEmpty(signPatientRecord)) {
|
||||
patientTaskExecuteRecord.setVisitRecordId(signPatientRecord.getPatientVisitRecordId());
|
||||
@ -355,7 +373,7 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
|
||||
// 发送短信
|
||||
if (needSendSms) {
|
||||
sendSms(signPatientManageRoute.getPatientId(), signPatientManageRouteNode);
|
||||
//sendSms(signPatientManageRoute.getPatientId(), signPatientManageRouteNode);
|
||||
}
|
||||
}
|
||||
// 增加任务执行记录
|
||||
@ -384,6 +402,11 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
// 任务统计表修改
|
||||
patientTaskStatisticsService.updateNum(signPatientManageRoute.getPatientId(), TaskStatisticsTypeConstants.TASK_EXECUTE_NUM, 1);
|
||||
}
|
||||
|
||||
// 问卷记录保存
|
||||
if (StringUtils.equals(signPatientManageRouteNode.getTaskNodeType(), TaskNodeTypeEnum.QUESTIONNAIRE_SCALE.getInfo())) {
|
||||
parseQuestionInfo(data.getRecord(), signPatientManageRouteNode, signPatientManageRoute.getPatientId(), patientTaskExecuteRecord.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return retObj;
|
||||
@ -406,7 +429,7 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
dto.setManageRouteNodeId(signPatientManageRouteNode.getId());
|
||||
dto.setPhoneMessageTemplateCode(textMessage.getTextMessageId());
|
||||
dto.setPhoneMessageTemplateContent(signPatientManageRouteNode.getPhoneMessageTemplateContent());
|
||||
signPatientManageRouteService.shortMessageSendRecordExtracted(dto, LocalDateTime.now(), b, "AI");
|
||||
signPatientManageRouteService.shortMessageSendRecordExtracted(dto, LocalDateTime.now(), b, PhoneDialMethodEnum.AI.getInfo());
|
||||
|
||||
if (!b) {
|
||||
log.info("短信发送失败");
|
||||
@ -450,11 +473,11 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
|
||||
/**
|
||||
* @description 通过通话记录解析问卷内容
|
||||
* @param record 通话记录
|
||||
* @param records 通话记录
|
||||
* @Author haown
|
||||
* @Date 2024-9-6 14:30
|
||||
*/
|
||||
private void parseQuestionInfo(JSONArray record) {
|
||||
private void parseQuestionInfo(JSONArray records, SignPatientManageRouteNode node, Long patientInfoId, Long taskExecuteRecordId) {
|
||||
// record=[{"role":"speech","timestamp":1724917698521,"contextText":"您好,我是山东省立医院的电话客服,请问您是李四本人或家属吗?", "sn":"19a09431-1ac6-43a1-8f9f-4b6f617bed73","intent":"NOINTENT","start":"00:00.033","stop":"00:06.974","timeLen":6941,"interrupted":false,"silent":false,"nodeInfo":"eyJwcm9jZXNzTmFtZSI6IuaFoueXheeUqOiNr+Wbnuiuv+ivneacryIsIm5vZGVOYW1lIjoi5byA5Zy655m96IqC54K5X3RwcnZtc2g4IiwiaW50ZW50IjoiIiwiZW50aXR5IjpbXSwic3lzdGVtRXZlbnQiOiIiLCJmYXEiOiIifQ=="},
|
||||
// {"role":"voice","timestamp":1724917707542,"content":"是的","contextText":"是的","sn":"0e5c9c4e65db11ef_2_1","start":"00:06.930","stop":"00:08.330","timeLen":1400,"interrupted":false,"silent":false},
|
||||
// {"role":"speech","timestamp":1724917708359,"content":"是的","contextText":"好的,您之前在我们医院住过院,想了解一下您近期的健康状况。","sn":"0e5c9c4e65db11ef_2_1","intent":"patient_self","start":"00:09.871","stop":"00:15.793","timeLen":5922,"interrupted":false,"silent":false,"nodeInfo":"eyJwcm9jZXNzTmFtZSI6IuaFoueXheeUqOiNr+Wbnuiuv+ivneacryIsIm5vZGVOYW1lIjoi5pys5Lq66IqC54K5X3Nyd2Q5MTR3IiwiaW50ZW50Ijoi5piv5pys5Lq6IiwiZW50aXR5IjpbXSwic3lzdGVtRXZlbnQiOiIiLCJmYXEiOiIifQ=="},
|
||||
@ -462,5 +485,115 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
// {"role":"speech","timestamp":1724917718873,"content":"好的嗯","contextText":"您是否正常按时服药呢?","sn":"0e5c9c4e65db11ef_4_1","intent":"NOINTENT","start":"00:20.385","stop":"00:22.917","timeLen":2532,"interrupted":false,"silent":false,"nodeInfo":"eyJwcm9jZXNzTmFtZSI6IuaFoueXheeUqOiNr+Wbnuiuv+ivneacryIsIm5vZGVOYW1lIjoi6IKv5a6a6IqC54K5X3F6aWpzb2g2IiwiaW50ZW50IjoiIiwiZW50aXR5IjpbXSwic3lzdGVtRXZlbnQiOiIiLCJmYXEiOiIifQ=="},
|
||||
// {"role":"voice","timestamp":1724917725425,"content":"是的","contextText":"是的","sn":"0e5c9c4e65db11ef_6_1","start":"00:24.810","stop":"00:26.210","timeLen":1400,"interrupted":false,"silent":false},
|
||||
// {"role":"speech","timestamp":1724917725993,"content":"是的","contextText":"祝您早日康复。","sn":"0e5c9c4e65db11ef_6_1","intent":"sys_yes","start":"00:27.505","stop":"00:29.637","timeLen":2132,"interrupted":false,"silent":false,"nodeInfo":"eyJwcm9jZXNzTmFtZSI6IuaFoueXheeUqOiNr+Wbnuiuv+ivneacryIsIm5vZGVOYW1lIjoi5oyJ5pe25pyN6I2v6IqC54K5X3Bxd2RkcDBpIiwiaW50ZW50Ijoi6IKv5a6a5oSP5Zu+IiwiZW50aXR5IjpbXSwic3lzdGVtRXZlbnQiOiIiLCJmYXEiOiIifQ=="}],
|
||||
|
||||
List<AiboRecord> aiboRecords = records.toList(AiboRecord.class);
|
||||
List<AiboRecord> speechList = aiboRecords.stream().filter(record -> StringUtils.equals("speech", record.getRole()))
|
||||
.sorted(Comparator.comparing(AiboRecord::getSn))
|
||||
.collect(Collectors.toMap(AiboRecord::getContextText, p -> p, (p1, p2) -> p2))
|
||||
.values()
|
||||
.stream()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查询患者画像信息
|
||||
List<LabelFieldInfoContentVo> labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfoId);
|
||||
|
||||
Map<String, String> contextMap = speechList.stream().collect(Collectors.toMap(AiboRecord::getContextText, AiboRecord::getIntent));
|
||||
|
||||
PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(patientInfoId);
|
||||
QuestionInfo questionInfo = questionInfoMapper.selectQuestionInfoById(node.getQuestionInfoId());
|
||||
// 1、保存patient_question_submit_result
|
||||
PatientQuestionSubmitResult patientQuestionSubmitResult = new PatientQuestionSubmitResult();
|
||||
patientQuestionSubmitResult.setTaskExecuteRecordId(taskExecuteRecordId);
|
||||
patientQuestionSubmitResult.setPatientName(patientInfo.getPatientName());
|
||||
patientQuestionSubmitResult.setPatientId(patientInfoId);
|
||||
patientQuestionSubmitResult.setManageRouteId(node.getManageRouteId());
|
||||
patientQuestionSubmitResult.setManageRouteNodeId(node.getId());
|
||||
patientQuestionSubmitResult.setManageRouteNodeName(node.getManageRouteName());
|
||||
patientQuestionSubmitResult.setQuestionInfoId(questionInfo.getId());
|
||||
patientQuestionSubmitResult.setDepartmentId(questionInfo.getDepartmentId());
|
||||
patientQuestionSubmitResult.setDepartmentName(questionInfo.getDepartmentName());
|
||||
patientQuestionSubmitResult.setDiseaseTypeId(questionInfo.getDiseaseTypeId());
|
||||
patientQuestionSubmitResult.setDiseaseTypeName(questionInfo.getDiseaseTypeName());
|
||||
patientQuestionSubmitResult.setQuestionnaireName(questionInfo.getQuestionnaireName());
|
||||
patientQuestionSubmitResult.setQuestionnaireDescription(questionInfo.getQuestionnaireDescription());
|
||||
patientQuestionSubmitResult.setAnsweringMethod(questionInfo.getAnsweringMethod());
|
||||
patientQuestionSubmitResult.setQuestionnaireId(questionInfo.getQuestionnaireId());
|
||||
patientQuestionSubmitResult.setQuestionCount(speechList.size());
|
||||
patientQuestionSubmitResult.setQuestionCount(questionInfo.getQuestionCount());
|
||||
patientQuestionSubmitResult.setResidentId(patientInfo.getResidentId());
|
||||
questionSubmitResultMapper.insertPatientQuestionSubmitResult(patientQuestionSubmitResult);
|
||||
// 2、保存patient_question_subject_result,计算总得分
|
||||
BigDecimal totalScore = BigDecimal.ZERO;
|
||||
List<QuestionSubjectVO> questionSubjectList = questionSubjectMapper.selectQuestionSubjectBy(node.getQuestionInfoId());
|
||||
questionSubjectList.forEach(questionSubjectVO -> {
|
||||
// 判断问题中有无变量,有变量替换变量
|
||||
String questionName = replaceQuestionName(questionSubjectVO.getQuestionName(), labelFieldContentList);
|
||||
// 根据通话记录筛查问题
|
||||
if (contextMap.containsKey(questionName)) {
|
||||
PatientQuestionSubjectResult patientQuestionSubjectResult = new PatientQuestionSubjectResult();
|
||||
BeanUtils.copyProperties(questionSubjectVO, patientQuestionSubjectResult);
|
||||
patientQuestionSubjectResult.setQuestionSubmitResultId(patientQuestionSubmitResult.getId());
|
||||
patientQuestionSubjectResultMapper.insertPatientQuestionSubjectResult(patientQuestionSubjectResult);
|
||||
|
||||
// 3、保存patient_question_option_result
|
||||
QuestionSubjectOption questionSubjectOptionQuery = new QuestionSubjectOption();
|
||||
questionSubjectOptionQuery.setQuestionnaireSubjectId(questionSubjectVO.getId());
|
||||
List<QuestionSubjectOption> questionSubjectOptions = questionSubjectOptionMapper.selectQuestionSubjectOptionList(questionSubjectOptionQuery);
|
||||
List<PatientQuestionOptionResult> patientQuestionOptionResults = new ArrayList<>();
|
||||
questionSubjectOptions.forEach(questionSubjectOption -> {
|
||||
PatientQuestionOptionResult patientQuestionOptionResult = new PatientQuestionOptionResult();
|
||||
BeanUtils.copyProperties(questionSubjectOptions, patientQuestionOptionResult);
|
||||
// 设置是否选中, 通过通话记录中下一个问题的intent字段查询QuestionSubjectOption,
|
||||
// speech_context_text中的字段需要替换为文本,竖线分隔的分段都要匹配 input.replaceAll("[\\p{Punct}]", "")
|
||||
//{% &department_name %} /.*{% & %}.*/ #\{([^\}]*)\}
|
||||
//Pattern pattern = Pattern.compile("\\{%\\s*&[\\s\\S]*?\\s*%}");
|
||||
//Matcher matcher = pattern.matcher(questionSubjectOption.getSpeechContextText());
|
||||
//while (matcher.find()) {
|
||||
// LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), matcher.group(1).replaceAll("_", "").toUpperCase())).findFirst().orElse(null);
|
||||
// if (ObjectUtils.isNotEmpty(labelFieldContent)) {
|
||||
// String speechContextText = questionSubjectOption.getSpeechContextText().replaceAll("\\{%\\s*&[\\s\\S]*?\\s*%}", ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue())
|
||||
// .replaceAll("[\\p{Punct}]", "")
|
||||
// .replaceAll("|", "");
|
||||
// }
|
||||
//}
|
||||
List<String> intents = Arrays.asList(questionSubjectOption.getIntent().split("|"));
|
||||
AiboRecord nextRecord = getNextQuestion(speechList, questionName);
|
||||
if (ObjectUtils.isNotEmpty(nextRecord) && intents.contains(nextRecord.getIntent())) {
|
||||
patientQuestionOptionResult.setOptionChooseSign(0);
|
||||
} else {
|
||||
patientQuestionOptionResult.setOptionChooseSign(1);
|
||||
}
|
||||
patientQuestionOptionResult.setQuestionSubjectResultId(patientQuestionSubjectResult.getId());
|
||||
patientQuestionOptionResults.add(patientQuestionOptionResult);
|
||||
});
|
||||
patientQuestionOptionResultMapper.saveQuestionOptionList(patientQuestionOptionResults);
|
||||
totalScore.add(questionSubjectVO.getQuestionScore());
|
||||
}
|
||||
});
|
||||
|
||||
// 4、更新总得分
|
||||
patientQuestionSubmitResult.setTotalScore(totalScore);
|
||||
questionSubmitResultMapper.updatePatientQuestionSubmitResult(patientQuestionSubmitResult);
|
||||
}
|
||||
|
||||
private AiboRecord getNextQuestion(List<AiboRecord> speechList, String currentQuestion) {
|
||||
for (int i = 0; i < speechList.size(); i++) {
|
||||
if (StringUtils.equals(speechList.get(i).getContextText(), currentQuestion)) {
|
||||
return speechList.get(i+1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String replaceQuestionName(String questionName, List<LabelFieldInfoContentVo> labelFieldContentList) {
|
||||
Pattern pattern = Pattern.compile("\\{%\\s*&[\\s\\S]*?\\s*%}");
|
||||
Matcher matcher = pattern.matcher(questionName);
|
||||
while (matcher.find()) {
|
||||
LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), matcher.group(1).replaceAll("_", "").toUpperCase())).findFirst().orElse(null);
|
||||
if (ObjectUtils.isNotEmpty(labelFieldContent)) {
|
||||
questionName = questionName.replaceAll("\\{%\\s*&[\\s\\S]*?\\s*%}", ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue());
|
||||
}
|
||||
}
|
||||
return questionName;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import com.xinelu.common.constant.TaskCreateTypeConstant;
|
||||
import com.xinelu.common.constant.TaskStatisticsTypeConstants;
|
||||
import com.xinelu.common.enums.NodeExecuteResultStatusEnum;
|
||||
import com.xinelu.common.enums.NodeExecuteStatusEnum;
|
||||
import com.xinelu.common.enums.PhoneDialMethodEnum;
|
||||
import com.xinelu.common.enums.PhoneRedialTimesEnum;
|
||||
import com.xinelu.manage.domain.patienttaskexecuterecord.PatientTaskExecuteRecord;
|
||||
import com.xinelu.manage.domain.phonedialrecord.PhoneDialRecord;
|
||||
@ -224,7 +225,7 @@ public class RobotPublishServiceImpl implements IRobotPublishService {
|
||||
dto.setManageRouteNodeId(signPatientManageRouteNode.getId());
|
||||
dto.setPhoneMessageTemplateCode(textMessage.getTextMessageId());
|
||||
dto.setPhoneMessageTemplateContent(signPatientManageRouteNode.getPhoneMessageTemplateContent());
|
||||
signPatientManageRouteService.shortMessageSendRecordExtracted(dto, LocalDateTime.now(), b, "AI");
|
||||
signPatientManageRouteService.shortMessageSendRecordExtracted(dto, LocalDateTime.now(), b, PhoneDialMethodEnum.AI.getInfo());
|
||||
|
||||
if (!b) {
|
||||
log.info("短信发送失败");
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<select id="getByScriptInfoId" resultType="java.lang.String">
|
||||
select task_id
|
||||
from script_info_task_info
|
||||
where script_info_id = #{scriptInfoId}
|
||||
where script_info_id = #{scriptInfoId} and del_flag = 0
|
||||
</select>
|
||||
|
||||
<insert id="insertScriptInfoTaskInfo" parameterType="ScriptInfoTaskInfo" useGeneratedKeys="true"
|
||||
@ -53,7 +53,6 @@
|
||||
</insert>
|
||||
|
||||
<delete id="deleteScriptInfoTaskInfo">
|
||||
delete
|
||||
from script_info_task_info
|
||||
update script_info_task_info set del_flag = 1 where del_flag = 0
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -516,14 +516,14 @@
|
||||
values
|
||||
<foreach collection="nodeList" item="item" separator=",">
|
||||
(#{item.manageRouteId},#{item.manageRouteName},#{item.routeNodeId},#{item.routeNodeName},#{item.routeNodeDay},#{item.taskType},#{item.taskStatus},#{item.taskSubdivision},#{item.taskNodeType},#{item.secondClassifyDescribe},
|
||||
#{item.executeTime},#{item.phonePushSign},#{item.scriptInfoId},#{item.robotPublishId},#{item.phoneTemplateId},#{item.phoneTemplateName},#{item.phoneNodeContent},#{phoneResultJson},#{item.phoneRedialTimes},#{item.phoneTimeInterval},#{item.phoneMessageRemind},#{item.phoneMessageTemplateId},
|
||||
#{item.executeTime},#{item.phonePushSign},#{item.scriptInfoId},#{item.robotPublishId},#{item.phoneTemplateId},#{item.phoneTemplateName},#{item.phoneNodeContent},#{item.phoneResultJson},#{item.phoneRedialTimes},#{item.phoneTimeInterval},#{item.phoneMessageRemind},#{item.phoneMessageTemplateId},
|
||||
#{item.phoneMessageTemplateName},#{item.phoneMessageTemplateContent},
|
||||
#{item.questionInfoId},#{item.questionnaireName},#{item.questionnaireContent},#{item.questionExpirationDate},#{item.propagandaInfoId},#{item.propagandaTitle},#{item.propagandaContent},#{item.messagePushSign},
|
||||
#{item.messageTemplateId}, #{item.messageTemplateCode},
|
||||
#{item.messageTemplateName},#{item.messagePreview},#{item.messageNodeContent},#{item.officialPushSign},#{item.officialTemplateId},#{item.officialTemplateCode},#{item.officialTemplateName},#{item.officialRemindContent},#{item.officialNodeContent},
|
||||
#{item.appletPushSign},#{item.appletTemplateId},#{item.appletTemplateCode},#{item.appletTemplateName},#{item.appletRemindContent},#{item.appletPromptDescription},#{item.appletNodeContent},
|
||||
#{item.routeCheckStatus},#{item.routeCheckPerson},#{item.routeCheckDate},#{item.routeCheckRemark},#{item.routeNodeRemark},#{item.nodeExecuteStatus},#{item.routeHandleRemark},#{item.phoneConnectStatus},
|
||||
#{item.routeHandleId},#{item.routeHandlePerson},#{item.routeLink},#{item.textRemindContent},#{item.nodeContent},0,#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.phoneDialMethod},#{item.followTemplateId},#{item.followTemplateName},#{taskIdExt})
|
||||
#{item.routeHandleId},#{item.routeHandlePerson},#{item.routeLink},#{item.textRemindContent},#{item.nodeContent},0,#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.phoneDialMethod},#{item.followTemplateId},#{item.followTemplateName},#{item.taskIdExt})
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateSignPatientManageRouteNode" parameterType="SignPatientManageRouteNode">
|
||||
|
||||
@ -3,7 +3,6 @@ package com.xinelu.quartz.task;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.xinelu.common.enums.NodeExecuteStatusEnum;
|
||||
import com.xinelu.common.enums.PhoneDialMethodEnum;
|
||||
import com.xinelu.common.enums.TaskNodeTypeEnum;
|
||||
import com.xinelu.common.utils.StringUtils;
|
||||
import com.xinelu.manage.domain.patientinfo.PatientInfo;
|
||||
import com.xinelu.manage.domain.patientvisitrecord.PatientVisitRecord;
|
||||
@ -85,7 +84,7 @@ public class UploadRobotPublishTask {
|
||||
log.info("开始执行百度智能外呼创建任务定时任务......");
|
||||
// 查找需要当天执行的AI打电话任务(问卷或电话外呼类型)
|
||||
SignPatientManageRouteNodeDto signPatientManageRouteNodeDto = new SignPatientManageRouteNodeDto();
|
||||
signPatientManageRouteNodeDto.setTaskNodeType(TaskNodeTypeEnum.PHONE_OUTBOUND.getInfo());
|
||||
//signPatientManageRouteNodeDto.setTaskNodeType(TaskNodeTypeEnum.PHONE_OUTBOUND.getInfo());
|
||||
signPatientManageRouteNodeDto.setNodeExecuteStatus(NodeExecuteStatusEnum.UNEXECUTED.getInfo());
|
||||
signPatientManageRouteNodeDto.setPhoneDialMethod(PhoneDialMethodEnum.AI.getInfo());
|
||||
List<SignPatientManageRouteNode> nodeList = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeList(signPatientManageRouteNodeDto);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user