百度外呼创建实时任务接口。
This commit is contained in:
parent
342f7444a5
commit
3034cf73ed
@ -4,12 +4,14 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.xinelu.common.core.controller.BaseController;
|
||||
import com.xinelu.common.core.domain.R;
|
||||
import com.xinelu.manage.dto.aibo.ActualTimeTaskDto;
|
||||
import com.xinelu.manage.dto.aibo.CreateTaskDto;
|
||||
import com.xinelu.manage.dto.aibo.TaskCallbackDto;
|
||||
import com.xinelu.manage.service.aibo.IAIOBService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -52,6 +54,21 @@ public class AIOBController extends BaseController {
|
||||
return R.ok(aiobService.createTask(createTaskDto));
|
||||
}
|
||||
|
||||
@ApiOperation("创建实时任务")
|
||||
@GetMapping("/createActualTimeTask")
|
||||
public R<Long> createActualTimeTask(ActualTimeTaskDto actualTimeTaskDto) {
|
||||
actualTimeTaskDto.setRobotId("8e5d5e08-9e82-44a7-ab38-c20f56388b25");
|
||||
actualTimeTaskDto.setMobile("15166940975");
|
||||
actualTimeTaskDto.setSecretType(2);
|
||||
JSONObject dialogVar = new JSONObject();
|
||||
dialogVar.fluentPut("patient_name", "张三")
|
||||
.fluentPut("department_name", "山东省立医院");
|
||||
actualTimeTaskDto.setDialogVar(dialogVar);
|
||||
actualTimeTaskDto.setCallBackUrl("http://8.131.93.145:54011/api/taskCallBack");
|
||||
actualTimeTaskDto.setExtJson("646");
|
||||
return R.ok(aiobService.createActualTimeTask(actualTimeTaskDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 任务状态变更
|
||||
* @param taskId 任务id
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
package com.xinelu.manage.dto.aibo;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description: 百度外呼创建实时任务传输对象
|
||||
* @author: haown
|
||||
* @create: 2024-09-20 15:35
|
||||
**/
|
||||
@Data
|
||||
public class ActualTimeTaskDto {
|
||||
|
||||
/**
|
||||
* 外呼机器人唯一标识
|
||||
*/
|
||||
private String robotId;
|
||||
|
||||
/**
|
||||
* 被叫号码
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 加密类型, 1:系统加密,即被叫号码采用系统的加密方式,AES128加密;
|
||||
* 2:不加密,即被叫号码为明文;
|
||||
* 3:自定义加密,即被叫号码采用客户自定义的加密方式,需在配置台-隐私配置-其他配置中配置自定义加解密服务地址,便于请求解密
|
||||
*/
|
||||
private Integer secretType;
|
||||
|
||||
/**
|
||||
* 呼叫截止时间,yyyy-MM-dd HH:mm:ss,默认为空,则不限制呼叫截止时间
|
||||
*/
|
||||
private String stopDate;
|
||||
|
||||
/**
|
||||
* 变量信息,用于短信或机器人对话中使用
|
||||
*/
|
||||
private JSONObject dialogVar;
|
||||
|
||||
/**
|
||||
* 任务级别,指定当前任务回调的地址,如果没有配置默认按照全局配置推送
|
||||
*/
|
||||
private String callBackUrl;
|
||||
|
||||
/**
|
||||
* 调用方的业务随路数据, 字符串,百度侧原文回传
|
||||
*/
|
||||
private String extJson;
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.xinelu.manage.service.aibo;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.xinelu.manage.dto.aibo.ActualTimeTaskDto;
|
||||
import com.xinelu.manage.dto.aibo.CreateTaskDto;
|
||||
import com.xinelu.manage.dto.aibo.ImportTaskDto;
|
||||
import com.xinelu.manage.dto.aibo.TaskCallbackDataDto;
|
||||
@ -33,6 +34,15 @@ public interface IAIOBService {
|
||||
*/
|
||||
String createTask(CreateTaskDto createTaskDto);
|
||||
|
||||
/**
|
||||
* @description 创建实时任务
|
||||
* @param actualTimeTaskDto 百度外呼创建实时任务传输对象
|
||||
* @return memberId 被叫号码系统唯一标识,可根据该标识查询通话记录
|
||||
* @Author haown
|
||||
* @Date 2024-9-20 16:15
|
||||
*/
|
||||
Long createActualTimeTask(ActualTimeTaskDto actualTimeTaskDto);
|
||||
|
||||
/**
|
||||
* @description 任务状态变更
|
||||
* @param taskId 任务id
|
||||
|
||||
@ -30,6 +30,7 @@ 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.ActualTimeTaskDto;
|
||||
import com.xinelu.manage.dto.aibo.AiboRecord;
|
||||
import com.xinelu.manage.dto.aibo.CreateTaskDto;
|
||||
import com.xinelu.manage.dto.aibo.CustomerInfoDto;
|
||||
@ -219,6 +220,30 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 创建实时任务
|
||||
* @param actualTimeTaskDto 百度外呼创建实时任务传输对象
|
||||
* @return memberId 被叫号码系统唯一标识,可根据该标识查询通话记录
|
||||
* @Author haown
|
||||
* @Date 2024-9-20 16:15
|
||||
*/
|
||||
@Override public Long createActualTimeTask(ActualTimeTaskDto actualTimeTaskDto) {
|
||||
String accessToken = getAccessToken();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set("Authorization", accessToken);
|
||||
|
||||
HttpEntity<JSONObject> requestEntity = new HttpEntity<>((JSONObject)JSON.toJSON(actualTimeTaskDto), headers);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url + "/v3/console/realtime/status/create", HttpMethod.POST, requestEntity, String.class);
|
||||
JSONObject object = JSON.parseObject(responseEntity.getBody());
|
||||
if (object == null || object.getInteger("code") == null || object.getInteger("code") != 200) {
|
||||
throw new ServiceException("创建任务失败," + object.getString("msg"));
|
||||
}
|
||||
JSONObject data = object.getJSONObject("data");
|
||||
return data.getLong("memberId");
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 任务状态变更
|
||||
* @param taskId 任务id
|
||||
@ -316,7 +341,7 @@ public class AIOBServiceImpl implements IAIOBService {
|
||||
public JSONObject taskCallBack(Integer callbackType, TaskCallbackDataDto data) throws ClientException {
|
||||
JSONObject retObj = new JSONObject();
|
||||
retObj.fluentPut("code", 200).fluentPut("msg", "success");
|
||||
if (callbackType == 0) {
|
||||
if (callbackType == 0 || callbackType == 3) {
|
||||
// 是否发送短信标识
|
||||
boolean needSendSms = false;
|
||||
// 根据id查询任务
|
||||
|
||||
Loading…
Reference in New Issue
Block a user