From 70f61b0638e32274d0e5f9b972ce2a18f139f1b4 Mon Sep 17 00:00:00 2001 From: zhubaomin <zhubaomin> Date: 星期四, 12 六月 2025 09:51:30 +0800 Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV --- pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/mqtt/MqttMessageListener.java | 64 ++++++++++--------------------- 1 files changed, 21 insertions(+), 43 deletions(-) diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/mqtt/MqttMessageListener.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/mqtt/MqttMessageListener.java index 7d8c6ea..c109e53 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/mqtt/MqttMessageListener.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/mqtt/MqttMessageListener.java @@ -22,51 +22,29 @@ @Override public void messageArrived(String topic, MqttMessage msg) throws Exception { - MqttTopic subTopic = MqttMsgParser.parseSubTopic(topic) ; - MqttSubMsg subMsg = MqttMsgParser.parseSubMsg(subTopic, msg, new MqttCallback(){ - @Override - public void callback(MqttSubMsg subMsg) { - DevStatusDealer.onLine(subMsg.deviceId, subMsg.protocol); - DevStatusDealer.afterReceiveSubMessage(subMsg.deviceId); - RtuLogDealer.log4Mqtt(subMsg.deviceId, "璁㈤槄娑堟伅 涓婚锛�" + subMsg.topic + " 娑堟伅锛�" + subMsg.msg); - } - @Override - public void notify(String devId, MqttNotifyInfo... infos) { - if(notify != null){ - notify.notify(devId, infos) ; + try { + MqttTopic subTopic = MqttMsgParser.parseSubTopic(topic); + MqttSubMsg subMsg = MqttMsgParser.parseSubMsg(subTopic, msg, new MqttCallback() { + @Override + public void callback(MqttSubMsg subMsg) { + DevStatusDealer.onLine(subMsg.deviceId, subMsg.protocol); + DevStatusDealer.afterReceiveSubMessage(subMsg.deviceId); + RtuLogDealer.log4Mqtt(subMsg.deviceId, "璁㈤槄娑堟伅 涓婚锛�" + subMsg.topic.longName() + " 鍏冩暟鎹細" + subMsg.metaData); } - } - }) ; - this.nextDeal(subMsg); - } - private void nextDeal(MqttSubMsg subMsg)throws Exception { - subMsg.action(new Callback() { - @Override - public void call(Object obj) { - MqttSubMsg subMs = (MqttSubMsg) obj ; - MqttPubMsg pubMs = MqttPubMsgCache.matchFromTail(subMs) ; - if(pubMs != null){ - //鍖归厤鍒颁笅琛屾秷鎭紙鍛戒护锛� - subMs.mqttResultSendWebUrl = pubMs.mqttResultSendWebUrl ; - subMs.commandId = pubMs.commandId ; - try { - MqttComResultCache.getInstance().cacheMqttComResult(new MqttComResultNode(subMs)); - } catch (Exception e) { - log.error("缂撳瓨鍙戝竷娑堟伅锛堝懡浠わ級缁撴灉鍙戠敓寮傚父", e); + + @Override + public void notify(String devId, MqttNotifyInfo... infos) { + if (notify != null) { + notify.notify(devId, infos); } } - try{ - MqttSubMsgCache.getInstance().cacheMsg(new MqttSubMsgNode(subMsg)); - }catch (Exception e){ - log.error("缂撳瓨璁㈤槄娑堟伅鏁版嵁鍙戠敓寮傚父", e); - } - } - @Override - public void call(Object... objs) { - } - @Override - public void exception(Exception e) { - } - }); + }); + this.nextDeal(subMsg); + }catch(Exception e){ + log.error("澶勭悊MQTT璁㈤槄娑堟伅鍙戠敓寮傚父", e); + } + } + private void nextDeal(MqttSubMsg subMsg)throws Exception { + subMsg.action(new MqttSubMsgDealer()); } } -- Gitblit v1.8.0