Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SmartBox
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
苗权威
SmartBox
Commits
74c584e1
Commit
74c584e1
authored
Jan 18, 2021
by
苗权威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0118
parent
b3beb8bf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
122 additions
and
12 deletions
+122
-12
XiaoDuHomeController.java
.../qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
+29
-7
WelcomeWordRequest.java
.../java/ai/qiwu/com/xiaoduhome/pojo/WelcomeWordRequest.java
+18
-0
DplBotServiceBoth.java
...ava/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java
+70
-5
RequestTerminal.java
.../java/ai/qiwu/com/xiaoduhome/service/RequestTerminal.java
+5
-0
No files found.
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
View file @
74c584e1
...
...
@@ -5,6 +5,7 @@ import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
import
ai.qiwu.com.xiaoduhome.common.Utils
;
import
ai.qiwu.com.xiaoduhome.dpl2.Dpl2Service
;
import
ai.qiwu.com.xiaoduhome.pojo.NoticeReceiveData
;
import
ai.qiwu.com.xiaoduhome.pojo.WelcomeWordRequest
;
import
ai.qiwu.com.xiaoduhome.pojo.data.BaseHostData
;
import
ai.qiwu.com.xiaoduhome.service.*
;
import
com.alibaba.fastjson.JSON
;
...
...
@@ -39,7 +40,7 @@ public class XiaoDuHomeController {
public
static
volatile
String
WELCOME_NOVEL
=
"欢迎来到晓悟智能小说。向您推荐新上线的妖刀异闻录,您可以说打开妖刀异闻录。或者说,推荐其它作品。"
;
public
static
volatile
String
WELCOME_SMART
=
"欢迎来到晓悟智能故事。我们新上线了
魔法世界大冒险,你可以说打开魔法世界大冒险
。或者说,推荐其它作品。"
;
public
static
volatile
String
WELCOME_SMART
=
"欢迎来到晓悟智能故事。我们新上线了
猜谜王国,你可以说打开猜谜王国
。或者说,推荐其它作品。"
;
public
static
volatile
String
WELCOME_FORMAT
=
"欢迎来到交游天下。与剧情人物自由对话,带您体验不同的人生和情怀。向您推荐新上线的%s,您可以说打开%s。或者说,推荐其它作品。"
;
// public static volatile String WELCOME_FORMAT = "欢迎来到交游天下。与剧情人物自由对话,带您体验不同的人生和情怀。向您推荐新上线的野蛮女友,您可以说打开野蛮女友。或者说,推荐其它作品。";
...
...
@@ -171,26 +172,35 @@ public class XiaoDuHomeController {
}
@PostMapping
(
"/change/welcome/word"
)
public
void
changeWelcomeWord
(
String
pwd
,
String
type
,
String
word
)
{
if
(
StringUtils
.
startsWith
(
pwd
,
"mqw"
)
&&
pwd
.
length
()
==
8
)
{
switch
(
type
)
{
case
"adult"
:
WELCOME_NOVEL
=
word
;
break
;
case
"child"
:
WELCOME_SMART
=
word
;
break
;
case
"all"
:
WELCOME_FORMAT
=
word
;
break
;
public
void
changeWelcomeWord
(
@RequestBody
WelcomeWordRequest
welcomeWordRequest
)
{
if
(
StringUtils
.
startsWith
(
welcomeWordRequest
.
getPwd
(),
"mqw"
)
&&
welcomeWordRequest
.
getPwd
().
length
()
==
8
&&
StringUtils
.
isNotBlank
(
welcomeWordRequest
.
getType
()))
{
switch
(
welcomeWordRequest
.
getType
())
{
case
"adult"
:
WELCOME_NOVEL
=
welcomeWordRequest
.
getWord
();
break
;
case
"child"
:
WELCOME_SMART
=
welcomeWordRequest
.
getWord
();
break
;
case
"all"
:
WELCOME_FORMAT
=
welcomeWordRequest
.
getWord
();
break
;
}
}
log
.
warn
(
"/change/welcome/word:adult:{},child:{},all:{}"
,
WELCOME_NOVEL
,
WELCOME_SMART
,
WELCOME_FORMAT
);
}
/**
* 主动更换中控服务url地址
* @param data
*/
@PostMapping
(
"/change/host"
)
public
void
changeBaseHost
(
@RequestBody
BaseHostData
data
)
{
if
(
StringUtils
.
startsWith
(
data
.
getSecretKey
(),
"mqw"
)
&&
StringUtils
.
endsWith
(
data
.
getSecretKey
(),
"#"
)
&&
data
.
getSecretKey
().
length
()
==
8
)
{
// 由于音箱项目是一台服务器有两个项目,分为主/从服务,这里调用主服务的该方法,再由主服务通知从服务
if
(
ScheduleServiceNew
.
THE_PROCESS_IS_MASTER
)
{
for
(
String
slaveProcessUrl
:
ScheduleServiceNew
.
serverAddresses
)
{
OkHttp3Utils
.
serverChangeCallOtherSalve
(
slaveProcessUrl
+
"xiaoduhome/change/host"
,
JSON
.
toJSONString
(
data
));
}
}
// 切换地址主要是不能影响正在玩的用户,就是切换要达到如下目的:这段时间正在玩的用户依然访问旧地址中控,
// 之后新进来的用户访问新的,为了不影响用户体验
// OLD_开头的字段记录旧中控服务,用于旧用户访问使用
ScheduleServiceNew
.
OLD_BASE_HOST_URL
=
ScheduleServiceNew
.
BASE_HOST_URL
;
ScheduleServiceNew
.
OLD_BASE_AUDIO_URL
=
ScheduleServiceNew
.
BASE_AUDIO_URL
;
ScheduleServiceNew
.
OLD_CDN_HOST_URL
=
ScheduleServiceNew
.
CDN_HOST_URL
;
...
...
@@ -198,7 +208,10 @@ public class XiaoDuHomeController {
ScheduleServiceNew
.
BASE_AUDIO_URL
=
data
.
getAudio
();
ScheduleServiceNew
.
CDN_HOST_URL
=
data
.
getCdn
();
// 什么算旧用户,即从接口调用开始计算4分钟内访问的用户都算作旧用户,这些用户访问旧接口,中控用户超时是3分钟
// redis设置一个4分钟的字段用于同级旧用户
stringRedisTemplate
.
opsForValue
().
setIfAbsent
(
Constants
.
SERVER_CHANGE_KEY
,
"1"
,
4
,
TimeUnit
.
MINUTES
);
// 标识访问接口变动发生
ScheduleServiceNew
.
SERVER_CHANGE
=
true
;
}
log
.
info
(
"BASE_HOST_URL:"
+
ScheduleServiceNew
.
BASE_HOST_URL
);
...
...
@@ -210,10 +223,17 @@ public class XiaoDuHomeController {
log
.
info
(
"OLD_CDN_HOST_URL:"
+
ScheduleServiceNew
.
OLD_CDN_HOST_URL
);
}
/**
* 服务地址更换后,通过调用该接口来查看旧用户数,
* 以及在所有旧用户退出后更改ScheduleServiceNew.SERVER_CHANGE标识,完成中控url切换工作
* @param data
* @return
*/
@PostMapping
(
"/change/host/getInOldServerNum"
)
public
String
getOldServerUserNum
(
@RequestBody
BaseHostData
data
)
{
if
(
StringUtils
.
startsWith
(
data
.
getSecretKey
(),
"mqw"
)
&&
StringUtils
.
endsWith
(
data
.
getSecretKey
(),
"#"
)
&&
data
.
getSecretKey
().
length
()
==
8
)
{
// 4分钟未过,也就是还在统计旧用户的阶段,打印旧用户数等信息
if
(
Boolean
.
TRUE
.
equals
(
stringRedisTemplate
.
hasKey
(
Constants
.
SERVER_CHANGE_KEY
)))
{
Cursor
<
byte
[]>
scan
=
stringRedisTemplate
.
getConnectionFactory
().
getConnection
()
.
scan
(
ScanOptions
.
scanOptions
().
match
(
Constants
.
CAN_NOT_MOVE_USER_KEY
+
"*"
).
build
());
...
...
@@ -231,6 +251,7 @@ public class XiaoDuHomeController {
log
.
info
(
s
);
return
s
;
}
//没有旧用户就将ScheduleServiceNew.SERVER_CHANGE = false,标识切换正式完成,若是主服务器就通知从服务器
Cursor
<
byte
[]>
scan
=
stringRedisTemplate
.
getConnectionFactory
().
getConnection
()
.
scan
(
ScanOptions
.
scanOptions
().
match
(
Constants
.
CAN_NOT_MOVE_USER_KEY
+
"*"
).
build
());
if
(!
scan
.
hasNext
())
{
...
...
@@ -243,6 +264,7 @@ public class XiaoDuHomeController {
log
.
info
(
"There is no one in old server,标志为值:"
+
ScheduleServiceNew
.
SERVER_CHANGE
+
",新BASE_HOST地址:"
+
ScheduleServiceNew
.
BASE_HOST_URL
);
return
"There is no one in old server"
;
}
else
{
// 仍有旧用户就打印旧用户等相关信息
int
staynUM
=
0
;
while
(
scan
.
hasNext
())
{
scan
.
next
();
...
...
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/WelcomeWordRequest.java
0 → 100644
View file @
74c584e1
package
ai
.
qiwu
.
com
.
xiaoduhome
.
pojo
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Getter
;
import
lombok.Setter
;
/**
* painter
* 21-1-15 下午6:48
*/
@Getter
@Setter
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
WelcomeWordRequest
{
private
String
pwd
;
private
String
type
;
private
String
word
;
}
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java
View file @
74c584e1
...
...
@@ -76,6 +76,11 @@ import static ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil.POOL;
import
static
ai
.
qiwu
.
com
.
xiaoduhome
.
service
.
DplbotServiceUtil
.
USER_HISTORY
;
/**
* 类中包含旧版本的有屏代码,可忽略
* 新版本在 Dpl2Service 类中
* 无屏端代码: 进入技能 onLaunch -> 意图处理 onInent -> 退出 onSessionEnded,只看这三个方法里的无屏代码部分,
* 即isNoScreenRequest()返回true的处理部分;
* 还有 onPlaybackStartedEvent onPlaybackStoppedEvent onPlaybackFinishedEvent 三个音频播放状态回调方法
* @author mqw
*/
@Slf4j
...
...
@@ -124,14 +129,18 @@ public class DplBotServiceBoth extends BaseBot {
public
Response
onLaunch
(
LaunchRequest
launchRequest
)
{
// getRequest().getContext().getScreen() == null
if
(
isNoScreenRequest
())
{
// 无屏端请求
// String userId = customUserId();
// 保险起见在用户进入技能时主动清除redis中储存的之前超时的数据(如果有的话)
String
redisId
;
if
(
Boolean
.
TRUE
.
equals
(
stringRedisTemplate
.
hasKey
((
redisId
=
SpiritRedisService
.
PREFIX_REDIS
+
customUserId
()))))
{
stringRedisTemplate
.
delete
(
redisId
);
}
String
welcomeWord
;
String
welcomeWord
;
// 欢迎语
String
skillName
;
String
num
=
RandomStringUtils
.
randomNumeric
(
3
);
// 根据不同技能返回不同的欢迎语句
switch
(
type
)
{
case
1
:
{
// welcomeWord = WELCOME_SMART_FORMAT;
...
...
@@ -226,12 +235,20 @@ public class DplBotServiceBoth extends BaseBot {
@Override
protected
Response
onInent
(
IntentRequest
intentRequest
)
{
if
(
isNoScreenRequest
())
{
final
String
userId
=
customUserId
();
// 无屏端请求
final
String
userId
=
customUserId
();
// 获取用户id
//由于中控地址可能变动,为了在不重启项目前提下更换请求服务器地址,
//配合XiaoDuHomeController#changeBaseHost方法,来实现url更新
// 切换逻辑在changeBaseHost方法里有详细解释
// baseHostUrl中控url,audioUrl 语音服务url,cdnUrl :cdn url
String
baseHostUrl
=
ScheduleServiceNew
.
BASE_HOST_URL
;
String
audioUrl
=
ScheduleServiceNew
.
BASE_AUDIO_URL
;
String
cdnUrl
=
ScheduleServiceNew
.
CDN_HOST_URL
;
//为true则说明正在url更换状态,该状态下旧用户要访问旧地址,新用户访问新的,旧/新只分在changeBaseHost方法有说明
if
(
ScheduleServiceNew
.
SERVER_CHANGE
)
{
// url变更开始后四分中内所哟访问用户都是旧用户,redis存储这些用户id
if
(
Boolean
.
TRUE
.
equals
(
stringRedisTemplate
.
hasKey
(
Constants
.
SERVER_CHANGE_KEY
)))
{
if
(
Boolean
.
TRUE
.
equals
(
stringRedisTemplate
.
hasKey
(
Constants
.
CAN_NOT_MOVE_USER_KEY
+
userId
)))
{
stringRedisTemplate
.
expire
(
Constants
.
CAN_NOT_MOVE_USER_KEY
+
userId
,
4
,
TimeUnit
.
MINUTES
);
...
...
@@ -242,6 +259,7 @@ public class DplBotServiceBoth extends BaseBot {
audioUrl
=
ScheduleServiceNew
.
OLD_BASE_AUDIO_URL
;
cdnUrl
=
ScheduleServiceNew
.
OLD_CDN_HOST_URL
;
}
else
if
(
Boolean
.
TRUE
.
equals
(
stringRedisTemplate
.
hasKey
(
Constants
.
CAN_NOT_MOVE_USER_KEY
+
userId
))){
// 四分中后所有在redis中已记录的用户都是旧用户,延长他们在redis中key的超时时间
stringRedisTemplate
.
expire
(
Constants
.
CAN_NOT_MOVE_USER_KEY
+
userId
,
4
,
TimeUnit
.
MINUTES
);
baseHostUrl
=
ScheduleServiceNew
.
OLD_BASE_HOST_URL
;
audioUrl
=
ScheduleServiceNew
.
OLD_BASE_AUDIO_URL
;
...
...
@@ -249,18 +267,25 @@ public class DplBotServiceBoth extends BaseBot {
}
}
// 百度方规定3s超时,也就是服务必须要在3s内返回,否则用户直接退出技能
// 那么对于超时的用户我们就要存储他之前超时的返回结果,在他再次访问时主动返回这一结果,无论用户说什么
// redisId 作为key存储该用户的超时结果
String
redisId
=
SpiritRedisService
.
PREFIX_REDIS
+
userId
;
// final String deviceUserId = PREFIX_USERID + getDeviceId();
try
{
// 如果上次该用户的处理超时了,获取超时结果返回
if
(
Boolean
.
TRUE
.
equals
(
stringRedisTemplate
.
hasKey
(
redisId
)))
{
String
data
=
stringRedisTemplate
.
opsForValue
().
get
(
redisId
);
String
data
=
stringRedisTemplate
.
opsForValue
().
get
(
redisId
);
// 超时结果
log
.
warn
(
"超时redis获取信息:"
+
data
);
if
(
StringUtils
.
isNotBlank
(
data
))
{
// 之前处理仍未完成,此时仍需要让用户等待,但是不能一致等待,这里限制为2,最多让用户等待两次,redisIdleId记录等嗲次数
String
redisIdleId
=
SpiritRedisService
.
PREFIX_REDIS_IDLE
+
userId
;
if
(
data
.
equals
(
"out"
))
{
if
(
"out"
.
equals
(
data
))
{
// 这说明仍没有获取到之前超时的处理结果
// 超时等待次数
String
idleNum
=
stringRedisTemplate
.
opsForValue
().
get
(
redisIdleId
);
boolean
firstIdle
;
// 最多允许等待两次
if
((
firstIdle
=
StringUtils
.
isBlank
(
idleNum
))
||
"1"
.
equals
(
idleNum
))
{
try
{
Thread
.
sleep
(
2000
);
...
...
@@ -279,10 +304,12 @@ public class DplBotServiceBoth extends BaseBot {
return
buildErrorResponse
((
RandomUtils
.
nextInt
()
&
1
)
==
1
?
XiaoAiConstants
.
TTS
.
WAIT_WORD_1
:
XiaoAiConstants
.
TTS
.
WAIT_WORD_2
);
}
else
{
// 删除超时状态标识
stringRedisTemplate
.
delete
(
redisIdleId
);
stringRedisTemplate
.
delete
(
redisId
);
}
}
else
{
// 获取到超时处理结果,返回该结果,删除超时状态标识
stringRedisTemplate
.
delete
(
redisId
);
stringRedisTemplate
.
delete
(
redisIdleId
);
Directive
play
=
buildNoScreenPlayDirec
(
data
,
AudioPlayerDirective
.
PlayBehaviorType
.
REPLACE_ALL
);
...
...
@@ -297,6 +324,7 @@ public class DplBotServiceBoth extends BaseBot {
// }
}
}
else
{
// 删除超时状态标识
stringRedisTemplate
.
delete
(
redisId
);
}
}
...
...
@@ -304,6 +332,7 @@ public class DplBotServiceBoth extends BaseBot {
log
.
error
(
"xiaodu redis error:"
+
e
);
}
// 利用线程池,控制线程执行时间,确保在3s内返回信息给百度平台
try
{
final
String
finalBaseHost
=
baseHostUrl
;
final
String
finalAudioUrl
=
audioUrl
;
...
...
@@ -311,7 +340,7 @@ public class DplBotServiceBoth extends BaseBot {
// log.info("BASE_HOST_URL:"+finalBaseHost);
Future
<
Response
>
future
=
DplbotServiceUtil
.
getPOOL
().
submit
(()
->
dealNoScreenIntentTemp
(
intentRequest
,
userId
,
finalBaseHost
,
finalAudioUrl
,
finalCdnUrl
));
return
future
.
get
(
2500
,
TimeUnit
.
MILLISECONDS
);
return
future
.
get
(
2500
,
TimeUnit
.
MILLISECONDS
);
// 2.5s
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
log
.
error
(
"获取任务执行结果出错:{}"
,
ExceptionUtils
.
getStackTrace
(
e
));
return
buildErrorResponse
(
SORRY_UNCATCH
);
...
...
@@ -416,6 +445,15 @@ public class DplBotServiceBoth extends BaseBot {
return
new
Response
();
}
/**
* 无屏端意图处理
* @param intentRequest
* @param userId
* @param baseUrl
* @param audioUrl
* @param cdnUrl
* @return
*/
private
Response
dealNoScreenIntentTemp
(
IntentRequest
intentRequest
,
String
userId
,
String
baseUrl
,
String
audioUrl
,
String
cdnUrl
)
{
// String intentName = getIntent().getName();
...
...
@@ -438,6 +476,7 @@ public class DplBotServiceBoth extends BaseBot {
}
// log.info("================小度.用户说的话:{}",userWord);
// 不同技能有不同渠道id
String
channel
;
switch
(
type
)
{
case
1
:
...
...
@@ -446,6 +485,7 @@ public class DplBotServiceBoth extends BaseBot {
case
4
:
channel
=
"jiaoyou-audio-adult-test"
;
break
;
default
:
channel
=
"jiaoyou-audio-test"
;
break
;
}
// 获取中控返回信息
String
response
=
RequestTerminal
.
requestTerminateUrl
(
userWord
,
userId
,
channel
,
baseUrl
);
// log.info("小度,小悟返回:{},",response);
if
(
StringUtils
.
isBlank
(
response
))
{
...
...
@@ -454,6 +494,9 @@ public class DplBotServiceBoth extends BaseBot {
// String mark = RandomStringUtils.randomAlphabetic(3);
// AudioBoxData pathData = new AudioBoxData();
// OkHttp3Utils.asyncPost(XiaoAiConstants.TTS_DIDI3, response, pathData);
// 中控识别出用户想退出技能时,返回的 commands 字段内会有 out 标识 ,这时主动退出技能
// 比如用户说:我要听音乐
JSONObject
object
=
JSON
.
parseObject
(
response
);
try
{
JSONArray
commands
=
object
.
getJSONArray
(
"commands"
);
...
...
@@ -486,6 +529,7 @@ public class DplBotServiceBoth extends BaseBot {
}
if
(
byeWord
==
null
)
byeWord
=
EndMsg
.
END_BYE_Adult
;
if
(
skillName
==
null
)
skillName
=
SKILL_DEFAULT
;
//这里如果返回中有退出结束语,我们就提取出来,拼接上技能名,否则选取默认的退出语句
if
(
StringUtils
.
isBlank
(
content
))
{
JSONArray
dialogs
=
object
.
getJSONArray
(
"dialogs"
);
if
(
dialogs
!=
null
&&
dialogs
.
size
()
!=
0
)
{
...
...
@@ -509,6 +553,7 @@ public class DplBotServiceBoth extends BaseBot {
}
catch
(
Exception
e
)
{
log
.
error
(
"推荐bot退出解析出错:"
+
e
);
}
// 将中控的返回结果发给TTS语音服务获取音频地址
String
path
=
OkHttp3Utils
.
doPostJsonStr
(
audioUrl
+
"/api/audio"
,
response
);
// String path = OkHttp3Utils.doPostJsonStr("http://didi-gz5.jiaoyou365.com:8190/api/audio", response);
if
(
StringUtils
.
isBlank
(
path
)
||
"null"
.
equals
(
path
))
{
...
...
@@ -523,6 +568,7 @@ public class DplBotServiceBoth extends BaseBot {
// data.getAttributes().put("botAcc",botAcc);
// }
// 作品id,用于构建访问音频的url链接使用
String
botAccount
=
object
.
getString
(
"aipioneerUsername"
);
if
(
StringUtils
.
isBlank
(
botAccount
))
{
log
.
warn
(
"没有获取到aipioneerUsername"
);
...
...
@@ -553,6 +599,8 @@ public class DplBotServiceBoth extends BaseBot {
// WebSocketLog.sendInfo(builder.toString(), "du2");
// });
// }
// 处理到这里如果发现处理时间超过了2.5s,超时标识存在,则将结果存储起来,用于在下次用户访问时返回
if
(
Boolean
.
TRUE
.
equals
(
stringRedisTemplate
.
opsForValue
()
.
setIfPresent
(
SpiritRedisService
.
PREFIX_REDIS
+
userId
,
path
,
15
,
TimeUnit
.
SECONDS
)))
{
log
.
warn
(
"xiaodu 超时redis存储成功"
);
...
...
@@ -568,6 +616,13 @@ public class DplBotServiceBoth extends BaseBot {
return
ScheduleServiceNew
.
BASE_AUDIO_URL
+
"/api/audio/get?path="
+
path
;
}
/**
* 构建访问音频的url链接使用
* @param path
* @param botAccount
* @param cdnUrl
* @return
*/
private
String
dealAudioUrlTemp
(
String
path
,
String
botAccount
,
String
cdnUrl
)
{
// return ScheduleServiceNew.BASE_HOST_URL+"9663/api/audio/get?path="+path;
if
(
path
.
startsWith
(
"a"
))
{
...
...
@@ -932,11 +987,13 @@ public class DplBotServiceBoth extends BaseBot {
@Override
protected
Response
onSessionEnded
(
SessionEndedRequest
sessionEndedRequest
)
{
// 针对不同退出原因分别处理
switch
(
sessionEndedRequest
.
getReason
())
{
case
ERROR:
dealWithError
(
sessionEndedRequest
);
break
;
case
USER_INITIATED:
log
.
info
(
EndMsg
.
USER_SAY_CANCEL
);
break
;
case
EXCEEDED_MAX_REPROMPTS:
log
.
info
(
EndMsg
.
CAN_NOT_UNDERSTAND
);
break
;
}
// 无屏端退出
if
(
isNoScreenRequest
())
{
String
userId
=
customUserId
();
String
byeWord
=
EndMsg
.
END_BYE_Adult
;
...
...
@@ -2896,6 +2953,10 @@ public class DplBotServiceBoth extends BaseBot {
return
new
Response
();
}
/**
* 返回经过处理的用户id
* @return
*/
private
String
customUserId
()
{
try
{
return
PREFIX_USERID
+
URLEncoder
.
encode
(
getUserId
(),
"UTF-8"
);
...
...
@@ -2907,6 +2968,10 @@ public class DplBotServiceBoth extends BaseBot {
// return PREFIX_USERID + getUserId().replaceAll(NUM_OR_ALPHA, "");
}
/**
* 区分有屏/无屏请求
* @return
*/
private
boolean
isNoScreenRequest
()
{
// return getSupportedInterfaces().getDPL() == null;
return
getSupportedInterfaces
().
getDisplay
()
==
null
;
...
...
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/RequestTerminal.java
View file @
74c584e1
...
...
@@ -113,6 +113,11 @@ public class RequestTerminal {
return
JSON
.
parseObject
(
resStr
,
QiWuResponse
.
class
);
}
/**
* 主动发出"退出"给中控,标识该用户退出了
* @param userId
* @param type
*/
static
void
backRequest
(
String
userId
,
int
type
)
{
SpiritTerminateRequest
requestPojo
=
new
SpiritTerminateRequest
();
requestPojo
.
setUid
(
userId
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment