提交测试数字人回答自定义
This commit is contained in:
parent
fa4f07af7c
commit
75fed7ac6f
@ -64,6 +64,7 @@ public class SystemTalkAnswerConfigService extends GenericReactiveCrudService<Sy
|
|||||||
log.info("初始化自定义回答缓存数据");
|
log.info("初始化自定义回答缓存数据");
|
||||||
group.clear();
|
group.clear();
|
||||||
groupCommand.clear();
|
groupCommand.clear();
|
||||||
|
commandList.clear();
|
||||||
ReactiveQuery<SystemTalkAnswerConfigEntity> reactiveQuery = createQuery();
|
ReactiveQuery<SystemTalkAnswerConfigEntity> reactiveQuery = createQuery();
|
||||||
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
||||||
reactiveQuery = reactiveQuery.lte("answer_type", AskTypeEnum.EXCOMMAND.getCode());
|
reactiveQuery = reactiveQuery.lte("answer_type", AskTypeEnum.EXCOMMAND.getCode());
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.qiuguo.iot.third.command;
|
package com.qiuguo.iot.third.command;
|
||||||
|
|
||||||
import com.qiuguo.iot.base.enums.AskTypeEnum;
|
import com.qiuguo.iot.base.enums.AskTypeEnum;
|
||||||
|
import com.qiuguo.iot.base.utils.StringUtils;
|
||||||
import com.qiuguo.iot.data.domain.BaseSession;
|
import com.qiuguo.iot.data.domain.BaseSession;
|
||||||
import com.qiuguo.iot.data.domain.IActionSendMessage;
|
import com.qiuguo.iot.data.domain.IActionSendMessage;
|
||||||
import com.qiuguo.iot.data.entity.system.SystemTalkBindUserEntity;
|
import com.qiuguo.iot.data.entity.system.SystemTalkBindUserEntity;
|
||||||
@ -30,15 +31,23 @@ public class UserConfigActionCommand extends ActionCommand implements IActionCo
|
|||||||
return systemTalkBindUserService.selectSystemTalkBindUserByRequest(request).defaultIfEmpty(new SystemTalkBindUserEntity())
|
return systemTalkBindUserService.selectSystemTalkBindUserByRequest(request).defaultIfEmpty(new SystemTalkBindUserEntity())
|
||||||
.flatMap(entity -> {
|
.flatMap(entity -> {
|
||||||
if(entity.getUserId() == null){
|
if(entity.getUserId() == null){
|
||||||
|
|
||||||
log.info("调用默认的回答");
|
log.info("调用默认的回答");
|
||||||
|
if(StringUtils.isNotEmpty(action.getSystemTalkAnswerConfigEntity().getAnswerValue())) {
|
||||||
return sendMessage(action,
|
return sendMessage(action,
|
||||||
baseSession,
|
baseSession,
|
||||||
action.getSystemTalkAnswerConfigEntity().getAnswerValue(),
|
action.getSystemTalkAnswerConfigEntity().getAnswerValue(),
|
||||||
AskTypeEnum.TTS.getCode(),
|
AskTypeEnum.TTS.getCode(),
|
||||||
actionSendMessage).flatMap(m ->{
|
actionSendMessage).flatMap(m -> {
|
||||||
//自定义只能到这里截止
|
//自定义只能到这里截止
|
||||||
return Mono.empty();
|
return Mono.empty();
|
||||||
});
|
});
|
||||||
|
}else{
|
||||||
|
log.info("用户自定义调用千问回答");
|
||||||
|
return toTongYi(action, baseSession, AskTypeEnum.TTS.getCode(), actionSendMessage).flatMap(b -> {
|
||||||
|
return Mono.empty();
|
||||||
|
});
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
log.info("调用用户匹配的回答");
|
log.info("调用用户匹配的回答");
|
||||||
return sendMessage(action,
|
return sendMessage(action,
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public enum ActionPartSpeechEnum implements IChinesePartSpeech{
|
|||||||
List<DeviceUserBindEntity> includs,
|
List<DeviceUserBindEntity> includs,
|
||||||
List<SystemTalkAnswerConfigEntity> commands){
|
List<SystemTalkAnswerConfigEntity> commands){
|
||||||
action.setAction(key);
|
action.setAction(key);
|
||||||
SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(action.getAction(), keyGroup, action.getNoTimeAsk());
|
SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(action.getAction(), keyGroup, action.getAsk());
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
systemTalkAnswerConfigEntities.add(entity);
|
systemTalkAnswerConfigEntities.add(entity);
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ public enum ActionPartSpeechEnum implements IChinesePartSpeech{
|
|||||||
List<DeviceUserBindEntity> includs,
|
List<DeviceUserBindEntity> includs,
|
||||||
List<SystemTalkAnswerConfigEntity> commands){
|
List<SystemTalkAnswerConfigEntity> commands){
|
||||||
//匹配到关键词就不能作为名词加入,未匹配到的,分割前的都加入名词
|
//匹配到关键词就不能作为名词加入,未匹配到的,分割前的都加入名词
|
||||||
SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(key, keyGroup, action.getNoTimeAsk());
|
SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(key, keyGroup, action.getAsk());
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
if(!entity.getAnswerType().equals(AskTypeEnum.COMMAND_N.getCode())){
|
if(!entity.getAnswerType().equals(AskTypeEnum.COMMAND_N.getCode())){
|
||||||
systemTalkAnswerConfigEntities.add(entity);
|
systemTalkAnswerConfigEntities.add(entity);
|
||||||
@ -184,7 +184,7 @@ public enum ActionPartSpeechEnum implements IChinesePartSpeech{
|
|||||||
//已记录的加进去
|
//已记录的加进去
|
||||||
if(StringUtils.isNotEmpty(actions.getName())){
|
if(StringUtils.isNotEmpty(actions.getName())){
|
||||||
//
|
//
|
||||||
entity = getSystemTalkWithKey(actions.getName(), keyGroup, action.getNoTimeAsk());
|
entity = getSystemTalkWithKey(actions.getName(), keyGroup, action.getAsk());
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
systemTalkAnswerConfigEntities.add(entity);
|
systemTalkAnswerConfigEntities.add(entity);
|
||||||
actions.setA(1);
|
actions.setA(1);
|
||||||
@ -253,7 +253,7 @@ public enum ActionPartSpeechEnum implements IChinesePartSpeech{
|
|||||||
List<DeviceUserBindEntity> includs,
|
List<DeviceUserBindEntity> includs,
|
||||||
List<SystemTalkAnswerConfigEntity> commands){
|
List<SystemTalkAnswerConfigEntity> commands){
|
||||||
if(StringUtils.isNotEmpty(actions.getName())){
|
if(StringUtils.isNotEmpty(actions.getName())){
|
||||||
SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(actions.getName(), keyGroup, action.getNoTimeAsk());
|
SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(actions.getName(), keyGroup, action.getAsk());
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
if(!entity.getAnswerType().equals(AskTypeEnum.COMMAND_N.getCode())){
|
if(!entity.getAnswerType().equals(AskTypeEnum.COMMAND_N.getCode())){
|
||||||
systemTalkAnswerConfigEntities.add(entity);
|
systemTalkAnswerConfigEntities.add(entity);
|
||||||
@ -414,7 +414,7 @@ public enum ActionPartSpeechEnum implements IChinesePartSpeech{
|
|||||||
List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
|
List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
|
||||||
List<DeviceUserBindEntity> includs,
|
List<DeviceUserBindEntity> includs,
|
||||||
List<SystemTalkAnswerConfigEntity> commands){
|
List<SystemTalkAnswerConfigEntity> commands){
|
||||||
SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(key, keyGroup, action.getNoTimeAsk());
|
SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(key, keyGroup, action.getAsk());
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
if(!entity.getAnswerType().equals(AskTypeEnum.COMMAND_N.getCode())){
|
if(!entity.getAnswerType().equals(AskTypeEnum.COMMAND_N.getCode())){
|
||||||
systemTalkAnswerConfigEntities.add(entity);
|
systemTalkAnswerConfigEntities.add(entity);
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import com.qiuguo.iot.base.constans.RedisConstans;
|
|||||||
import com.qiuguo.iot.base.enums.*;
|
import com.qiuguo.iot.base.enums.*;
|
||||||
import com.qiuguo.iot.base.model.UserDeviceInfoModel;
|
import com.qiuguo.iot.base.model.UserDeviceInfoModel;
|
||||||
import com.qiuguo.iot.base.utils.StringUtils;
|
import com.qiuguo.iot.base.utils.StringUtils;
|
||||||
|
import com.qiuguo.iot.data.domain.BaseMessageResp;
|
||||||
|
import com.qiuguo.iot.data.resp.third.MusicResp;
|
||||||
import com.qiuguo.iot.third.command.ActionCommand;
|
import com.qiuguo.iot.third.command.ActionCommand;
|
||||||
import com.qiuguo.iot.box.websocket.api.config.properties.SomeProperties;
|
import com.qiuguo.iot.box.websocket.api.config.properties.SomeProperties;
|
||||||
import com.qiuguo.iot.data.domain.BaseSession;
|
import com.qiuguo.iot.data.domain.BaseSession;
|
||||||
@ -164,10 +166,31 @@ public class BoxWebSocketHandler implements WebSocketHandler {
|
|||||||
if(alarm.getId() == null){
|
if(alarm.getId() == null){
|
||||||
log.info("未找到相关闹钟");
|
log.info("未找到相关闹钟");
|
||||||
return Mono.empty();
|
return Mono.empty();
|
||||||
}else{
|
}else if(alarm.getAlarmType().equals(YesNo.YES.getCode())){
|
||||||
boxTalkMessage.setMessage(alarm.getAction());
|
boxTalkMessage.setMessage(alarm.getAction());
|
||||||
boxSession.setListen(YesNo.NO.getCode());
|
boxSession.setListen(YesNo.NO.getCode());
|
||||||
return processMessage(boxSession, boxTalkMessage);
|
return processMessage(boxSession, boxTalkMessage);
|
||||||
|
}else{
|
||||||
|
if(StringUtils.isNotEmpty(alarm.getReadText())){
|
||||||
|
BaseMessageResp resp = new BaseMessageResp();
|
||||||
|
resp.setText(alarm.getReadText());
|
||||||
|
resp.setListen(0);
|
||||||
|
resp.setType(AskTypeEnum.TTS.getCode());
|
||||||
|
return baseWebSocketService.sendMsgWithMono(boxSession, resp).flatMap(b -> {
|
||||||
|
return Mono.empty();
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
BaseMessageResp resp = new BaseMessageResp();
|
||||||
|
MusicResp musicResp = new MusicResp();
|
||||||
|
musicResp.setPlay(0);
|
||||||
|
musicResp.setUrl(alarm.getSound());
|
||||||
|
resp.setMusic(musicResp);
|
||||||
|
resp.setListen(0);
|
||||||
|
resp.setType(AskTypeEnum.MUSIC.getCode());
|
||||||
|
return baseWebSocketService.sendMsgWithMono(boxSession, JSONObject.toJSONString(resp)).flatMap(b -> {
|
||||||
|
return Mono.empty();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user