Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-execute-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0d234804
authored
Sep 11, 2023
by
叶立庆
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]接入ai外呼http接口
1 parent
f0767cea
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
789 additions
and
1 deletions
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/rop/MethodEnum.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetCustomerDetailRequestDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetCustomerDetailResponseDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetRobotListRequestDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetRobotListResponseDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiImportCallJobCustomerRequestDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiImportCallJobCustomerResponseDTO.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/converter/rop/RopRequestConveter.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/converter/rop/RopResponseConveter.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/proxy/AiOutboundCallService.java
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/BaseTest.java
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/Utils/SendMessageServiceTest.java
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/aioutboundcall/AiOutboundCallTest.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/rop/MethodEnum.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
execute
.
modules
.
enums
.
rop
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* @Author yelq
* @Version 1.0
* @Description: rop框架的方法地址
* @Date 2023/9/11 11:58
*/
@Getter
@AllArgsConstructor
public
enum
MethodEnum
{
ROBOT_LIST
(
"marketing.api.ai.outbound.call.getRobotList"
,
"获取机器人列表"
),
INVOKE_AI_CALL
(
"marketing.api.ai.outbound.call.invokeAICall"
,
"执行AI外呼"
),
CUSTOMER_CALL_DETAIL
(
"marketing.api.ai.outbound.call.customer.detail"
,
"客户通话详情"
),
;
private
String
method
;
private
String
describe
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetCustomerDetailRequestDTO.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.ToString
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.io.Serializable
;
/**
* @Description
* @author chizw
* @create 2023/7/5 10:32
* @version ver.1.0.0
*/
@JsonSerialize
()
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiGetCustomerDetailRequestDTO
implements
Serializable
{
/**
* 导入客户id
*/
@JsonProperty
(
"importCustomerId"
)
@Schema
(
name
=
"importCustomerId"
,
description
=
"导入客户id"
)
private
Integer
importCustomerId
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetCustomerDetailResponseDTO.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.ToString
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Description
* @author chizw
* @create 2023/7/5 10:32
* @version ver.1.0.0
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@JsonSerialize
(
include
=
JsonSerialize
.
Inclusion
.
NON_NULL
)
@Data
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiGetCustomerDetailResponseDTO
implements
Serializable
{
/**
* 通话时长
*/
@JsonProperty
(
"duration"
)
@Schema
(
name
=
"duration"
,
description
=
"通话时长"
)
private
Long
duration
;
/**
* 录音地址
*/
@JsonProperty
(
"luyinOssUrl"
)
@Schema
(
name
=
"luyinOssUrl"
,
description
=
"录音地址"
)
private
String
luyinOssUrl
;
/**
* 通话日志
*/
@JsonProperty
(
"phoneLogs"
)
@Schema
(
name
=
"phoneLogs"
,
description
=
"通话日志"
)
private
List
<
PhoneLogVO
>
phoneLogs
;
@Data
public
static
class
PhoneLogVO
implements
Serializable
{
/**
* 是否是ai无法应答的问题,1-是,0-否
*/
@JsonProperty
(
"aiUnknown"
)
@Schema
(
name
=
"aiUnknown"
,
description
=
"是否是ai无法应答的问题,1-是,0-否"
)
private
Long
aiUnknown
;
/**
* 通话id
*/
@JsonProperty
(
"callInstanceId"
)
@Schema
(
name
=
"callInstanceId"
,
description
=
"通话id"
)
private
Long
callInstanceId
;
/**
* 说话内容
*/
@JsonProperty
(
"content"
)
@Schema
(
name
=
"content"
,
description
=
"说话内容"
)
private
String
content
;
/**
* 说话的结束时间
*/
@JsonProperty
(
"endTime"
)
@Schema
(
name
=
"endTime"
,
description
=
"说话的结束时间"
)
private
Date
endTime
;
/**
* 说话人,ME: 客户 AI: 机器人
*/
@JsonProperty
(
"speaker"
)
@Schema
(
name
=
"speaker"
,
description
=
"说话人,ME: 客户 AI: 机器人"
)
private
String
speaker
;
/**
* 说话的开始时间
*/
@JsonProperty
(
"startTime"
)
@Schema
(
name
=
"startTime"
,
description
=
"说话的开始时间"
)
private
Date
startTime
;
}
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetRobotListRequestDTO.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.ToString
;
import
java.io.Serializable
;
/**
* @Description 百应话术列表请求
* @author chizw
* @create 2023/7/5 10:32
* @version ver.1.0.0
*/
@JsonSerialize
()
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiGetRobotListRequestDTO
implements
Serializable
{
/**
* 商户号
*/
@JsonProperty
(
"merchantId"
)
@Schema
(
name
=
"merchantId"
,
description
=
"商户号"
,
example
=
"0"
)
private
Integer
merchantId
;
/**
* 公司Id
*/
@JsonProperty
(
"companyId"
)
@Schema
(
name
=
"companyId"
,
description
=
"公司Id"
,
example
=
"1"
)
private
Long
companyId
;
/**
* 话术状态 0:所有话术,1:已上线话术,2:查询发布过(含已上线和上线后重新修改)的话术 ;默认为0
*/
@JsonProperty
(
"robotStatus"
)
@Schema
(
name
=
"robotStatus"
,
description
=
"话术状态 0:所有话术,1:已上线话术,2:查询发布过(含已上线和上线后重新修改)的话术 ;默认为0"
,
example
=
"0"
)
private
Long
robotStatus
;
/**
* 查询百应所有话术
*/
@JsonProperty
(
"selectAll"
)
@Schema
(
name
=
"selectAll"
,
description
=
"查询百应所有话术"
)
private
Boolean
selectAll
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetRobotListResponseDTO.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.ToString
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @author chizw
* @version ver.1.0.0
* @Description 百应话术列表返回
* @create 2023/7/5 10:32
*/
@Data
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiGetRobotListResponseDTO
implements
Serializable
{
/**
* 公司的机器人话术列表
*/
@Schema
(
name
=
"list"
,
description
=
"公司的机器人话术列表"
)
private
List
<
RobotVO
>
list
;
/**
* 公司的机器人话术列表
*/
@Data
public
static
class
RobotVO
implements
Serializable
{
/**
* 机器人ID
*/
@Schema
(
name
=
"robotDefId"
,
description
=
"机器人ID"
,
example
=
"1"
)
private
Long
robotDefId
;
/**
* 机器人名称
*/
@Schema
(
name
=
"robotName"
,
description
=
"机器人名称"
,
example
=
"测试"
)
private
String
robotName
;
/**
* 一级行业名
*/
@Schema
(
name
=
"industryOneName"
,
description
=
"一级行业名"
,
example
=
"房产"
)
private
String
industryOneName
;
/**
* 二级行业名
*/
@Schema
(
name
=
"industryTwoName"
,
description
=
"二级行业名"
,
example
=
"卖房"
)
private
String
industryTwoName
;
/**
* 话术状态 0:待发布 1:待审核 2:待录音 3:待上线 4:审核不通过 5:已上线
*/
@Schema
(
name
=
"robotStatus"
,
description
=
"话术状态 0:待发布 1:待审核 2:待录音 3:待上线 4:审核不通过 5:已上线"
,
example
=
"0"
)
private
Long
robotStatus
;
/**
* 发布时间
*/
@Schema
(
name
=
"deployTime"
,
description
=
"发布时间"
,
example
=
"2022-02-22 17:04:18"
)
private
String
deployTime
;
}
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiImportCallJobCustomerRequestDTO.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.ToString
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author chizw
* @version ver.1.0.0
* @Description 百应导入客户请求
* @create 2023/7/5 10:32
*/
@JsonSerialize
()
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiImportCallJobCustomerRequestDTO
implements
Serializable
{
/**
* 商户号
*/
@JsonProperty
(
"merchantId"
)
@Schema
(
name
=
"merchantId"
,
description
=
"商户号"
)
private
Integer
merchantId
;
/**
* 话术状态 0:所有话术,1:已上线话术,2:查询发布过(含已上线和上线后重新修改)的话术 ;默认为0
*/
@JsonProperty
(
"callJobId"
)
@Schema
(
name
=
"callJobId"
,
description
=
"话术状态 0:所有话术,1:已上线话术,2:查询发布过(含已上线和上线后重新修改)的话术 ;默认为0"
)
private
Long
callJobId
;
/**
* 公司Id
*/
@JsonProperty
(
"companyId"
)
@Schema
(
name
=
"companyId"
,
description
=
"公司Id"
,
example
=
"30123"
)
private
Long
companyId
;
/**
* 用户信息字段,其中phone为必传,name可不传,properties字段在话术中有变量时为必传字段;
* 如果需自定义参数也可以通过properties入参;变量可通过“查询话术变量”接口查询;
* 如果使用了SDK中AES方式加密数据,需要入参encryptionProp、encryptionPhone为true
*/
@JsonProperty
(
"customerInfoVOList"
)
@Schema
(
name
=
"customerInfoVOList"
,
required
=
true
,
description
=
"话术状态 0:所有话术,1:已上线话术,2:查询发布过(含已上线和上线后重新修改)的话术 ;默认为0"
)
private
List
<
CustomerInfoVO
>
customerInfoVOList
;
@Data
public
static
class
CustomerInfoVO
implements
Serializable
{
/**
* 客户名称
*/
@JsonProperty
(
"name"
)
@Schema
(
name
=
"name"
,
description
=
"客户名称"
,
example
=
"赵四"
,
required
=
true
)
private
String
name
;
/**
* 客户电话
*/
@JsonProperty
(
"phone"
)
@Schema
(
name
=
"phone"
,
description
=
"客户电话"
,
example
=
"13900008888"
,
required
=
true
)
private
String
phone
;
/**
* 客户自定义额外信息
*/
@JsonProperty
(
"properties"
)
@Schema
(
name
=
"properties"
,
description
=
"客户自定义额外信息"
,
example
=
"{\"客户名称\":\"赵四\",\"联系方式\":\"13700000731\"}"
)
private
Map
<
String
,
String
>
properties
;
}
/**
* 手机号码加密,默认false;仅在使用sdk加密(AES)时需要传,并需传入 true
*/
@JsonProperty
(
"encryptionPhone"
)
@Schema
(
name
=
"encryptionPhone"
,
description
=
"手机号码加密,默认false;仅在使用sdk加密(AES)时需要传,并需传入 true"
,
example
=
"false"
)
private
Boolean
encryptionPhone
;
/**
* 客户属性加密,默认false;仅在使用sdk加密(AES)时需要传,并需传入 true
*/
@JsonProperty
(
"encryptionProp"
)
@Schema
(
name
=
"encryptionProp"
,
description
=
"客户属性加密,默认false;仅在使用sdk加密(AES)时需要传,并需传入 true"
,
example
=
"false"
)
private
Boolean
encryptionProp
;
/**
* 同一个任务中是否支持重复导入手机号,默认false
*/
@JsonProperty
(
"permitrepeatnum"
)
@Schema
(
name
=
"permitrepeatnum"
,
description
=
"同一个任务中是否支持重复导入手机号,默认false"
,
example
=
"true"
)
private
Boolean
permitrepeatnum
;
/**
* 任务类型, 1-定时,2-手动;当选择定时任务时,startDate为必传
*/
@JsonProperty
(
"callJobType"
)
@Schema
(
name
=
"callJobType"
,
description
=
"任务类型, 1-定时,2-手动;当选择定时任务时,startDate为必传"
,
example
=
"true"
)
private
Long
callJobType
;
/**
* 任务开始日期(定时任务必填)格式2019-08-08 精确到天
*/
@JsonProperty
(
"startDate"
)
@Schema
(
name
=
"startDate"
,
description
=
"任务开始日期(定时任务必填)格式2019-08-08 精确到天"
,
example
=
"2019-08-08"
)
private
String
startDate
;
/**
* 自定义多时段
*/
@JsonProperty
(
"workingTimeRuleList"
)
@Schema
(
name
=
"workingTimeRuleList"
,
description
=
"自定义多时段"
,
example
=
"[{\"timeRanges\":[{\"startTime\":\"09:00\",\"endTime\":\"20:00\"}],\"weeks\":[1,2]}]"
)
private
List
<
JobWorkingTimeRuleDetailVO
>
workingTimeRuleList
;
@Data
public
static
class
JobWorkingTimeRuleDetailVO
implements
Serializable
{
/**
* timeRanges
*/
@JsonProperty
(
"timeRanges"
)
@Schema
(
name
=
"timeRanges"
,
description
=
"timeRanges"
)
private
List
<
TimeRangeVO
>
timeRanges
;
/**
* weeks
*/
@JsonProperty
(
"weeks"
)
@Schema
(
name
=
"weeks"
,
description
=
"weeks"
)
private
List
<
Integer
>
weeks
;
@Data
public
static
class
TimeRangeVO
implements
Serializable
{
/**
* 开始时间
*/
@JsonProperty
(
"startTime"
)
@Schema
(
name
=
"startTime"
,
description
=
"开始时间"
)
private
String
startTime
;
/**
* 结束时间
*/
@JsonProperty
(
"endTime"
)
@Schema
(
name
=
"endTime"
,
description
=
"结束时间"
)
private
String
endTime
;
}
}
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiImportCallJobCustomerResponseDTO.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.ToString
;
import
java.io.Serializable
;
/**
* @Description 百应导入客户返回
* @author chizw
* @create 2023/7/5 10:32
* @version ver.1.0.0
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@JsonSerialize
(
include
=
JsonSerialize
.
Inclusion
.
NON_NULL
)
@Data
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiImportCallJobCustomerResponseDTO
implements
Serializable
{
/**
* 导入结果
*/
@JsonProperty
(
"success"
)
@Schema
(
name
=
"success"
,
description
=
"导入结果"
)
private
Boolean
success
;
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/converter/rop/RopRequestConveter.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
execute
.
modules
.
converter
.
rop
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiGetCustomerDetailRequestDTO
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiGetRobotListRequestDTO
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiImportCallJobCustomerRequestDTO
;
import
cn.com.glsx.execute.modules.model.rop.RopResponseDTO
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
java.lang.reflect.Field
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Author yelq
* @Version 1.0
* @Description: rop框架请求转化
* @Date 2023/9/11 11:44
*/
public
class
RopRequestConveter
{
/**
* 详情参数
* @param requestDTO
* @return
*/
public
static
MultiValueMap
<
String
,
String
>
toMultiValueMap
(
ByaiGetCustomerDetailRequestDTO
requestDTO
){
if
(
requestDTO
==
null
)
return
new
LinkedMultiValueMap
<>();
Class
<?
extends
ByaiGetCustomerDetailRequestDTO
>
aClass
=
requestDTO
.
getClass
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
requestDTO
));
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
for
(
Field
field
:
declaredFields
)
{
Object
o
=
jsonObject
.
get
(
field
.
getName
());
if
(
o
==
null
)
continue
;
paramsMap
.
add
(
field
.
getName
(),
o
.
toString
());
}
return
paramsMap
;
}
/**
* 机器人列表参数封装
* @param requestDTO
* @return
*/
public
static
MultiValueMap
<
String
,
String
>
toMultiValueMap
(
ByaiGetRobotListRequestDTO
requestDTO
){
if
(
requestDTO
==
null
)
return
new
LinkedMultiValueMap
<>();
Class
<?
extends
ByaiGetRobotListRequestDTO
>
aClass
=
requestDTO
.
getClass
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
requestDTO
));
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
for
(
Field
field
:
declaredFields
)
{
Object
o
=
jsonObject
.
get
(
field
.
getName
());
if
(
o
==
null
)
continue
;
paramsMap
.
add
(
field
.
getName
(),
o
.
toString
());
}
return
paramsMap
;
}
/**
* 外呼参数封装
* @param requestDTO
* @return
*/
public
static
MultiValueMap
<
String
,
String
>
toMultiValueMap
(
ByaiImportCallJobCustomerRequestDTO
requestDTO
)
{
if
(
requestDTO
==
null
)
return
new
LinkedMultiValueMap
<>();
Class
<?
extends
ByaiImportCallJobCustomerRequestDTO
>
aClass
=
requestDTO
.
getClass
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
requestDTO
));
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
for
(
Field
field
:
declaredFields
)
{
if
(
"customerInfoVOList"
.
equals
(
field
.
getName
()))
{
List
<
ByaiImportCallJobCustomerRequestDTO
.
CustomerInfoVO
>
o
=
JSON
.
parseArray
(
jsonObject
.
getString
(
field
.
getName
()),
ByaiImportCallJobCustomerRequestDTO
.
CustomerInfoVO
.
class
);
if
(
CollectionUtils
.
isEmpty
(
o
))
continue
;
for
(
int
i
=
0
;
i
<
o
.
size
();
i
++)
{
ByaiImportCallJobCustomerRequestDTO
.
CustomerInfoVO
customerInfoVO
=
o
.
get
(
i
);
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].name"
,
customerInfoVO
.
getName
());
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].phone"
,
customerInfoVO
.
getPhone
());
if
(
customerInfoVO
.
getProperties
()
!=
null
&&
customerInfoVO
.
getProperties
().
size
()
>
0
)
{
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].properties"
,
JSON
.
toJSONString
(
customerInfoVO
.
getProperties
()));
}
}
}
else
if
(
"workingTimeRuleList"
.
equals
(
field
.
getName
()))
{
List
<
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
>
o
=
JSON
.
parseArray
(
jsonObject
.
getString
(
field
.
getName
()),
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
.
class
);
if
(
CollectionUtils
.
isEmpty
(
o
))
continue
;
for
(
int
i
=
0
;
i
<
o
.
size
();
i
++)
{
if
(!
CollectionUtils
.
isEmpty
(
o
.
get
(
i
).
getWeeks
()))
{
for
(
int
j
=
0
;
j
<
o
.
get
(
i
).
getWeeks
().
size
();
j
++)
{
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].weeks["
+
j
+
"]"
,
o
.
get
(
i
).
getWeeks
().
get
(
j
).
toString
());
}
}
if
(!
CollectionUtils
.
isEmpty
(
o
.
get
(
i
).
getTimeRanges
()))
{
for
(
int
j
=
0
;
j
<
o
.
get
(
i
).
getTimeRanges
().
size
();
j
++)
{
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].timeRanges["
+
j
+
"].startTime"
,
o
.
get
(
i
).
getTimeRanges
().
get
(
j
).
getStartTime
());
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].timeRanges["
+
j
+
"].endTime"
,
o
.
get
(
i
).
getTimeRanges
().
get
(
j
).
getEndTime
());
}
}
}
}
else
{
Object
o
=
jsonObject
.
get
(
field
.
getName
());
if
(
o
==
null
)
continue
;
paramsMap
.
add
(
field
.
getName
(),
o
.
toString
());
}
}
return
paramsMap
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/converter/rop/RopResponseConveter.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
execute
.
modules
.
converter
.
rop
;
import
cn.com.glsx.execute.modules.model.rop.RopResponseDTO
;
import
com.alibaba.fastjson.JSON
;
/**
* @Author yelq
* @Version 1.0
* @Description: rop框架请求返回转化
* @Date 2023/9/11 11:44
*/
public
class
RopResponseConveter
{
public
static
<
T
>
RopResponseDTO
<
T
>
convertRopResponse
(
String
source
,
Class
<
T
>
clazz
)
{
if
(
source
==
null
)
return
null
;
RopResponseDTO
ropResponseDTO
=
JSON
.
parseObject
(
source
,
RopResponseDTO
.
class
);
Object
data
=
ropResponseDTO
.
getData
();
if
(
data
!=
null
)
{
T
t
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
data
),
clazz
);
ropResponseDTO
.
setData
(
t
);
}
RopResponseDTO
<
T
>
resp
=
ropResponseDTO
;
return
resp
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/proxy/AiOutboundCallService.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
execute
.
modules
.
service
.
proxy
;
import
cn.com.glsx.execute.modules.converter.rop.RopRequestConveter
;
import
cn.com.glsx.execute.modules.converter.rop.RopResponseConveter
;
import
cn.com.glsx.execute.modules.enums.AppKeyEnum
;
import
cn.com.glsx.execute.modules.enums.rop.MethodEnum
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.*
;
import
cn.com.glsx.execute.modules.model.rop.RopResponseDTO
;
import
cn.com.glsx.execute.utils.RopHttpUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.formula.functions.T
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.MultiValueMap
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.UUID
;
/**
* @Author yelq
* @Version 1.0
* @Description: Ai外呼http对接
* @Date 2023/9/8 13:53
*/
@Service
@Slf4j
public
class
AiOutboundCallService
{
@Autowired
private
Environment
environment
;
/**
* 获取客户通话详情
* @param requestDTO
* @return
* @throws Exception
*/
public
ByaiGetCustomerDetailResponseDTO
getCustomerDetail
(
ByaiGetCustomerDetailRequestDTO
requestDTO
)
throws
Exception
{
String
url
=
environment
.
getProperty
(
""
);
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
);
log
.
info
(
"请求参数:{}"
,
paramsMap
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
CUSTOMER_CALL_DETAIL
.
getMethod
(),
null
);
log
.
info
(
"请求结果:{}"
,
post
);
RopResponseDTO
<
ByaiGetCustomerDetailResponseDTO
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
ByaiGetCustomerDetailResponseDTO
.
class
);
return
ropResponseDTO
.
getData
();
}
/**
* 导入客户执行外呼
* @param requestDTO
* @return
* @throws Exception
*/
public
ByaiImportCallJobCustomerResponseDTO
outboundCallInvoke
(
ByaiImportCallJobCustomerRequestDTO
requestDTO
)
throws
Exception
{
String
url
=
environment
.
getProperty
(
""
);
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
);
log
.
info
(
"请求参数:{}"
,
paramsMap
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
INVOKE_AI_CALL
.
getMethod
(),
null
);
log
.
info
(
"请求结果:{}"
,
post
);
RopResponseDTO
<
ByaiImportCallJobCustomerResponseDTO
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
ByaiImportCallJobCustomerResponseDTO
.
class
);
return
ropResponseDTO
.
getData
();
}
/**
* 获取机器人列表
* @param requestDTO
* @return
* @throws Exception
*/
public
ByaiGetRobotListResponseDTO
getRobotList
(
ByaiGetRobotListRequestDTO
requestDTO
)
throws
Exception
{
String
url
=
environment
.
getProperty
(
""
);
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
);
log
.
info
(
"请求参数:{}"
,
paramsMap
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
ROBOT_LIST
.
getMethod
(),
null
);
log
.
info
(
"请求结果:{}"
,
post
);
RopResponseDTO
<
ByaiGetRobotListResponseDTO
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
ByaiGetRobotListResponseDTO
.
class
);
return
ropResponseDTO
.
getData
();
}
}
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/BaseTest.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
cn
.
com
.
glsx
;
import
cn.com.glsx.Application
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
/**
* @Author yelq
* @Version 1.0
* @Description: 基础测试类
* @Date 2023/9/8 14:00
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
)
public
class
BaseTest
{
}
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/Utils/SendMessageServiceTest.java
View file @
0d23480
...
...
@@ -18,7 +18,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @Description:
* @Date 2023/9/7 17:14
*/
//@ComponentScan(basePackages = "cn.com.glsx.execute,cn.com.glsx.cn.com.glsx")
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
)
public
class
SendMessageServiceTest
{
...
...
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/aioutboundcall/AiOutboundCallTest.java
0 → 100644
View file @
0d23480
package
cn
.
com
.
glsx
.
cn
.
com
.
glsx
.
aioutboundcall
;
import
cn.com.glsx.cn.com.glsx.BaseTest
;
import
cn.com.glsx.execute.modules.converter.rop.RopRequestConveter
;
import
cn.com.glsx.execute.modules.converter.rop.RopResponseConveter
;
import
cn.com.glsx.execute.modules.enums.rop.MethodEnum
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.*
;
import
cn.com.glsx.execute.modules.model.rop.RopResponseDTO
;
import
cn.com.glsx.execute.utils.RopHttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
org.junit.Test
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Field
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* @Author yelq
* @Version 1.0
* @Description: 外呼对接测试
* @Date 2023/9/8 13:59
*/
public
class
AiOutboundCallTest
extends
BaseTest
{
@Test
public
void
Test01
()
throws
Exception
{
String
url
=
"http://192.168.1.104:8097/rop-scrm-marketing/router"
;
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
paramsMap
.
add
(
"importCustomerId"
,
"33"
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
CUSTOMER_CALL_DETAIL
.
getMethod
(),
null
);
RopResponseDTO
<
ByaiGetCustomerDetailResponseDTO
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
ByaiGetCustomerDetailResponseDTO
.
class
);
System
.
out
.
println
(
ropResponseDTO
);
}
@Test
public
void
invokeAICallTest01
()
throws
Exception
{
String
url
=
"http://192.168.1.104:8097/rop-scrm-marketing/router"
;
ByaiImportCallJobCustomerRequestDTO
requestDTO
=
new
ByaiImportCallJobCustomerRequestDTO
();
ByaiImportCallJobCustomerRequestDTO
.
CustomerInfoVO
vo
=
new
ByaiImportCallJobCustomerRequestDTO
.
CustomerInfoVO
();
vo
.
setName
(
"叶之魂"
);
vo
.
setPhone
(
"18126301457"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"uuid"
,
UUID
.
randomUUID
().
toString
());
map
.
put
(
"robotDefId"
,
"320475"
);
//机器人id
map
.
put
(
"importCustomerId"
,
"18126301457"
);
//客户唯一标识
map
.
put
(
"sopId"
,
"10241024"
);
//sopid
vo
.
setProperties
(
map
);
requestDTO
.
setCustomerInfoVOList
(
Arrays
.
asList
(
vo
));
// requestDTO.setMerchantId(44211277);
requestDTO
.
setCallJobType
(
1L
);
requestDTO
.
setStartDate
(
"2023-09-11"
);
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
jobWorkingTimeRuleDetailVO
=
new
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
();
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
.
TimeRangeVO
timeRangeVO
=
new
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
.
TimeRangeVO
();
timeRangeVO
.
setStartTime
(
"2023-09-11 17:00:00"
);
timeRangeVO
.
setEndTime
(
"2023-09-11 18:00:00"
);
jobWorkingTimeRuleDetailVO
.
setTimeRanges
(
Arrays
.
asList
(
timeRangeVO
));
jobWorkingTimeRuleDetailVO
.
setWeeks
(
Arrays
.
asList
(
1
));
requestDTO
.
setWorkingTimeRuleList
(
Arrays
.
asList
(
jobWorkingTimeRuleDetailVO
));
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
INVOKE_AI_CALL
.
getMethod
(),
null
);
System
.
out
.
println
(
post
);
RopResponseDTO
<
ByaiImportCallJobCustomerResponseDTO
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
ByaiImportCallJobCustomerResponseDTO
.
class
);
System
.
out
.
println
(
ropResponseDTO
);
}
@Test
public
void
outboundCallTest01
()
throws
Exception
{
String
url
=
"http://192.168.1.104:8097/rop-scrm-marketing/router"
;
ByaiGetRobotListRequestDTO
requestDTO
=
new
ByaiGetRobotListRequestDTO
();
requestDTO
.
setSelectAll
(
true
);
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
ROBOT_LIST
.
getMethod
(),
null
);
RopResponseDTO
<
ByaiGetRobotListResponseDTO
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
ByaiGetRobotListResponseDTO
.
class
);
System
.
out
.
println
(
ropResponseDTO
);
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment