增加古诗、时间
This commit is contained in:
parent
fd4b22607e
commit
ae040421ce
@ -14,6 +14,7 @@ public enum AskTypeEnum {
|
|||||||
U3D(4, "U3D动作"),
|
U3D(4, "U3D动作"),
|
||||||
MUSIC(5, "音乐,声音"),
|
MUSIC(5, "音乐,声音"),
|
||||||
TIME(6, "询问时间"),
|
TIME(6, "询问时间"),
|
||||||
|
POEM(7, "古诗"),
|
||||||
|
|
||||||
UPDATE(100, "固件升级"),
|
UPDATE(100, "固件升级"),
|
||||||
BOX_ON_LINE(101, "Box配网成功"),
|
BOX_ON_LINE(101, "Box配网成功"),
|
||||||
|
|||||||
@ -69,7 +69,7 @@ public class SystemTalkAnswerConfigEntity extends GenericEntity<Long> {
|
|||||||
@Column(name = "key_order", nullable = false)
|
@Column(name = "key_order", nullable = false)
|
||||||
private Long keyOrder;
|
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)
|
@Column(name = "answer_type", nullable = false)
|
||||||
private Integer answerType;
|
private Integer answerType;
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public class SystemTalkAnswerConfigRequest implements java.io.Serializable {
|
|||||||
//关键字的排序,越小越第一个匹配上
|
//关键字的排序,越小越第一个匹配上
|
||||||
private Long keyOrder;
|
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;
|
private Integer answerType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public class SystemTalkAnswerConfigResp {
|
|||||||
//关键字的排序,越小越第一个匹配上
|
//关键字的排序,越小越第一个匹配上
|
||||||
private Long keyOrder;
|
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;
|
private Integer answerType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -20,4 +20,8 @@ public class BoxMessageResp extends BaseMessageResp {
|
|||||||
* 天气
|
* 天气
|
||||||
*/
|
*/
|
||||||
WeatherResp weather;
|
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.BoxSession;
|
||||||
import com.qiuguo.iot.box.websocket.api.domain.box.resp.ActionResp;
|
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.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.box.websocket.api.domain.box.resp.WeatherResp;
|
||||||
import com.qiuguo.iot.data.constants.YunxiRabbitConst;
|
import com.qiuguo.iot.data.constants.YunxiRabbitConst;
|
||||||
import com.qiuguo.iot.data.entity.device.DeviceUserBindEntity;
|
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);
|
baseSession.setRequestId(baseSession.getRequestId() + 1);
|
||||||
TongYiCommunicationRest tongYiCommunicationRest = new TongYiCommunicationRest();
|
TongYiCommunicationRest tongYiCommunicationRest = new TongYiCommunicationRest();
|
||||||
tongYiCommunicationRest.setText(action.getAsk());
|
tongYiCommunicationRest.setText(action.getAsk());
|
||||||
@ -159,7 +160,7 @@ public class BaseWebSocketProcess {
|
|||||||
sb.append(old.substring(m));
|
sb.append(old.substring(m));
|
||||||
old = old.substring(0, m);
|
old = old.substring(0, m);
|
||||||
|
|
||||||
normalSendMsg(baseSession, old, AskTypeEnum.TTS.getCode());
|
normalSendMsg(baseSession, old, type);
|
||||||
}else{
|
}else{
|
||||||
sb.append(message);
|
sb.append(message);
|
||||||
}
|
}
|
||||||
@ -192,6 +193,7 @@ public class BaseWebSocketProcess {
|
|||||||
U3dMsg u3dMsg = new U3dMsg();
|
U3dMsg u3dMsg = new U3dMsg();
|
||||||
u3dMsg.setMsgType(U3dMsgTypeEnum.IOT.getCode());
|
u3dMsg.setMsgType(U3dMsgTypeEnum.IOT.getCode());
|
||||||
u3dMsg.setMetaId(String.valueOf(metaId));
|
u3dMsg.setMetaId(String.valueOf(metaId));
|
||||||
|
u3dMsg.setTime(System.currentTimeMillis());
|
||||||
u3dMsg.setScenceId(String.valueOf(action.getDeviceUserBindEntity().getScenceId()));
|
u3dMsg.setScenceId(String.valueOf(action.getDeviceUserBindEntity().getScenceId()));
|
||||||
u3dMsg.setStatusId(String.valueOf(systemTalkBindDeviceEntity.getU3dStatusId()));
|
u3dMsg.setStatusId(String.valueOf(systemTalkBindDeviceEntity.getU3dStatusId()));
|
||||||
sendMq(JSONObject.toJSONString(u3dMsg));
|
sendMq(JSONObject.toJSONString(u3dMsg));
|
||||||
@ -205,7 +207,7 @@ public class BaseWebSocketProcess {
|
|||||||
u3dMsg.setScenceId("0");
|
u3dMsg.setScenceId("0");
|
||||||
u3dMsg.setExParam(systemTalkBindU3dEntity.getAnswerAction());
|
u3dMsg.setExParam(systemTalkBindU3dEntity.getAnswerAction());
|
||||||
u3dMsg.setStatusId(String.valueOf(systemTalkBindU3dEntity.getU3dStatusId()));
|
u3dMsg.setStatusId(String.valueOf(systemTalkBindU3dEntity.getU3dStatusId()));
|
||||||
|
u3dMsg.setTime(System.currentTimeMillis());
|
||||||
sendMq(JSONObject.toJSONString(u3dMsg));
|
sendMq(JSONObject.toJSONString(u3dMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +231,7 @@ public class BaseWebSocketProcess {
|
|||||||
Action action = new Action();
|
Action action = new Action();
|
||||||
action.setAsk(actions.getRecordText());
|
action.setAsk(actions.getRecordText());
|
||||||
action.setAction(actions.getRecordText());
|
action.setAction(actions.getRecordText());
|
||||||
toQianWen(action, baseSession);
|
toQianWen(action, baseSession, AskTypeEnum.TTS.getCode());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//boolean isToQianWen = false;
|
//boolean isToQianWen = false;
|
||||||
@ -238,7 +240,7 @@ public class BaseWebSocketProcess {
|
|||||||
log.info("匹配到自定义指令{}", action.getSystemTalkAnswerConfigEntity());
|
log.info("匹配到自定义指令{}", action.getSystemTalkAnswerConfigEntity());
|
||||||
if(action.getSystemTalkAnswerConfigEntity() == null){
|
if(action.getSystemTalkAnswerConfigEntity() == null){
|
||||||
log.info("调用千问{}", action.getAsk());
|
log.info("调用千问{}", action.getAsk());
|
||||||
toQianWen(action, baseSession);
|
toQianWen(action, baseSession, AskTypeEnum.TTS.getCode());
|
||||||
return;
|
return;
|
||||||
//
|
//
|
||||||
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.IOT.getCode())){
|
}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())){
|
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.TTS.getCode())){
|
||||||
if(!action.getAction().equals(action.getAsk())){
|
if(!action.getAction().equals(action.getAsk())){
|
||||||
toQianWen(action, baseSession);
|
toQianWen(action, baseSession, AskTypeEnum.TTS.getCode());
|
||||||
return;
|
return;
|
||||||
/*if(!isToQianWen){
|
|
||||||
isToQianWen = true;
|
|
||||||
toQianWen(action, baseSession);
|
|
||||||
}*/
|
|
||||||
}else{
|
}else{
|
||||||
sendMessage(action, baseSession, action.getSystemTalkAnswerConfigEntity().getAnswerValue(), AskTypeEnum.TTS.getCode());
|
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());
|
sendMessage(action, baseSession, action.getSystemTalkAnswerConfigEntity().getAnswerValue(), AskTypeEnum.TTS.getCode());
|
||||||
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.TIME.getCode())){
|
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.TIME.getCode())){
|
||||||
DateTimeFormatter df = DateTimeFormatter.ofPattern(action.getSystemTalkAnswerConfigEntity().getAnswerValue());
|
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())){
|
}else if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.U3D.getCode())){
|
||||||
SystemTalkBindU3dRequest request = new SystemTalkBindU3dRequest();
|
SystemTalkBindU3dRequest request = new SystemTalkBindU3dRequest();
|
||||||
request.setSystemTalkId(action.getSystemTalkAnswerConfigEntity().getId());
|
request.setSystemTalkId(action.getSystemTalkAnswerConfigEntity().getId());
|
||||||
@ -465,6 +484,9 @@ public class BaseWebSocketProcess {
|
|||||||
|
|
||||||
return systemTalkBindU3d;
|
return systemTalkBindU3d;
|
||||||
}).subscribe();
|
}).subscribe();
|
||||||
|
}else{
|
||||||
|
toQianWen(action, baseSession, action.getSystemTalkAnswerConfigEntity().getAnswerType());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user