闹钟其他动作类提测
This commit is contained in:
parent
e11095552c
commit
c76b3fb768
@ -81,7 +81,7 @@ public class DeviceAlarmClockRecordEntity extends GenericEntity<Long> {
|
|||||||
@Column(name = "alarm_type", nullable = false)
|
@Column(name = "alarm_type", nullable = false)
|
||||||
private Integer alarmType;
|
private Integer alarmType;
|
||||||
|
|
||||||
@Comment("服务端配合操作的动作:1:IOT控制 2天气 4U3D动作 5音乐")
|
@Comment("服务端配合操作的动作:0:无相关动作(文本播放或者音乐) 1:IOT控制 2天气 4U3D动作 5音乐")
|
||||||
@Column(name = "action_type")
|
@Column(name = "action_type")
|
||||||
private Integer actionType;
|
private Integer actionType;
|
||||||
|
|
||||||
|
|||||||
@ -111,7 +111,7 @@ public class DeviceAlarmClockRecordRequest implements java.io.Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer alarmType;
|
private Integer alarmType;
|
||||||
/**
|
/**
|
||||||
*服务端配合操作的动作:1:IOT控制 2天气 4U3D动作 5音乐
|
*服务端配合操作的动作:0:无相关动作(文本播放或者音乐) 1:IOT控制 2天气 4U3D动作 5音乐
|
||||||
*/
|
*/
|
||||||
private Integer actionType;
|
private Integer actionType;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -94,7 +94,7 @@ public class DeviceAlarmClockRecordResp {
|
|||||||
*/
|
*/
|
||||||
private Integer alarmType;
|
private Integer alarmType;
|
||||||
/**
|
/**
|
||||||
*服务端配合操作的动作:1:IOT控制 2天气 4U3D动作 5音乐
|
*服务端配合操作的动作:0:无相关动作(文本播放或者音乐) 1:IOT控制 2天气 4U3D动作 5音乐
|
||||||
*/
|
*/
|
||||||
private Integer actionType;
|
private Integer actionType;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.qiuguo.iot.box.websocket.api.command;
|
package com.qiuguo.iot.box.websocket.api.command;
|
||||||
|
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.qiuguo.iot.base.enums.AlarmRepeatEnum;
|
import com.qiuguo.iot.base.enums.AlarmRepeatEnum;
|
||||||
import com.qiuguo.iot.base.enums.AskTypeEnum;
|
import com.qiuguo.iot.base.enums.AskTypeEnum;
|
||||||
import com.qiuguo.iot.base.enums.YesNo;
|
import com.qiuguo.iot.base.enums.YesNo;
|
||||||
@ -48,12 +49,13 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
|
|||||||
|
|
||||||
public Mono<Boolean> process(Action action, BaseSession baseSession) {
|
public Mono<Boolean> process(Action action, BaseSession baseSession) {
|
||||||
log.info("闹钟 Action:{}", action.getAsk());
|
log.info("闹钟 Action:{}", action.getAsk());
|
||||||
|
if(StringUtils.isEmpty(action.getNoTimeAsk())){
|
||||||
|
log.info("一个提醒后无有效动作");
|
||||||
|
return Mono.just(false);
|
||||||
|
}
|
||||||
ActionTime actionTime = action.getTime();
|
ActionTime actionTime = action.getTime();
|
||||||
action.setNoTimeAsk(
|
|
||||||
action.getNoTimeAsk()
|
|
||||||
.replace(action.getAction(), "")
|
|
||||||
.replace("我", "")
|
|
||||||
);
|
|
||||||
DeviceAlarmClockRecordRequest request;
|
DeviceAlarmClockRecordRequest request;
|
||||||
Integer day = null;
|
Integer day = null;
|
||||||
if(actionTime.getDayOfWeek().size() > 0) {
|
if(actionTime.getDayOfWeek().size() > 0) {
|
||||||
@ -70,6 +72,7 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
|
|||||||
);
|
);
|
||||||
request.setUserId(baseSession.getUserId());
|
request.setUserId(baseSession.getUserId());
|
||||||
request.setDeviceId(baseSession.getDeviceId());
|
request.setDeviceId(baseSession.getDeviceId());
|
||||||
|
|
||||||
request.setRepeat(AlarmRepeatEnum.EVERY_DAY.getCode());
|
request.setRepeat(AlarmRepeatEnum.EVERY_DAY.getCode());
|
||||||
day = repeatDay;
|
day = repeatDay;
|
||||||
}else {
|
}else {
|
||||||
@ -98,6 +101,25 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(action.
|
||||||
|
getSystemTalkAnswerConfigEntity().
|
||||||
|
getAnswerType().
|
||||||
|
equals(AskTypeEnum.ALARM_CLOCK.getCode())
|
||||||
|
){
|
||||||
|
action.setNoTimeAsk(
|
||||||
|
action.getNoTimeAsk()
|
||||||
|
.replace(action.getAction(), "")
|
||||||
|
.replace("我", "")
|
||||||
|
);
|
||||||
|
request.setActionType(YesNo.NO.getCode());
|
||||||
|
request.setAlarmType(YesNo.NO.getCode());
|
||||||
|
}else{
|
||||||
|
request.setAlarmType(YesNo.YES.getCode());
|
||||||
|
request.setActionType(action.getSystemTalkAnswerConfigEntity().getAnswerType());
|
||||||
|
action.getSystemTalkAnswerConfigEntity().setAnswerValueFaild("已有相关提醒");
|
||||||
|
}
|
||||||
|
|
||||||
Integer rDay = day;
|
Integer rDay = day;
|
||||||
return deviceAlarmClockRecordService
|
return deviceAlarmClockRecordService
|
||||||
.selectDeviceAlarmClockRecordByRequest(request)
|
.selectDeviceAlarmClockRecordByRequest(request)
|
||||||
@ -110,12 +132,14 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
|
|||||||
alarmClock.setUserId(baseSession.getUserId());
|
alarmClock.setUserId(baseSession.getUserId());
|
||||||
alarmClock.setDeviceId(baseSession.getDeviceId());
|
alarmClock.setDeviceId(baseSession.getDeviceId());
|
||||||
alarmClock.setRepeatDay(rDay);
|
alarmClock.setRepeatDay(rDay);
|
||||||
|
alarmClock.setActionType(request.getActionType());
|
||||||
|
alarmClock.setAlarmType(request.getAlarmType());
|
||||||
|
if(!AskTypeEnum.TTS.getCode().equals(request.getActionType())){
|
||||||
|
alarmClock.setAction(action.getNoTimeAsk());
|
||||||
|
}
|
||||||
alarmClock.setTime(
|
alarmClock.setTime(
|
||||||
Date.from(actionTime.getDetailTime().getLocalDateTime().atZone(ZoneId.systemDefault()).toInstant())
|
Date.from(actionTime.getDetailTime().getLocalDateTime().atZone(ZoneId.systemDefault()).toInstant())
|
||||||
);
|
);
|
||||||
|
|
||||||
alarmClock.setAlarmType(YesNo.NO.getCode());
|
|
||||||
alarmClock.setRepeat(request.getRepeat());
|
alarmClock.setRepeat(request.getRepeat());
|
||||||
if(!alarmClock.getRepeat().equals(AlarmRepeatEnum.ONE.getCode())){
|
if(!alarmClock.getRepeat().equals(AlarmRepeatEnum.ONE.getCode())){
|
||||||
alarmClock.setTitle("循环闹钟");
|
alarmClock.setTitle("循环闹钟");
|
||||||
@ -153,8 +177,8 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
|
|||||||
}else{
|
}else{
|
||||||
//更新闹钟
|
//更新闹钟
|
||||||
Boolean isUpdate = false;
|
Boolean isUpdate = false;
|
||||||
if(StringUtils.isEmpty(alarmClock.getReadText()) &&
|
if(StringUtils.isNotEmpty(alarmClock.getReadText()) &&
|
||||||
StringUtils.isEmpty(action.getNoTimeAsk()) &&
|
StringUtils.isNotEmpty(action.getNoTimeAsk()) &&
|
||||||
!alarmClock.getReadText().contains(action.getNoTimeAsk())){
|
!alarmClock.getReadText().contains(action.getNoTimeAsk())){
|
||||||
alarmClock.setReadText(alarmClock.getReadText() + "," + action.getNoTimeAsk());
|
alarmClock.setReadText(alarmClock.getReadText() + "," + action.getNoTimeAsk());
|
||||||
log.info("修改提醒文案:{}", alarmClock);
|
log.info("修改提醒文案:{}", alarmClock);
|
||||||
@ -251,13 +275,29 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
|
|||||||
SimpleDateFormat df = new SimpleDateFormat("H:m");
|
SimpleDateFormat df = new SimpleDateFormat("H:m");
|
||||||
String v = df.format(alarm.getTime());
|
String v = df.format(alarm.getTime());
|
||||||
String[] p = v.split(":");
|
String[] p = v.split(":");
|
||||||
|
if(!alarm.getRepeat().equals(AlarmRepeatEnum.ONE.getCode())){
|
||||||
|
df = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
v = df.format(alarm.getTime());
|
||||||
|
p = v.split("-");
|
||||||
|
actionResp.setYear(Integer.parseInt(p[0]));
|
||||||
|
actionResp.setMonth(Integer.parseInt(p[1]));
|
||||||
|
actionResp.setDay(Integer.parseInt(p[2]));
|
||||||
|
}
|
||||||
|
|
||||||
actionResp.setHour(Integer.parseInt(p[0]));
|
actionResp.setHour(Integer.parseInt(p[0]));
|
||||||
actionResp.setMinute(Integer.parseInt(p[1]));
|
actionResp.setMinute(Integer.parseInt(p[1]));
|
||||||
actionResp.setType(alarm.getRepeat());;
|
actionResp.setType(alarm.getRepeat());
|
||||||
actionResp.setReadText(alarm.getReadText());
|
if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.ALARM_CLOCK.getCode())){
|
||||||
|
actionResp.setReadText(alarm.getReadText());
|
||||||
|
}else{
|
||||||
|
df = new SimpleDateFormat("yyyy年M月d日H点m分");
|
||||||
|
msg = df.format(alarm.getTime()) + alarm.getAction();
|
||||||
|
}
|
||||||
|
|
||||||
actionResp.setSound(alarm.getSound());
|
actionResp.setSound(alarm.getSound());
|
||||||
actionResp.setAlarmType(YesNo.NO.getCode());
|
actionResp.setAlarmType(YesNo.NO.getCode());
|
||||||
actionResp.setDayOfWeek(dayOfWeek);
|
actionResp.setDayOfWeek(dayOfWeek);
|
||||||
|
actionResp.setAlarmType(alarm.getAlarmType());
|
||||||
//读取星期
|
//读取星期
|
||||||
resp.setAction(actionResp);
|
resp.setAction(actionResp);
|
||||||
resp.setType(AskTypeEnum.ALARM_CLOCK.getCode());
|
resp.setType(AskTypeEnum.ALARM_CLOCK.getCode());
|
||||||
|
|||||||
@ -33,6 +33,9 @@ public class IotActionCommand extends ActionCommand implements IActionCommand{
|
|||||||
@Resource
|
@Resource
|
||||||
protected DeviceUserBindService deviceUserBindService;
|
protected DeviceUserBindService deviceUserBindService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AlarmClockActionCommand alarmClockActionCommand;
|
||||||
|
|
||||||
|
|
||||||
public Mono<Boolean> process(Action action, BaseSession baseSession) {
|
public Mono<Boolean> process(Action action, BaseSession baseSession) {
|
||||||
log.info("IOT物联网 Action:{}", action.getAsk());
|
log.info("IOT物联网 Action:{}", action.getAsk());
|
||||||
@ -60,6 +63,7 @@ public class IotActionCommand extends ActionCommand implements IActionCommand{
|
|||||||
//判断action是否有所有、全部。一切
|
//判断action是否有所有、全部。一切
|
||||||
if(YesNo.YES.getCode().equals(action.getIgnore())){
|
if(YesNo.YES.getCode().equals(action.getIgnore())){
|
||||||
//忽略词,控制所有设备
|
//忽略词,控制所有设备
|
||||||
|
|
||||||
return controllerDevice(action, binds.getData(), 0, baseSession);
|
return controllerDevice(action, binds.getData(), 0, baseSession);
|
||||||
}else{
|
}else{
|
||||||
return baseWebSocketService.sendMessage(action,
|
return baseWebSocketService.sendMessage(action,
|
||||||
@ -95,6 +99,11 @@ public class IotActionCommand extends ActionCommand implements IActionCommand{
|
|||||||
List<DeviceUserBindEntity> deviceUserBindEntitys,
|
List<DeviceUserBindEntity> deviceUserBindEntitys,
|
||||||
int i,
|
int i,
|
||||||
BaseSession baseSession){
|
BaseSession baseSession){
|
||||||
|
if(action.getTime() != null){
|
||||||
|
//定时查询天气
|
||||||
|
log.info("定期执行物联网操作1");
|
||||||
|
return alarmClockActionCommand.process(action, baseSession);
|
||||||
|
}
|
||||||
if(i < deviceUserBindEntitys.size()){
|
if(i < deviceUserBindEntitys.size()){
|
||||||
DeviceUserBindEntity deviceUserBindEntity = deviceUserBindEntitys.get(i++);
|
DeviceUserBindEntity deviceUserBindEntity = deviceUserBindEntitys.get(i++);
|
||||||
action.setDeviceUserBindEntity(deviceUserBindEntity);
|
action.setDeviceUserBindEntity(deviceUserBindEntity);
|
||||||
@ -106,7 +115,11 @@ public class IotActionCommand extends ActionCommand implements IActionCommand{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Mono<Boolean> controllerDevice(Action action, DeviceUserBindEntity deviceUserBindEntity, BaseSession baseSession) {
|
protected Mono<Boolean> controllerDevice(Action action, DeviceUserBindEntity deviceUserBindEntity, BaseSession baseSession) {
|
||||||
|
if(action.getTime() != null){
|
||||||
|
//定时查询天气
|
||||||
|
log.info("定期执行物联网操作1");
|
||||||
|
return alarmClockActionCommand.process(action, baseSession);
|
||||||
|
}
|
||||||
SystemTalkBindDeviceRequest systemTalkBindDeviceRequest = new SystemTalkBindDeviceRequest();
|
SystemTalkBindDeviceRequest systemTalkBindDeviceRequest = new SystemTalkBindDeviceRequest();
|
||||||
systemTalkBindDeviceRequest.setCategoryCode(deviceUserBindEntity.getCategoryCode());
|
systemTalkBindDeviceRequest.setCategoryCode(deviceUserBindEntity.getCategoryCode());
|
||||||
systemTalkBindDeviceRequest.setSystemTalkId(action.getSystemTalkAnswerConfigEntity().getId());
|
systemTalkBindDeviceRequest.setSystemTalkId(action.getSystemTalkAnswerConfigEntity().getId());
|
||||||
|
|||||||
@ -24,6 +24,8 @@ import java.util.ArrayList;
|
|||||||
public class MusicActionCommand extends ActionCommand implements IActionCommand{
|
public class MusicActionCommand extends ActionCommand implements IActionCommand{
|
||||||
@Resource
|
@Resource
|
||||||
protected MusicService musicService;
|
protected MusicService musicService;
|
||||||
|
@Resource
|
||||||
|
private AlarmClockActionCommand alarmClockActionCommand;
|
||||||
public Mono<Boolean> process(Action action, BaseSession baseSession) {
|
public Mono<Boolean> process(Action action, BaseSession baseSession) {
|
||||||
log.info("音乐acion:{}", action.getAsk());
|
log.info("音乐acion:{}", action.getAsk());
|
||||||
|
|
||||||
@ -32,6 +34,11 @@ public class MusicActionCommand extends ActionCommand implements IActionCommand
|
|||||||
search = search.replaceAll(action.getPName(), "");
|
search = search.replaceAll(action.getPName(), "");
|
||||||
}
|
}
|
||||||
BoxMessageResp resp = new BoxMessageResp();
|
BoxMessageResp resp = new BoxMessageResp();
|
||||||
|
if(action.getTime() != null){
|
||||||
|
//定时查询天气
|
||||||
|
log.info("定期打开音乐播放");
|
||||||
|
return alarmClockActionCommand.process(action, baseSession);
|
||||||
|
}
|
||||||
if(action.getSystemTalkAnswerConfigEntity().getPlayType().equals(PlayEnum.START.getCode())){
|
if(action.getSystemTalkAnswerConfigEntity().getPlayType().equals(PlayEnum.START.getCode())){
|
||||||
return musicService.searchMusic(search, 1).defaultIfEmpty(new ArrayList<>()).flatMap(resultSongs -> {
|
return musicService.searchMusic(search, 1).defaultIfEmpty(new ArrayList<>()).flatMap(resultSongs -> {
|
||||||
//BoxMessageResp resp = new BoxMessageResp();
|
//BoxMessageResp resp = new BoxMessageResp();
|
||||||
|
|||||||
@ -35,6 +35,9 @@ public class U3DActionCommand extends ActionCommand implements IActionCommand{
|
|||||||
@Resource
|
@Resource
|
||||||
protected U3dActionService u3dActionService;
|
protected U3dActionService u3dActionService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AlarmClockActionCommand alarmClockActionCommand;
|
||||||
|
|
||||||
public Mono<Boolean> process(Action action, BaseSession baseSession) {
|
public Mono<Boolean> process(Action action, BaseSession baseSession) {
|
||||||
log.info("U3d Action:{}", action.getAsk());
|
log.info("U3d Action:{}", action.getAsk());
|
||||||
|
|
||||||
@ -60,6 +63,11 @@ public class U3DActionCommand extends ActionCommand implements IActionCommand{
|
|||||||
resp.setText("抱歉,我还么学会跳舞");
|
resp.setText("抱歉,我还么学会跳舞");
|
||||||
return baseWebSocketService.sendMessage(action, baseSession, resp);
|
return baseWebSocketService.sendMessage(action, baseSession, resp);
|
||||||
}else{
|
}else{
|
||||||
|
if(action.getTime() != null){
|
||||||
|
//
|
||||||
|
log.info("定期跳舞");
|
||||||
|
return alarmClockActionCommand.process(action, baseSession);
|
||||||
|
}
|
||||||
return u3dActionService.selectU3dActionById(systemTalkBindU3d.getU3dActionId())
|
return u3dActionService.selectU3dActionById(systemTalkBindU3d.getU3dActionId())
|
||||||
.flatMap(u3d -> {
|
.flatMap(u3d -> {
|
||||||
//获取跳舞配置,并随机一个
|
//获取跳舞配置,并随机一个
|
||||||
@ -86,7 +94,11 @@ public class U3DActionCommand extends ActionCommand implements IActionCommand{
|
|||||||
//return baseWebSocketService.sendMessage(action, baseSession, resp);
|
//return baseWebSocketService.sendMessage(action, baseSession, resp);
|
||||||
}else{
|
}else{
|
||||||
//推送MQ换装
|
//推送MQ换装
|
||||||
|
if(action.getTime() != null){
|
||||||
|
//定时查询天气
|
||||||
|
log.info("定期换装");
|
||||||
|
return alarmClockActionCommand.process(action, baseSession);
|
||||||
|
}
|
||||||
DeviceUserTalkRecordEntity talkRecord = new DeviceUserTalkRecordEntity();
|
DeviceUserTalkRecordEntity talkRecord = new DeviceUserTalkRecordEntity();
|
||||||
talkRecord.setAskType(AskTypeEnum.U3D.getCode());
|
talkRecord.setAskType(AskTypeEnum.U3D.getCode());
|
||||||
talkRecord.setAskValue(action.getAsk());
|
talkRecord.setAskValue(action.getAsk());
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import com.qiuguo.iot.third.nlp.action.Action;
|
|||||||
import com.qiuguo.iot.third.nlp.action.ActionTime;
|
import com.qiuguo.iot.third.nlp.action.ActionTime;
|
||||||
import com.qiuguo.iot.third.service.WeatherService;
|
import com.qiuguo.iot.third.service.WeatherService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
@ -35,6 +36,9 @@ public class WeatherActionCommand extends ActionCommand implements IActionComma
|
|||||||
@Value("${Ali.accesskeySecret}")
|
@Value("${Ali.accesskeySecret}")
|
||||||
private String accessKeySecret;
|
private String accessKeySecret;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
AlarmClockActionCommand alarmClockActionCommand;
|
||||||
|
|
||||||
protected static com.aliyun.alimt20181012.Client transClient = null;
|
protected static com.aliyun.alimt20181012.Client transClient = null;
|
||||||
protected static com.aliyun.teautil.models.RuntimeOptions transRuntime = new com.aliyun.teautil.models.RuntimeOptions();
|
protected static com.aliyun.teautil.models.RuntimeOptions transRuntime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||||
public Mono<Boolean> process(Action action, BaseSession baseSession) {
|
public Mono<Boolean> process(Action action, BaseSession baseSession) {
|
||||||
@ -59,7 +63,11 @@ public class WeatherActionCommand extends ActionCommand implements IActionComma
|
|||||||
return baseWebSocketService.sendMessage(action, baseSession, "该城市不支持天气查询", action.getSystemTalkAnswerConfigEntity().getAnswerType());
|
return baseWebSocketService.sendMessage(action, baseSession, "该城市不支持天气查询", action.getSystemTalkAnswerConfigEntity().getAnswerType());
|
||||||
//return Mono.empty();
|
//return Mono.empty();
|
||||||
}
|
}
|
||||||
|
if(action.getTime() != null){
|
||||||
|
//定时查询天气
|
||||||
|
log.info("定期查询天气");
|
||||||
|
return alarmClockActionCommand.process(action, baseSession);
|
||||||
|
}
|
||||||
TianqiapiItemResp item = null;
|
TianqiapiItemResp item = null;
|
||||||
|
|
||||||
if(StringUtils.isNotEmpty(action.getTime().getDateTime())){
|
if(StringUtils.isNotEmpty(action.getTime().getDateTime())){
|
||||||
|
|||||||
@ -26,6 +26,18 @@ public class ActionResp {
|
|||||||
* 分钟
|
* 分钟
|
||||||
*/
|
*/
|
||||||
Integer minute;
|
Integer minute;
|
||||||
|
/**
|
||||||
|
* 年
|
||||||
|
*/
|
||||||
|
Integer year;
|
||||||
|
/**
|
||||||
|
* 月
|
||||||
|
*/
|
||||||
|
Integer month;
|
||||||
|
/**
|
||||||
|
* 天
|
||||||
|
*/
|
||||||
|
Integer day;
|
||||||
/**
|
/**
|
||||||
* 重复的星期
|
* 重复的星期
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user