Merge branch '20231110_v1.0.1' into test

This commit is contained in:
wulin 2023-11-15 17:42:28 +08:00
commit 47259ad59c
9 changed files with 110 additions and 19 deletions

View File

@ -81,7 +81,7 @@ public class DeviceAlarmClockRecordEntity extends GenericEntity<Long> {
@Column(name = "alarm_type", nullable = false)
private Integer alarmType;
@Comment("服务端配合操作的动作:1IOT控制 2天气 4U3D动作 5音乐")
@Comment("服务端配合操作的动作:0无相关动作(文本播放或者音乐) 1IOT控制 2天气 4U3D动作 5音乐")
@Column(name = "action_type")
private Integer actionType;

View File

@ -111,7 +111,7 @@ public class DeviceAlarmClockRecordRequest implements java.io.Serializable {
*/
private Integer alarmType;
/**
*服务端配合操作的动作1IOT控制 2天气 4U3D动作 5音乐
*服务端配合操作的动作0无相关动作(文本播放或者音乐) 1IOT控制 2天气 4U3D动作 5音乐
*/
private Integer actionType;
/**

View File

@ -94,7 +94,7 @@ public class DeviceAlarmClockRecordResp {
*/
private Integer alarmType;
/**
*服务端配合操作的动作1IOT控制 2天气 4U3D动作 5音乐
*服务端配合操作的动作0无相关动作(文本播放或者音乐) 1IOT控制 2天气 4U3D动作 5音乐
*/
private Integer actionType;
/**

View File

@ -1,5 +1,6 @@
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.AskTypeEnum;
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) {
log.info("闹钟 Action{}", action.getAsk());
if(StringUtils.isEmpty(action.getNoTimeAsk())){
log.info("一个提醒后无有效动作");
return Mono.just(false);
}
ActionTime actionTime = action.getTime();
action.setNoTimeAsk(
action.getNoTimeAsk()
.replace(action.getAction(), "")
.replace("", "")
);
DeviceAlarmClockRecordRequest request;
Integer day = null;
if(actionTime.getDayOfWeek().size() > 0) {
@ -70,6 +72,7 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
);
request.setUserId(baseSession.getUserId());
request.setDeviceId(baseSession.getDeviceId());
request.setRepeat(AlarmRepeatEnum.EVERY_DAY.getCode());
day = repeatDay;
}else {
@ -85,7 +88,6 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
request.setTimes(
date.getTime() / 1000
);
//request.setTime(Date.from(actionTime.getDetailTime().getLocalDateTime().atZone(ZoneId.systemDefault()).toInstant()));
request.setUserId(baseSession.getUserId());
request.setDeviceId(baseSession.getDeviceId());
request.setRepeat(AlarmRepeatEnum.ONE.getCode());
@ -99,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;
return deviceAlarmClockRecordService
.selectDeviceAlarmClockRecordByRequest(request)
@ -111,12 +132,14 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
alarmClock.setUserId(baseSession.getUserId());
alarmClock.setDeviceId(baseSession.getDeviceId());
alarmClock.setRepeatDay(rDay);
alarmClock.setActionType(request.getActionType());
alarmClock.setAlarmType(request.getAlarmType());
if(!AskTypeEnum.TTS.getCode().equals(request.getActionType())){
alarmClock.setAction(action.getNoTimeAsk());
}
alarmClock.setTime(
Date.from(actionTime.getDetailTime().getLocalDateTime().atZone(ZoneId.systemDefault()).toInstant())
);
alarmClock.setAlarmType(YesNo.NO.getCode());
alarmClock.setRepeat(request.getRepeat());
if(!alarmClock.getRepeat().equals(AlarmRepeatEnum.ONE.getCode())){
alarmClock.setTitle("循环闹钟");
@ -154,8 +177,8 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
}else{
//更新闹钟
Boolean isUpdate = false;
if(StringUtils.isEmpty(alarmClock.getReadText()) &&
StringUtils.isEmpty(action.getNoTimeAsk()) &&
if(StringUtils.isNotEmpty(alarmClock.getReadText()) &&
StringUtils.isNotEmpty(action.getNoTimeAsk()) &&
!alarmClock.getReadText().contains(action.getNoTimeAsk())){
alarmClock.setReadText(alarmClock.getReadText() + "" + action.getNoTimeAsk());
log.info("修改提醒文案:{}", alarmClock);
@ -252,13 +275,29 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
SimpleDateFormat df = new SimpleDateFormat("H:m");
String v = df.format(alarm.getTime());
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.setMinute(Integer.parseInt(p[1]));
actionResp.setType(alarm.getRepeat());;
actionResp.setReadText(alarm.getReadText());
actionResp.setType(alarm.getRepeat());
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.setAlarmType(YesNo.NO.getCode());
actionResp.setDayOfWeek(dayOfWeek);
actionResp.setAlarmType(alarm.getAlarmType());
//读取星期
resp.setAction(actionResp);
resp.setType(AskTypeEnum.ALARM_CLOCK.getCode());

View File

@ -33,6 +33,9 @@ public class IotActionCommand extends ActionCommand implements IActionCommand{
@Resource
protected DeviceUserBindService deviceUserBindService;
@Resource
private AlarmClockActionCommand alarmClockActionCommand;
public Mono<Boolean> process(Action action, BaseSession baseSession) {
log.info("IOT物联网 Action{}", action.getAsk());
@ -60,6 +63,7 @@ public class IotActionCommand extends ActionCommand implements IActionCommand{
//判断action是否有所有全部一切
if(YesNo.YES.getCode().equals(action.getIgnore())){
//忽略词控制所有设备
return controllerDevice(action, binds.getData(), 0, baseSession);
}else{
return baseWebSocketService.sendMessage(action,
@ -95,6 +99,11 @@ public class IotActionCommand extends ActionCommand implements IActionCommand{
List<DeviceUserBindEntity> deviceUserBindEntitys,
int i,
BaseSession baseSession){
if(action.getTime() != null){
//定时查询天气
log.info("定期执行物联网操作1");
return alarmClockActionCommand.process(action, baseSession);
}
if(i < deviceUserBindEntitys.size()){
DeviceUserBindEntity deviceUserBindEntity = deviceUserBindEntitys.get(i++);
action.setDeviceUserBindEntity(deviceUserBindEntity);
@ -106,7 +115,11 @@ public class IotActionCommand extends ActionCommand implements IActionCommand{
}
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.setCategoryCode(deviceUserBindEntity.getCategoryCode());
systemTalkBindDeviceRequest.setSystemTalkId(action.getSystemTalkAnswerConfigEntity().getId());

View File

@ -24,6 +24,8 @@ import java.util.ArrayList;
public class MusicActionCommand extends ActionCommand implements IActionCommand{
@Resource
protected MusicService musicService;
@Resource
private AlarmClockActionCommand alarmClockActionCommand;
public Mono<Boolean> process(Action action, BaseSession baseSession) {
log.info("音乐acion{}", action.getAsk());
@ -32,6 +34,11 @@ public class MusicActionCommand extends ActionCommand implements IActionCommand
search = search.replaceAll(action.getPName(), "");
}
BoxMessageResp resp = new BoxMessageResp();
if(action.getTime() != null){
//定时查询天气
log.info("定期打开音乐播放");
return alarmClockActionCommand.process(action, baseSession);
}
if(action.getSystemTalkAnswerConfigEntity().getPlayType().equals(PlayEnum.START.getCode())){
return musicService.searchMusic(search, 1).defaultIfEmpty(new ArrayList<>()).flatMap(resultSongs -> {
//BoxMessageResp resp = new BoxMessageResp();

View File

@ -35,6 +35,9 @@ public class U3DActionCommand extends ActionCommand implements IActionCommand{
@Resource
protected U3dActionService u3dActionService;
@Resource
private AlarmClockActionCommand alarmClockActionCommand;
public Mono<Boolean> process(Action action, BaseSession baseSession) {
log.info("U3d Action{}", action.getAsk());
@ -60,6 +63,11 @@ public class U3DActionCommand extends ActionCommand implements IActionCommand{
resp.setText("抱歉,我还么学会跳舞");
return baseWebSocketService.sendMessage(action, baseSession, resp);
}else{
if(action.getTime() != null){
//
log.info("定期跳舞");
return alarmClockActionCommand.process(action, baseSession);
}
return u3dActionService.selectU3dActionById(systemTalkBindU3d.getU3dActionId())
.flatMap(u3d -> {
//获取跳舞配置并随机一个
@ -86,7 +94,11 @@ public class U3DActionCommand extends ActionCommand implements IActionCommand{
//return baseWebSocketService.sendMessage(action, baseSession, resp);
}else{
//推送MQ换装
if(action.getTime() != null){
//定时查询天气
log.info("定期换装");
return alarmClockActionCommand.process(action, baseSession);
}
DeviceUserTalkRecordEntity talkRecord = new DeviceUserTalkRecordEntity();
talkRecord.setAskType(AskTypeEnum.U3D.getCode());
talkRecord.setAskValue(action.getAsk());

View File

@ -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.service.WeatherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;
@ -35,6 +36,9 @@ public class WeatherActionCommand extends ActionCommand implements IActionComma
@Value("${Ali.accesskeySecret}")
private String accessKeySecret;
@Autowired
AlarmClockActionCommand alarmClockActionCommand;
protected static com.aliyun.alimt20181012.Client transClient = null;
protected static com.aliyun.teautil.models.RuntimeOptions transRuntime = new com.aliyun.teautil.models.RuntimeOptions();
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 Mono.empty();
}
if(action.getTime() != null){
//定时查询天气
log.info("定期查询天气");
return alarmClockActionCommand.process(action, baseSession);
}
TianqiapiItemResp item = null;
if(StringUtils.isNotEmpty(action.getTime().getDateTime())){

View File

@ -26,6 +26,18 @@ public class ActionResp {
* 分钟
*/
Integer minute;
/**
*
*/
Integer year;
/**
*
*/
Integer month;
/**
*
*/
Integer day;
/**
* 重复的星期
*/