增加古诗、时间
This commit is contained in:
parent
fd4b22607e
commit
ae040421ce
@ -14,6 +14,7 @@ public enum AskTypeEnum {
|
||||
U3D(4, "U3D动作"),
|
||||
MUSIC(5, "音乐,声音"),
|
||||
TIME(6, "询问时间"),
|
||||
POEM(7, "古诗"),
|
||||
|
||||
UPDATE(100, "固件升级"),
|
||||
BOX_ON_LINE(101, "Box配网成功"),
|
||||
|
||||
@ -69,7 +69,7 @@ public class SystemTalkAnswerConfigEntity extends GenericEntity<Long> {
|
||||
@Column(name = "key_order", nullable = false)
|
||||
private Long keyOrder;
|
||||
|
||||
@Comment("回答类型0:文本问答 1:iOT控制 2:天气 3:闹钟 4:U3D 5:音乐声音 6:询问时间 100:固件升级 101:Box上线 200:动作后必须跟的名称词 300秋果专有名词 400:全部,所有,一切忽略词")
|
||||
@Comment("回答类型0:文本问答 1:iOT控制 2:天气 3:闹钟 4:U3D 5:音乐声音 6:询问时间 7:古诗、诗歌、诗 100:固件升级 101:Box上线 200:动作后必须跟的名称词 300秋果专有名词 400:全部,所有,一切忽略词")
|
||||
@Column(name = "answer_type", nullable = false)
|
||||
private Integer answerType;
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ public class SystemTalkAnswerConfigRequest implements java.io.Serializable {
|
||||
//关键字的排序,越小越第一个匹配上
|
||||
private Long keyOrder;
|
||||
|
||||
//回答类型0:文本问答 1:iOT控制 2:天气 3:闹钟 4:U3D 5:音乐声音 6:询问时间 100:固件升级 101:Box上线 200:动作后必须跟的名称词 300秋果专有名词 400:全部,所有,一切忽略词
|
||||
//回答类型0:文本问答 1:iOT控制 2:天气 3:闹钟 4:U3D 5:音乐声音 6:询问时间 7:古诗、诗歌、诗 100:固件升级 101:Box上线 200:动作后必须跟的名称词 300秋果专有名词 400:全部,所有,一切忽略词
|
||||
private Integer answerType;
|
||||
|
||||
/**
|
||||
|
||||
@ -32,7 +32,7 @@ public class SystemTalkAnswerConfigResp {
|
||||
//关键字的排序,越小越第一个匹配上
|
||||
private Long keyOrder;
|
||||
|
||||
//回答类型0:文本问答 1:iOT控制 2:天气 3:闹钟 4:U3D 5:音乐声音 6:询问时间 100:固件升级 101:Box上线 200:动作后必须跟的名称词 300秋果专有名词 400:全部,所有,一切忽略词
|
||||
//回答类型0:文本问答 1:iOT控制 2:天气 3:闹钟 4:U3D 5:音乐声音 6:询问时间 7:古诗、诗歌、诗 100:固件升级 101:Box上线 200:动作后必须跟的名称词 300秋果专有名词 400:全部,所有,一切忽略词
|
||||
private Integer answerType;
|
||||
|
||||
/**
|
||||
|
||||
@ -20,4 +20,8 @@ public class BoxMessageResp extends BaseMessageResp {
|
||||
* 天气
|
||||
*/
|
||||
WeatherResp weather;
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
DateTimeResp time;
|
||||
}
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package com.qiuguo.iot.box.websocket.api.domain.box.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DateTimeResp {
|
||||
/**
|
||||
* 年
|
||||
*/
|
||||
String year;
|
||||
/**
|
||||
* 月
|
||||
*/
|
||||
String month;
|
||||
/**
|
||||
* 天
|
||||
*/
|
||||
String day;
|
||||
/**
|
||||
* 时
|
||||
*/
|
||||
String hour;
|
||||
/**
|
||||
* 分
|
||||
*/
|
||||
String minute;
|
||||
/**
|
||||
* 秒
|
||||
*/
|
||||
String second;
|
||||
/**
|
||||
* 周
|
||||
*/
|
||||
String weak;
|
||||
}
|
||||
@ -8,6 +8,7 @@ import com.qiuguo.iot.box.websocket.api.domain.BaseSession;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.BoxSession;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.resp.ActionResp;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.resp.BoxMessageResp;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.resp.DateTimeResp;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.resp.WeatherResp;
|
||||
import com.qiuguo.iot.data.constants.YunxiRabbitConst;
|
||||
import com.qiuguo.iot.data.entity.device.DeviceUserBindEntity;
|
||||
@ -129,7 +130,7 @@ public class BaseWebSocketProcess {
|
||||
}
|
||||
}
|
||||
|
||||
private void toQianWen(Action action, BaseSession baseSession){
|
||||
private void toQianWen(Action action, BaseSession baseSession, Integer type){
|
||||
baseSession.setRequestId(baseSession.getRequestId() + 1);
|
||||
TongYiCommunicationRest tongYiCommunicationRest = new TongYiCommunicationRest();
|
||||
tongYiCommunicationRest.setText(action.getAsk());
|
||||
@ -159,7 +160,7 @@ public class BaseWebSocketProcess {
|
||||
sb.append(old.substring(m));
|
||||
old = old.substring(0, m);
|
||||
|
||||
normalSendMsg(baseSession, old, AskTypeEnum.TTS.getCode());
|
||||
normalSendMsg(baseSession, old, type);
|
||||
}else{
|
||||
sb.append(message);
|
||||
}
|
||||
@ -192,6 +193,7 @@ public class BaseWebSocketProcess {
|
||||
U3dMsg u3dMsg = new U3dMsg();
|
||||
u3dMsg.setMsgType(U3dMsgTypeEnum.IOT.getCode());
|
||||
u3dMsg.setMetaId(String.valueOf(metaId));
|
||||
u3dMsg.setTime(System.currentTimeMillis());
|
||||
u3dMsg.setScenceId(String.valueOf(action.getDeviceUserBindEntity().getScenceId()));
|
||||
u3dMsg.setStatusId(String.valueOf(systemTalkBindDeviceEntity.getU3dStatusId()));
|
||||
sendMq(JSONObject.toJSONString(u3dMsg));
|
||||
@ -205,7 +207,7 @@ public class BaseWebSocketProcess {
|
||||
u3dMsg.setScenceId("0");
|
||||
u3dMsg.setExParam(systemTalkBindU3dEntity.getAnswerAction());
|
||||
u3dMsg.setStatusId(String.valueOf(systemTalkBindU3dEntity.getU3dStatusId()));
|
||||
|
||||
u3dMsg.setTime(System.currentTimeMillis());
|
||||
sendMq(JSONObject.toJSONString(u3dMsg));
|
||||
}
|
||||
|
||||
@ -229,7 +231,7 @@ public class BaseWebSocketProcess {
|
||||
Action action = new Action();
|
||||
action.setAsk(actions.getRecordText());
|
||||
action.setAction(actions.getRecordText());
|
||||
toQianWen(action, baseSession);
|
||||
toQianWen(action, baseSession, AskTypeEnum.TTS.getCode());
|
||||
return;
|
||||
}
|
||||
//boolean isToQianWen = false;
|
||||
@ -238,7 +240,7 @@ public class BaseWebSocketProcess {
|
||||
log.info("匹配到自定义指令{}", action.getSystemTalkAnswerConfigEntity());
|
||||
if(action.getSystemTalkAnswerConfigEntity() == null){
|
||||
log.info("调用千问{}", action.getAsk());
|
||||
toQianWen(action, baseSession);
|
||||
toQianWen(action, baseSession, AskTypeEnum.TTS.getCode());
|
||||
return;
|
||||
//
|
||||
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.IOT.getCode())){
|
||||
@ -415,12 +417,8 @@ public class BaseWebSocketProcess {
|
||||
|
||||
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.TTS.getCode())){
|
||||
if(!action.getAction().equals(action.getAsk())){
|
||||
toQianWen(action, baseSession);
|
||||
toQianWen(action, baseSession, AskTypeEnum.TTS.getCode());
|
||||
return;
|
||||
/*if(!isToQianWen){
|
||||
isToQianWen = true;
|
||||
toQianWen(action, baseSession);
|
||||
}*/
|
||||
}else{
|
||||
sendMessage(action, baseSession, action.getSystemTalkAnswerConfigEntity().getAnswerValue(), AskTypeEnum.TTS.getCode());
|
||||
}
|
||||
@ -428,7 +426,28 @@ public class BaseWebSocketProcess {
|
||||
sendMessage(action, baseSession, action.getSystemTalkAnswerConfigEntity().getAnswerValue(), AskTypeEnum.TTS.getCode());
|
||||
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.TIME.getCode())){
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern(action.getSystemTalkAnswerConfigEntity().getAnswerValue());
|
||||
sendMessage(action, baseSession, action.getTime().getDetailTime().format(df), AskTypeEnum.TTS.getCode());
|
||||
if(this instanceof BoxWebSocketHandler){
|
||||
DateTimeResp dateTimeResp = new DateTimeResp();
|
||||
dateTimeResp.setYear(String.valueOf(action.getTime().getDetailTime().getYear()));
|
||||
dateTimeResp.setMonth(String.valueOf(action.getTime().getDetailTime().getMonthValue()));
|
||||
dateTimeResp.setDay(String.valueOf(action.getTime().getDetailTime().getDayOfMonth()));
|
||||
dateTimeResp.setHour(String.valueOf(action.getTime().getDetailTime().getHour()));
|
||||
dateTimeResp.setMinute(String.valueOf(action.getTime().getDetailTime().getMinute()));
|
||||
dateTimeResp.setSecond(String.valueOf(action.getTime().getDetailTime().getSecond()));
|
||||
dateTimeResp.setWeak(String.valueOf(action.getTime().getDetailTime().getDayOfWeek().getValue()));
|
||||
|
||||
BoxMessageResp resp = new BoxMessageResp();
|
||||
resp.setType(action.getSystemTalkAnswerConfigEntity().getAnswerType());
|
||||
resp.setText(action.getTime().getDetailTime().format(df));
|
||||
resp.setTime(dateTimeResp);
|
||||
sendMessage(action, baseSession, resp);
|
||||
|
||||
}else{
|
||||
sendMessage(action, baseSession, action.getTime().getDetailTime().format(df), AskTypeEnum.TIME.getCode());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.U3D.getCode())){
|
||||
SystemTalkBindU3dRequest request = new SystemTalkBindU3dRequest();
|
||||
request.setSystemTalkId(action.getSystemTalkAnswerConfigEntity().getId());
|
||||
@ -465,6 +484,9 @@ public class BaseWebSocketProcess {
|
||||
|
||||
return systemTalkBindU3d;
|
||||
}).subscribe();
|
||||
}else{
|
||||
toQianWen(action, baseSession, action.getSystemTalkAnswerConfigEntity().getAnswerType());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user