完成天气、时间、换装
This commit is contained in:
parent
4290419bba
commit
1ef0b727c6
@ -1,20 +0,0 @@
|
||||
package com.qiuguo.iot.data.resp.u3d;
|
||||
import lombok.Data;
|
||||
/**
|
||||
* <p>
|
||||
* </p>*U3D动作配置返回类
|
||||
* @author wulin
|
||||
* @since 2023-09-05
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class U3dActionResp {
|
||||
//
|
||||
private Long id;
|
||||
//名称
|
||||
private String name;
|
||||
//动作类型
|
||||
private Integer type;
|
||||
//具体动作
|
||||
private String action;
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package com.qiuguo.iot.data.resp.u3d;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 与U3D通过MQ交互信息
|
||||
*/
|
||||
@Data
|
||||
public class U3dBaseMsg {
|
||||
|
||||
|
||||
/**
|
||||
* msgType=0,1,3时数字人ID,msgType=3时设备所在虚拟世界ID
|
||||
*/
|
||||
private String metaId;
|
||||
|
||||
/**
|
||||
* 状态ID
|
||||
*/
|
||||
private String statusId;
|
||||
|
||||
/**
|
||||
* 场景ID
|
||||
*/
|
||||
private String scenceId;
|
||||
|
||||
/**
|
||||
* 类型ID
|
||||
*/
|
||||
private String typeId;
|
||||
|
||||
/**
|
||||
* 扩展参数
|
||||
*/
|
||||
private String exParam;
|
||||
/**
|
||||
* 坐标x
|
||||
*/
|
||||
String x;
|
||||
/**
|
||||
* 坐标y
|
||||
*/
|
||||
String y;
|
||||
|
||||
/**
|
||||
* 坐标z
|
||||
*/
|
||||
String z;
|
||||
|
||||
}
|
||||
@ -6,51 +6,15 @@ import lombok.Data;
|
||||
* 与U3D通过MQ交互信息
|
||||
*/
|
||||
@Data
|
||||
public class U3dMsg {
|
||||
public class U3dMsg extends U3dBaseMsg{
|
||||
/**
|
||||
* 消息类型:0:跳舞 1 :换装 2:口型 100:IOT
|
||||
*/
|
||||
private Integer msgType;
|
||||
|
||||
/**
|
||||
* msgType=0,1,3时数字人ID,msgType=3时设备所在虚拟世界ID
|
||||
*/
|
||||
private String metaId;
|
||||
|
||||
/**
|
||||
* 状态ID
|
||||
*/
|
||||
private String statusId;
|
||||
|
||||
/**
|
||||
* 场景ID
|
||||
*/
|
||||
private String scenceId;
|
||||
|
||||
/**
|
||||
* 类型ID
|
||||
*/
|
||||
private String typeId;
|
||||
|
||||
/**
|
||||
* 扩展参数
|
||||
*/
|
||||
private String exParam;
|
||||
/**
|
||||
* 坐标x
|
||||
*/
|
||||
String x;
|
||||
/**
|
||||
* 坐标y
|
||||
*/
|
||||
String y;
|
||||
|
||||
/**
|
||||
* 坐标z
|
||||
*/
|
||||
String z;
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
Long time;
|
||||
|
||||
}
|
||||
|
||||
@ -498,7 +498,9 @@ public enum ActionPartSpeechEnum implements IChinesePartSpeech{
|
||||
List<DeviceUserBindEntity> includs,
|
||||
List<SystemTalkAnswerConfigEntity> commands){
|
||||
//解析时间关键字
|
||||
action.setTime(new ActionTime());
|
||||
if(action.getTime() == null){
|
||||
action.setTime(new ActionTime());
|
||||
}
|
||||
action.getTime().setTime(key);
|
||||
return action;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ public class ActionTime {
|
||||
public void setTime(String t){
|
||||
LocalDateTime localDateTime;
|
||||
if(StringUtils.isNotEmpty(time)){
|
||||
localDateTime = LocalDateTime.parse(dateDetailTime);//time转
|
||||
localDateTime = detailTime;
|
||||
}else{
|
||||
time = t;
|
||||
localDateTime = DateTimeUtils.getNowLocalDateTime();
|
||||
|
||||
@ -61,7 +61,8 @@ public class TimeActionCommand extends ActionCommand implements IActionCommand{
|
||||
|
||||
BoxMessageResp resp = new BoxMessageResp();
|
||||
resp.setType(action.getSystemTalkAnswerConfigEntity().getAnswerType());
|
||||
resp.setText(getDayOfWeek(action.getTime().getDetailTime().format(df)));
|
||||
|
||||
resp.setText(action.getAsk().replaceAll(action.getAction(), getDayOfWeek(action.getTime().getDetailTime().format(df))));
|
||||
resp.setTime(dateTimeResp);
|
||||
return baseWebSocketService.sendMessage(
|
||||
action,
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package com.qiuguo.iot.box.websocket.api.command;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.qiuguo.iot.base.enums.AskTypeEnum;
|
||||
import com.qiuguo.iot.base.enums.U3dMsgTypeEnum;
|
||||
@ -9,9 +12,11 @@ import com.qiuguo.iot.box.websocket.api.domain.box.resp.BoxMessageResp;
|
||||
import com.qiuguo.iot.data.entity.device.DeviceUserTalkRecordEntity;
|
||||
import com.qiuguo.iot.data.entity.system.SystemTalkBindU3dEntity;
|
||||
import com.qiuguo.iot.data.request.system.SystemTalkBindU3dRequest;
|
||||
import com.qiuguo.iot.data.resp.u3d.U3dBaseMsg;
|
||||
import com.qiuguo.iot.data.resp.u3d.U3dMsg;
|
||||
import com.qiuguo.iot.data.service.device.DeviceUserTalkRecordService;
|
||||
import com.qiuguo.iot.data.service.system.SystemTalkBindU3dService;
|
||||
import com.qiuguo.iot.data.service.u3d.U3dActionService;
|
||||
import com.qiuguo.iot.third.nlp.action.Action;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -27,6 +32,9 @@ public class U3DActionCommand extends ActionCommand implements IActionCommand{
|
||||
@Resource
|
||||
protected SystemTalkBindU3dService systemTalkBindU3dService;
|
||||
|
||||
@Resource
|
||||
protected U3dActionService u3dActionService;
|
||||
|
||||
public Mono<Boolean> process(Action action, BaseSession baseSession) {
|
||||
log.info("U3d Action:{}", action.getAsk());
|
||||
|
||||
@ -41,26 +49,41 @@ public class U3DActionCommand extends ActionCommand implements IActionCommand{
|
||||
//return systemTalkBindU3d;
|
||||
}
|
||||
//数字人的id直接用用户id来代替
|
||||
BoxMessageResp resp = new BoxMessageResp();
|
||||
if(U3dMsgTypeEnum.DANCE.getCode().equals(systemTalkBindU3d.getU3dType())){
|
||||
//推送客户端跳舞
|
||||
|
||||
BoxMessageResp resp = new BoxMessageResp();
|
||||
|
||||
if(baseSession.getUserId().equals(1291978L)){
|
||||
//临时取消
|
||||
resp.setType(AskTypeEnum.TTS.getCode());
|
||||
resp.setText("抱歉,我还么学会跳舞");
|
||||
/*ActionResp actionResp = new ActionResp();
|
||||
actionResp.setType(7);
|
||||
resp.setAction(actionResp);*/
|
||||
return baseWebSocketService.sendMessage(action, baseSession, resp);
|
||||
}else{
|
||||
resp.setType(AskTypeEnum.U3D.getCode());
|
||||
resp.setText("开始跳舞");
|
||||
ActionResp actionResp = new ActionResp();
|
||||
actionResp.setType(7);
|
||||
resp.setAction(actionResp);
|
||||
return u3dActionService.selectU3dActionById(systemTalkBindU3d.getU3dActionId())
|
||||
.flatMap(u3d -> {
|
||||
//获取跳舞配置,并随机一个
|
||||
JSONObject jsonObject = JSON.parseObject(u3d.getAction());
|
||||
JSONArray arr = jsonObject.getJSONArray("dances");
|
||||
int num = RandomUtil.randomInt(arr.size());
|
||||
jsonObject = arr.getJSONObject(num);
|
||||
resp.setType(AskTypeEnum.U3D.getCode());
|
||||
resp.setText("开始跳舞");
|
||||
|
||||
ActionResp actionResp = new ActionResp();
|
||||
actionResp.setType(7);
|
||||
actionResp.setSound(jsonObject.getString("sound"));
|
||||
U3dBaseMsg u3dMsg = new U3dBaseMsg();
|
||||
u3dMsg.setStatusId(jsonObject.getString("id"));
|
||||
actionResp.setU3d(u3dMsg);
|
||||
resp.setAction(actionResp);
|
||||
return baseWebSocketService.sendMessage(action, baseSession, resp);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
return baseWebSocketService.sendMessage(action, baseSession, resp);
|
||||
//return baseWebSocketService.sendMessage(action, baseSession, resp);
|
||||
}else{
|
||||
//推送MQ换装
|
||||
|
||||
@ -72,7 +95,10 @@ public class U3DActionCommand extends ActionCommand implements IActionCommand{
|
||||
talkRecord.setUserId(baseSession.getUserId());
|
||||
talkRecord.setDeviceId(baseSession.getDeviceId());
|
||||
return deviceUserTalkRecordService.insertDeviceUserTalkRecord(talkRecord).flatMap(integer -> {
|
||||
return toU3DMq(systemTalkBindU3d, baseSession.getUserId());
|
||||
return toU3DMq(systemTalkBindU3d, baseSession.getUserId()).flatMap(b -> {
|
||||
resp.setType(AskTypeEnum.EXIT.getCode());//告诉Box退出思考
|
||||
return baseWebSocketService.sendMsgWithMono(baseSession, JSONObject.toJSONString(resp));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.qiuguo.iot.box.websocket.api.command;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.qiuguo.iot.base.utils.StringUtils;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.BaseSession;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.BoxSession;
|
||||
@ -7,6 +8,7 @@ import com.qiuguo.iot.box.websocket.api.domain.box.resp.BoxMessageResp;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.resp.WeatherResp;
|
||||
import com.qiuguo.iot.data.request.third.ThirdWeatherInfoRequest;
|
||||
import com.qiuguo.iot.data.resp.third.weather.TianqiapiItemResp;
|
||||
import com.qiuguo.iot.data.resp.third.weather.TianqiapiLifeItemResp;
|
||||
import com.qiuguo.iot.third.nlp.action.Action;
|
||||
import com.qiuguo.iot.third.nlp.action.ActionTime;
|
||||
import com.qiuguo.iot.third.service.WeatherService;
|
||||
@ -62,10 +64,16 @@ public class WeatherActionCommand extends ActionCommand implements IActionComma
|
||||
String msg = "";
|
||||
if(item != null){
|
||||
//返回给客户端播报内容
|
||||
for (TianqiapiLifeItemResp life : item.getIndex()){
|
||||
if(life.getTitle().equals("穿衣指数")){
|
||||
msg = life.getDesc();
|
||||
break;
|
||||
}
|
||||
}
|
||||
msg = t.getCity() + action.getTime().getTime() + "天气"
|
||||
+ item.getNarrative().replace("每 km / h", "千米每小时")
|
||||
+ ",空气质量" + item.getAir_level()
|
||||
+ ",湿度" + item.getHumidity() + ",最低气温" + item.getTem2() + "°C";
|
||||
+ ",湿度" + item.getHumidity() + ",最低气温" + item.getTem2() + "°C " + msg;
|
||||
msg = msg.replace(" ", "");
|
||||
if(baseSession instanceof BoxSession){
|
||||
WeatherResp weatherResp = new WeatherResp();
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.qiuguo.iot.box.websocket.api.domain.box.resp;
|
||||
|
||||
import com.qiuguo.iot.data.resp.u3d.U3dBaseMsg;
|
||||
import com.qiuguo.iot.data.resp.u3d.U3dMsg;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ -20,4 +22,6 @@ public class ActionResp {
|
||||
* 图片地址
|
||||
*/
|
||||
String image;
|
||||
|
||||
U3dBaseMsg u3d;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public class LogWebFilter implements WebFilter {
|
||||
String requestId = request.getId();
|
||||
MDC.put(LogMdcConfiguration.PRINT_LOG_ID, requestId);
|
||||
|
||||
String customerIp = request.getRemoteAddress().getAddress().getHostAddress();//.getHostName();
|
||||
String customerIp = request.getRemoteAddress().getAddress().getHostAddress();
|
||||
String m = request.getMethod().toString();
|
||||
|
||||
log.info("api start time:{} ip:{} method:{} url:{} param:{} headers:{}",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user