From 2b7afe7d52a44a93fe0d12716ba1b7e08eaed621 Mon Sep 17 00:00:00 2001 From: haown <454902499@qq.com> Date: Fri, 13 Sep 2024 11:32:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BE=E5=BA=A6=E6=99=BA=E8=83=BD=E5=A4=96?= =?UTF-8?q?=E5=91=BC=E5=AF=B9=E6=8E=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScriptInfoTaskInfo.java | 5 ++ .../xinelu/manage/dto/aibo/CreateTaskDto.java | 12 ++++ .../ScriptInfoTaskInfoMapper.java | 2 +- .../service/aibo/impl/AIOBServiceImpl.java | 71 ++++++++----------- .../ScriptInfoTaskInfoMapper.xml | 8 ++- .../quartz/task/UploadRobotPublishTask.java | 63 ++++++++-------- 6 files changed, 84 insertions(+), 77 deletions(-) diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/scriptinfotaskinfo/ScriptInfoTaskInfo.java b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/scriptinfotaskinfo/ScriptInfoTaskInfo.java index a89ab777..0fc28d6e 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/scriptinfotaskinfo/ScriptInfoTaskInfo.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/scriptinfotaskinfo/ScriptInfoTaskInfo.java @@ -38,6 +38,11 @@ public class ScriptInfoTaskInfo { */ private String taskId; + /** + * 任务Id + */ + private Long signPatientManageRouteNodeId; + /** * 创建时间 */ diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aibo/CreateTaskDto.java b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aibo/CreateTaskDto.java index 00ad9a62..7f84b162 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aibo/CreateTaskDto.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/aibo/CreateTaskDto.java @@ -44,6 +44,16 @@ public class CreateTaskDto { */ private List forbidDialDate; + /** + * 重试次数,整数,且 N ≤ 3,默认为空,表示不重试 + */ + private Integer retryTimes; + + /** + * 重试间隔时间,单位min,0≤ N ≤720 + */ + private Integer retryInterval; + /** * 是否开启24小时空号检测 */ @@ -70,4 +80,6 @@ public class CreateTaskDto { */ private Integer callFinishTaskEnd = 0; + private Integer callOnePhoneTimeLimit = 0; + } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/scriptinfotaskinfo/ScriptInfoTaskInfoMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/scriptinfotaskinfo/ScriptInfoTaskInfoMapper.java index 377a9eca..07a1d394 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/scriptinfotaskinfo/ScriptInfoTaskInfoMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/scriptinfotaskinfo/ScriptInfoTaskInfoMapper.java @@ -10,7 +10,7 @@ import com.xinelu.manage.domain.scriptinfotaskinfo.ScriptInfoTaskInfo; */ public interface ScriptInfoTaskInfoMapper { - String getByScriptInfoId(Long scriptInfoId); + String getByNodeId(Long signPatientManageRouteNodeId); /** * 新增百度外呼话术任务临时表 diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/aibo/impl/AIOBServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/aibo/impl/AIOBServiceImpl.java index 3da36469..381a2ff0 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/aibo/impl/AIOBServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/aibo/impl/AIOBServiceImpl.java @@ -14,7 +14,6 @@ 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; @@ -73,7 +72,6 @@ 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; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; @@ -332,15 +330,8 @@ public class AIOBServiceImpl implements IAIOBService { List phoneDialRecordList = phoneDialRecordMapper.selectPhoneDialRecordList(phoneDialRecordQuery); // 电话拨打未成功,判断是否需要重拨;电话拨打成功,设置电话拨通情况为成功 if (data.getEndType() != null && data.getEndType() == 0) {//接通状态,1-已接通 0-未接通 - // 已经拨打的次数 - int dialCount = CollectionUtils.isEmpty(phoneDialRecordList) ? 0 : phoneDialRecordList.size() + 1; - if (PhoneRedialTimesEnum.getValueByInfo(signPatientManageRouteNode.getPhoneRedialTimes()).getValue() + 1 > dialCount) { - // 需要重拨-导入名单 - uploadCustomerInfoList(signPatientManageRouteNode, data.getTaskId()); - } else { - // 不需要重拨,设置电话拨通情况 - signPatientManageRouteNode.setPhoneNodeExecuteResultStatus(NodeExecuteResultStatusEnum.FAILURE.getInfo()); - } + // 不需要重拨,设置电话拨通情况 + signPatientManageRouteNode.setPhoneNodeExecuteResultStatus(NodeExecuteResultStatusEnum.FAILURE.getInfo()); // 电话短信提醒 if (StringUtils.equals(PhoneMessageRemindConstants.NOT_CONNECTED_SEND_MESSAGE, signPatientManageRouteNode.getPhoneMessageRemind())) { // 发送短信 @@ -373,6 +364,7 @@ public class AIOBServiceImpl implements IAIOBService { // 发送短信 if (needSendSms) { + System.out.println("发送短信"); //sendSms(signPatientManageRoute.getPatientId(), signPatientManageRouteNode); } } @@ -478,20 +470,12 @@ public class AIOBServiceImpl implements IAIOBService { * @Date 2024-9-6 14:30 */ 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=="}, - // {"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=="}], - List aiboRecords = records.toList(AiboRecord.class); List 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() + .sorted(Comparator.comparing(AiboRecord::getTimestamp)) .collect(Collectors.toList()); // 查询患者画像信息 @@ -522,17 +506,28 @@ public class AIOBServiceImpl implements IAIOBService { patientQuestionSubmitResult.setQuestionCount(questionInfo.getQuestionCount()); patientQuestionSubmitResult.setResidentId(patientInfo.getResidentId()); questionSubmitResultMapper.insertPatientQuestionSubmitResult(patientQuestionSubmitResult); - // 2、保存patient_question_subject_result,计算总得分 + // 2、保存patient_question_subject_result BigDecimal totalScore = BigDecimal.ZERO; List questionSubjectList = questionSubjectMapper.selectQuestionSubjectBy(node.getQuestionInfoId()); questionSubjectList.forEach(questionSubjectVO -> { // 判断问题中有无变量,有变量替换变量 String questionName = replaceQuestionName(questionSubjectVO.getQuestionName(), labelFieldContentList); - // 根据通话记录筛查问题 - if (contextMap.containsKey(questionName)) { + // 根据通话记录筛查是否询问该问题 + boolean hasQuestion = false; + String aiobQuestionName = ""; + for (String questionContent : contextMap.keySet()) { + if (questionContent.replaceAll("\\p{P}", "").contains(questionName.replaceAll("\\p{P}", ""))) { + hasQuestion = true; + aiobQuestionName = questionContent; + break; + } + } + if (hasQuestion) { PatientQuestionSubjectResult patientQuestionSubjectResult = new PatientQuestionSubjectResult(); BeanUtils.copyProperties(questionSubjectVO, patientQuestionSubjectResult); + patientQuestionSubjectResult.setId(null); patientQuestionSubjectResult.setQuestionSubmitResultId(patientQuestionSubmitResult.getId()); + patientQuestionSubjectResult.setCreateTime(LocalDateTime.now()); patientQuestionSubjectResultMapper.insertPatientQuestionSubjectResult(patientQuestionSubjectResult); // 3、保存patient_question_option_result @@ -540,29 +535,20 @@ public class AIOBServiceImpl implements IAIOBService { questionSubjectOptionQuery.setQuestionnaireSubjectId(questionSubjectVO.getId()); List questionSubjectOptions = questionSubjectOptionMapper.selectQuestionSubjectOptionList(questionSubjectOptionQuery); List patientQuestionOptionResults = new ArrayList<>(); + String finalAiobQuestionName = aiobQuestionName; questionSubjectOptions.forEach(questionSubjectOption -> { PatientQuestionOptionResult patientQuestionOptionResult = new PatientQuestionOptionResult(); - BeanUtils.copyProperties(questionSubjectOptions, patientQuestionOptionResult); + BeanUtils.copyProperties(questionSubjectOption, 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 intents = Arrays.asList(questionSubjectOption.getIntent().split("|")); - AiboRecord nextRecord = getNextQuestion(speechList, questionName); + List intents = Arrays.asList(questionSubjectOption.getIntent().split("\\|")); + AiboRecord nextRecord = getNextQuestion(speechList, finalAiobQuestionName); if (ObjectUtils.isNotEmpty(nextRecord) && intents.contains(nextRecord.getIntent())) { patientQuestionOptionResult.setOptionChooseSign(0); } else { patientQuestionOptionResult.setOptionChooseSign(1); } + patientQuestionOptionResult.setId(null); + patientQuestionOptionResult.setCreateTime(LocalDateTime.now()); patientQuestionOptionResult.setQuestionSubjectResultId(patientQuestionSubjectResult.getId()); patientQuestionOptionResults.add(patientQuestionOptionResult); }); @@ -577,9 +563,11 @@ public class AIOBServiceImpl implements IAIOBService { } private AiboRecord getNextQuestion(List speechList, String currentQuestion) { - for (int i = 0; i < speechList.size(); i++) { - if (StringUtils.equals(speechList.get(i).getContextText(), currentQuestion)) { - return speechList.get(i+1); + if (StringUtils.isNotBlank(currentQuestion)) { + for (int i = 0; i < speechList.size(); i++) { + if (StringUtils.equals(speechList.get(i).getContextText(), currentQuestion)) { + return speechList.get(i+1); + } } } return null; @@ -596,4 +584,5 @@ public class AIOBServiceImpl implements IAIOBService { } return questionName; } + } diff --git a/postdischarge-manage/src/main/resources/mapper/manage/scriptinfotaskinfo/ScriptInfoTaskInfoMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/scriptinfotaskinfo/ScriptInfoTaskInfoMapper.xml index f7c3a1e9..4ac9a008 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/scriptinfotaskinfo/ScriptInfoTaskInfoMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/scriptinfotaskinfo/ScriptInfoTaskInfoMapper.xml @@ -21,10 +21,10 @@ from script_info_task_info - select task_id from script_info_task_info - where script_info_id = #{scriptInfoId} and del_flag = 0 + where sign_patient_manage_route_node_id = #{signPatientManageRouteNodeId} and del_flag = 0 task_id, + sign_patient_manage_route_node_id, + create_time, @@ -47,6 +49,8 @@ #{taskId}, + #{signPatientManageRouteNodeId}, + #{createTime}, diff --git a/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java b/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java index be1380b1..289af93b 100644 --- a/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java +++ b/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java @@ -3,6 +3,7 @@ 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.PhoneRedialTimesEnum; import com.xinelu.common.utils.StringUtils; import com.xinelu.manage.domain.patientinfo.PatientInfo; import com.xinelu.manage.domain.patientvisitrecord.PatientVisitRecord; @@ -33,9 +34,7 @@ import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.Objects; -import java.util.stream.Collectors; import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -95,28 +94,28 @@ public class UploadRobotPublishTask { SignPatientRecord signPatientRecord = signPatientRecordMapper.selectByPrimaryKey(signPatientManageRoute.getSignPatientRecordId()); PatientVisitRecord patientVisitRecord = patientVisitRecordMapper.selectPatientVisitRecordById(signPatientRecord.getPatientVisitRecordId()); LocalDateTime executeTime = signPatientManageRouteNodeService.getExecuteTime(node.getExecuteTime(), node.getRouteNodeName(), node.getRouteNodeDay(), patientVisitRecord); - if (executeTime.toLocalDate().isBefore(LocalDate.now())|| executeTime.toLocalDate().isEqual(LocalDate.now())) { + if (node.getScriptInfoId() != null && (executeTime.toLocalDate().isBefore(LocalDate.now()) || executeTime.toLocalDate().isEqual(LocalDate.now()))) { executeNodeList.add(node); } }); if (CollectionUtils.isNotEmpty(executeNodeList)) { - // 按照话术id分组,每个话术id对应不同的机器人id, 每个机器人每天创建一条任务 - Map> groupByScriptInfo = executeNodeList.stream().filter(node -> node.getScriptInfoId() != null).collect(Collectors.groupingBy(SignPatientManageRouteNode::getScriptInfoId)); // 根据机器人id查询智能外呼系统的任务id - for (Long scriptInfoId : groupByScriptInfo.keySet()) { - ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(scriptInfoId); - String taskId = scriptInfoTaskInfoMapper.getByScriptInfoId(scriptInfoId); + executeNodeList.forEach(node -> { + ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(node.getScriptInfoId()); + String taskId = scriptInfoTaskInfoMapper.getByNodeId(node.getId()); if (StringUtils.isBlank(taskId)) { // 没有任务则创建任务 if (ObjectUtils.isNotEmpty(scriptInfo)) { log.info("创建任务......"); CreateTaskDto createTaskDto = new CreateTaskDto(); - createTaskDto.setTaskName(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + scriptInfo.getScriptName()); + createTaskDto.setTaskName(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + scriptInfo.getScriptName() + "(" +node.getId()+ ")"); createTaskDto.setRobotId(scriptInfo.getRobotPublishId()); createTaskDto.setDialStartDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); createTaskDto.setDialEndDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); createTaskDto.setForbidDialDate(Arrays.asList(99)); + createTaskDto.setRetryTimes(StringUtils.isBlank(node.getPhoneRedialTimes()) ? 0 : PhoneRedialTimesEnum.getValueByInfo(node.getPhoneRedialTimes()).getValue()); + createTaskDto.setRetryInterval(node.getPhoneTimeInterval()); createTaskDto.setNumTypeFilterList(Arrays.asList(1,2)); createTaskDto.setTaskDataCallback(true); createTaskDto.setCallBackUrl(callBackUrl); @@ -126,37 +125,36 @@ public class UploadRobotPublishTask { aiobService.updateTaskStatus(taskId, 2); ScriptInfoTaskInfo scriptInfoTaskInfo = new ScriptInfoTaskInfo(); - scriptInfoTaskInfo.setScriptInfoId(scriptInfoId); + scriptInfoTaskInfo.setScriptInfoId(node.getScriptInfoId()); scriptInfoTaskInfo.setTaskId(taskId); scriptInfoTaskInfo.setRobotId(scriptInfo.getRobotPublishId()); scriptInfoTaskInfo.setCreateTime(LocalDateTime.now()); + scriptInfoTaskInfo.setSignPatientManageRouteNodeId(node.getId()); scriptInfoTaskInfoMapper.insertScriptInfoTaskInfo(scriptInfoTaskInfo); } } // 客户名单list - List scriptNodeList = groupByScriptInfo.get(scriptInfoId); List customerInfoList = new ArrayList<>(); - scriptNodeList.forEach(node -> { - CustomerInfoDto customerInfoDto = new CustomerInfoDto(); - customerInfoDto.setExtJson(node.getId() + ""); - SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId()); - PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(signPatientManageRoute.getPatientId()); - customerInfoDto.setMobile(patientInfo.getPatientPhone()); - // 查询患者画像信息 - List labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfo.getId()); - // 处理变量 - JSONObject jsonObject = new JSONObject(); - if (StringUtils.isNotBlank(scriptInfo.getVariables())) { - List variables = Arrays.asList(scriptInfo.getVariables().split("\\|")); - variables.forEach(variable -> { - LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), variable.replaceAll("_", "").toUpperCase())).findFirst().orElse(null); - jsonObject.fluentPut(variable, ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); - }); - } - customerInfoDto.setVar(jsonObject); - customerInfoList.add(customerInfoDto); - }); + CustomerInfoDto customerInfoDto = new CustomerInfoDto(); + customerInfoDto.setExtJson(node.getId() + ""); + SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId()); + PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(signPatientManageRoute.getPatientId()); + customerInfoDto.setMobile(patientInfo.getPatientPhone()); + // 查询患者画像信息 + List labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfo.getId()); + // 处理变量 + JSONObject jsonObject = new JSONObject(); + if (StringUtils.isNotBlank(scriptInfo.getVariables())) { + List variables = Arrays.asList(scriptInfo.getVariables().split("\\|")); + variables.forEach(variable -> { + LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), variable.replaceAll("_", "").toUpperCase())).findFirst().orElse(null); + jsonObject.fluentPut(variable, ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); + }); + } + + customerInfoDto.setVar(jsonObject); + customerInfoList.add(customerInfoDto); // 上传名单 log.info("任务导入客户名单......"); @@ -169,13 +167,12 @@ public class UploadRobotPublishTask { importTaskList.forEach(importTaskVo -> { // 名单导入成功后,sign_patient_manage_route_node表中设置taskId if (importTaskVo.getStatus()) { - SignPatientManageRouteNode node = new SignPatientManageRouteNode(); node.setTaskIdExt(finalTaskId); node.setId(Long.valueOf(importTaskVo.getExtJson())); signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(node); } }); - } + }); } log.info("百度智能外呼创建任务定时任务执行完成......"); }