增加对全部、一切、所有支持

This commit is contained in:
wulin 2023-10-12 19:17:10 +08:00
parent ecb1f16ac0
commit 083077b6da
20 changed files with 212 additions and 59 deletions

View File

@ -20,7 +20,8 @@ public enum AskTypeEnum {
DEVICE_UNBIND(103, "设备解绑"),
DEVICE_BIND(104, "设备绑定成功"),
COMMAND_N(200, "指令后必须跟的名称词"),
QIU_GUO(300, "秋果专有名词")
QIU_GUO(300, "秋果专有名词"),
IGNORE(400, "^^^"),//全部所有一切等忽略此
;
AskTypeEnum(Integer c, String n){
code = c;

View File

@ -0,0 +1,59 @@
package com.qiuguo.iot.base.enums;
/*
* 与U3D消息类型
* 作者吴林
* */
// 动作类型0文本播放 1音频播放 2 U3D动作 3物联网设备动作
public enum U3dMsgTypeEnum {
TTS(0, "文本播放"),
IOT(1, "IOT控制"),
ALARM_CLOCK(3, "闹钟"),
WEATHER(2, "天气"),
U3D(4, "U3D动作"),
MUSIC(5, "音乐,声音"),
UPDATE(100, "固件升级"),
BOX_ON_LINE(101, "Box配网成功"),
BOX_OFF_LINE(102, "Box离线"),
DEVICE_UNBIND(103, "设备解绑"),
DEVICE_BIND(104, "设备绑定成功"),
COMMAND_N(200, "指令后必须跟的名称词"),
QIU_GUO(300, "秋果专有名词"),
IGNORE(400, "^^^"),//全部所有一切等忽略此
;
U3dMsgTypeEnum(Integer c, String n){
code = c;
name = n;
}
private Integer code;
private String name;
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
public static U3dMsgTypeEnum getEnumWithCode(Integer c){
for (U3dMsgTypeEnum e:values()
) {
if(e.getCode().compareTo(c) == 0){
return e;
}
}
return null;
}
public static U3dMsgTypeEnum getEnumWithName(String name){
for (U3dMsgTypeEnum e:values()
) {
if(e.getName().equals(name)){
return e;
}
}
return null;
}
}

View File

@ -2,6 +2,7 @@ package com.qiuguo.iot.base.utils;
import cn.hutool.core.math.Money;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
@ -9,7 +10,7 @@ import reactor.core.publisher.Mono;
import java.util.Map;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Slf4j
public class WebClientUtils {
private static WebClient webClient = WebClient.builder().defaultHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON_VALUE).build();
@ -19,35 +20,50 @@ public class WebClientUtils {
}
public static Mono<JSONObject> post(String url, JSONObject body) {
return post(url, body, null);
}
public static Mono<JSONObject> get(String url, Map<String, String> headers) {
log.info("GET WebClient URL:{} headers:{}", url, headers);
if(headers == null || headers.size() == 0) {
return webClient.get().uri(url).retrieve().bodyToMono(String.class).flatMap(s-> Mono.just(JSONObject.parseObject(s)));
return webClient.get().uri(url).retrieve().bodyToMono(String.class).flatMap(s-> {
log.info("GET WebClient Respon:{}", s);
return Mono.just(JSONObject.parseObject(s));
});
}else{
return webClient.get().uri(url).headers(httpHeaders -> {
for (String key:headers.keySet()
) {
httpHeaders.set(key, headers.get(key));
}
}).retrieve().bodyToMono(String.class).flatMap(s-> Mono.just(JSONObject.parseObject(s)));
}).retrieve().bodyToMono(String.class).flatMap(s-> {
log.info("GET WebClient Respon:{}", s);
return Mono.just(JSONObject.parseObject(s));
});
}
}
public static Mono<JSONObject> post(String url, JSONObject body, Map<String, String> headers) {
log.info("POST WebClient URL:{} body:{} headers:{}", url, body, headers);
if(headers == null || headers.size() == 0) {
return webClient.post().uri(url).bodyValue(body.toString()).retrieve().bodyToMono(String.class).flatMap(s->
Mono.just(JSONObject.parseObject(s)));
{
log.info("POST WebClient Respon:{}", s);
return Mono.just(JSONObject.parseObject(s));
});
}else{
return webClient.post().uri(url).bodyValue(body.toString()).headers(httpHeaders -> {
for (String key:headers.keySet()
) {
httpHeaders.set(key, headers.get(key));
}
}).retrieve().bodyToMono(String.class).flatMap(s-> Mono.just(JSONObject.parseObject(s)));
}).retrieve().bodyToMono(String.class).flatMap(s-> {
log.info("POST WebClient Respon:{}", s);
return Mono.just(JSONObject.parseObject(s));
});
}
}

View File

@ -9,15 +9,20 @@ public class YunxiRabbitConst {
/**
* 云栖活动交换机
*/
public static final String EXCHANGE_YUNXI_EVENT = "iot-yunxi-exchange";
public static final String EXCHANGE_YUNXI_EVENT = "iot-exchange";
/**
* 云栖活动队列
*/
public static final String QUEUE_YUNXI = "iot.yunxi.queue";
public static final String QUEUE_YUNXI = "IOT.TO.U3D";
/**
* 云栖活动发送的路由键
*/
public static final String ROUTE_KEY_YUNXI = "iot.yunxi";
public static final String ROUTE_KEY_YUNXI = "IOT";
/**
* 订阅队列
*/
public static final String QUEUE_LISTENER = "U3D.TO.IOT";
}

View File

@ -69,7 +69,7 @@ public class SystemTalkAnswerConfigEntity extends GenericEntity<Long> {
@Column(name = "key_order", nullable = false)
private Long keyOrder;
@Comment("回答类型0文本问答 1iOT控制 2天气 3闹钟 4U3D 5音乐声音 100固件升级 101Box上线 200动作后必须跟的名称词")
@Comment("回答类型0文本问答 1iOT控制 2天气 3闹钟 4U3D 5音乐声音 100固件升级 101Box上线 200动作后必须跟的名称词 300秋果专有名词 400全部所有一切忽略词")
@Column(name = "answer_type", nullable = false)
private Integer answerType;
@ -77,8 +77,6 @@ public class SystemTalkAnswerConfigEntity extends GenericEntity<Long> {
@Column(name = "play_type", nullable = false)
private Integer playType;
@Comment("U3D对应的状态ID")
@Column(name = "u3d_status_id", length = 11, nullable = false, unique = true)
private Long u3dStatusId;
}

View File

@ -77,4 +77,7 @@ public class SystemTalkBindDeviceEntity extends GenericEntity<Long> {
@Column(name = "remark", length = 255)
private String remark;
@Comment("U3D对应的状态ID")
@Column(name = "u3d_status_id", length = 11, nullable = false, unique = true)
private Long u3dStatusId;
}

View File

@ -68,6 +68,8 @@ public class UserHandlingDeviceEntity extends GenericEntity<Long> {
@Comment("modify_time")
@Column(name = "modify_time")
private Date modifyTime;
@Comment("U3D对应的状态ID")
@Column(name = "u3d_status_id", length = 11, nullable = false, unique = true)
private Long u3dStatusId;
}

View File

@ -54,7 +54,7 @@ public class SystemTalkAnswerConfigRequest implements java.io.Serializable {
//关键字的排序越小越第一个匹配上
private Long keyOrder;
//回答类型0文本问答 1iOT控制 2天气 3闹钟 4U3D 5音乐声音 100固件升级 101Box上线 200动作后必须跟的名称词
//回答类型0文本问答 1iOT控制 2天气 3闹钟 4U3D 5音乐声音 100固件升级 101Box上线 200动作后必须跟的名称词 300秋果专有名词 400全部所有一切忽略词
private Integer answerType;
/**
@ -63,8 +63,5 @@ public class SystemTalkAnswerConfigRequest implements java.io.Serializable {
private Integer playType;
/**
* U3D对应的状态ID
*/
private Long u3dStatusId;
}

View File

@ -65,4 +65,9 @@ public class SystemTalkBindDeviceRequest implements java.io.Serializable {
private String answerBackImg;
//备注
private String remark;
/**
* U3D对应的状态ID
*/
private Long u3dStatusId;
}

View File

@ -57,6 +57,9 @@ public class UserHandlingDeviceRequest implements java.io.Serializable {
//搜索结束
private Date modifyTimeEnd;
/**
* U3D对应的状态ID
*/
private Long u3dStatusId;
}

View File

@ -32,7 +32,7 @@ public class SystemTalkAnswerConfigResp {
//关键字的排序越小越第一个匹配上
private Long keyOrder;
//回答类型0文本问答 1iOT控制 2天气 3闹钟 4U3D 5音乐声音 100固件升级 101Box上线 200动作后必须跟的名称词
//回答类型0文本问答 1iOT控制 2天气 3闹钟 4U3D 5音乐声音 100固件升级 101Box上线 200动作后必须跟的名称词 300秋果专有名词 400全部所有一切忽略词
private Integer answerType;
/**
@ -40,9 +40,4 @@ public class SystemTalkAnswerConfigResp {
*/
private Integer playType;
/**
* U3D对应的状态ID
*/
private Long u3dStatusId;
}

View File

@ -23,6 +23,7 @@ public class SystemTalkBindDeviceResp {
systemTalkId = entity.getSystemTalkId();
userHandlingId = entity.getUserHandlingId();
remark = entity.getRemark();
u3dStatusId = entity.getU3dStatusId();
}
//
@ -57,4 +58,8 @@ public class SystemTalkBindDeviceResp {
private String answerBackImg;
//备注
private String remark;
/**
* U3D对应的状态ID
*/
private Long u3dStatusId;
}

View File

@ -52,4 +52,8 @@ public class UserHandlingDeviceResp {
private Date createTime;
//
private Date modifyTime;
/**
* U3D对应的状态ID
*/
private Long u3dStatusId;
}

View File

@ -42,6 +42,7 @@ public class MqService {
public Mono<Boolean> sendMessageWithConfirmation(String exchange, String routingKey, Object message) {
rabbitTemplate.convertAndSend(exchange, routingKey, message);
return Mono.defer(() -> {
boolean result = confirmationResult.get();
return Mono.just(result);

View File

@ -128,9 +128,6 @@ public class SystemTalkAnswerConfigService extends GenericReactiveCrudService<Sy
if(request.getPlayType() != null){
reactiveQuery = reactiveQuery.and(SystemTalkAnswerConfigRequest::getPlayType, request.getPlayType());
}
if(request.getU3dStatusId() != null){
reactiveQuery = reactiveQuery.and(SystemTalkAnswerConfigRequest::getU3dStatusId, request.getU3dStatusId());
}
SortOrder sortOrder = null;
if(StringUtils.isNotEmpty(request.getOrder())){
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
@ -199,9 +196,6 @@ public class SystemTalkAnswerConfigService extends GenericReactiveCrudService<Sy
if(request.getPlayType() != null){
reactiveQuery = reactiveQuery.and(SystemTalkAnswerConfigRequest::getPlayType, request.getPlayType());
}
if(request.getU3dStatusId() != null){
reactiveQuery = reactiveQuery.and(SystemTalkAnswerConfigRequest::getU3dStatusId, request.getU3dStatusId());
}
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
if(StringUtils.isNotEmpty(request.getOrder())){
Sort sort = new Sort();
@ -279,9 +273,6 @@ public class SystemTalkAnswerConfigService extends GenericReactiveCrudService<Sy
if(entity.getPlayType() != null){
update = update.set(SystemTalkAnswerConfigEntity::getPlayType, entity.getPlayType());
}
if(entity.getU3dStatusId() != null){
update = update.set(SystemTalkAnswerConfigEntity::getU3dStatusId, entity.getU3dStatusId());
}
return update.where(SystemTalkAnswerConfigEntity::getId, entity.getId()).and("is_delete", 0).execute();
}
@ -302,7 +293,6 @@ public class SystemTalkAnswerConfigService extends GenericReactiveCrudService<Sy
update = update.set(SystemTalkAnswerConfigEntity::getKeyOrder, entity.getKeyOrder());
update = update.set(SystemTalkAnswerConfigEntity::getAnswerType, entity.getAnswerType());
update = update.set(SystemTalkAnswerConfigEntity::getPlayType, entity.getPlayType());
update = update.set(SystemTalkAnswerConfigEntity::getU3dStatusId, entity.getU3dStatusId());
return update.where(SystemTalkAnswerConfigEntity::getId, entity.getId()).and("is_delete", 0).execute();
}

View File

@ -82,6 +82,9 @@ public class SystemTalkBindDeviceService extends GenericReactiveCrudService<Syst
if(StringUtils.isNotEmpty(request.getRemark())){
reactiveQuery = reactiveQuery.and(SystemTalkBindDeviceRequest::getRemark, request.getRemark());
}
if(request.getU3dStatusId() != null){
reactiveQuery = reactiveQuery.and(SystemTalkBindDeviceRequest::getU3dStatusId, request.getU3dStatusId());
}
SortOrder sortOrder = null;
if(StringUtils.isNotEmpty(request.getOrder())){
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
@ -150,6 +153,9 @@ public class SystemTalkBindDeviceService extends GenericReactiveCrudService<Syst
if(StringUtils.isNotEmpty(request.getRemark())){
reactiveQuery = reactiveQuery.$like$(SystemTalkBindDeviceRequest::getRemark, request.getRemark());
}
if(request.getU3dStatusId() != null){
reactiveQuery = reactiveQuery.and(SystemTalkBindDeviceRequest::getU3dStatusId, request.getU3dStatusId());
}
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
if(StringUtils.isNotEmpty(request.getOrder())){
Sort sort = new Sort();
@ -227,6 +233,9 @@ public class SystemTalkBindDeviceService extends GenericReactiveCrudService<Syst
if(StringUtils.isNotEmpty(entity.getRemark())){
update = update.set(SystemTalkBindDeviceEntity::getRemark, entity.getRemark());
}
if(entity.getU3dStatusId() != null){
update = update.set(SystemTalkBindDeviceEntity::getU3dStatusId, entity.getU3dStatusId());
}
return update.where(SystemTalkBindDeviceEntity::getId, entity.getId()).and("is_delete", 0).execute();
}
@ -247,6 +256,7 @@ public class SystemTalkBindDeviceService extends GenericReactiveCrudService<Syst
update = update.set(SystemTalkBindDeviceEntity::getAnswerBackSound, entity.getAnswerBackSound());
update = update.set(SystemTalkBindDeviceEntity::getAnswerBackImg, entity.getAnswerBackImg());
update = update.set(SystemTalkBindDeviceEntity::getRemark, entity.getRemark());
update = update.set(SystemTalkBindDeviceEntity::getU3dStatusId, entity.getU3dStatusId());
return update.where(SystemTalkBindDeviceEntity::getId, entity.getId()).and("is_delete", 0).execute();
}

View File

@ -3,6 +3,7 @@ package com.qiuguo.iot.data.service.user;
import com.qiuguo.iot.base.utils.StringUtils;
import com.qiuguo.iot.data.entity.system.SystemTalkBindDeviceEntity;
import com.qiuguo.iot.data.entity.user.UserHandlingDeviceEntity;
import com.qiuguo.iot.data.request.user.UserHandlingDeviceRequest;
@ -79,6 +80,9 @@ public class UserHandlingDeviceService extends GenericReactiveCrudService<UserHa
if(request.getModifyTime() != null){
reactiveQuery = reactiveQuery.and(UserHandlingDeviceRequest::getModifyTime, request.getModifyTime());
}
if(request.getU3dStatusId() != null){
reactiveQuery = reactiveQuery.lte(UserHandlingDeviceRequest::getU3dStatusId, request.getU3dStatusId());
}
SortOrder sortOrder = null;
if(StringUtils.isNotEmpty(request.getOrder())){
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
@ -141,6 +145,9 @@ public class UserHandlingDeviceService extends GenericReactiveCrudService<UserHa
if(request.getModifyTimeEnd() != null){
reactiveQuery = reactiveQuery.lte(UserHandlingDeviceRequest::getModifyTime, request.getModifyTimeEnd());
}
if(request.getU3dStatusId() != null){
reactiveQuery = reactiveQuery.lte(UserHandlingDeviceRequest::getU3dStatusId, request.getU3dStatusId());
}
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
if(StringUtils.isNotEmpty(request.getOrder())){
Sort sort = new Sort();
@ -219,6 +226,9 @@ public class UserHandlingDeviceService extends GenericReactiveCrudService<UserHa
if(entity.getIsDelete() != null){
update = update.set(UserHandlingDeviceEntity::getIsDelete, entity.getIsDelete());
}
if(entity.getU3dStatusId() != null) {
update = update.set(UserHandlingDeviceEntity::getU3dStatusId, entity.getU3dStatusId());
}
return update.where(UserHandlingDeviceEntity::getId, entity.getId()).and("is_delete", 0).execute();
}
@ -237,6 +247,7 @@ public class UserHandlingDeviceService extends GenericReactiveCrudService<UserHa
update = update.set(UserHandlingDeviceEntity::getCategoryCode, entity.getCategoryCode());
update = update.set(UserHandlingDeviceEntity::getCategoryName, entity.getCategoryName());
update = update.set(UserHandlingDeviceEntity::getIsDelete, entity.getIsDelete());
update = update.set(UserHandlingDeviceEntity::getU3dStatusId, entity.getU3dStatusId());
return update.where(UserHandlingDeviceEntity::getId, entity.getId()).and("is_delete", 0).execute();
}

View File

@ -709,15 +709,7 @@ public enum ChinesePartSpeechEnum implements IChinesePartSpeech{
//动词后面的名词只支持已经产生的action后面的不要
int index = Integer.parseInt(key.replace("#", ""));
SystemTalkAnswerConfigEntity command = commands.get(index);
if(command.getAnswerType().equals(AskTypeEnum.COMMAND_N.getCode())){
action.setActionCommand(commands.get(index).getAskKey());
for (Action ac: actions.getActions()
) {
if(!StringUtils.isNotEmpty(ac.getActionCommand())){
ac.setActionCommand(action.getActionCommand());
}
}
}else{
if(command.getAnswerType().equals(AskTypeEnum.QIU_GUO.getCode())){
//秋果专有名称
systemTalkAnswerConfigEntities.add(command);
action.setSystemTalkAnswerConfigEntity(command);
@ -725,6 +717,24 @@ public enum ChinesePartSpeechEnum implements IChinesePartSpeech{
action.setName(action.getAction());
actions.setA(1);
actions.setB(1);
}else{
Integer ignore = 0;
if(command.getAnswerType().equals(AskTypeEnum.IGNORE.getCode())){
ignore = 1;
}else{
action.setActionCommand(commands.get(index).getAskKey());
}
action.setIgnore(ignore);
for (Action ac: actions.getActions()
) {
if(!StringUtils.isNotEmpty(ac.getActionCommand())){
ac.setActionCommand(action.getActionCommand());
ac.setIgnore(ignore);
}
}
}
return action;

View File

@ -23,6 +23,11 @@ public class Action {
* 动作后跟的名词自定义
*/
private String actionCommand;
/**
* 忽略词所有一切全部
* 0 不忽略1忽略
*/
private Integer ignore = 0;
/**
* 动作对象(名词)可能存在多个如果有关系词连接
*/

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.qiuguo.iot.base.enums.AskTypeEnum;
import com.qiuguo.iot.base.enums.PlayEnum;
import com.qiuguo.iot.base.enums.RespCodeEnum;
import com.qiuguo.iot.base.enums.YesNo;
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;
@ -30,8 +31,11 @@ import com.qiuguo.iot.third.nlp.action.Actions;
import com.qiuguo.iot.third.query.TuyaQuery;
import com.qiuguo.iot.third.resp.SongInfoResponse;
import com.qiuguo.iot.third.service.*;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.hswebframework.web.api.crud.entity.PagerResult;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
@ -80,6 +84,20 @@ public class BaseWebSocketProcess {
protected static String apiType = "api-type";
protected static String apiToken = "api-token";
@RabbitListener(queues = YunxiRabbitConst.QUEUE_LISTENER, containerFactory = "simpleRabbitListenerContainerFactory")
private void processRabbitMq(Channel channel, Message message){
try {
String messageContent = new String(message.getBody(), "UTF-8");
log.info("来自RabbitMQ的消息{}", messageContent);
U3dMsg u3dMsg = JSONObject.parseObject(messageContent, U3dMsg.class);
//处理完毕 手动消息确认 配置需开启 acknowledge-mode: manual
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
}catch(Exception e){
log.info("RabbitMQ 消息处理异常{}", e);
}
}
private void toQianWen(Action action, BaseSession baseSession){
baseSession.setRequestId(baseSession.getRequestId() + 1);
TongYiCommunicationRest tongYiCommunicationRest = new TongYiCommunicationRest();
@ -148,7 +166,7 @@ public class BaseWebSocketProcess {
log.info("匹配时未找到对应的设备,模糊匹配{}", action.getName());
DeviceUserBindRequest deviceUserBindRequest = new DeviceUserBindRequest();
deviceUserBindRequest.setUserId(userId);
deviceUserBindRequest.setPageSize(2);
deviceUserBindRequest.setPageSize(200);
deviceUserBindRequest.setBindName(action.getName());
//查询是否有相关设备
@ -164,22 +182,33 @@ public class BaseWebSocketProcess {
action.getSystemTalkAnswerConfigEntity().getAnswerType());
}else if(binds.getTotal() > 1){
//返回告诉有多个设备请详细说明具体说明设备
//判断action是否有所有全部一切
if(YesNo.YES.getCode().equals(action.getIgnore())){
//忽略词控制所有设备
for (DeviceUserBindEntity bindEntity :binds.getData()
) {
action.setDeviceUserBindEntity(bindEntity);
controllerDevice(action, action.getDeviceUserBindEntity(), baseSession);
}
}else{
sendMessage(action,
baseSession,
"您有多个" + action.getName() + "相同设备,请明确说明",
action.getSystemTalkAnswerConfigEntity().getAnswerType());
}
sendMessage(action,
baseSession,
"您有多个" + action.getName() + "相同设备,请明确说明",
action.getSystemTalkAnswerConfigEntity().getAnswerType());
}else{
//查询是否有相关指令绑定
action.setDeviceUserBindEntity(binds.getData().get(0));
controllerDevice(action, action.getDeviceUserBindEntity(), baseSession, action.getName());
controllerDevice(action, action.getDeviceUserBindEntity(), baseSession);
}
return Mono.empty();
}).subscribe();
}else{
log.info("匹配时已找到对应的设备{}", action.getName());
controllerDevice(action, action.getDeviceUserBindEntity(), baseSession, action.getName());
controllerDevice(action, action.getDeviceUserBindEntity(), baseSession);
}
}else{
@ -203,7 +232,11 @@ public class BaseWebSocketProcess {
action.getTime().setTime("今天");
}
weatherService.tianqiApi(req).map(t ->{
log.info("查询的天气{}", JSONObject.toJSONString(t));
if(t.getData() == null){
sendMessage(action, baseSession, "该城市不支持天气查询", action.getSystemTalkAnswerConfigEntity().getAnswerType());
return t;
}
TianqiapiItemResp item = null;
if(StringUtils.isNotEmpty(action.getTime().getDateTime())){
@ -296,7 +329,7 @@ public class BaseWebSocketProcess {
}
}
private void controllerDevice(Action action, DeviceUserBindEntity deviceUserBindEntity, BaseSession baseSession, String deviceName) {
private void controllerDevice(Action action, DeviceUserBindEntity deviceUserBindEntity, BaseSession baseSession) {
SystemTalkBindDeviceRequest systemTalkBindDeviceRequest = new SystemTalkBindDeviceRequest();
systemTalkBindDeviceRequest.setCategoryCode(deviceUserBindEntity.getCategoryCode());
@ -310,7 +343,7 @@ public class BaseWebSocketProcess {
if(systemTalkBindDeviceEntity.getId() == null){
//通知不支持的指令
sendMessage(action, baseSession,
deviceName + "不支持" + action.getAction() + "指令!",
deviceUserBindEntity.getBindName() + "不支持" + action.getAction() + "指令!",
action.getSystemTalkAnswerConfigEntity().getAnswerType());
}else{
@ -329,9 +362,9 @@ public class BaseWebSocketProcess {
u3dMsg.setMsgType(100);
u3dMsg.setMetaId(action.getDeviceUserBindEntity().getU3dId());
u3dMsg.setScenceId(action.getDeviceUserBindEntity().getScenceId());
u3dMsg.setStatusId(action.getSystemTalkAnswerConfigEntity().getU3dStatusId());
u3dMsg.setStatusId(1l);
//发送消息到MQ通知U3D
mqService.sendMessage(YunxiRabbitConst.EXCHANGE_YUNXI_EVENT,
mqService.sendMessageWithConfirmation(YunxiRabbitConst.EXCHANGE_YUNXI_EVENT,
YunxiRabbitConst.ROUTE_KEY_YUNXI,
JSONObject.toJSONString(u3dMsg)).subscribe();
}catch (Exception e){
@ -341,7 +374,7 @@ public class BaseWebSocketProcess {
}
//通知打开灯成功
msg = systemTalkBindDeviceEntity.getAnswerValue().replaceAll("#name#", deviceName);
msg = systemTalkBindDeviceEntity.getAnswerValue().replaceAll("#name#", deviceUserBindEntity.getBindName());
if(StringUtils.isNotEmpty(action.getStatus())){
msg = msg.replace("#value#", action.getStatus());
}
@ -350,7 +383,7 @@ public class BaseWebSocketProcess {
log.info("执行指令");
}else{
//通知开灯失败;
msg = systemTalkBindDeviceEntity.getAnswerValueFaild().replaceAll("#name#", deviceName);
msg = systemTalkBindDeviceEntity.getAnswerValueFaild().replaceAll("#name#", deviceUserBindEntity.getBindName());
log.info("执行指令失败");
}