增加设备调用闹钟功能
This commit is contained in:
parent
c76b3fb768
commit
ee30856dd1
@ -275,6 +275,8 @@ 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(":");
|
||||||
|
actionResp.setHour(Integer.parseInt(p[0]));
|
||||||
|
actionResp.setMinute(Integer.parseInt(p[1]));
|
||||||
if(!alarm.getRepeat().equals(AlarmRepeatEnum.ONE.getCode())){
|
if(!alarm.getRepeat().equals(AlarmRepeatEnum.ONE.getCode())){
|
||||||
df = new SimpleDateFormat("yyyy-MM-dd");
|
df = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
v = df.format(alarm.getTime());
|
v = df.format(alarm.getTime());
|
||||||
@ -284,8 +286,7 @@ public class AlarmClockActionCommand extends ActionCommand implements IActionCom
|
|||||||
actionResp.setDay(Integer.parseInt(p[2]));
|
actionResp.setDay(Integer.parseInt(p[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
actionResp.setHour(Integer.parseInt(p[0]));
|
|
||||||
actionResp.setMinute(Integer.parseInt(p[1]));
|
|
||||||
actionResp.setType(alarm.getRepeat());
|
actionResp.setType(alarm.getRepeat());
|
||||||
if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.ALARM_CLOCK.getCode())){
|
if(action.getSystemTalkAnswerConfigEntity().getAnswerType().equals(AskTypeEnum.ALARM_CLOCK.getCode())){
|
||||||
actionResp.setReadText(alarm.getReadText());
|
actionResp.setReadText(alarm.getReadText());
|
||||||
|
|||||||
@ -6,4 +6,12 @@ import lombok.Data;
|
|||||||
public class BoxTalkMessage {
|
public class BoxTalkMessage {
|
||||||
String sn;
|
String sn;
|
||||||
String message;
|
String message;
|
||||||
|
/**
|
||||||
|
* 消息类型 0 文本类型 1 闹钟
|
||||||
|
*/
|
||||||
|
Integer type;
|
||||||
|
/**
|
||||||
|
* 消息需要处理的id
|
||||||
|
*/
|
||||||
|
Long id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,11 +17,14 @@ import com.qiuguo.iot.box.websocket.api.domain.user.UserTalkMessage;
|
|||||||
import com.qiuguo.iot.box.websocket.api.filter.LogMdcConfiguration;
|
import com.qiuguo.iot.box.websocket.api.filter.LogMdcConfiguration;
|
||||||
import com.qiuguo.iot.box.websocket.api.filter.LogWebFilter;
|
import com.qiuguo.iot.box.websocket.api.filter.LogWebFilter;
|
||||||
import com.qiuguo.iot.box.websocket.api.service.BaseWebSocketService;
|
import com.qiuguo.iot.box.websocket.api.service.BaseWebSocketService;
|
||||||
|
import com.qiuguo.iot.data.entity.device.DeviceAlarmClockRecordEntity;
|
||||||
import com.qiuguo.iot.data.entity.device.DeviceInfoEntity;
|
import com.qiuguo.iot.data.entity.device.DeviceInfoEntity;
|
||||||
import com.qiuguo.iot.data.entity.device.DeviceUserBindEntity;
|
import com.qiuguo.iot.data.entity.device.DeviceUserBindEntity;
|
||||||
import com.qiuguo.iot.data.request.device.DeviceUserBindRequest;
|
import com.qiuguo.iot.data.request.device.DeviceUserBindRequest;
|
||||||
|
import com.qiuguo.iot.data.service.device.DeviceAlarmClockRecordService;
|
||||||
import com.qiuguo.iot.data.service.device.DeviceInfoService;
|
import com.qiuguo.iot.data.service.device.DeviceInfoService;
|
||||||
import com.qiuguo.iot.data.service.device.DeviceUserBindService;
|
import com.qiuguo.iot.data.service.device.DeviceUserBindService;
|
||||||
|
import com.qiuguo.iot.data.service.device.DeviceUserTalkRecordService;
|
||||||
import com.qiuguo.iot.third.nlp.action.Actions;
|
import com.qiuguo.iot.third.nlp.action.Actions;
|
||||||
import com.qiuguo.iot.third.service.NlpService;
|
import com.qiuguo.iot.third.service.NlpService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -67,6 +70,9 @@ public class BoxWebSocketHandler implements WebSocketHandler {
|
|||||||
@Resource
|
@Resource
|
||||||
private SomeProperties lacProperties;
|
private SomeProperties lacProperties;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DeviceAlarmClockRecordService deviceAlarmClockRecordService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<Void> handle(WebSocketSession session) {
|
public Mono<Void> handle(WebSocketSession session) {
|
||||||
@ -151,11 +157,32 @@ public class BoxWebSocketHandler implements WebSocketHandler {
|
|||||||
return baseWebSocketService.closeSendMsg(boxSession, "设备信息不全", AskTypeEnum.TIME.getCode());
|
return baseWebSocketService.closeSendMsg(boxSession, "设备信息不全", AskTypeEnum.TIME.getCode());
|
||||||
}
|
}
|
||||||
log.info("收到SN:{},消息:{}", boxTalkMessage.getSn(), boxTalkMessage.getMessage());
|
log.info("收到SN:{},消息:{}", boxTalkMessage.getSn(), boxTalkMessage.getMessage());
|
||||||
|
if(boxTalkMessage.getType().equals(YesNo.NO.getCode())){
|
||||||
if(StringUtils.isEmpty(boxTalkMessage.getMessage())){
|
if(StringUtils.isEmpty(boxTalkMessage.getMessage())){
|
||||||
log.info("收到空字符串,不处理,请求编号+1");
|
log.info("收到空字符串,不处理,请求编号+1");
|
||||||
boxSession.setRequestId(boxSession.getRequestId() + 1);
|
boxSession.setRequestId(boxSession.getRequestId() + 1);
|
||||||
return Mono.empty();
|
return Mono.empty();
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
return deviceAlarmClockRecordService.selectDeviceAlarmClockRecordById(boxTalkMessage.getId())
|
||||||
|
.defaultIfEmpty(new DeviceAlarmClockRecordEntity())
|
||||||
|
.flatMap(alarm -> {
|
||||||
|
if(alarm.getId() == null){
|
||||||
|
log.info("未找到相关闹钟");
|
||||||
|
return Mono.empty();
|
||||||
|
}else{
|
||||||
|
boxTalkMessage.setMessage(alarm.getAction());
|
||||||
|
return processMessage(boxSession, boxTalkMessage);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
return processMessage(boxSession, boxTalkMessage);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<Void> processMessage(BoxSession boxSession, BoxTalkMessage boxTalkMessage){
|
||||||
return nlpService.getActionWithLacSingle(
|
return nlpService.getActionWithLacSingle(
|
||||||
boxSession.getUserId(),
|
boxSession.getUserId(),
|
||||||
boxTalkMessage.getMessage(),
|
boxTalkMessage.getMessage(),
|
||||||
@ -166,6 +193,8 @@ public class BoxWebSocketHandler implements WebSocketHandler {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Mono<Void> disconnect(BoxSession boxSession){
|
private Mono<Void> disconnect(BoxSession boxSession){
|
||||||
MDC.put(LogMdcConfiguration.PRINT_LOG_ID, boxSession.getLogId());
|
MDC.put(LogMdcConfiguration.PRINT_LOG_ID, boxSession.getLogId());
|
||||||
BoxSession boxSession1 = baseWebSocketService.getBoxSessionWithSn(boxSession.getSn());
|
BoxSession boxSession1 = baseWebSocketService.getBoxSessionWithSn(boxSession.getSn());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user