fix:针对前端请求过载问题修改mqtt发送通知消息的message内容。使用json方式
parent
4295b7e9f6
commit
749e565d3d
|
|
@ -33,7 +33,7 @@ public class ProtocalMing implements Iprotocal {
|
|||
|
||||
// 交互的
|
||||
List<IotSensorInfoBO> list = new ArrayList<>();
|
||||
|
||||
int report_flag = 0;
|
||||
// 判断mqtt json 标识,兼容多种格式
|
||||
if(msg.contains("sid")){
|
||||
List<SimpleProtocolMqtt> tmpList = JSON.parseArray(msg, SimpleProtocolMqtt.class);
|
||||
|
|
@ -88,15 +88,16 @@ public class ProtocalMing implements Iprotocal {
|
|||
|
||||
// websocket 发送消息
|
||||
if(ObjectUtil.isNotEmpty(iotNodeInfo)){
|
||||
String message = "{\"report_flag\":\"" + report_flag + "\"" + (report_flag == 1 ? ", \"sensor_id\":\"" + list.get(0).getId() + "\"" : "") + "}";
|
||||
String scene_id = ProCacheUtil.getCache(CacheName.SCENE_IPDATE_FLAG , "scene_" + iotNodeInfo.getScene_id() );
|
||||
if(ObjectUtil.isNotEmpty(scene_id)){
|
||||
// LogUtil4j.debugLogger.debug("will send msg to /scene/update/{}", iotNodeInfo.getScene_id());
|
||||
MqttService.pubMessage( "1", "/scene/update/"+ iotNodeInfo.getScene_id() );
|
||||
MqttService.pubMessage( message, "/scene/update/"+ iotNodeInfo.getScene_id() );
|
||||
}
|
||||
String node_id = ProCacheUtil.getCache(CacheName.SCENE_IPDATE_FLAG , "node_" + iotNodeInfo.getId() );
|
||||
if(ObjectUtil.isNotEmpty(node_id)){
|
||||
// LogUtil4j.debugLogger.debug("will send msg to /node/update/{}", iotNodeInfo.getId());
|
||||
MqttService.pubMessage( "1", "/node/update/"+ iotNodeInfo.getId() );
|
||||
MqttService.pubMessage( message, "/node/update/"+ iotNodeInfo.getId() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class ProtocalXRxasn implements Iprotocal {
|
|||
LogUtil4j.debugLogger.warn("get no nodeInfo with {}", deviceCode);
|
||||
return ;
|
||||
}
|
||||
|
||||
int report_flag = 0;
|
||||
if(ObjectUtil.isNotEmpty(xRxasnProtocolMqtt.getType()) && !topic.endsWith("/rtg")){
|
||||
if(topic.endsWith("cmd/set/cack")){
|
||||
IotLoggingServiceImpl iotLoggingService = (IotLoggingServiceImpl) SpringApplicationContext.getBean("iotLoggingServiceImpl") ;
|
||||
|
|
@ -75,9 +75,11 @@ public class ProtocalXRxasn implements Iprotocal {
|
|||
tmp.setScene_id(nodeInfo.getScene_id());
|
||||
tmp.setSeq(Integer.valueOf(xRxasnProtocolMqtt.getSeq()));
|
||||
if(xRsasnTag.getValid() == 1 && xRsasnTag.getRemark().equals("success")) {
|
||||
report_flag = 1;
|
||||
IotSensorInfoBO tp = new IotSensorInfoBO();
|
||||
tp.setSensor_device_id(sensor_device_id);
|
||||
tp.setSdata(xRsasnTag.getV());
|
||||
tp.setId(sensorInfo.getId());
|
||||
list.add(tp);
|
||||
tmp.setSensor_device_id(sensor_device_id);
|
||||
tmp.setInfos("0");
|
||||
|
|
@ -92,6 +94,7 @@ public class ProtocalXRxasn implements Iprotocal {
|
|||
}
|
||||
else return;
|
||||
} else if (topic.endsWith("/rtg") && ObjectUtil.isEmpty(xRxasnProtocolMqtt.getType())) {
|
||||
report_flag = 0;
|
||||
List<XRsasnDev> xRsasnDevs = JSON.parseArray(xRxasnProtocolMqtt.getDevs().toString(), XRsasnDev.class);
|
||||
xRsasnDevs.forEach(dev -> {
|
||||
dev.getDev();
|
||||
|
|
@ -136,14 +139,16 @@ public class ProtocalXRxasn implements Iprotocal {
|
|||
IotNodeInfoBO iotNodeInfo = ProCacheUtil.getCache(CacheName.NODEINFO_DEVICECODE, deviceCode);
|
||||
// LogUtil4j.debugLogger.debug("sending update to web for {}", ObjectUtil.isNotEmpty(iotNodeInfo) ? iotNodeInfo.getScene_id() : null);
|
||||
// websocket 发送消息
|
||||
|
||||
if(ObjectUtil.isNotEmpty(iotNodeInfo)){
|
||||
String message = "{\"report_flag\":\"" + report_flag + "\"" + (report_flag == 1 ? ", \"sensor_id\":\"" + list.get(0).getId() + "\"" : "") + "}";
|
||||
String scene_id = ProCacheUtil.getCache(CacheName.SCENE_IPDATE_FLAG , "scene_" + iotNodeInfo.getScene_id() );
|
||||
if(ObjectUtil.isNotEmpty(scene_id)){
|
||||
MqttService.pubMessage( "1", "/scene/update/"+ iotNodeInfo.getScene_id() );
|
||||
MqttService.pubMessage( message, "/scene/update/"+ iotNodeInfo.getScene_id() );
|
||||
}
|
||||
String node_id = ProCacheUtil.getCache(CacheName.SCENE_IPDATE_FLAG , "node_" + iotNodeInfo.getId() );
|
||||
if(ObjectUtil.isNotEmpty(node_id)){
|
||||
MqttService.pubMessage( "1", "/node/update/"+ iotNodeInfo.getId() );
|
||||
MqttService.pubMessage( message, "/node/update/"+ iotNodeInfo.getId() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue