U3D通讯协议类型修改

This commit is contained in:
wulin 2023-10-13 16:45:26 +08:00
parent 1b11bc0366
commit c26c530122
4 changed files with 40 additions and 37 deletions

View File

@ -15,22 +15,22 @@ public class U3dMsg {
/**
* msgType=013时数字人IDmsgType=3时设备所在虚拟世界ID
*/
private Long metaId;
private String metaId;
/**
* 状态ID
*/
private Long statusId;
private String statusId;
/**
* 场景ID
*/
private Long scenceId;
private String scenceId;
/**
* 类型ID
*/
private Long typeId;
private String typeId;
/**
* 扩展参数

View File

@ -201,7 +201,7 @@ public enum ChinesePartSpeechEnum implements IChinesePartSpeech{
if(actions.getB() == 1 && actions.getA() == 0){
//本名称没有找到对应的动作
action.setSystemTalkAnswerConfigEntity(actions.getLastSystemTalkAnswerConfigEntity());
action.setAction(action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setAction(action.getSystemTalkAnswerConfigEntity() == null ? null : action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setDeviceUserBindEntity(actions.getLastDeviceUserBindEntity());
actions.getActions().add(action);
actions.setLastName(action.getName());//lastName = action.getName();
@ -266,7 +266,7 @@ public enum ChinesePartSpeechEnum implements IChinesePartSpeech{
if(actions.getB() == 1 && actions.getA() == 0){
//本名称没有找到对应的动作
action.setSystemTalkAnswerConfigEntity(actions.getLastSystemTalkAnswerConfigEntity());
action.setAction(action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setAction(action.getSystemTalkAnswerConfigEntity() == null ? null : action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setDeviceUserBindEntity(actions.getLastDeviceUserBindEntity());
actions.getActions().add(action);
actions.setLastName(action.getName());
@ -416,7 +416,7 @@ public enum ChinesePartSpeechEnum implements IChinesePartSpeech{
List<SystemTalkAnswerConfigEntity> systemTalkAnswerConfigEntities,
List<DeviceUserBindEntity> includs,
List<SystemTalkAnswerConfigEntity> commands){
SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(actions.getName(), keyGroup);
SystemTalkAnswerConfigEntity entity = getSystemTalkWithKey(key, keyGroup);
if(entity != null){
if(!entity.getAnswerType().equals(AskTypeEnum.COMMAND_N.getCode())){
systemTalkAnswerConfigEntities.add(entity);
@ -689,7 +689,7 @@ public enum ChinesePartSpeechEnum implements IChinesePartSpeech{
if(actions.getB() == 1 && actions.getA() == 0){
//本名称没有找到对应的动作
action.setSystemTalkAnswerConfigEntity(actions.getLastSystemTalkAnswerConfigEntity());
action.setAction(action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setAction(action.getSystemTalkAnswerConfigEntity() == null ? null : action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setDeviceUserBindEntity(actions.getLastDeviceUserBindEntity());
actions.getActions().add(action);
actions.setLastName(action.getName());
@ -703,7 +703,7 @@ public enum ChinesePartSpeechEnum implements IChinesePartSpeech{
int index = Integer.parseInt(key.replace(">", ""));
action.setDeviceUserBindEntity(includs.get(index));
actions.setName("");
action.setName(action.getDeviceUserBindEntity().getBindName());
action.setName(action.getDeviceUserBindEntity() == null ? null : action.getDeviceUserBindEntity().getBindName());
actions.setB(1);
return action;
}

View File

@ -139,11 +139,11 @@ public class NlpService {
actions.setLastSystemTalkAnswerConfigEntity(action.getSystemTalkAnswerConfigEntity());
actions.setLastDeviceUserBindEntity(action.getDeviceUserBindEntity());
action.setAction(action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setAction(action.getSystemTalkAnswerConfigEntity() == null ? null : action.getSystemTalkAnswerConfigEntity().getAskKey());
systemTalkAnswerConfigEntities.clear();
}else if(actions.getLastSystemTalkAnswerConfigEntity() != null){
action.setSystemTalkAnswerConfigEntity(actions.getLastSystemTalkAnswerConfigEntity());
action.setAction(action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setAction(action.getSystemTalkAnswerConfigEntity() == null ? null : action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setDeviceUserBindEntity(actions.getLastDeviceUserBindEntity());
}
@ -162,7 +162,7 @@ public class NlpService {
if(StringUtils.isNotEmpty(action.getName()) && actions.getA() == 0){
//这说明已经匹配到设备了,但是没有匹配到动作
action.setSystemTalkAnswerConfigEntity(actions.getLastSystemTalkAnswerConfigEntity());
action.setAction(action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setAction(action.getSystemTalkAnswerConfigEntity() == null ? null : action.getSystemTalkAnswerConfigEntity().getAskKey());
actions.setLastSystemTalkAnswerConfigEntity(null);
actions.setLastName("");
actions.setLastDeviceUserBindEntity(null);
@ -193,10 +193,10 @@ public class NlpService {
if(systemTalkAnswerConfigEntities.size() > 0){//指令按照优先级排序
systemTalkAnswerConfigEntities.sort(Comparator.comparing(SystemTalkAnswerConfigEntity::getKeyOrder));
action.setSystemTalkAnswerConfigEntity(systemTalkAnswerConfigEntities.get(0));
action.setAction(action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setAction(action.getSystemTalkAnswerConfigEntity() == null ? null : action.getSystemTalkAnswerConfigEntity().getAskKey());
}else if(actions.getLastSystemTalkAnswerConfigEntity() != null){
action.setSystemTalkAnswerConfigEntity(actions.getLastSystemTalkAnswerConfigEntity());
action.setAction(action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setAction(action.getSystemTalkAnswerConfigEntity() == null ? null : action.getSystemTalkAnswerConfigEntity().getAskKey());
action.setDeviceUserBindEntity(actions.getLastDeviceUserBindEntity());
}
if(actions.getA() + actions.getB() > 0){

View File

@ -98,11 +98,11 @@ public class BaseWebSocketProcess {
if(U3dMsgTypeEnum.IOT.getCode().equals(u3dMsg.getMsgType())){
//物联网操作
DeviceUserBindRequest deviceBindRequest = new DeviceUserBindRequest();
deviceBindRequest.setU3dId(u3dMsg.getMetaId());
deviceBindRequest.setScenceId(u3dMsg.getScenceId());
deviceBindRequest.setU3dId(Long.getLong(u3dMsg.getMetaId()));
deviceBindRequest.setScenceId(Long.getLong(u3dMsg.getScenceId()));
deviceUserBindService.selectDeviceUserBindByRequest(deviceBindRequest).map(db ->{
SystemTalkBindDeviceRequest systemTalkBindDeviceRequest = new SystemTalkBindDeviceRequest();
systemTalkBindDeviceRequest.setU3dStatusId(u3dMsg.getStatusId());
systemTalkBindDeviceRequest.setU3dStatusId(Long.getLong(u3dMsg.getStatusId()));
systemTalkBindDeviceRequest.setCategoryCode(db.getCategoryCode());
systemTalkBindDeviceService.selectSystemTalkBindDeviceByRequest(systemTalkBindDeviceRequest).map(sd -> {
TuyaQuery query = new TuyaQuery();
@ -170,9 +170,9 @@ public class BaseWebSocketProcess {
U3dMsg u3dMsg = new U3dMsg();
u3dMsg.setMsgType(U3dMsgTypeEnum.IOT.getCode());
u3dMsg.setMetaId(metaId);
u3dMsg.setScenceId(action.getDeviceUserBindEntity().getScenceId());
u3dMsg.setStatusId(systemTalkBindDeviceEntity.getU3dStatusId());
u3dMsg.setMetaId(String.valueOf(metaId));
u3dMsg.setScenceId(String.valueOf(action.getDeviceUserBindEntity().getScenceId()));
u3dMsg.setStatusId(String.valueOf(systemTalkBindDeviceEntity.getU3dStatusId()));
sendMq(JSONObject.toJSONString(u3dMsg));
}
@ -180,10 +180,10 @@ public class BaseWebSocketProcess {
U3dMsg u3dMsg = new U3dMsg();
u3dMsg.setMsgType(systemTalkBindU3dEntity.getU3dType());
u3dMsg.setMetaId(metaId);
u3dMsg.setScenceId(0L);
u3dMsg.setMetaId(String.valueOf(metaId));
u3dMsg.setScenceId("0");
u3dMsg.setExParam(systemTalkBindU3dEntity.getAnswerAction());
u3dMsg.setStatusId(systemTalkBindU3dEntity.getU3dStatusId());
u3dMsg.setStatusId(String.valueOf(systemTalkBindU3dEntity.getU3dStatusId()));
sendMq(JSONObject.toJSONString(u3dMsg));
}
@ -204,23 +204,21 @@ public class BaseWebSocketProcess {
protected void processAction(Actions actions, Long userId, BaseSession baseSession) {
if(actions.getActions() == null || actions.getActions().size() == 0){
//调用千问回答\
log.info("调用千问");
log.info("调用千问{}", actions.getRecordText());
Action action = new Action();
action.setAsk(actions.getRecordText());
action.setAction(actions.getRecordText());
toQianWen(action, baseSession);
return;
}
boolean isToQianWen = false;
//boolean isToQianWen = false;
for (Action action : actions.getActions()
) {
log.info("匹配到自定义指令{}", action.getSystemTalkAnswerConfigEntity());
if(action.getSystemTalkAnswerConfigEntity() == null){
if(!isToQianWen){
isToQianWen = true;;
log.info("调用千问,千问只能调用一边");
toQianWen(action, baseSession);
}
log.info("调用千问{}", action.getAsk());
toQianWen(action, baseSession);
return;
//
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.IOT.getCode())){
@ -276,8 +274,12 @@ public class BaseWebSocketProcess {
}
}else{
if(StringUtils.isEmpty(action.getName())){
sendMessage(action, baseSession, "请说明确的设备名称", action.getSystemTalkAnswerConfigEntity().getAnswerType());
}else{
sendMessage(action, baseSession, "未找到对应的设备", action.getSystemTalkAnswerConfigEntity().getAnswerType());
}
sendMessage(action, baseSession, "未找到对应的设备", action.getSystemTalkAnswerConfigEntity().getAnswerType());
}
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.WEATHER.getCode())){
@ -286,7 +288,8 @@ public class BaseWebSocketProcess {
if(action.getLbs() != null && action.getLbs().size() > 0){
//根据地址查询天气
// city = ;
req.setCity(action.getLbs().get(action.getLbs().size() - 1));
req.setCity(action.getLbs().get(action.getLbs().size() - 1).replace("", "")
.replace("", "").replace("", ""));
}else{
//使用IP查询天气
req.setIp("115.205.2.137");
@ -378,19 +381,19 @@ public class BaseWebSocketProcess {
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.TTS.getCode())){
if(!action.getAction().equals(action.getAsk())){
if(!isToQianWen){
toQianWen(action, baseSession);
return;
/*if(!isToQianWen){
isToQianWen = true;
toQianWen(action, baseSession);
}
}*/
}else{
sendMessage(action, baseSession, action.getSystemTalkAnswerConfigEntity().getAnswerValue(), AskTypeEnum.TTS.getCode());
}
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.QIU_GUO.getCode())){
sendMessage(action, baseSession, action.getSystemTalkAnswerConfigEntity().getAnswerValue(), AskTypeEnum.TTS.getCode());
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.TIME.getCode())){
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy年M月d日 H时m分 星期E");
DateTimeFormatter df = DateTimeFormatter.ofPattern(action.getSystemTalkAnswerConfigEntity().getAnswerValue());
sendMessage(action, baseSession, action.getTime().getDetailTime().format(df), AskTypeEnum.TTS.getCode());
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.U3D.getCode())){
SystemTalkBindU3dRequest request = new SystemTalkBindU3dRequest();