增加U3D MQ通知
This commit is contained in:
parent
dc17707b81
commit
604d80147c
@ -92,4 +92,11 @@ public class DeviceUserBindEntity extends GenericEntity<Long> {
|
||||
@Column(name = "category_code", length = 20, nullable = false)
|
||||
private String categoryCode;
|
||||
|
||||
@Comment("U3D对应物品ID")
|
||||
@Column(name = "u3d_id", length = 11)
|
||||
private Long u3dId;
|
||||
@Comment("U3D场景ID")
|
||||
@Column(name = "scence_id", length = 11)
|
||||
private Long scenceId;
|
||||
|
||||
}
|
||||
@ -77,4 +77,8 @@ 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;
|
||||
|
||||
}
|
||||
@ -69,4 +69,5 @@ public class UserHandlingDeviceEntity extends GenericEntity<Long> {
|
||||
@Column(name = "modify_time")
|
||||
private Date modifyTime;
|
||||
|
||||
|
||||
}
|
||||
@ -64,8 +64,20 @@ public class DeviceUserBindRequest implements java.io.Serializable {
|
||||
|
||||
//分类字段名称
|
||||
private String categoryCode;
|
||||
|
||||
/**
|
||||
* U3D对应物品ID
|
||||
*/
|
||||
private Long u3dId;
|
||||
|
||||
/**
|
||||
* U3D场景ID
|
||||
*/
|
||||
private Long scenceId;
|
||||
/**
|
||||
* 是否在线 0 不在线 1 在线
|
||||
*/
|
||||
private Integer onLine;
|
||||
|
||||
|
||||
}
|
||||
@ -62,4 +62,9 @@ public class SystemTalkAnswerConfigRequest implements java.io.Serializable {
|
||||
*/
|
||||
|
||||
private Integer playType;
|
||||
|
||||
/**
|
||||
* U3D对应的状态ID
|
||||
*/
|
||||
private Long u3dStatusId;
|
||||
}
|
||||
@ -1,5 +1,8 @@
|
||||
package com.qiuguo.iot.data.request.user;
|
||||
import lombok.Data;
|
||||
import org.hswebframework.ezorm.rdb.mapping.annotation.Comment;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* <p>
|
||||
@ -54,4 +57,6 @@ public class UserHandlingDeviceRequest implements java.io.Serializable {
|
||||
|
||||
//搜索结束
|
||||
private Date modifyTimeEnd;
|
||||
|
||||
|
||||
}
|
||||
@ -33,6 +33,8 @@ public class DeviceUserBindResp {
|
||||
village = entity.getVillage();
|
||||
address = entity.getAddress();
|
||||
categoryCode = entity.getCategoryCode();
|
||||
u3dId = entity.getU3dId();
|
||||
scenceId = entity.getScenceId();
|
||||
}
|
||||
//
|
||||
private Long id;
|
||||
@ -70,6 +72,14 @@ public class DeviceUserBindResp {
|
||||
private String address;
|
||||
//分类字段名称
|
||||
private String categoryCode;
|
||||
/**
|
||||
* U3D对应物品ID
|
||||
*/
|
||||
private Long u3dId;
|
||||
/**
|
||||
* U3D场景ID
|
||||
*/
|
||||
private Long scenceId;
|
||||
/**
|
||||
* 是否在线0 b不在线 1在线
|
||||
*/
|
||||
|
||||
@ -40,4 +40,9 @@ public class SystemTalkAnswerConfigResp {
|
||||
*/
|
||||
|
||||
private Integer playType;
|
||||
|
||||
/**
|
||||
* U3D对应的状态ID
|
||||
*/
|
||||
private Long u3dStatusId;
|
||||
}
|
||||
@ -32,6 +32,10 @@ public class U3dMsg {
|
||||
*/
|
||||
private Long typeId;
|
||||
|
||||
/**
|
||||
* 扩展参数
|
||||
*/
|
||||
private String extParam;
|
||||
/**
|
||||
* 坐标x
|
||||
*/
|
||||
|
||||
@ -112,6 +112,12 @@ public class DeviceUserBindService extends GenericReactiveCrudService<DeviceUser
|
||||
if(StringUtils.isNotEmpty(request.getCategoryCode())){
|
||||
reactiveQuery = reactiveQuery.and(DeviceUserBindRequest::getCategoryCode, request.getCategoryCode());
|
||||
}
|
||||
if(request.getU3dId() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceUserBindRequest::getU3dId, request.getU3dId());
|
||||
}
|
||||
if(request.getScenceId() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceUserBindRequest::getScenceId, request.getScenceId());
|
||||
}
|
||||
SortOrder sortOrder = null;
|
||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||
if(StringUtils.isNotEmpty(request.getSort()) && request.getSort().compareTo("0") == 0){
|
||||
@ -197,6 +203,12 @@ public class DeviceUserBindService extends GenericReactiveCrudService<DeviceUser
|
||||
if(StringUtils.isNotEmpty(request.getCategoryCode())){
|
||||
reactiveQuery = reactiveQuery.$like$(DeviceUserBindRequest::getCategoryCode, request.getCategoryCode());
|
||||
}
|
||||
if(request.getU3dId() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceUserBindRequest::getU3dId, request.getU3dId());
|
||||
}
|
||||
if(request.getScenceId() != null){
|
||||
reactiveQuery = reactiveQuery.and(DeviceUserBindRequest::getScenceId, request.getScenceId());
|
||||
}
|
||||
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
|
||||
if(StringUtils.isNotEmpty(request.getOrder())){
|
||||
Sort sort = new Sort();
|
||||
@ -286,6 +298,12 @@ public class DeviceUserBindService extends GenericReactiveCrudService<DeviceUser
|
||||
if(StringUtils.isNotEmpty(entity.getCategoryCode())){
|
||||
update = update.set(DeviceUserBindEntity::getCategoryCode, entity.getCategoryCode());
|
||||
}
|
||||
if(entity.getU3dId() != null){
|
||||
update = update.set(DeviceUserBindEntity::getU3dId, entity.getU3dId());
|
||||
}
|
||||
if(entity.getScenceId() != null){
|
||||
update = update.set(DeviceUserBindEntity::getScenceId, entity.getScenceId());
|
||||
}
|
||||
return update.where(DeviceUserBindEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||
}
|
||||
|
||||
@ -310,6 +328,8 @@ public class DeviceUserBindService extends GenericReactiveCrudService<DeviceUser
|
||||
update = update.set(DeviceUserBindEntity::getVillage, entity.getVillage());
|
||||
update = update.set(DeviceUserBindEntity::getAddress, entity.getAddress());
|
||||
update = update.set(DeviceUserBindEntity::getCategoryCode, entity.getCategoryCode());
|
||||
update = update.set(DeviceUserBindEntity::getU3dId, entity.getU3dId());
|
||||
update = update.set(DeviceUserBindEntity::getScenceId, entity.getScenceId());
|
||||
return update.where(DeviceUserBindEntity::getId, entity.getId()).and("is_delete", 0).execute();
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,9 @@ package com.qiuguo.iot.data.service.system;
|
||||
import com.qiuguo.iot.base.enums.AskTypeEnum;
|
||||
import com.qiuguo.iot.base.utils.StringUtils;
|
||||
import com.qiuguo.iot.data.entity.system.SystemTalkAnswerConfigEntity;
|
||||
import com.qiuguo.iot.data.entity.user.UserHandlingDeviceEntity;
|
||||
import com.qiuguo.iot.data.request.system.SystemTalkAnswerConfigRequest;
|
||||
import com.qiuguo.iot.data.request.user.UserHandlingDeviceRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hswebframework.ezorm.core.param.Sort;
|
||||
import org.hswebframework.ezorm.rdb.mapping.ReactiveQuery;
|
||||
@ -126,6 +128,9 @@ 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){
|
||||
@ -194,6 +199,9 @@ 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();
|
||||
@ -271,6 +279,9 @@ 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();
|
||||
}
|
||||
|
||||
@ -291,6 +302,7 @@ 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();
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ public class NlpService {
|
||||
private static Integer MAX_COUT = 2000;
|
||||
|
||||
public Mono<Actions> getActionWithLacSingle(Long userId, String text){
|
||||
if(userId != null) {
|
||||
if(userId == null) {
|
||||
userId = 0L;
|
||||
}
|
||||
DeviceUserBindRequest request = new DeviceUserBindRequest();
|
||||
@ -60,6 +60,7 @@ public class NlpService {
|
||||
if(entity.getAnswerType().equals(KeyTypeEnum.SYSTEM_COMMAND.getCode())) {
|
||||
systemTalkKeyAndDeviceName.setType(KeyTypeEnum.SYSTEM_COMMAND.getCode());
|
||||
}else{
|
||||
//只要内容中含有改词的都直接使用系统配置回答,而不会调用千问
|
||||
systemTalkKeyAndDeviceName.setType(KeyTypeEnum.QIUGUO_NAME.getCode());
|
||||
}
|
||||
systemTalkKeyAndDeviceName.setIndex(i++);
|
||||
|
||||
@ -8,6 +8,7 @@ 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;
|
||||
import com.qiuguo.iot.box.websocket.api.domain.box.resp.BoxMessageResp;
|
||||
import com.qiuguo.iot.data.constants.YunxiRabbitConst;
|
||||
import com.qiuguo.iot.data.entity.device.DeviceUserBindEntity;
|
||||
import com.qiuguo.iot.data.entity.device.DeviceUserTalkRecordEntity;
|
||||
import com.qiuguo.iot.data.entity.system.SystemTalkBindDeviceEntity;
|
||||
@ -17,8 +18,10 @@ import com.qiuguo.iot.data.request.system.SystemTalkBindDeviceRequest;
|
||||
import com.qiuguo.iot.data.request.third.ThirdWeatherInfoRequest;
|
||||
import com.qiuguo.iot.data.resp.third.MusicResp;
|
||||
import com.qiuguo.iot.data.resp.third.weather.TianqiapiItemResp;
|
||||
import com.qiuguo.iot.data.resp.u3d.U3dMsg;
|
||||
import com.qiuguo.iot.data.service.device.DeviceUserBindService;
|
||||
import com.qiuguo.iot.data.service.device.DeviceUserTalkRecordService;
|
||||
import com.qiuguo.iot.data.service.mq.MqService;
|
||||
import com.qiuguo.iot.data.service.system.SystemAddressService;
|
||||
import com.qiuguo.iot.data.service.system.SystemTalkBindDeviceService;
|
||||
import com.qiuguo.iot.third.nlp.action.Action;
|
||||
@ -66,6 +69,9 @@ public class BaseWebSocketProcess {
|
||||
@Autowired
|
||||
protected QWenService qwenService;
|
||||
|
||||
@Autowired
|
||||
protected MqService mqService;
|
||||
|
||||
|
||||
protected static ConcurrentHashMap<Long, BaseSession> userGroup = new ConcurrentHashMap<>();
|
||||
|
||||
@ -316,12 +322,26 @@ public class BaseWebSocketProcess {
|
||||
tuyaDeviceService.controlDevice(query).map(isOk ->{
|
||||
String msg = "";
|
||||
if(isOk.getCode().equals(RespCodeEnum.SUCESS.getCode())){
|
||||
if(action.getDeviceUserBindEntity().getU3dId() != null){
|
||||
log.info("通知U3DMQ");
|
||||
U3dMsg u3dMsg = new U3dMsg();
|
||||
u3dMsg.setMsgType(100);
|
||||
u3dMsg.setMetaId(action.getDeviceUserBindEntity().getU3dId());
|
||||
u3dMsg.setScenceId(action.getDeviceUserBindEntity().getScenceId());
|
||||
u3dMsg.setStatusId(action.getSystemTalkAnswerConfigEntity().getU3dStatusId());
|
||||
//发送消息到MQ,通知U3D
|
||||
mqService.sendMessage(YunxiRabbitConst.EXCHANGE_YUNXI_EVENT,
|
||||
YunxiRabbitConst.ROUTE_KEY_YUNXI,
|
||||
JSONObject.toJSONString(u3dMsg)).subscribe();
|
||||
}
|
||||
|
||||
//通知打开灯成功
|
||||
msg = systemTalkBindDeviceEntity.getAnswerValue().replaceAll("#name#", deviceName);
|
||||
if(StringUtils.isNotEmpty(action.getStatus())){
|
||||
msg = msg.replace("#value#", action.getStatus());
|
||||
}
|
||||
|
||||
|
||||
log.info("执行指令");
|
||||
}else{
|
||||
//通知开灯失败;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user