百度实时外呼定时任务。
This commit is contained in:
parent
34afde73e9
commit
f54ec4e100
@ -0,0 +1,19 @@
|
||||
package com.xinelu.common.constant;
|
||||
|
||||
/**
|
||||
* @description: 百度外呼任务类型常量
|
||||
* @author: haown
|
||||
* @create: 2024-09-24 14:38
|
||||
**/
|
||||
public class AiboTaskTypeContant {
|
||||
|
||||
/**
|
||||
* 批量任务
|
||||
*/
|
||||
public static final String BATCHTASK = "BATCH_TASK";
|
||||
|
||||
/**
|
||||
* 实时任务
|
||||
*/
|
||||
public static final String ACTUALTIMETASK = "ACTUAL_TIME_TASK";
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.xinelu.manage.domain.scriptinfotaskinfo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -43,6 +44,20 @@ public class ScriptInfoTaskInfo {
|
||||
*/
|
||||
private Long signPatientManageRouteNodeId;
|
||||
|
||||
/**
|
||||
* 执行时间
|
||||
*/
|
||||
private LocalDateTime executeTime;
|
||||
|
||||
/**
|
||||
* 百度外呼任务类型,BATCH_TASK:批量任务,ACTUAL_TIME_TASK:实时任务
|
||||
*/
|
||||
private String aiobTaskType;
|
||||
|
||||
/** 任务执行状态,已执行:EXECUTED,未执行:UNEXECUTED */
|
||||
@ApiModelProperty(value = "任务执行状态,已执行:EXECUTED,未执行:UNEXECUTED")
|
||||
private String executeStatus;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.xinelu.manage.mapper.scriptinfotaskinfo;
|
||||
|
||||
import com.xinelu.manage.domain.scriptinfotaskinfo.ScriptInfoTaskInfo;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 百度外呼话术任务临时表Mapper接口
|
||||
@ -10,7 +11,9 @@ import com.xinelu.manage.domain.scriptinfotaskinfo.ScriptInfoTaskInfo;
|
||||
*/
|
||||
public interface ScriptInfoTaskInfoMapper {
|
||||
|
||||
String getByNodeId(Long signPatientManageRouteNodeId);
|
||||
String getByNodeId(Long signPatientManageRouteNodeId, String aiobTaskType);
|
||||
|
||||
List<ScriptInfoTaskInfo> selectList(ScriptInfoTaskInfo scriptInfoTaskInfo);
|
||||
|
||||
/**
|
||||
* 新增百度外呼话术任务临时表
|
||||
@ -20,6 +23,8 @@ public interface ScriptInfoTaskInfoMapper {
|
||||
*/
|
||||
int insertScriptInfoTaskInfo(ScriptInfoTaskInfo scriptInfoTaskInfo);
|
||||
|
||||
int updateExecuteStatusByNodeId(Long signPatientManageRouteNodeId);
|
||||
|
||||
int deleteScriptInfoTaskInfo();
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.xinelu.common.config.AliYunSmsTwoConfig;
|
||||
import com.xinelu.common.constant.AiboTaskTypeContant;
|
||||
import com.xinelu.common.constant.PhoneMessageRemindConstants;
|
||||
import com.xinelu.common.constant.TaskCreateTypeConstant;
|
||||
import com.xinelu.common.constant.TaskStatisticsTypeConstants;
|
||||
@ -14,6 +15,7 @@ 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;
|
||||
@ -22,10 +24,12 @@ import com.xinelu.manage.domain.patientquestionoptionresult.PatientQuestionOptio
|
||||
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.patientvisitrecord.PatientVisitRecord;
|
||||
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.scriptinfotaskinfo.ScriptInfoTaskInfo;
|
||||
import com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute;
|
||||
import com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode;
|
||||
import com.xinelu.manage.domain.signpatientrecord.SignPatientRecord;
|
||||
@ -44,11 +48,13 @@ import com.xinelu.manage.mapper.patientquestionoptionresult.PatientQuestionOptio
|
||||
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.patientvisitrecord.PatientVisitRecordMapper;
|
||||
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.scriptinfotaskinfo.ScriptInfoTaskInfoMapper;
|
||||
import com.xinelu.manage.mapper.signpatientmanageroute.SignPatientManageRouteMapper;
|
||||
import com.xinelu.manage.mapper.signpatientmanageroutenode.SignPatientManageRouteNodeMapper;
|
||||
import com.xinelu.manage.mapper.signpatientrecord.SignPatientRecordMapper;
|
||||
@ -56,6 +62,7 @@ import com.xinelu.manage.mapper.textmessage.TextMessageMapper;
|
||||
import com.xinelu.manage.service.aibo.IAIOBService;
|
||||
import com.xinelu.manage.service.patienttaskstatistics.IPatientTaskStatisticsService;
|
||||
import com.xinelu.manage.service.signpatientmanageroute.ISignPatientManageRouteService;
|
||||
import com.xinelu.manage.service.signpatientmanageroutenode.ISignPatientManageRouteNodeService;
|
||||
import com.xinelu.manage.vo.aibo.ImportTaskVo;
|
||||
import com.xinelu.manage.vo.labelfieldcontent.LabelFieldInfoContentVo;
|
||||
import com.xinelu.manage.vo.questionsubject.QuestionSubjectVO;
|
||||
@ -73,6 +80,7 @@ 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;
|
||||
@ -117,6 +125,8 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
@Resource
|
||||
private ISignPatientManageRouteService signPatientManageRouteService;
|
||||
@Resource
|
||||
private ISignPatientManageRouteNodeService signPatientManageRouteNodeService;
|
||||
@Resource
|
||||
private TextMessageMapper textMessageMapper;
|
||||
@Resource
|
||||
private PatientTaskExecuteRecordMapper patientTaskExecuteRecordMapper;
|
||||
@ -130,7 +140,6 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
private ScriptInfoMapper scriptInfoMapper;
|
||||
@Resource
|
||||
private QuestionInfoMapper questionInfoMapper;
|
||||
|
||||
@Resource
|
||||
private PatientQuestionSubmitResultMapper questionSubmitResultMapper;
|
||||
@Resource
|
||||
@ -141,6 +150,10 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
private QuestionSubjectOptionMapper questionSubjectOptionMapper;
|
||||
@Resource
|
||||
private PatientQuestionOptionResultMapper patientQuestionOptionResultMapper;
|
||||
@Resource
|
||||
private ScriptInfoTaskInfoMapper scriptInfoTaskInfoMapper;
|
||||
@Resource
|
||||
private PatientVisitRecordMapper patientVisitRecordMapper;
|
||||
|
||||
/**
|
||||
* @description 获取外呼平台accessToken
|
||||
@ -344,23 +357,35 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
if (callbackType == 0 || callbackType == 3) {
|
||||
// 是否发送短信标识
|
||||
boolean needSendSms = false;
|
||||
// 是否重拨
|
||||
boolean needRedial = false;
|
||||
// 根据id查询任务
|
||||
SignPatientManageRouteNode signPatientManageRouteNode = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeById(Long.valueOf(data.getExtJson()));
|
||||
if (ObjectUtils.isNotEmpty(signPatientManageRouteNode)) {
|
||||
// 标记任务执行状态
|
||||
signPatientManageRouteNode.setNodeExecuteStatus(NodeExecuteStatusEnum.EXECUTED.getInfo());
|
||||
// 获取电话已拨打次数
|
||||
PhoneDialRecord phoneDialRecordQuery = new PhoneDialRecord();
|
||||
phoneDialRecordQuery.setManageRouteNodeId(signPatientManageRouteNode.getId());
|
||||
// 电话拨打未成功,判断是否需要重拨;电话拨打成功,设置电话拨通情况为成功
|
||||
if (data.getEndType() != null && data.getEndType() == 0) {//接通状态,1-已接通 0-未接通
|
||||
// 不需要重拨,设置电话拨通情况
|
||||
//接通状态,1-已接通 0-未接通
|
||||
if (data.getEndType() != null && data.getEndType() == 0) {
|
||||
// 设置电话拨通情况
|
||||
signPatientManageRouteNode.setPhoneNodeExecuteResultStatus(NodeExecuteResultStatusEnum.FAILURE.getInfo());
|
||||
// 电话短信提醒
|
||||
if (StringUtils.equals(PhoneMessageRemindConstants.NOT_CONNECTED_SEND_MESSAGE, signPatientManageRouteNode.getPhoneMessageRemind())) {
|
||||
// 发送短信
|
||||
needSendSms = true;
|
||||
}
|
||||
|
||||
// 实时任务设置电话重拨
|
||||
if (callbackType == 3) {
|
||||
// 查询拨打次数
|
||||
PhoneDialRecord phoneDialRecordQuery = new PhoneDialRecord();
|
||||
phoneDialRecordQuery.setManageRouteNodeId(signPatientManageRouteNode.getId());
|
||||
List<PhoneDialRecord> phoneDialRecordList = phoneDialRecordMapper.selectPhoneDialRecordList(phoneDialRecordQuery);
|
||||
if (CollectionUtils.isEmpty(phoneDialRecordList) || phoneDialRecordList.size() + 1 < PhoneRedialTimesEnum.getValueByInfo(signPatientManageRouteNode.getPhoneRedialTimes()).getValue()) {
|
||||
// 重拨
|
||||
needRedial = true;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
signPatientManageRouteNode.setPhoneNodeExecuteResultStatus(NodeExecuteResultStatusEnum.SUCCESS.getInfo());
|
||||
if (StringUtils.equals(PhoneMessageRemindConstants.CONNECTED_SEND_MESSAGE, signPatientManageRouteNode.getPhoneMessageRemind())) {
|
||||
@ -373,9 +398,15 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
|
||||
signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(signPatientManageRouteNode);
|
||||
|
||||
// 重拨表任务执行状态修改
|
||||
ScriptInfoTaskInfo scriptInfoTaskInfo = new ScriptInfoTaskInfo();
|
||||
scriptInfoTaskInfo.setSignPatientManageRouteNodeId(signPatientManageRouteNode.getRouteNodeId());
|
||||
scriptInfoTaskInfo.setAiobTaskType(AiboTaskTypeContant.ACTUALTIMETASK);
|
||||
scriptInfoTaskInfoMapper.updateExecuteStatusByNodeId(signPatientManageRouteNode.getRouteNodeId());
|
||||
|
||||
// 任务执行记录
|
||||
PatientTaskExecuteRecord patientTaskExecuteRecord = new PatientTaskExecuteRecord();
|
||||
BeanUtils.copyProperties(signPatientManageRouteNode, patientTaskExecuteRecord);
|
||||
|
||||
SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(signPatientManageRouteNode.getManageRouteId());
|
||||
if (ObjectUtils.isNotEmpty(signPatientManageRoute)) {
|
||||
patientTaskExecuteRecord.setPatientId(signPatientManageRoute.getPatientId());
|
||||
@ -390,6 +421,11 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
if (needSendSms) {
|
||||
sendSms(signPatientManageRoute.getPatientId(), signPatientManageRouteNode);
|
||||
}
|
||||
// 重拨
|
||||
if (needRedial) {
|
||||
PatientVisitRecord patientVisitRecord = patientVisitRecordMapper.selectPatientVisitRecordById(signPatientRecord.getPatientVisitRecordId());
|
||||
redialInfoSave(signPatientManageRouteNode, patientVisitRecord);
|
||||
}
|
||||
}
|
||||
// 增加任务执行记录
|
||||
patientTaskExecuteRecord.setManageRouteNodeId(signPatientManageRouteNode.getId());
|
||||
@ -422,6 +458,7 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
if (StringUtils.equals(signPatientManageRouteNode.getTaskNodeType(), TaskNodeTypeEnum.QUESTIONNAIRE_SCALE.getInfo())) {
|
||||
parseQuestionInfo(data.getRecord(), signPatientManageRouteNode, signPatientManageRoute.getPatientId(), patientTaskExecuteRecord.getId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return retObj;
|
||||
@ -610,4 +647,22 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
return questionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 重拨信息保存
|
||||
* @param signPatientManageRouteNode 任务信息
|
||||
* @param patientVisitRecord 就诊记录信息
|
||||
* @Author haown
|
||||
* @Date 2024-9-24 15:08
|
||||
*/
|
||||
private void redialInfoSave(SignPatientManageRouteNode signPatientManageRouteNode, PatientVisitRecord patientVisitRecord) {
|
||||
ScriptInfoTaskInfo scriptInfoTaskInfo = new ScriptInfoTaskInfo();
|
||||
scriptInfoTaskInfo.setScriptInfoId(signPatientManageRouteNode.getScriptInfoId());
|
||||
scriptInfoTaskInfo.setRobotId(signPatientManageRouteNode.getRobotPublishId());
|
||||
scriptInfoTaskInfo.setCreateTime(LocalDateTime.now());
|
||||
scriptInfoTaskInfo.setSignPatientManageRouteNodeId(signPatientManageRouteNode.getId());
|
||||
scriptInfoTaskInfo.setAiobTaskType(AiboTaskTypeContant.ACTUALTIMETASK);
|
||||
LocalDateTime executeTime = signPatientManageRouteNodeService.getExecuteTime(signPatientManageRouteNode.getExecuteTime(), signPatientManageRouteNode.getRouteNodeName(), signPatientManageRouteNode.getRouteNodeDay(), patientVisitRecord);
|
||||
scriptInfoTaskInfo.setExecuteTime(executeTime.minusMinutes(signPatientManageRouteNode.getPhoneTimeInterval()));
|
||||
scriptInfoTaskInfoMapper.insertScriptInfoTaskInfo(scriptInfoTaskInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -722,6 +722,10 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage
|
||||
generateByManageRoute(signPatientManageRoute, signPatientRecord.getPatientId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动创建的任务标签替换
|
||||
* @param signRecordId 签约记录主键
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void manualCreateTaskLabelReplace(Long signRecordId) {
|
||||
@ -1232,9 +1236,8 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage
|
||||
.taskExecuteNum(BigDecimal.ZERO)
|
||||
.taskFinishNum(BigDecimal.ZERO)
|
||||
.build());
|
||||
}
|
||||
|
||||
// 任务上传至爱医生
|
||||
}
|
||||
}
|
||||
|
||||
private String replaceNodeContent(String nodeContent, List<PatientNodeParamsCurrent> paramsList) {
|
||||
|
||||
@ -9,6 +9,10 @@
|
||||
<result property="scriptInfoId" column="script_info_id"/>
|
||||
<result property="robotId" column="robot_id"/>
|
||||
<result property="taskId" column="task_id"/>
|
||||
<result property="signPatientManageRouteNodeId" column="sign_patient_manage_route_node_id"/>
|
||||
<result property="executeTime" column="execute_time"/>
|
||||
<result property="aiobTaskType" column="aiob_task_type"/>
|
||||
<result property="executeStatus" column="execute_status"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
</resultMap>
|
||||
|
||||
@ -17,6 +21,10 @@
|
||||
script_info_id,
|
||||
robot_id,
|
||||
task_id,
|
||||
sign_patient_manage_route_node_id,
|
||||
execute_time,
|
||||
aiob_task_type,
|
||||
execute_status,
|
||||
create_time,
|
||||
from script_info_task_info
|
||||
</sql>
|
||||
@ -24,7 +32,24 @@
|
||||
<select id="getByNodeId" resultType="java.lang.String">
|
||||
select task_id
|
||||
from script_info_task_info
|
||||
where sign_patient_manage_route_node_id = #{signPatientManageRouteNodeId} and del_flag = 0
|
||||
where sign_patient_manage_route_node_id = #{signPatientManageRouteNodeId}
|
||||
and aiob_task_type = #{aiobTaskType}
|
||||
and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectList" resultType="ScriptInfoTaskInfo">
|
||||
<include refid="selectScriptInfoTaskInfoVo"/>
|
||||
<where>
|
||||
<if test="signPatientManageRouteNodeId != null ">
|
||||
and sign_patient_manage_route_node_id = #{signPatientManageRouteNodeId}
|
||||
</if>
|
||||
<if test="aiobTaskType != null ">
|
||||
and aiob_task_type = #{aiobTaskType}
|
||||
</if>
|
||||
<if test="executeStatus != null ">
|
||||
and execute_status = #{executeStatus}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertScriptInfoTaskInfo" parameterType="ScriptInfoTaskInfo" useGeneratedKeys="true"
|
||||
@ -39,6 +64,12 @@
|
||||
</if>
|
||||
<if test="signPatientManageRouteNodeId != null">sign_patient_manage_route_node_id,
|
||||
</if>
|
||||
<if test="executeTime != null">execute_time,
|
||||
</if>
|
||||
<if test="aiobTaskType != null">aiob_task_type,
|
||||
</if>
|
||||
<if test="executeStatus != null">execute_status,
|
||||
</if>
|
||||
<if test="createTime != null">create_time,
|
||||
</if>
|
||||
</trim>
|
||||
@ -51,11 +82,22 @@
|
||||
</if>
|
||||
<if test="signPatientManageRouteNodeId != null">#{signPatientManageRouteNodeId},
|
||||
</if>
|
||||
<if test="executeTime != null">#{executeTime},
|
||||
</if>
|
||||
<if test="aiobTaskType != null">#{aiobTaskType},
|
||||
</if>
|
||||
<if test="executeStatus != null">#{executeStatus},
|
||||
</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateExecuteStatusByNodeId" parameterType="java.lang.Long">
|
||||
update script_info_task_info set execute_status = 'EXECUTED'
|
||||
where signPatientManageRouteNodeId = #{signPatientManageRouteNodeId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteScriptInfoTaskInfo">
|
||||
update script_info_task_info set del_flag = 1 where del_flag = 0
|
||||
</delete>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.xinelu.quartz.task;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.xinelu.common.constant.AiboTaskTypeContant;
|
||||
import com.xinelu.common.enums.NodeExecuteStatusEnum;
|
||||
import com.xinelu.common.enums.PhoneDialMethodEnum;
|
||||
import com.xinelu.common.enums.PhoneRedialTimesEnum;
|
||||
@ -12,6 +13,7 @@ import com.xinelu.manage.domain.scriptinfotaskinfo.ScriptInfoTaskInfo;
|
||||
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.dto.aibo.ActualTimeTaskDto;
|
||||
import com.xinelu.manage.dto.aibo.CreateTaskDto;
|
||||
import com.xinelu.manage.dto.aibo.CustomerInfoDto;
|
||||
import com.xinelu.manage.dto.aibo.ImportTaskDto;
|
||||
@ -103,7 +105,7 @@ public class UploadRobotPublishTask {
|
||||
// 根据机器人id查询智能外呼系统的任务id
|
||||
executeNodeList.forEach(node -> {
|
||||
ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(node.getScriptInfoId());
|
||||
String taskId = scriptInfoTaskInfoMapper.getByNodeId(node.getId());
|
||||
String taskId = scriptInfoTaskInfoMapper.getByNodeId(node.getId(), AiboTaskTypeContant.BATCHTASK);
|
||||
if (StringUtils.isBlank(taskId)) {
|
||||
// 没有任务则创建任务
|
||||
if (ObjectUtils.isNotEmpty(scriptInfo)) {
|
||||
@ -130,6 +132,7 @@ public class UploadRobotPublishTask {
|
||||
scriptInfoTaskInfo.setRobotId(scriptInfo.getRobotPublishId());
|
||||
scriptInfoTaskInfo.setCreateTime(LocalDateTime.now());
|
||||
scriptInfoTaskInfo.setSignPatientManageRouteNodeId(node.getId());
|
||||
scriptInfoTaskInfo.setAiobTaskType(AiboTaskTypeContant.BATCHTASK);
|
||||
scriptInfoTaskInfoMapper.insertScriptInfoTaskInfo(scriptInfoTaskInfo);
|
||||
}
|
||||
}
|
||||
@ -177,6 +180,100 @@ public class UploadRobotPublishTask {
|
||||
log.info("百度智能外呼创建任务定时任务执行完成......");
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 创建实时任务
|
||||
* @return null
|
||||
* @Author haown
|
||||
* @Date 2024-9-23 10:41
|
||||
*/
|
||||
public void actualTimeTask() {
|
||||
log.info("开始执行百度智能外呼创建实时任务定时任务......");
|
||||
// 查找需要当天执行的AI打电话任务(问卷或电话外呼类型)
|
||||
SignPatientManageRouteNodeDto signPatientManageRouteNodeDto = new SignPatientManageRouteNodeDto();
|
||||
signPatientManageRouteNodeDto.setNodeExecuteStatus(NodeExecuteStatusEnum.UNEXECUTED.getInfo());
|
||||
signPatientManageRouteNodeDto.setPhoneDialMethod(PhoneDialMethodEnum.AI.getInfo());
|
||||
List<SignPatientManageRouteNode> nodeList = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeList(signPatientManageRouteNodeDto);
|
||||
List<SignPatientManageRouteNode> executeNodeList = new ArrayList<>();
|
||||
nodeList.forEach(node -> {
|
||||
SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId());
|
||||
SignPatientRecord signPatientRecord = signPatientRecordMapper.selectByPrimaryKey(signPatientManageRoute.getSignPatientRecordId());
|
||||
PatientVisitRecord patientVisitRecord = patientVisitRecordMapper.selectPatientVisitRecordById(signPatientRecord.getPatientVisitRecordId());
|
||||
LocalDateTime executeTime = signPatientManageRouteNodeService.getExecuteTime(node.getExecuteTime(), node.getRouteNodeName(), node.getRouteNodeDay(), patientVisitRecord);
|
||||
if (node.getScriptInfoId() != null && (executeTime.toLocalDate().isBefore(LocalDate.now()) || executeTime.toLocalDate().isEqual(LocalDate.now()))) {
|
||||
executeNodeList.add(node);
|
||||
}
|
||||
});
|
||||
|
||||
// 查询需要重拨的任务
|
||||
ScriptInfoTaskInfo scriptInfoTaskInfo = new ScriptInfoTaskInfo();
|
||||
List<ScriptInfoTaskInfo> scriptInfoTaskInfoList = scriptInfoTaskInfoMapper.selectList(scriptInfoTaskInfo);
|
||||
scriptInfoTaskInfoList.forEach(taskInfo -> {
|
||||
SignPatientManageRouteNode node = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeById(taskInfo.getSignPatientManageRouteNodeId());
|
||||
if (taskInfo.getExecuteTime().isBefore(LocalDateTime.now()) || taskInfo.getExecuteTime().isEqual(LocalDateTime.now())) {
|
||||
executeNodeList.add(node);
|
||||
}
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(executeNodeList)) {
|
||||
// 根据机器人id查询智能外呼系统的任务id
|
||||
executeNodeList.forEach(node -> {
|
||||
createTask(node);
|
||||
});
|
||||
}
|
||||
log.info("百度智能外呼创建实时任务定时任务执行完成......");
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 创建重拨任务
|
||||
* @return null
|
||||
* @Author haown
|
||||
* @Date 2024-9-24 16:10
|
||||
*/
|
||||
//public void redialTask() {
|
||||
// log.info("开始执行重拨任务定时任务......");
|
||||
// List<SignPatientManageRouteNode> executeNodeList = new ArrayList<>();
|
||||
// // 查询需要重拨的任务
|
||||
// ScriptInfoTaskInfo scriptInfoTaskInfo = new ScriptInfoTaskInfo();
|
||||
// List<ScriptInfoTaskInfo> scriptInfoTaskInfoList = scriptInfoTaskInfoMapper.selectList(scriptInfoTaskInfo);
|
||||
// scriptInfoTaskInfoList.forEach(taskInfo -> {
|
||||
// SignPatientManageRouteNode node = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeById(taskInfo.getSignPatientManageRouteNodeId());
|
||||
// if (taskInfo.getExecuteTime().isBefore(LocalDateTime.now()) || taskInfo.getExecuteTime().isEqual(LocalDateTime.now())) {
|
||||
// createTask(node);
|
||||
// }
|
||||
// });
|
||||
// log.info("重拨任务定时任务执行完成......");
|
||||
//}
|
||||
|
||||
private void createTask(SignPatientManageRouteNode node) {
|
||||
ScriptInfo scriptInfo = scriptInfoMapper.selectScriptInfoById(node.getScriptInfoId());
|
||||
SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId());
|
||||
PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(signPatientManageRoute.getPatientId());
|
||||
// 没有任务则创建任务
|
||||
if (ObjectUtils.isNotEmpty(scriptInfo)) {
|
||||
log.info("创建任务......");
|
||||
ActualTimeTaskDto actualTimeTaskDto = new ActualTimeTaskDto();
|
||||
actualTimeTaskDto.setRobotId(scriptInfo.getRobotPublishId());
|
||||
actualTimeTaskDto.setMobile(patientInfo.getPatientPhone());
|
||||
actualTimeTaskDto.setSecretType(2);
|
||||
actualTimeTaskDto.setStopDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
||||
// 查询患者画像信息
|
||||
List<LabelFieldInfoContentVo> labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfo.getId());
|
||||
// 处理变量
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (StringUtils.isNotBlank(scriptInfo.getVariables())) {
|
||||
List<String> 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());
|
||||
});
|
||||
}
|
||||
actualTimeTaskDto.setDialogVar(jsonObject);
|
||||
actualTimeTaskDto.setCallBackUrl(callBackUrl);
|
||||
actualTimeTaskDto.setExtJson(node.getId()+ "");
|
||||
aiobService.createActualTimeTask(actualTimeTaskDto);
|
||||
log.info("创建任务完成......");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 删除话术任务记录表信息,每天晚上执行一次
|
||||
* @Author haown
|
||||
|
||||
Loading…
Reference in New Issue
Block a user