Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
	
		
		2 文件已重命名
	
		
		21个文件已修改
	
		
		18个文件已添加
	
	
 
	
	
	
	
	
	
	
	
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void main(String[] args) throws Exception { | 
|---|
|  |  |  | String hex = "69426981371425010201130084020AF00200000000620902003004050077289364503912943449101006255833070000000000000000000000000000000000014000009000C616"; | 
|---|
|  |  |  | byte[] bs = ByteUtil.hex2Bytes(hex) ; | 
|---|
|  |  |  | Cd_84_Up p = new Cd_84_Up() ; | 
|---|
|  |  |  | Data d = new Data() ; | 
|---|
|  |  |  | DataV202404 subd = new DataV202404() ; | 
|---|
|  |  |  | d.subData = subd ; | 
|---|
|  |  |  | p.doParse(bs, bs.length, "84", d); | 
|---|
|  |  |  | System.out.println(d.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | GlParse.parseCd85(bs, cdData) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void main(String[] args) throws Exception { | 
|---|
|  |  |  | String hex = "695569813714250102011300850200090000000062090200300405007728936450391294344910100625485510100625683907000000000000000000001000000000000000000000100600000000000000000140000090004916"; | 
|---|
|  |  |  | byte[] bs = ByteUtil.hex2Bytes(hex) ; | 
|---|
|  |  |  | Cd_85_Up p = new Cd_85_Up() ; | 
|---|
|  |  |  | Data d = new Data() ; | 
|---|
|  |  |  | DataV202404 subd = new DataV202404() ; | 
|---|
|  |  |  | d.subData = subd ; | 
|---|
|  |  |  | p.doParse(bs, bs.length, "85", d); | 
|---|
|  |  |  | System.out.println(d.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 15:39 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface MqttCallback { | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @param subMsg è®¢é
çæ¶æ¯ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | void callback(MqttSubMsg subMsg) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * åªæå议解æå¨æç¥éRTUçå®çç¶æï¼æè®¤æä¾æ¤æ¥å£ï¼åå¤éç¥è®¾å¤çä¸äºç¶æ | 
|---|
|  |  |  | * @param infos | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | void notify(String devId, MqttNotifyInfo...infos) ; | 
|---|
|  |  |  | } | 
|---|
| File was renamed from pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/Com4Mqtt.java | 
|  |  |  | 
|---|
|  |  |  | * @Description å½ä»¤å¼å¯¹è±¡ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class Com4Mqtt { | 
|---|
|  |  |  | public class MqttCom { | 
|---|
|  |  |  | public String commandId ;//å½ä»¤ID | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String deviceId ;//设å¤ID | 
|---|
|  |  |  | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public class MqttMsgParser { | 
|---|
|  |  |  | public MqttSubMsg parseSubMsg(String topic, MqttMessage mqttMsg) throws Exception { | 
|---|
|  |  |  | public static MqttTopic parseSubTopic(String topic) throws Exception { | 
|---|
|  |  |  | if(topic != null && topic.trim().length() != 0){ | 
|---|
|  |  |  | String[] topicGrp = topic.split("/") ; | 
|---|
|  |  |  | if(topicGrp.length != 4){ | 
|---|
|  |  |  | throw new Exception("æ¥æ¶çmqttæ¶æ¯ä¸»é¢ä¸å¯è¯å«") ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(topicGrp[1].equals("sd1")){ | 
|---|
|  |  |  | MqttTopic vo = new MqttTopic() ; | 
|---|
|  |  |  | vo.orgTag = topicGrp[0] ; | 
|---|
|  |  |  | vo.protocol = topicGrp[1] ; | 
|---|
|  |  |  | vo.devId = topicGrp[2] ; | 
|---|
|  |  |  | vo.topic = topicGrp[3] ; | 
|---|
|  |  |  | return vo ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | throw new Exception("æ¥æ¶çmqttæ¶æ¯ä¸»é¢ä¸åæ³") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static String createPubTopic(MqttTopic tp) throws Exception { | 
|---|
|  |  |  | return tp.orgTag + "/" + tp.protocol + "/" + tp.devId + "/" + tp.topic ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static MqttSubMsg parseSubMsg(MqttTopic subTopic, MqttMessage mqttMsg, MqttCallback callback) throws Exception { | 
|---|
|  |  |  | if(subTopic.protocol.equals(ProtocolConstantSdV1.protocolName + ProtocolConstantSdV1.protocolVer)){ | 
|---|
|  |  |  | //å±±ä¸è®¾å¤(åè®®)ï¼ä¸çæ¬å·ä¸º1 | 
|---|
|  |  |  | return new ProtocolParserSdV1().parseSubMsg(topicGrp[2], topic, mqttMsg); | 
|---|
|  |  |  | return new ProtocolParserSdV1().parseSubMsg(subTopic, mqttMsg, callback); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | throw new Exception("æ¥æ¶çmqttæ¶æ¯ä¸»é¢ä¸åè®®ï¼åå®¶åçæ¬ï¼ä¸å¯è¯å«") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | throw new Exception("æ¥æ¶çmqttæ¶æ¯ä¸»é¢ä¸ºç©º") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public MqttPubMsg createPubMsg(String orgTag, Command com) throws Exception { | 
|---|
|  |  |  | public static MqttPubMsg createPubMsg(String orgTag, Command com) throws Exception { | 
|---|
|  |  |  | if(com.protocol == null && com.protocol.trim().length() != 0){ | 
|---|
|  |  |  | throw new Exception("æ¥æ¶å°MQTTå½ä»¤ï¼ä½æªæä¾åè®®") ; | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 15:56 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface MqttNotify { | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * MQTT DEV ä¿¡æ¯éç¥ | 
|---|
|  |  |  | * @param devId | 
|---|
|  |  |  | * @param info | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | void notify(String devId, | 
|---|
|  |  |  | MqttNotifyInfo...info) ; | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 15:42 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface MqttNotifyInfo { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public abstract class MqttSubMsg { | 
|---|
|  |  |  | public String commandId ;//å½ä»¤ID | 
|---|
|  |  |  | public String mqttResultSendWebUrl ;//Mttè¿åå½ä»¤ç»æ ååç®çå°web URL | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String deviceId ;//设å¤ID | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String mqttResultSendWebUrl ;//Mttè¿åå½ä»¤ç»æ ååç®çå°web URL | 
|---|
|  |  |  | public String protocol;//åè®® | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String topic ;//æ¶æ¯ä¸»é¢ | 
|---|
|  |  |  | public String msg ;//æ¶æ¯ | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.AllArgsConstructor; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.NoArgsConstructor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 9:47 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | @NoArgsConstructor | 
|---|
|  |  |  | @AllArgsConstructor | 
|---|
|  |  |  | public class MqttTopic { | 
|---|
|  |  |  | public String orgTag ;//ç»ç»æ è¯ | 
|---|
|  |  |  | public String protocol ;//åè®®åç§° | 
|---|
|  |  |  | public String devId ;//设å¤ï¼FBoxï¼ID | 
|---|
|  |  |  | public String topic ;//æ¶æ¯ä¸»é¢ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 14:11 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface Vo4Down { | 
|---|
|  |  |  | String toString() ; | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 10:06 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public interface Vo4Up { | 
|---|
|  |  |  | String toString() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @EqualsAndHashCode(callSuper=false) | 
|---|
|  |  |  | public class MqttPubMsgSdV1 extends MqttPubMsg { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer address ;//å¯åå¨å°å | 
|---|
|  |  |  | public String value ;//å¯åå¨å¼ | 
|---|
|  |  |  | public String cd ;//åè½ç  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public boolean valid() { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttPubMsg; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttSubMsg; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttTopic; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.StateVo; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.Vo4Up; | 
|---|
|  |  |  | import com.dy.common.util.Callback; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.EqualsAndHashCode; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | @EqualsAndHashCode(callSuper=false) | 
|---|
|  |  |  | public class MqttSubMsgSdV1 extends MqttSubMsg { | 
|---|
|  |  |  | public Integer address ;//å¯åå¨å°å | 
|---|
|  |  |  | public String value ;//å¯åå¨å¼ | 
|---|
|  |  |  | public Vo4Up vo4Up;//订é
çæ¶æ¯æ°æ®å¼å¯¹è±¡ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public MqttSubMsgSdV1(){} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public MqttSubMsgSdV1(String deviceId, String topic, String msg) { | 
|---|
|  |  |  | this.deviceId = deviceId ; | 
|---|
|  |  |  | this.topic = topic ; | 
|---|
|  |  |  | public MqttSubMsgSdV1(MqttTopic subTopic, String msg) { | 
|---|
|  |  |  | this.deviceId = subTopic.devId ; | 
|---|
|  |  |  | this.protocol = subTopic.protocol ; | 
|---|
|  |  |  | this.topic = subTopic.topic ; | 
|---|
|  |  |  | this.msg = msg ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public String toString(){ | 
|---|
|  |  |  | 
|---|
|  |  |  | sb.append("æ¶æ¯:") | 
|---|
|  |  |  | .append(msg) | 
|---|
|  |  |  | .append("\n") ; | 
|---|
|  |  |  | if(vo4Up != null){ | 
|---|
|  |  |  | sb.append("æ°æ®:") | 
|---|
|  |  |  | .append(vo4Up.toString()) | 
|---|
|  |  |  | .append("\n") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return sb.toString() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | public boolean subMsgMatchPubMsg(MqttPubMsg pubMsg){ | 
|---|
|  |  |  | if (pubMsg instanceof MqttPubMsgSdV1) { | 
|---|
|  |  |  | MqttPubMsgSdV1 pubMsgSdV1 = (MqttPubMsgSdV1) pubMsg; | 
|---|
|  |  |  | if(this.address.intValue() == pubMsgSdV1.getAddress().intValue()){ | 
|---|
|  |  |  | if(this.vo4Up != null && this.vo4Up instanceof StateVo){ | 
|---|
|  |  |  | return true ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | public class ProtocolConstantSdV1 { | 
|---|
|  |  |  | public static final String protocolName = "sd" ; | 
|---|
|  |  |  | public static final short protocolVer = 1 ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //订é
çä¸»é¢ | 
|---|
|  |  |  | public static final String SubTopicWeather = "weather" ;//æ°è±¡ | 
|---|
|  |  |  | public static final String SubTopicSoil = "soil" ;//å壤墿 | 
|---|
|  |  |  | public static final String SubTopicManure = "manure" ;//æ°´è¥ | 
|---|
|  |  |  | public static final String SubTopicState = "state" ;//ç¶æ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //åå¸çä¸»é¢ | 
|---|
|  |  |  | public static final String PubTopicFault = "ctrlFault" ;//æ
éè§£é¤ | 
|---|
|  |  |  | public static final String PubTopicStir = "ctrlStir" ;//æ
æå¯å | 
|---|
|  |  |  | public static final String PubTopicInject = "ctrlInject" ;//注è¥å¯å | 
|---|
|  |  |  | public static final String PubTopicIrr = "ctrlIrr" ;//çæºå¯å | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSONObject; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.Command; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.pSdV1.downVos.ComCtrlVo; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttCallback; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttMsgParser; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttTopic; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.Vo4Up; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.pSdV1.comParam.ComCtrlVo; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.pSdV1.downVos.FaultClearVo; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.pSdV1.downVos.InjectStartVo; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.pSdV1.downVos.StirStartVo; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.*; | 
|---|
|  |  |  | import org.eclipse.paho.client.mqttv3.MqttMessage; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public class ProtocolParserSdV1 { | 
|---|
|  |  |  | public MqttSubMsgSdV1 parseSubMsg(String deviceId, String topic, MqttMessage mqttMsg) throws Exception { | 
|---|
|  |  |  | MqttSubMsgSdV1 ms = new MqttSubMsgSdV1(deviceId, topic, new String(mqttMsg.getPayload(), "UTF-8")); | 
|---|
|  |  |  | public MqttSubMsgSdV1 parseSubMsg(MqttTopic subTopic, MqttMessage mqttMsg, MqttCallback callback) throws Exception { | 
|---|
|  |  |  | String msg = new String(mqttMsg.getPayload(), "UTF-8"); | 
|---|
|  |  |  | if(JSON.isValid(msg)){ | 
|---|
|  |  |  | throw new Exception("æ¥æ¶å°MQTTæ¶æ¯ï¼åè®®" + subTopic.protocol + "ï¼è®¾å¤ID" + subTopic.devId + "ï¼ä¸»é¢" + subTopic.topic + "æ¶æ¯æ ¼å¼éjsonæ°æ®(" + msg + ")") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MqttSubMsgSdV1 ms = new MqttSubMsgSdV1(subTopic, msg); | 
|---|
|  |  |  | Vo4Up vo ; | 
|---|
|  |  |  | switch (subTopic.topic) { | 
|---|
|  |  |  | case ProtocolConstantSdV1.SubTopicWeather -> { | 
|---|
|  |  |  | vo = JSON.parseObject(msg, WeatherVo.class); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case ProtocolConstantSdV1.SubTopicSoil -> { | 
|---|
|  |  |  | vo = JSON.parseObject(msg, SoilVo.class); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case ProtocolConstantSdV1.SubTopicManure -> { | 
|---|
|  |  |  | vo = JSON.parseObject(msg, ManureVo.class); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case ProtocolConstantSdV1.SubTopicState -> { | 
|---|
|  |  |  | //æ¤å¤æªå®æï¼åºè¯¥äº§çä¸äºéä¿¡çinfoï¼ä¾ä¸é¢callback.notify(objs)éç¥åºå» | 
|---|
|  |  |  | vo = JSON.parseObject(msg, StateVo.class); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | default -> { | 
|---|
|  |  |  | throw new Exception("æ¥æ¶å°MQTTæ¶æ¯ï¼åè®®" + subTopic.protocol + "ï¼è®¾å¤ID" + subTopic.devId + "ï¼ä¸»é¢" + subTopic.topic + "æ¶æ¯è§£æé»è¾æªå®ç°"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ms.vo4Up = vo ; | 
|---|
|  |  |  | callback.callback(ms); | 
|---|
|  |  |  | callback.notify(null);//æ¤å¤æªå®æ | 
|---|
|  |  |  | return ms; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public MqttPubMsgSdV1 createPubMsg(String orgTag, Command com) throws Exception { | 
|---|
|  |  |  | MqttPubMsgSdV1 msg = null ; | 
|---|
|  |  |  | MqttPubMsgSdV1 msg ; | 
|---|
|  |  |  | switch (com.code){ | 
|---|
|  |  |  | case CodeSdV1.cd_Fault:{ | 
|---|
|  |  |  | case CodeSdV1.cd_Fault -> { | 
|---|
|  |  |  | //æ
éè§£é¤å½ä»¤ | 
|---|
|  |  |  | this.checkParam(com); | 
|---|
|  |  |  | this.checkRtnWebUrl(com); | 
|---|
|  |  |  | msg = this.createPubMsgOfFault(orgTag, com) ; | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeSdV1.cd_Stir:{ | 
|---|
|  |  |  | case CodeSdV1.cd_Stir -> { | 
|---|
|  |  |  | //æ
æå¯åå½ä»¤ | 
|---|
|  |  |  | this.checkParam(com); | 
|---|
|  |  |  | this.checkRtnWebUrl(com); | 
|---|
|  |  |  | msg = this.createPubMsgOfStir(orgTag, com) ; | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeSdV1.cd_Inject:{ | 
|---|
|  |  |  | case CodeSdV1.cd_Inject -> { | 
|---|
|  |  |  | //注è¥å¯åå½ä»¤ | 
|---|
|  |  |  | this.checkParam(com); | 
|---|
|  |  |  | this.checkRtnWebUrl(com); | 
|---|
|  |  |  | msg = this.createPubMsgOfInject(orgTag, com) ; | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeSdV1.cd_Irr:{ | 
|---|
|  |  |  | case CodeSdV1.cd_Irr -> { | 
|---|
|  |  |  | //çæºå¯åå½ä»¤ | 
|---|
|  |  |  | this.checkParam(com); | 
|---|
|  |  |  | this.checkRtnWebUrl(com); | 
|---|
|  |  |  | msg = this.createPubMsgOfIrr(orgTag, com) ; | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | default:{ | 
|---|
|  |  |  | default -> { | 
|---|
|  |  |  | throw new Exception("æ¥æ¶å°MQTTå½ä»¤ï¼åè®®" + com.protocol + "çæ¬" + com.protocolVersion + "åè½ç " + com.code + "æé å¨æªå®ç°") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | this.setPubMsgBase(com, msg); | 
|---|
|  |  |  | msg.isCacheForOffLine = false ; | 
|---|
|  |  |  | msg.hasResponse = true ; | 
|---|
|  |  |  | msg.address = 123 ; | 
|---|
|  |  |  | msg.value = "" + (cvo.isDo?1:0); | 
|---|
|  |  |  | msg.topic = createTopic(orgTag, com) ; | 
|---|
|  |  |  | msg.msg = "" ; | 
|---|
|  |  |  | msg.cd = CodeSdV1.cd_Fault ; | 
|---|
|  |  |  | msg.topic = MqttMsgParser.createPubTopic(new MqttTopic(orgTag, com.protocol, com.rtuAddr, ProtocolConstantSdV1.PubTopicFault)) ; | 
|---|
|  |  |  | msg.msg = JSON.toJSONString(new FaultClearVo(cvo.isDo)) ; | 
|---|
|  |  |  | return msg ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private MqttPubMsgSdV1 createPubMsgOfStir(String orgTag, Command com) throws Exception { | 
|---|
|  |  |  | 
|---|
|  |  |  | this.setPubMsgBase(com, msg); | 
|---|
|  |  |  | msg.isCacheForOffLine = false ; | 
|---|
|  |  |  | msg.hasResponse = true ; | 
|---|
|  |  |  | msg.address = 123 ; | 
|---|
|  |  |  | msg.value = "" + (cvo.isDo?1:0); | 
|---|
|  |  |  | msg.topic = createTopic(orgTag, com) ; | 
|---|
|  |  |  | msg.msg = "" ; | 
|---|
|  |  |  | msg.cd = CodeSdV1.cd_Fault ; | 
|---|
|  |  |  | msg.topic = MqttMsgParser.createPubTopic(new MqttTopic(orgTag, com.protocol, com.rtuAddr, ProtocolConstantSdV1.PubTopicFault)) ; | 
|---|
|  |  |  | msg.msg = JSON.toJSONString(new StirStartVo(cvo.isDo)) ; | 
|---|
|  |  |  | return msg ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private MqttPubMsgSdV1 createPubMsgOfInject(String orgTag, Command com) throws Exception { | 
|---|
|  |  |  | 
|---|
|  |  |  | this.setPubMsgBase(com, msg); | 
|---|
|  |  |  | msg.isCacheForOffLine = false ; | 
|---|
|  |  |  | msg.hasResponse = true ; | 
|---|
|  |  |  | msg.address = 123 ; | 
|---|
|  |  |  | msg.value = "" + (cvo.isDo?1:0); | 
|---|
|  |  |  | msg.topic = createTopic(orgTag, com) ; | 
|---|
|  |  |  | msg.msg = "" ; | 
|---|
|  |  |  | msg.cd = CodeSdV1.cd_Fault ; | 
|---|
|  |  |  | msg.topic = MqttMsgParser.createPubTopic(new MqttTopic(orgTag, com.protocol, com.rtuAddr, ProtocolConstantSdV1.PubTopicFault)) ; | 
|---|
|  |  |  | msg.msg = JSON.toJSONString(new InjectStartVo(cvo.isDo)) ; | 
|---|
|  |  |  | return msg ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private MqttPubMsgSdV1 createPubMsgOfIrr(String orgTag, Command com) throws Exception { | 
|---|
|  |  |  | 
|---|
|  |  |  | this.setPubMsgBase(com, msg); | 
|---|
|  |  |  | msg.isCacheForOffLine = false ; | 
|---|
|  |  |  | msg.hasResponse = true ; | 
|---|
|  |  |  | msg.address = 123 ; | 
|---|
|  |  |  | msg.value = "" + (cvo.isDo?1:0); | 
|---|
|  |  |  | msg.topic = createTopic(orgTag, com) ; | 
|---|
|  |  |  | msg.msg = "" ; | 
|---|
|  |  |  | msg.cd = CodeSdV1.cd_Fault ; | 
|---|
|  |  |  | msg.topic = MqttMsgParser.createPubTopic(new MqttTopic(orgTag, com.protocol, com.rtuAddr, ProtocolConstantSdV1.PubTopicFault)) ; | 
|---|
|  |  |  | msg.msg = JSON.toJSONString(new StirStartVo(cvo.isDo)) ; | 
|---|
|  |  |  | return msg ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | msg.mqttResultSendWebUrl = com.rtuResultSendWebUrl ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String createTopic(String orgTag, Command com){ | 
|---|
|  |  |  | String topic = null ; | 
|---|
|  |  |  | switch (com.code){ | 
|---|
|  |  |  | case CodeSdV1.cd_Fault:{ | 
|---|
|  |  |  | topic = orgTag + "/" + com.protocol + com.protocolVersion + "/" + com.rtuAddr + "/control/m4" ; | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeSdV1.cd_Stir:{ | 
|---|
|  |  |  | topic = orgTag + "/" + com.protocol + com.protocolVersion + "/" + com.rtuAddr + "/control/m80" ; | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeSdV1.cd_Inject:{ | 
|---|
|  |  |  | topic = orgTag + "/" + com.protocol + com.protocolVersion + "/" + com.rtuAddr + "/control/m1" ; | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeSdV1.cd_Irr:{ | 
|---|
|  |  |  | topic = orgTag + "/" + com.protocol + com.protocolVersion + "/" + com.rtuAddr + "/control/m2" ; | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | default:{ | 
|---|
|  |  |  | topic = null ; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return topic ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| File was renamed from pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/downVos/ComCtrlVo.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.pSdV1.downVos; | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.pSdV1.comParam; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.pSdV1.downVos; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.annotation.JSONField; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.Vo4Down; | 
|---|
|  |  |  | import lombok.AllArgsConstructor; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.NoArgsConstructor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 14:07 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | @NoArgsConstructor | 
|---|
|  |  |  | @AllArgsConstructor | 
|---|
|  |  |  | public class FaultClearVo implements Vo4Down { | 
|---|
|  |  |  | @JSONField(name = "æ
éè§£é¤") | 
|---|
|  |  |  | public boolean isDo ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String toString(){ | 
|---|
|  |  |  | return "æ
éè§£é¤ï¼" + (isDo?"æ¯":"å¦") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.pSdV1.downVos; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.annotation.JSONField; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.Vo4Down; | 
|---|
|  |  |  | import lombok.AllArgsConstructor; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.NoArgsConstructor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 14:13 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | @NoArgsConstructor | 
|---|
|  |  |  | @AllArgsConstructor | 
|---|
|  |  |  | public class InjectStartVo implements Vo4Down { | 
|---|
|  |  |  | @JSONField(name = "注è¥å¯å") | 
|---|
|  |  |  | public boolean isDo ;//true为å¯ï¼false为å | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String toString(){ | 
|---|
|  |  |  | return "注è¥å¯åï¼" + (isDo?"å¯":"å") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.pSdV1.downVos; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.annotation.JSONField; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.Vo4Down; | 
|---|
|  |  |  | import lombok.AllArgsConstructor; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.NoArgsConstructor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 14:13 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | @NoArgsConstructor | 
|---|
|  |  |  | @AllArgsConstructor | 
|---|
|  |  |  | public class IrrStartVo implements Vo4Down { | 
|---|
|  |  |  | @JSONField(name = "çæºå¯å") | 
|---|
|  |  |  | public boolean isDo ;//true为å¯ï¼false为å | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String toString(){ | 
|---|
|  |  |  | return "çæºå¯åï¼" + (isDo?"å¯":"å") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.pSdV1.downVos; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.annotation.JSONField; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.Vo4Down; | 
|---|
|  |  |  | import lombok.AllArgsConstructor; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.NoArgsConstructor; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 14:13 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | @NoArgsConstructor | 
|---|
|  |  |  | @AllArgsConstructor | 
|---|
|  |  |  | public class StirStartVo implements Vo4Down { | 
|---|
|  |  |  | @JSONField(name = "æ
æå¯å") | 
|---|
|  |  |  | public boolean isDo ;//true为å¯ï¼false为å | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String toString(){ | 
|---|
|  |  |  | return "æ
æå¯åï¼" + (isDo?"å¯":"å") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.pSdV1.upVos; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.annotation.JSONField; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.Vo4Up; | 
|---|
|  |  |  | import com.dy.common.util.DateTime; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 10:05 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class ManureVo implements Vo4Up { | 
|---|
|  |  |  | @JSONField(name = "flexem_timestamp") | 
|---|
|  |  |  | public Long devDt ;//è®¾å¤æ¶é´ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String devDtStr ;//è®¾å¤æ¶é´ | 
|---|
|  |  |  | public String getDevDtStr() { | 
|---|
|  |  |  | if(devDt == null){ | 
|---|
|  |  |  | return DateTime.yyyy_MM_dd_HH_mm_ss(DateTime.getDate(devDt)) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return "" ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String toString(){ | 
|---|
|  |  |  | StringBuilder sb = new StringBuilder(); | 
|---|
|  |  |  | sb.append("æ°´è¥æ°æ®ï¼") ; | 
|---|
|  |  |  | sb.append(" è®¾å¤æ¶é´ï¼"+devDt) ; | 
|---|
|  |  |  | sb.append(" è®¾å¤æ¶é´ï¼"+ this.getDevDtStr()) ; | 
|---|
|  |  |  | sb.append("\n") ; | 
|---|
|  |  |  | return sb.toString() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.pSdV1.upVos; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.annotation.JSONField; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.Vo4Up; | 
|---|
|  |  |  | import com.dy.common.util.DateTime; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 10:05 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class SoilVo implements Vo4Up { | 
|---|
|  |  |  | @JSONField(name = "flexem_timestamp") | 
|---|
|  |  |  | public Long devDt ;//è®¾å¤æ¶é´ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String devDtStr ;//è®¾å¤æ¶é´ | 
|---|
|  |  |  | public String getDevDtStr() { | 
|---|
|  |  |  | if(devDt == null){ | 
|---|
|  |  |  | return DateTime.yyyy_MM_dd_HH_mm_ss(DateTime.getDate(devDt)) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return "" ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String toString(){ | 
|---|
|  |  |  | StringBuilder sb = new StringBuilder(); | 
|---|
|  |  |  | sb.append("墿
æ°æ®ï¼") ; | 
|---|
|  |  |  | sb.append(" è®¾å¤æ¶é´ï¼"+devDt) ; | 
|---|
|  |  |  | sb.append(" è®¾å¤æ¶é´ï¼"+ this.getDevDtStr()) ; | 
|---|
|  |  |  | sb.append("\n") ; | 
|---|
|  |  |  | return sb.toString() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.pSdV1.upVos; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.annotation.JSONField; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.Vo4Up; | 
|---|
|  |  |  | import com.dy.common.util.DateTime; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 10:05 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class StateVo implements Vo4Up { | 
|---|
|  |  |  | @JSONField(name = "flexem_timestamp") | 
|---|
|  |  |  | public Long devDt ;//è®¾å¤æ¶é´ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String devDtStr ;//è®¾å¤æ¶é´ | 
|---|
|  |  |  | public String getDevDtStr() { | 
|---|
|  |  |  | if(devDt == null){ | 
|---|
|  |  |  | return DateTime.yyyy_MM_dd_HH_mm_ss(DateTime.getDate(devDt)) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return "" ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String toString(){ | 
|---|
|  |  |  | StringBuilder sb = new StringBuilder(); | 
|---|
|  |  |  | sb.append("ç¶ææ°æ®ï¼") ; | 
|---|
|  |  |  | sb.append(" è®¾å¤æ¶é´ï¼"+devDt) ; | 
|---|
|  |  |  | sb.append(" è®¾å¤æ¶é´ï¼"+ this.getDevDtStr()) ; | 
|---|
|  |  |  | sb.append("\n") ; | 
|---|
|  |  |  | return sb.toString() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.pSdV1.upVos; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.annotation.JSONField; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.Vo4Up; | 
|---|
|  |  |  | import com.dy.common.util.DateTime; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 10:04 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class WeatherVo implements Vo4Up { | 
|---|
|  |  |  | //{"PM10":10,"PM2.5":0,"flexem_message_id":1311,"flexem_timestamp":1749522958,"äºæ°§å碳":10,"å
ç
§å¼ºåº¦":0,"大æ°åå":20,"ç©ºæ°æ¸©åº¦":0,"ç©ºæ°æ¹¿åº¦":65} | 
|---|
|  |  |  | @JSONField(name = "flexem_message_id") | 
|---|
|  |  |  | public Integer messageId ;//æ¶æ¯ID | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @JSONField(name = "äºæ°§å碳") | 
|---|
|  |  |  | public Integer carbonDioxide ;//äºæ°§å碳 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @JSONField(name = "å
ç
§å¼ºåº¦") | 
|---|
|  |  |  | public Integer lightIntensity ;//å
ç
§å¼ºåº¦ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @JSONField(name = "大æ°åå") | 
|---|
|  |  |  | public Integer atmosphericPressure ;//大æ°åå | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @JSONField(name = "ç©ºæ°æ¸©åº¦") | 
|---|
|  |  |  | public Integer airTemperature ;//ç©ºæ°æ¸©åº¦ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @JSONField(name = "ç©ºæ°æ¹¿åº¦") | 
|---|
|  |  |  | public Integer airHumidity ;//ç©ºæ°æ¹¿åº¦ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @JSONField(name = "PM2.5") | 
|---|
|  |  |  | public Integer pm25 ;//PM2.5 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @JSONField(name = "PM10") | 
|---|
|  |  |  | public Integer pm10 ;//PM10 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @JSONField(name = "flexem_timestamp") | 
|---|
|  |  |  | public Long devDt ;//è®¾å¤æ¶é´ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String devDtStr ;//è®¾å¤æ¶é´ | 
|---|
|  |  |  | public String getDevDtStr() { | 
|---|
|  |  |  | if(devDt == null){ | 
|---|
|  |  |  | return DateTime.yyyy_MM_dd_HH_mm_ss(DateTime.getDate(devDt)) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return "" ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String toString(){ | 
|---|
|  |  |  | StringBuilder sb = new StringBuilder(); | 
|---|
|  |  |  | sb.append("æ°è±¡æ°æ®ï¼") ; | 
|---|
|  |  |  | sb.append(" æ¶æ¯IDï¼"+messageId) ; | 
|---|
|  |  |  | sb.append(" äºæ°§å碳ï¼"+carbonDioxide) ; | 
|---|
|  |  |  | sb.append(" å
ç
§å¼ºåº¦ï¼"+lightIntensity) ; | 
|---|
|  |  |  | sb.append(" å¤§æ°ååï¼"+atmosphericPressure) ; | 
|---|
|  |  |  | sb.append(" ç©ºæ°æ¸©åº¦ï¼"+airTemperature) ; | 
|---|
|  |  |  | sb.append(" ç©ºæ°æ¹¿åº¦ï¼"+airHumidity) ; | 
|---|
|  |  |  | sb.append(" PM2.5ï¼"+pm25) ; | 
|---|
|  |  |  | sb.append(" PM10ï¼"+pm10) ; | 
|---|
|  |  |  | sb.append(" è®¾å¤æ¶é´ï¼"+devDt) ; | 
|---|
|  |  |  | sb.append(" è®¾å¤æ¶é´ï¼"+ this.getDevDtStr()) ; | 
|---|
|  |  |  | sb.append("\n") ; | 
|---|
|  |  |  | return sb.toString() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | 山䏿³°å®å
¬å¸æä¾æ°´è¥æºãå壤墿
ç«ãæ°è±¡ç«ãFBoxç³»ç»åè®® | 
|---|
|  |  |  |  | 
|---|
|  |  |  | å»ºè®®æ¶æ¯ä¸»é¢è§åï¼ | 
|---|
|  |  |  | åç³»ç»ï¼æºæï¼/åè®®åç§°ï¼åå®¶ï¼+çæ¬å·/设å¤ç¼å·/åè½ç»/å°å | 
|---|
|  |  |  | åç³»ç»ï¼æºæï¼/åè®®åç§°ï¼åå®¶ï¼+çæ¬å·/设å¤ç¼å·/åè½ç» | 
|---|
|  |  |  | ä¾å¦ï¼ | 
|---|
|  |  |  | ym/sd1/10000/control/m4  (å
è°/å±±ä¸+çæ¬1/设å¤ç¼å·/è®¾å¤æ§å¶/å°å) | 
|---|
|  |  |  | ym/sd1/10000/weather  (å
è°/å±±ä¸+çæ¬1/设å¤ç¼å·/æ°è±¡) | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.status; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttNotifyInfo; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 15:50 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class DevOnLineSt implements MqttNotifyInfo { | 
|---|
|  |  |  | public String id ; | 
|---|
|  |  |  | public String protocol ; | 
|---|
|  |  |  | public Boolean onLine ; | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol4Mqtt.status; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttNotifyInfo; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 15:52 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class DevRunSt implements MqttNotifyInfo { | 
|---|
|  |  |  | public String id ; | 
|---|
|  |  |  | public Boolean stirRunning ;//æ
æè¿è¡ true毠falseå¦ | 
|---|
|  |  |  | public Boolean injectRunning ;//注è¥è¿è¡ true毠falseå¦ | 
|---|
|  |  |  | public Boolean irrRunning ;//çæºè¿è¡ true毠falseå¦ | 
|---|
|  |  |  | public Boolean alarm ;//æ¥è¦ true毠falseå¦ | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static String getStateName(int state){ | 
|---|
|  |  |  | switch (state) { | 
|---|
|  |  |  | case STATE_OPEN: | 
|---|
|  |  |  | return "éå¼"; | 
|---|
|  |  |  | case STATE_OFFLINE: | 
|---|
|  |  |  | return "离线"; | 
|---|
|  |  |  | case STATE_UNSTART: | 
|---|
|  |  |  | return "æªå¼å§"; | 
|---|
|  |  |  | case STATE_RUNNING: | 
|---|
|  |  |  | return "å级ä¸"; | 
|---|
|  |  |  | case STATE_SUCCESS: | 
|---|
|  |  |  | return "å级æå"; | 
|---|
|  |  |  | case STATE_FAILONE: | 
|---|
|  |  |  | return "ä¸å
æ»"; | 
|---|
|  |  |  | case STATE_FAIL: | 
|---|
|  |  |  | return "å¤å
æ»"; | 
|---|
|  |  |  | case STATE_FAILOFFLINE: | 
|---|
|  |  |  | return "离线失败"; | 
|---|
|  |  |  | case STATE_FAILOPEN: | 
|---|
|  |  |  | return "éå¼å¤±è´¥"; | 
|---|
|  |  |  | case STATE_FAILRTU: | 
|---|
|  |  |  | return "RTU失败"; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | return "æªç¥"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return switch (state) { | 
|---|
|  |  |  | case STATE_OPEN -> "éå¼"; | 
|---|
|  |  |  | case STATE_OFFLINE -> "离线"; | 
|---|
|  |  |  | case STATE_UNSTART -> "æªå¼å§"; | 
|---|
|  |  |  | case STATE_RUNNING -> "å级ä¸"; | 
|---|
|  |  |  | case STATE_SUCCESS -> "å级æå"; | 
|---|
|  |  |  | case STATE_FAILONE -> "ä¸å
æ»"; | 
|---|
|  |  |  | case STATE_FAIL -> "å¤å
æ»"; | 
|---|
|  |  |  | case STATE_FAILOFFLINE -> "离线失败"; | 
|---|
|  |  |  | case STATE_FAILOPEN -> "éå¼å¤±è´¥"; | 
|---|
|  |  |  | case STATE_FAILRTU -> "RTU失败"; | 
|---|
|  |  |  | default -> "æªç¥"; | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | company = "" ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | System.out.println("OOOOOOOOOO           OOOOOOOO       OOOOOOOO") ; | 
|---|
|  |  |  | System.out.println("@@@@@@@@@@@@@@@@#O    $@@@@@@@@&    @@@@@@@@#") ; | 
|---|
|  |  |  | System.out.println("$$$$$$$$$$$$         $$$$$$$$       $$$$$$$$") ; | 
|---|
|  |  |  | System.out.println("@@@@@@@@@@@@@@@@#$    $@@@@@@@@&    @@@@@@@@#") ; | 
|---|
|  |  |  | System.out.println("@@@@@@@@@@@@@@@@@@@#    @@@@@@@@# $@@@@@@@@&") ; | 
|---|
|  |  |  | System.out.println("@@@@@@@@@@@@@@@@@@@@@#   #@@@@@@@@@@@@@@@@O") ; | 
|---|
|  |  |  | System.out.println("@@@@@@@@@@@@@@@@@@@@@#   #@@@@@@@@@@@@@@@@$") ; | 
|---|
|  |  |  | System.out.println("@@@@@@@@@@@@@@@@@@@@@@@   &@@@@@@@@@@@@@@") ; | 
|---|
|  |  |  | System.out.println("@@@@@@$      $@@@@@@@@@&   O@@@@@@@@@@@#") ; | 
|---|
|  |  |  | System.out.println("@@@@@@$      $@@@@@@@@@&   $@@@@@@@@@@@#") ; | 
|---|
|  |  |  | System.out.println("@@@@@@$        @@@@@@@@@     @@@@@@@@@&      " + this.orgTag + svName + "RtuMw 1.0.00" ) ; | 
|---|
|  |  |  | if(this.HttpSvPath != null && this.HttpSvPort != null){ | 
|---|
|  |  |  | System.out.println("@@@@@@$       O@@@@@@@@@     &@@@@@@@@       HttpSv [ip]:" + this.HttpSvPort + this.HttpSvPath) ; | 
|---|
|  |  |  | 
|---|
|  |  |  | mqVo.enable = conf.getSetAttrBoolean(doc, "config.mqtt", "enable", null, null) ; | 
|---|
|  |  |  | ServerProperties.mqttUnitEnable = mqVo.enable ; | 
|---|
|  |  |  | if(mqVo.enable){ | 
|---|
|  |  |  | mqVo.svIp = conf.getSetAttrTxt(doc, "config.mqtt", "svIp", null, true, null) ; | 
|---|
|  |  |  | mqVo.svIp = conf.getSetAttrTxt(doc, "config.mqtt", "svIp", null, false, null) ; | 
|---|
|  |  |  | if(!IPUtils.ipValid(mqVo.svIp)){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.svIpé
ç½®çIPä¸åæ³") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if(mqVo.svPort < 0 || mqVo.svPort > 65535){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.svPorté
ç½®ç端å£ä¸åæ³") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | mqVo.svUserName = conf.getSetAttrTxt(doc, "config.mqtt", "svUserName", null, true, null) ; | 
|---|
|  |  |  | mqVo.svUserName = conf.getSetAttrTxt(doc, "config.mqtt", "svUserName", null, false, null) ; | 
|---|
|  |  |  | if(mqVo.svUserName == null || mqVo.svUserName.trim().equals("")){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.svUserNameé
ç½®çç¨æ·åä¸åæ³") ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | mqVo.svUserName = mqVo.svUserName.trim() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | mqVo.svUserPassword = conf.getSetAttrTxt(doc, "config.mqtt", "svUserPassword", null, true, null) ; | 
|---|
|  |  |  | mqVo.svUserPassword = conf.getSetAttrTxt(doc, "config.mqtt", "svUserPassword", null, false, null) ; | 
|---|
|  |  |  | if(mqVo.svUserPassword == null || mqVo.svUserPassword.trim().equals("")){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.svUserNameé
ç½®çç¨æ·å¯ç ä¸åæ³") ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | 
|---|
|  |  |  | if(mqVo.poolMaxSize <= 1 || mqVo.poolMaxSize > 1000){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.poolMaxSizeé
ç½®çè¿æ¥æ± è¿æ¥æå¤§æ°éä¸åæ³") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String topicAndQos = conf.getSetAttrTxt(doc, "config.mqtt", "topicAndQos", null, true, null) ; | 
|---|
|  |  |  | if(topicAndQos == null || topicAndQos.trim().equals("")){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.topicAndQosé
ç½®ç主é¢åQosä¸åæ³") ; | 
|---|
|  |  |  | String proAndDevIds = conf.getSetAttrTxt(doc, "config.mqtt", "protocolAndDeviceIds", null, false, null) ; | 
|---|
|  |  |  | if(proAndDevIds == null || proAndDevIds.trim().equals("")){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.protocolAndDeviceIdsé
ç½®ä¸åæ³") ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | topicAndQos = topicAndQos.trim() ; | 
|---|
|  |  |  | topicAndQos = topicAndQos.replaceAll("ï¼", ","); | 
|---|
|  |  |  | topicAndQos = topicAndQos.replaceAll("ï¼", ";"); | 
|---|
|  |  |  | String[] topicAndQosArr = topicAndQos.split(";") ; | 
|---|
|  |  |  | proAndDevIds = proAndDevIds.trim() ; | 
|---|
|  |  |  | proAndDevIds = proAndDevIds.replaceAll("ï¼", ","); | 
|---|
|  |  |  | proAndDevIds = proAndDevIds.replaceAll("ï¼", ";"); | 
|---|
|  |  |  | proAndDevIds = proAndDevIds.replaceAll("\\\\", "/"); | 
|---|
|  |  |  | mqVo.protocolAndDeviceIds = proAndDevIds.split(",") ; | 
|---|
|  |  |  | mqVo.deviceIds = new String[mqVo.protocolAndDeviceIds.length] ; | 
|---|
|  |  |  | int index = 0 ; | 
|---|
|  |  |  | for(String topicAndQosStr : mqVo.protocolAndDeviceIds){ | 
|---|
|  |  |  | String[] pd = topicAndQosStr.split("/") ; | 
|---|
|  |  |  | mqVo.deviceIds[index] = pd[1].trim() ; | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String subTopicAndQos = conf.getSetAttrTxt(doc, "config.mqtt", "subTopicAndQos", null, false, null) ; | 
|---|
|  |  |  | if(subTopicAndQos == null || subTopicAndQos.trim().equals("")){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.subTopicAndQosé
ç½®ç主é¢åQosä¸åæ³") ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | subTopicAndQos = subTopicAndQos.trim() ; | 
|---|
|  |  |  | subTopicAndQos = subTopicAndQos.replaceAll("ï¼", ","); | 
|---|
|  |  |  | subTopicAndQos = subTopicAndQos.replaceAll("ï¼", ";"); | 
|---|
|  |  |  | String[] topicAndQosArr = subTopicAndQos.split(";") ; | 
|---|
|  |  |  | mqVo.subTopics = new String[topicAndQosArr.length] ; | 
|---|
|  |  |  | mqVo.topicsQos = new int[topicAndQosArr.length] ; | 
|---|
|  |  |  | mqVo.subTopicsQos = new int[topicAndQosArr.length] ; | 
|---|
|  |  |  | int index = 0 ; | 
|---|
|  |  |  | for(String topicAndQosStr : topicAndQosArr){ | 
|---|
|  |  |  | String[] tq = topicAndQosStr.split(",") ; | 
|---|
|  |  |  | mqVo.subTopics[index] = tq[0].trim() ; | 
|---|
|  |  |  | mqVo.topicsQos[index] = Integer.parseInt(tq[1].trim()) ; | 
|---|
|  |  |  | mqVo.subTopicsQos[index] = Integer.parseInt(tq[1].trim()) ; | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | mqVo.publishQos = conf.getSetAttrPlusInt(doc, "config.mqtt", "publishQos", null, 0, 3, null); | 
|---|
|  |  |  | if(mqVo.publishQos < 0 || mqVo.publishQos > 3){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.publishQosé
ç½®ä¸åæ³") ; | 
|---|
|  |  |  | mqVo.pubTopicQos = conf.getSetAttrPlusInt(doc, "config.mqtt", "pubTopicQos", null, 0, 3, null); | 
|---|
|  |  |  | if(mqVo.pubTopicQos < 0 || mqVo.pubTopicQos > 3){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.pubTopicQosé
ç½®ä¸åæ³") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer intNoSubThenOff = conf.getSetAttrPlusInt(doc, "config.mqtt", "noSubThenOff", null, 1, 1440, null); | 
|---|
|  |  |  | mqVo.noSubThenOff = intNoSubThenOff * 60 * 1000L ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mqVo.showStartInfo = showStartInfo ; | 
|---|
|  |  |  | AdapterImp_MqttUnit mqAdapt = new AdapterImp_MqttUnit(); | 
|---|
|  |  |  | mqAdapt.setConfig(mqVo); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ResourceUnit.getInstance().rtuLog(logNode); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * è®°å½Rtuæ¥å¿ | 
|---|
|  |  |  | * @param devId | 
|---|
|  |  |  | * @param content | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static void log4Mqtt(String devId, String content){ | 
|---|
|  |  |  | if(devId == null || devId.trim().equals("")){ | 
|---|
|  |  |  | log.error("严éé误ï¼è®°å½Mqttè®¾å¤æ¥å¿æ¶ï¼è®¾å¤å°åæªæä¾ï¼") ; | 
|---|
|  |  |  | return ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(content == null || content.equals("")){ | 
|---|
|  |  |  | log.error("严éé误ï¼è®°å½Mqttè®¾å¤æ¥å¿æ¶ï¼æ¥å¿å
å®¹æªæä¾ï¼") ; | 
|---|
|  |  |  | return ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | RtuLogNode logNode = new RtuLogNode(devId, content) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ResourceUnit.getInstance().rtuLog(logNode); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol.Command; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.rtuState.RtuStatus; | 
|---|
|  |  |  | import com.dy.rtuMw.server.local.localProtocol.*; | 
|---|
|  |  |  | import com.dy.rtuMw.server.mqtt.DevStatus; | 
|---|
|  |  |  | import com.dy.rtuMw.server.mqtt.DevStatusDealer; | 
|---|
|  |  |  | import com.dy.rtuMw.server.mqtt.MqttUnit; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Command deal(Command com) throws Exception{ | 
|---|
|  |  |  | Command rCom ; | 
|---|
|  |  |  | String code = com.getCode() ; | 
|---|
|  |  |  | if(code.equals(CodeLocal.clock)){ | 
|---|
|  |  |  | return this.clock(com) ; | 
|---|
|  |  |  | }else if(code.equals(CodeLocal.onAllLine)){ | 
|---|
|  |  |  | return this.onAllLine(com) ; | 
|---|
|  |  |  | }else if(code.equals(CodeLocal.onPartLine)){ | 
|---|
|  |  |  | return this.onPartLine(com) ; | 
|---|
|  |  |  | }else if(code.equals(CodeLocal.onLineStatistics)){ | 
|---|
|  |  |  | return this.onLineStateStatistics(com) ; | 
|---|
|  |  |  | }else if(code.equals(CodeLocal.allRtuStates)){ | 
|---|
|  |  |  | return this.allRtuStates(com) ; | 
|---|
|  |  |  | }else if(code.equals(CodeLocal.partRtuStates)){ | 
|---|
|  |  |  | return this.someRtuStates(com) ; | 
|---|
|  |  |  | }else if(code.equals(CodeLocal.oneRtuStates)){ | 
|---|
|  |  |  | return this.oneRtuStates(com) ; | 
|---|
|  |  |  | }else if(code.equals(CodeLocal.allProtocols)){ | 
|---|
|  |  |  | return this.allProtocols(com) ; | 
|---|
|  |  |  | }else if(code.equals(CodeLocal.stopTcpSv)){ | 
|---|
|  |  |  | return this.stopTcpSv(com) ; | 
|---|
|  |  |  | }else if(code.equals(CodeLocal.recoverTcpSv)){ | 
|---|
|  |  |  | return this.recoverTcpSv(com) ; | 
|---|
|  |  |  | }else if(code.equals(CodeLocal.recoverMqttSv)){ | 
|---|
|  |  |  | return this.stopMqttSv(com) ; | 
|---|
|  |  |  | }else if(code.equals(CodeLocal.mwState)){ | 
|---|
|  |  |  | return this.mwInfo(com) ; | 
|---|
|  |  |  | switch (code) { | 
|---|
|  |  |  | case CodeLocal.clock -> { | 
|---|
|  |  |  | rCom = this.clock(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ReturnCommand.errored("åºéï¼æ¶å°å
é¨å½ä»¤çåè½ç ä¸è½è¯å«ï¼", com.getId(), com.getCode()) ; | 
|---|
|  |  |  | case CodeLocal.mwState -> { | 
|---|
|  |  |  | rCom = this.mwInfo(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //////////////////////////////////////////// | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // ä»¥ä¸æ¯ç¸å
³åºäºTCPè¿æ¥çRTU设å¤çå
é¨å½ä»¤ | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //////////////////////////////////////////// | 
|---|
|  |  |  | case CodeLocal.onAllLine -> { | 
|---|
|  |  |  | rCom = this.onAllLine(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.onPartLine -> { | 
|---|
|  |  |  | rCom = this.onPartLine(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.onLineStatistics -> { | 
|---|
|  |  |  | rCom = this.onLineStateStatistics(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.allRtuStates -> { | 
|---|
|  |  |  | rCom = this.allRtuStates(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.partRtuStates -> { | 
|---|
|  |  |  | rCom = this.someRtuStates(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.oneRtuStates -> { | 
|---|
|  |  |  | rCom = this.oneRtuStates(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.allProtocols -> { | 
|---|
|  |  |  | rCom = this.allProtocols(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.stopTcpSv -> { | 
|---|
|  |  |  | rCom = this.stopTcpSv(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.recoverTcpSv -> { | 
|---|
|  |  |  | rCom = this.recoverTcpSv(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //////////////////////////////////////////// | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // ä»¥ä¸æ¯ç¸å
³åºäºMQTTè¿æ¥ç设å¤çå
é¨å½ä»¤ | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //////////////////////////////////////////// | 
|---|
|  |  |  | case CodeLocal.onAllLineMqtt -> { | 
|---|
|  |  |  | rCom = this.onAllLineMqtt(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.onPartLineMqtt -> { | 
|---|
|  |  |  | rCom = this.onPartLineMqtt(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.onLineStatisticsMqtt -> { | 
|---|
|  |  |  | rCom = this.onLineStateStatisticsMqtt(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.allRtuStatesMqtt -> { | 
|---|
|  |  |  | rCom = this.allRtuStatesMqtt(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.partRtuStatesMqtt -> { | 
|---|
|  |  |  | rCom = this.someRtuStatesMqtt(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.oneRtuStatesMqtt -> { | 
|---|
|  |  |  | rCom = this.oneRtuStatesMqtt(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | case CodeLocal.stopMqttSv -> { | 
|---|
|  |  |  | rCom = this.stopMqttSv(com); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | default -> { | 
|---|
|  |  |  | rCom = ReturnCommand.errored("åºéï¼æ¶å°å
é¨å½ä»¤çåè½ç ä¸è½è¯å«ï¼", com.getId(), com.getCode()); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return rCom ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æ¥è¯¢éä¿¡ä¸é´ä»¶æ¶é | 
|---|
|  |  |  | * @param  command | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Command clock(Command command) throws Exception{ | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<String, RtuStatus> map = new RtuStatusDeal().dealSome(rtuAddrGrp) ; | 
|---|
|  |  |  | return ReturnCommand.successed("æ¥è¯¢é¨åRTUç¶æç»æ", command.getId(), command.getCode(), map) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return ReturnCommand.errored("åºéï¼å½ä»¤åæ°åºè¯¥æ¯ææ¥è¯¢RTUçå°å串",  command.getId(), command.getCode()) ; | 
|---|
|  |  |  | return ReturnCommand.errored("åºéï¼å½ä»¤åæ°åºè¯¥æææ¥è¯¢RTUçå°å串",  command.getId(), command.getCode()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | RtuStatus rtuStatus = new RtuStatusDeal().dealOne(rtuAddr) ; | 
|---|
|  |  |  | return ReturnCommand.successed("æ¥è¯¢ä¸ä¸ªRTUç¶æç»æ", command.getId(), command.getCode(), rtuStatus) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return ReturnCommand.errored("åºéï¼å½ä»¤åæ°åºè¯¥æ¯ææ¥è¯¢RTUçå°å",  command.getId(), command.getCode()) ; | 
|---|
|  |  |  | return ReturnCommand.errored("åºéï¼å½ä»¤åæ°åºè¯¥æææ¥è¯¢RTUçå°å",  command.getId(), command.getCode()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return ReturnCommand.successed("å·²ç»å¯å¨æ¢å¤TCPæå¡", command.getId(), command.getCode(), null) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * åæ¢TCPæå¡ï¼ä¸åæ¥å
¥æ°çTCPè¿æ¥ï¼å·²ç»TCPè¿æ¥çå
¨é¨æè¿æ¥ | 
|---|
|  |  |  | * æ¥è¯¢ææMQTT设å¤å¨çº¿æ
åµ | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Command onAllLineMqtt(Command command) throws Exception{ | 
|---|
|  |  |  | HashMap<String, Boolean> map = DevStatusDealer.allOnLine() ; | 
|---|
|  |  |  | return ReturnCommand.successed("æ¥è¯¢ææMqtt设å¤å¨çº¿æ
åµç»æ", command.getId(), command.getCode(), map) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æ¥è¯¢é¨åMQTT设å¤å¨çº¿æ
åµ | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Command onPartLineMqtt(Command command) throws Exception{ | 
|---|
|  |  |  | if(command.param != null && command.param instanceof String && !command.param.equals("")){ | 
|---|
|  |  |  | String[] devIds = ((String)command.param).split(","); | 
|---|
|  |  |  | HashMap<String, Boolean> map = DevStatusDealer.partOnLine(devIds) ; | 
|---|
|  |  |  | return ReturnCommand.successed("æ¥è¯¢é¨åMqtt设å¤å¨çº¿æ
åµç»æ", command.getId(), command.getCode(), map) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return ReturnCommand.errored("åºéï¼å½ä»¤åæ°åºè¯¥æææ¥è¯¢Mqtt设å¤çå°å串",  command.getId(), command.getCode()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * ç»è®¡MQTT设å¤å¨çº¿ä¸ä¸å¨çº¿æ
åµ | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Command onLineStateStatisticsMqtt(Command command) throws Exception{ | 
|---|
|  |  |  | RtuOnLineStateStatisticsVo vo = DevStatusDealer.statisticsOnLine() ; | 
|---|
|  |  |  | return ReturnCommand.successed("æ¥è¯¢ææMqtt设å¤å¨çº¿æ
åµç»æ", command.getId(), command.getCode(), vo) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æ¥è¯¢ææMQTT设å¤ç¶æ | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Command allRtuStatesMqtt(Command command) throws Exception{ | 
|---|
|  |  |  | Map<String, DevStatus> map =  DevStatusDealer.allStatus() ; | 
|---|
|  |  |  | return ReturnCommand.successed("æ¥è¯¢ææMqtt设å¤ç¶æç»æ", command.getId(), command.getCode(), map) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æ¥è¯¢é¨åMQTT设å¤ç¶æ | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Command someRtuStatesMqtt(Command command) throws Exception{ | 
|---|
|  |  |  | if(command.param != null && command.param instanceof String && !command.param.equals("")){ | 
|---|
|  |  |  | String[] devIds = ((String)command.param).split(","); | 
|---|
|  |  |  | Map<String, DevStatus> map = DevStatusDealer.someStatus(devIds) ; | 
|---|
|  |  |  | return ReturnCommand.successed("æ¥è¯¢é¨åMqtt设å¤ç¶æç»æ", command.getId(), command.getCode(), map) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return ReturnCommand.errored("åºéï¼å½ä»¤åæ°åºè¯¥æææ¥è¯¢Mqtt设å¤çå°å串",  command.getId(), command.getCode()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æ¥è¯¢é¨åMQTT设å¤ç¶æ | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Command oneRtuStatesMqtt(Command command) throws Exception{ | 
|---|
|  |  |  | if(command.param != null && command.param instanceof String && !command.param.equals("")){ | 
|---|
|  |  |  | String devId = (String)command.param; | 
|---|
|  |  |  | DevStatus devStatus = DevStatusDealer.oneStatus(devId) ; | 
|---|
|  |  |  | return ReturnCommand.successed("æ¥è¯¢ä¸ä¸ªMqtt设å¤ç¶æç»æ", command.getId(), command.getCode(), devStatus) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return ReturnCommand.errored("åºéï¼å½ä»¤åæ°åºè¯¥æææ¥è¯¢Mqtt设å¤çå°å",  command.getId(), command.getCode()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * åæ¢MQTTæå¡ | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Command stopMqttSv(Command command) throws Exception{ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æ¢å¤TCPæå¡ï¼æ¥å
¥æ°çTCPè¿æ¥ | 
|---|
|  |  |  | * æ¢å¤MQTTæå¡ | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Command recoverMqttSv(Command command) throws Exception{ | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.dy.rtuMw.server.local.localProtocol; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class CodeLocal { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String clock = "LCD0000" ;//æ¥è¯¢çæ§ä¸é´ä»¶æ¶é | 
|---|
|  |  |  | public static final String mwState = "LCD0200" ;//å¾å°éä¿¡ä¸é´ä»¶è¿è¡ä¿¡æ¯ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //////////////////////////////////////////// | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // ä»¥ä¸æ¯ç¸å
³åºäºTCPè¿æ¥çRTU设å¤çå
é¨å½ä»¤ | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //////////////////////////////////////////// | 
|---|
|  |  |  | public static final String onAllLine = "LCD0001" ;//æ¥è¯¢ææRTUå¨çº¿æ
åµ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String onPartLine = "LCD0002" ;//æ¥è¯¢ææRTUå¨çº¿æ
åµ | 
|---|
|  |  |  | public static final String onPartLine = "LCD0002" ;//æ¥è¯¢é¨åRTUå¨çº¿æ
åµ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String onLineStatistics = "LCD0003" ;//æ¥è¯¢ææRTUç¶æç»è®¡æ
åµ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String recoverTcpSv = "LCD0112" ;//éå¯TCPæå¡ï¼æ¥å
¥æ°çTCPè¿æ¥ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String stopMqttSv = "LCD0114" ;//忢Mqttæå¡ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String recoverMqttSv = "LCD0116" ;//éå¯Mqttæå¡ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String mwState = "LCD0200" ;//å¾å°éä¿¡ä¸é´ä»¶è¿è¡ä¿¡æ¯ | 
|---|
|  |  |  | //////////////////////////////////////////// | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // ä»¥ä¸æ¯ç¸å
³åºäºMQTTè¿æ¥ç设å¤çå
é¨å½ä»¤ | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //////////////////////////////////////////// | 
|---|
|  |  |  | public static final String onAllLineMqtt = "LMCD0001" ;//æ¥è¯¢ææMQTT设å¤å¨çº¿æ
åµ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String onPartLineMqtt = "LMCD0002" ;//æ¥è¯¢é¨åMQTT设å¤å¨çº¿æ
åµ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String onLineStatisticsMqtt = "LMCD0003" ;//æ¥è¯¢ææMQTT设å¤ç¶æç»è®¡æ
åµ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String allRtuStatesMqtt = "LMCD0010" ;//æ¥è¯¢ææMQTT设å¤ç¶æ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String partRtuStatesMqtt = "LMCD0011" ;//æ¥è¯¢é¨åMQTT设å¤ç¶æ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String oneRtuStatesMqtt = "LMCD0012" ;//æ¥è¯¢ä¸ä¸ªMQTT设å¤ç¶æ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String stopMqttSv = "LMCD0110" ;//忢Mqttæå¡ | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.rtuMw.server.mqtt; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 14:54 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class DevStatus { | 
|---|
|  |  |  | public String id ;//设å¤ID | 
|---|
|  |  |  | public String protocol;//åè®® | 
|---|
|  |  |  | public Boolean onLine ;//æ¯å¦å¨çº¿ trueå¨çº¿ false离线 | 
|---|
|  |  |  | public Boolean stirRunning ;//æ
æè¿è¡ true毠falseå¦ | 
|---|
|  |  |  | public Boolean injectRunning ;//注è¥è¿è¡ true毠falseå¦ | 
|---|
|  |  |  | public Boolean irrRunning ;//çæºè¿è¡ true毠falseå¦ | 
|---|
|  |  |  | public Boolean alarm ;//æ¥è¦ true毠falseå¦ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Long lastDownComTime ;//䏿¬¡ä¸åå½ä»¤æ¶å»(æ¯«ç§æ¶å» System.currentTimeMillis()) | 
|---|
|  |  |  | public Long lastUpDataTime ;//䏿¬¡æ¶å°ä¸è¡æ°æ®æ¶å»(æ¯«ç§æ¶å» System.currentTimeMillis()) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.rtuMw.server.mqtt; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.status.DevRunSt; | 
|---|
|  |  |  | import com.dy.rtuMw.server.forTcp.RtuLogDealer; | 
|---|
|  |  |  | import com.dy.rtuMw.server.local.localProtocol.RtuOnLineStateStatisticsVo; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.Iterator; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | import java.util.Set; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | * @Date: 2025/6/10 15:00 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public class DevStatusDealer { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static Map<String, DevStatus> map = new HashMap<String, DevStatus>() ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static HashMap<String, Boolean> allOnLine(){ | 
|---|
|  |  |  | synchronized (map){ | 
|---|
|  |  |  | HashMap<String, Boolean> rsMap = new HashMap<>(); | 
|---|
|  |  |  | Iterator<Map.Entry<String, DevStatus>> it = map.entrySet().iterator() ; | 
|---|
|  |  |  | Map.Entry<String, DevStatus> entry = null ; | 
|---|
|  |  |  | while(it.hasNext()){ | 
|---|
|  |  |  | entry = it.next() ; | 
|---|
|  |  |  | rsMap.put(entry.getKey(), entry.getValue().onLine) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return rsMap ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static HashMap<String, Boolean> partOnLine(String[] devIds){ | 
|---|
|  |  |  | synchronized (map){ | 
|---|
|  |  |  | HashMap<String, Boolean> rsMap = new HashMap<String, Boolean>(); | 
|---|
|  |  |  | for(String devid : devIds){ | 
|---|
|  |  |  | DevStatus st = map.get(devid) ; | 
|---|
|  |  |  | if(st != null){ | 
|---|
|  |  |  | rsMap.put(devid, st.onLine) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return rsMap ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * ç»è®¡å¨çº¿ä¸ä¸å¨çº¿æ
åµ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static RtuOnLineStateStatisticsVo statisticsOnLine(){ | 
|---|
|  |  |  | RtuOnLineStateStatisticsVo vo = new RtuOnLineStateStatisticsVo() ; | 
|---|
|  |  |  | vo.onLineNum = 0 ; | 
|---|
|  |  |  | vo.offLineNum = 0 ; | 
|---|
|  |  |  | synchronized (map){ | 
|---|
|  |  |  | Iterator<Map.Entry<String, DevStatus>> it = map.entrySet().iterator() ; | 
|---|
|  |  |  | Map.Entry<String, DevStatus> entry = null ; | 
|---|
|  |  |  | while(it.hasNext()){ | 
|---|
|  |  |  | entry = it.next() ; | 
|---|
|  |  |  | if(((DevStatus)entry).onLine != null && ((DevStatus)entry).onLine.booleanValue()){ | 
|---|
|  |  |  | vo.onLineNum++ ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | vo.offLineNum++ ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return vo ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å¾å°å
¨é¨ç¶æ | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static Map<String, DevStatus> allStatus(){ | 
|---|
|  |  |  | return map ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å¾å°é¨åç¶æ | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static Map<String, DevStatus> someStatus(String[] devIdArrGrp){ | 
|---|
|  |  |  | synchronized (map){ | 
|---|
|  |  |  | Map<String, DevStatus> rsMap = new HashMap<>(); | 
|---|
|  |  |  | for(String devId : devIdArrGrp){ | 
|---|
|  |  |  | DevStatus status = map.get(devId) ; | 
|---|
|  |  |  | if(status != null){ | 
|---|
|  |  |  | rsMap.put(devId, status) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return rsMap ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å¾å°ä¸ä¸ªRTUçç¶æ | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static DevStatus oneStatus(String devId){ | 
|---|
|  |  |  | return map.get(devId) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void updateOnLineState() { | 
|---|
|  |  |  | if (MqttUnit.confVo != null | 
|---|
|  |  |  | && MqttUnit.confVo.noSubThenOff != null | 
|---|
|  |  |  | && MqttUnit.confVo.noSubThenOff.longValue() > 0) { | 
|---|
|  |  |  | Long now = System.currentTimeMillis() ; | 
|---|
|  |  |  | synchronized (map){ | 
|---|
|  |  |  | Set<Map.Entry<String, DevStatus>> entrySet = map.entrySet() ; | 
|---|
|  |  |  | Iterator<Map.Entry<String, DevStatus>> it = entrySet.iterator() ; | 
|---|
|  |  |  | Map.Entry<String, DevStatus> entry ; | 
|---|
|  |  |  | DevStatus st; | 
|---|
|  |  |  | while(it.hasNext()){ | 
|---|
|  |  |  | entry = it.next() ; | 
|---|
|  |  |  | st = entry.getValue(); | 
|---|
|  |  |  | if(st.onLine != null && st.onLine.booleanValue() && st.lastUpDataTime != null){ | 
|---|
|  |  |  | if(now - st.lastUpDataTime > MqttUnit.confVo.noSubThenOff.longValue()){ | 
|---|
|  |  |  | st.onLine = false ; | 
|---|
|  |  |  | RtuLogDealer.log4Mqtt(entry.getKey(), "å è¾é¿æ¶é´æªæ¶ä¸è¡æ°æ®ï¼è®¤ä¸ºè®¾å¤ç¦»çº¿"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * åéæ¶æ¯å | 
|---|
|  |  |  | * @param devId | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static void afterSendPubMessage(String devId){ | 
|---|
|  |  |  | DevStatus st = map.get(devId); | 
|---|
|  |  |  | if(st != null){ | 
|---|
|  |  |  | st.lastDownComTime = System.currentTimeMillis() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æ¥æ¶æ¶æ¯å | 
|---|
|  |  |  | * @param devId | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static void afterReceiveSubMessage(String devId){ | 
|---|
|  |  |  | DevStatus st = map.get(devId); | 
|---|
|  |  |  | if(st != null){ | 
|---|
|  |  |  | st.lastUpDataTime = System.currentTimeMillis() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void onLine(String devId, String protocol){ | 
|---|
|  |  |  | DevStatus vo = map.get(devId) ; | 
|---|
|  |  |  | if(vo == null) { | 
|---|
|  |  |  | vo = new DevStatus(); | 
|---|
|  |  |  | vo.id = devId ; | 
|---|
|  |  |  | vo.protocol = protocol ; | 
|---|
|  |  |  | vo.onLine = true ; | 
|---|
|  |  |  | map.put(devId, vo); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | vo.onLine = true ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void offLine(String devId){ | 
|---|
|  |  |  | DevStatus vo = map.get(devId) ; | 
|---|
|  |  |  | if(vo == null) { | 
|---|
|  |  |  | vo = new DevStatus(); | 
|---|
|  |  |  | vo.onLine = false ; | 
|---|
|  |  |  | map.put(devId, vo); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | vo.onLine = false ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void setStatus(String devId, DevRunSt st){ | 
|---|
|  |  |  | DevStatus vo = map.get(devId) ; | 
|---|
|  |  |  | if(vo != null) { | 
|---|
|  |  |  | if(st.stirRunning != null){ | 
|---|
|  |  |  | vo.stirRunning = st.stirRunning ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(st.injectRunning != null){ | 
|---|
|  |  |  | vo.injectRunning = st.injectRunning ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(st.irrRunning != null){ | 
|---|
|  |  |  | vo.irrRunning = st.irrRunning ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(st.alarm != null){ | 
|---|
|  |  |  | vo.alarm = st.alarm ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.dy.rtuMw.server.mqtt; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.channel.mqtt.MqttClientPool; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttNotify; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttNotifyInfo; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.status.DevOnLineSt; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.status.DevRunSt; | 
|---|
|  |  |  | import com.dy.rtuMw.server.ServerProperties; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
|  |  |  | import org.eclipse.paho.client.mqttv3.MqttClient; | 
|---|
|  |  |  | 
|---|
|  |  |  | this.configVo = configVo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * åå»ºè¿æ¥æ±  + è®¢é
ä¸»é¢ | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void start()throws Exception{ | 
|---|
|  |  |  | String URL = "tcp://" + this.configVo.svIp + ":" + this.configVo.svPort; | 
|---|
|  |  |  | this.pool = new MqttClientPool(URL, this.configVo.svUserName, this.configVo.svUserPassword, this.configVo.poolMaxSize); | 
|---|
|  |  |  | if(this.pool.isClose()){ | 
|---|
|  |  |  | throw new Exception("Mqttè¿æ¥æ± åå§å失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | MqttClient clientSub = null ; | 
|---|
|  |  |  | MqttClient clientSub ; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | clientSub = pool.popClient();//æ°å建ä¸ä¸ªClientæ¶ï¼æ¤Clientå®é
å»è¿æ¥MQTTæå¡å¨ï¼å¦æè¿æ¥ä¸ä¸ï¼å°±ä¼æåºå¼å¸¸ | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | 
|---|
|  |  |  | if(clientSub == null || !clientSub.isConnected()){ | 
|---|
|  |  |  | throw new Exception("Mqttè¿æ¥æ± è·å¾è®¢é
è¿æ¥ä¸å¯ç¨"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // è®¢é
ä¸»é¢ | 
|---|
|  |  |  | for(int i = 0; i < this.configVo.subTopics.length; i++){ | 
|---|
|  |  |  | clientSub.subscribe(this.configVo.subTopics[i], this.configVo.topicsQos[i], new MqttMessageListener()); | 
|---|
|  |  |  | for(int j = 0 ; j < this.configVo.protocolAndDeviceIds.length; j++){ | 
|---|
|  |  |  | clientSub.subscribe(ServerProperties.orgTag + "/" | 
|---|
|  |  |  | + this.configVo.protocolAndDeviceIds[j] + "/" | 
|---|
|  |  |  | + this.configVo.subTopics[i], | 
|---|
|  |  |  | this.configVo.subTopicsQos[i], | 
|---|
|  |  |  | //æ¯ä¸ä¸ªè®¢é
主é¢é½æä¸ä¸ªMqttMessageListenerå®ä¾ | 
|---|
|  |  |  | new MqttMessageListener(new MqttNotify(){ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void notify(String devId, MqttNotifyInfo... infos) { | 
|---|
|  |  |  | if(devId != null && infos != null && infos.length > 0){ | 
|---|
|  |  |  | for(MqttNotifyInfo info : infos){ | 
|---|
|  |  |  | if(info instanceof DevOnLineSt){ | 
|---|
|  |  |  | DevOnLineSt onLineSt = (DevOnLineSt)info; | 
|---|
|  |  |  | if(onLineSt.onLine != null && onLineSt.onLine.booleanValue()){ | 
|---|
|  |  |  | DevStatusDealer.onLine(devId, ((DevOnLineSt)info).protocol); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | DevStatusDealer.offLine(devId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if(info instanceof DevRunSt){ | 
|---|
|  |  |  | DevStatusDealer.setStatus(devId, (DevRunSt)info); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void publishMsg(MqttClient client, String topic, byte[] msg) throws Exception{ | 
|---|
|  |  |  | client.publish(topic, msg, this.configVo.publishQos, false); | 
|---|
|  |  |  | client.publish(topic, msg, this.configVo.pubTopicQos, false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void publishMsg(MqttClient client, String topic, String msg) throws Exception{ | 
|---|
|  |  |  | byte[] bs = msg.getBytes("UTF-8") ; | 
|---|
|  |  |  | client.publish(topic, bs, this.configVo.publishQos, false); | 
|---|
|  |  |  | client.publish(topic, bs, this.configVo.pubTopicQos, false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public boolean poolIsClose(){ | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.dy.rtuMw.server.mqtt; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttMsgParser; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttPubMsg; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttSubMsg; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.*; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttCallback; | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttTopic; | 
|---|
|  |  |  | import com.dy.common.util.Callback; | 
|---|
|  |  |  | import com.dy.rtuMw.server.forTcp.RtuLogDealer; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.eclipse.paho.client.mqttv3.* ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | * @Date: 2025/6/4 15:52 | 
|---|
|  |  |  | * @Description | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | public class MqttMessageListener implements IMqttMessageListener{ | 
|---|
|  |  |  | private MqttNotify notify ; | 
|---|
|  |  |  | public MqttMessageListener(MqttNotify notify){ | 
|---|
|  |  |  | this.notify = notify ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void messageArrived(String topic, MqttMessage msg) throws Exception { | 
|---|
|  |  |  | MqttMsgParser parser = new MqttMsgParser() ; | 
|---|
|  |  |  | MqttSubMsg subMsg = parser.parseSubMsg(topic, msg) ; | 
|---|
|  |  |  | 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) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) ; | 
|---|
|  |  |  | this.nextDeal(subMsg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private void nextDeal(MqttSubMsg subMsg)throws Exception { | 
|---|
|  |  |  | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | log.error("ç¼åå叿¶æ¯ï¼å½ä»¤ï¼ç»æåçå¼å¸¸", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | MqttSubMsgCache.getInstance().cacheMsg(new MqttSubMsgNode(subMsg)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | log.error("ç¼å订é
æ¶æ¯æ°æ®åçå¼å¸¸", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol4Mqtt.MqttPubMsg; | 
|---|
|  |  |  | import com.dy.common.queue.NodeObj; | 
|---|
|  |  |  | import com.dy.rtuMw.server.ServerProperties; | 
|---|
|  |  |  | import com.dy.rtuMw.server.forTcp.RtuLogDealer; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
|  |  |  | import org.eclipse.paho.client.mqttv3.MqttClient; | 
|---|
|  |  |  | 
|---|
|  |  |  | if(mqttClient != null && mqttClient.isConnected()){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | mqttManager.publishMsg(mqttClient, this.result.topic, this.result.msg); | 
|---|
|  |  |  | DevStatusDealer.afterSendPubMessage(this.result.deviceId); | 
|---|
|  |  |  | RtuLogDealer.log4Mqtt(this.result.deviceId, "å叿¶æ¯    ä¸»é¢ï¼" + this.result.topic + "   æ¶æ¯ï¼" + this.result.msg); | 
|---|
|  |  |  | log.info("åå¸MQTTæ¶æ¯ï¼ä¸»é¢=" + this.result.topic + "ï¼" + this.result.msg); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | log.error("MQTTå叿¶æ¯å¤±è´¥ï¼ä¸»é¢=" + this.result.topic + "ï¼" , e); | 
|---|
|  |  |  | 
|---|
|  |  |  | public String svUserName ;// | 
|---|
|  |  |  | public String svUserPassword ;// | 
|---|
|  |  |  | public Integer poolMaxSize ;// | 
|---|
|  |  |  | public String[] protocolAndDeviceIds ;//设å¤åè®®ä¸IDï¼FBoxï¼id | 
|---|
|  |  |  | public String[] deviceIds ;//设å¤ï¼FBoxï¼id | 
|---|
|  |  |  | public String[] subTopics ;//订é
çä¸»é¢ | 
|---|
|  |  |  | public int[] topicsQos ;////订é
主é¢çQos | 
|---|
|  |  |  | public int publishQos ;////å叿¶æ¯çQos | 
|---|
|  |  |  | public int[] subTopicsQos;//订é
主é¢çQos | 
|---|
|  |  |  | public int pubTopicQos;//å叿¶æ¯çQos | 
|---|
|  |  |  | public Long noSubThenOff; //MQtt设å¤å¨ä¸å®æ¶é´åæªå叿¶æ¯ï¼è®¤ä¸ºè®¾å¤ç¦»çº¿ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public MqttUnitConfigVo(){ | 
|---|
|  |  |  | this.enable = false ; | 
|---|
|  |  |  | 
|---|
|  |  |  | this.svUserName = "dyyjy" ; | 
|---|
|  |  |  | this.svUserPassword = "Dyyjy2025,;.abc!@#" ; | 
|---|
|  |  |  | this.poolMaxSize = 10 ; | 
|---|
|  |  |  | this.publishQos = 1 ; | 
|---|
|  |  |  | this.pubTopicQos = 1 ; | 
|---|
|  |  |  | this.noSubThenOff = 10 * 60 * 10000L ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.core.CoreTask; | 
|---|
|  |  |  | import com.dy.common.queue.Node; | 
|---|
|  |  |  | import com.dy.rtuMw.server.mqtt.DevStatusDealer; | 
|---|
|  |  |  | import com.dy.rtuMw.server.mqtt.MqttSubMsgCache; | 
|---|
|  |  |  | import com.dy.rtuMw.server.mqtt.MqttSubMsgNode; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer execute() { | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | dealOneline() ; | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | log.error("æ´æ°RTUä¼è¯ä¸æ¥æ°æ®æ¶å»æ¶åçéåæä½å¼å¸¸ï¼æ¤å¼å¸¸å¹¶ä¸å½±åç³»ç»æ£å¸¸è¿è¡", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | dealMqMsg() ; | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | log.error(e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return MqttSubMsgCache.size()>0?0:1 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void dealOneline(){ | 
|---|
|  |  |  | DevStatusDealer.updateOnLineState(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å¤çMQTT订é
çæ¶æ¯ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void dealMqMsg() { | 
|---|
|  |  |  | private void dealMqMsg() { | 
|---|
|  |  |  | Node first = MqttSubMsgCache.getFirstQueueNode() ; | 
|---|
|  |  |  | if(first != null){ | 
|---|
|  |  |  | Node last = MqttSubMsgCache.getLastQueueNode() ; | 
|---|
|  |  |  | 
|---|
|  |  |  | #   çå·ï¼ gz | 
|---|
|  |  |  | #   åå·ï¼ lz | 
|---|
|  |  |  | #   éå·ï¼ jc | 
|---|
|  |  |  | base.orgTag=ym | 
|---|
|  |  |  | base.orgTag=mq | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # 233æå¡å¨ï¼ | 
|---|
|  |  |  | #   å
è°ï¼ 60000 | 
|---|
|  |  |  | 
|---|
|  |  |  | base.upData.min.interval=6 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | # MQTTæå¡é
ç½® | 
|---|
|  |  |  | #   mqtt.enable æ¯å¦å¯å¨ | 
|---|
|  |  |  | #   mqtt.protocolAndDeviceIds å¨åç³»ç»ï¼orgTagï¼ä¸æ¥å
¥ç设å¤(FBox)æç¨åè®®å设å¤idéå,å¤ä¸ªç¨éå·éå¼ï¼åè®®ä¸IDç¨æ£ææ éå¼ï¼ä¾å¦ï¼sd1/338220031439,sd1/338220031440 | 
|---|
|  |  |  | #   mqtt.subTopicAndQos è®¢é
主é¢ä¸Qosï¼ä¸»é¢åä¸å
¶Qosç¨éå·éå¼ï¼å¤ä¸ªä¸»é¢åQosç¨åå·éå¼ï¼ä¾å¦ï¼topic1,1;topic2,1;topic3,1 | 
|---|
|  |  |  | # 233æå¡å¨ï¼ | 
|---|
|  |  |  | #   å
è°ï¼ mqtt.enable=false | 
|---|
|  |  |  | #   æ²çï¼ mqtt.enable=false | 
|---|
|  |  |  | #   æµè¯ï¼ mqtt.enable=false | 
|---|
|  |  |  | #   æ¢
æ±ï¼ mqtt.enable=false | 
|---|
|  |  |  | #   å
è°ï¼ mqtt.enable=false  mqtt.protocolAndDeviceIds= mqtt.topicAndQos= | 
|---|
|  |  |  | #   æ²çï¼ mqtt.enable=false  mqtt.protocolAndDeviceIds= mqtt.topicAndQos= | 
|---|
|  |  |  | #   æµè¯ï¼ mqtt.enable=false  mqtt.protocolAndDeviceIds= mqtt.topicAndQos= | 
|---|
|  |  |  | #   æ¢
æ±ï¼ mqtt.enable=false  mqtt.protocolAndDeviceIds= mqtt.topicAndQos= | 
|---|
|  |  |  | # 121æå¡å¨ï¼ | 
|---|
|  |  |  | #   æ°å¤ï¼ mqtt.enable=true | 
|---|
|  |  |  | #   å»¶åºï¼ mqtt.enable=false | 
|---|
|  |  |  | #   é»é¾æ±ï¼ mqtt.enable=false | 
|---|
|  |  |  | #   çå·ï¼ mqtt.enable=false | 
|---|
|  |  |  | #   åå·ï¼ mqtt.enable=false | 
|---|
|  |  |  | #   éå·ï¼ mqtt.enable=true | 
|---|
|  |  |  | # mq/sd1/338220031439/weather | 
|---|
|  |  |  | #   æ°å¤ï¼ mqtt.enable=true  mqtt.protocolAndDeviceIds=? mqtt.topicAndQos=weather,1;soil,1;manure,1;state,1 | 
|---|
|  |  |  | #   å»¶åºï¼ mqtt.enable=false  mqtt.protocolAndDeviceIds= mqtt.topicAndQos= | 
|---|
|  |  |  | #   é»é¾æ±ï¼ mqtt.enable=false  mqtt.protocolAndDeviceIds= mqtt.topicAndQos= | 
|---|
|  |  |  | #   çå·ï¼ mqtt.enable=false  mqtt.protocolAndDeviceIds= mqtt.topicAndQos= | 
|---|
|  |  |  | #   åå·ï¼ mqtt.enable=false  mqtt.protocolAndDeviceIds= mqtt.topicAndQos= | 
|---|
|  |  |  | #   éå·ï¼ mqtt.enable=true  mqtt.protocolAndDeviceIds=? mqtt.topicAndQos=weather,1;soil,1;manure,1;state,1 | 
|---|
|  |  |  | mqtt.enable=true | 
|---|
|  |  |  | mqtt.topicAndQos=ym/sd1/10000/control/m1,1;ym/sd1/10000/control/m2,1;ym/sd1/control/m4,1;ym/sd1/10000/control/m80,1 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mqtt.protocolAndDeviceIds=sd1/338220031439,sd1/338220031440 | 
|---|
|  |  |  | mqtt.subTopicAndQos=weather,1;soil,1;manure,1;state,1 | 
|---|
|  |  |  | #MQtt设å¤å¨ä¸å®æ¶é´ï¼åéï¼åæªå叿¶æ¯ï¼è®¤ä¸ºè®¾å¤ç¦»çº¿ | 
|---|
|  |  |  | mqtt.noSubThenOff=10 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!-- | 
|---|
|  |  |  | topicAndQos: ä¸»é¢ä¸Qosï¼ä¸»é¢åä¸å
¶Qosç¨éå·éå¼ï¼å¤ä¸ªä¸»é¢åQosç¨åå·éå¼ï¼ä¾å¦ï¼ym/topic1,1;ym/topic2,1;ym/topic3,1ï¼å¦ææå¤ä¸ªOrgTagï¼ä¸»é¢åç¼ç¨å
¶OrgTag | 
|---|
|  |  |  | publishQos: å叿¶æ¯çQosï¼åå¼èå´ï¼ | 
|---|
|  |  |  | enable æ¯å¦å¯å¨ | 
|---|
|  |  |  | svIp MQTTæå¡å¨IP | 
|---|
|  |  |  | svUserName MQTTæå¡å¨ç¨æ·å | 
|---|
|  |  |  | svUserPassword MQTTæå¡å¨ç¨æ·å¯ç  | 
|---|
|  |  |  | poolMaxSize è¿æ¥æ± æå¤§è¿æ¥æ° | 
|---|
|  |  |  | protocolAndDeviceIds å¨åç³»ç»ï¼orgTagï¼ä¸æ¥å
¥ç设å¤(FBox)æç¨åè®®å设å¤idéå,å¤ä¸ªç¨éå·éå¼ï¼åè®®ä¸IDç¨æ£ææ éå¼ï¼ä¾å¦ï¼sd1/338220031439,sd1/338220031440 | 
|---|
|  |  |  | subTopicAndQos: è®¢é
主é¢ä¸Qosï¼ä¸»é¢åä¸å
¶Qosç¨éå·éå¼ï¼å¤ä¸ªä¸»é¢åQosç¨åå·éå¼ï¼ä¾å¦ï¼ym/topic1,1;ym/topic2,1;ym/topic3,1ï¼å¦ææå¤ä¸ªOrgTagï¼ä¸»é¢åç¼ç¨å
¶OrgTag | 
|---|
|  |  |  | pubTopicQos: åå¸ä¸»é¢çQosï¼åå¼èå´ï¼ | 
|---|
|  |  |  | 0    è³å¤ä¸æ¬¡ï¼At most onceï¼    æ¶æ¯åéåä¸ä¿è¯å°è¾¾ï¼å¯è½ä¸¢å¤±æéå¤ï¼å¼éæå°ï¼å¯é æ§æä½ã | 
|---|
|  |  |  | 1    è³å°ä¸æ¬¡ï¼At least onceï¼    æ¶æ¯è³å°ä¼å°è¾¾ä¸æ¬¡ï¼å¯è½éå¤ï¼ä½ä¸ä¼ä¸¢å¤±ï¼å¯é æ§ä¸çï¼éç¨äºå¤æ°åºæ¯ã | 
|---|
|  |  |  | 2    æ°å¥½ä¸æ¬¡ï¼Exactly onceï¼    æ¶æ¯ä»
ä¼å°è¾¾ä¸æ¬¡ï¼ä¸éå¤ä¸ä¸ä¸¢å¤±ï¼å¯é æ§æé«ï¼ä½å¼éæå¤§ï¼å®ç°æå¤æã | 
|---|
|  |  |  | noSubThenOff: MQtt设å¤å¨ä¸å®æ¶é´ï¼åéï¼åæªå叿¶æ¯ï¼è®¤ä¸ºè®¾å¤ç¦»çº¿ | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <mqtt enable="${mqtt.enable}" | 
|---|
|  |  |  | svIp="121.199.41.121" | 
|---|
|  |  |  | 
|---|
|  |  |  | svUserName="dyyjy" | 
|---|
|  |  |  | svUserPassword="Dyyjy2025,;.abc!@#" | 
|---|
|  |  |  | poolMaxSize="10" | 
|---|
|  |  |  | topicAndQos="${mqtt.topicAndQos}" | 
|---|
|  |  |  | publishQos="1" | 
|---|
|  |  |  | protocolAndDeviceIds="${mqtt.protocolAndDeviceIds}" | 
|---|
|  |  |  | subTopicAndQos="${mqtt.subTopicAndQos}" | 
|---|
|  |  |  | pubTopicQos="1" | 
|---|
|  |  |  | noSubThenOff="${mqtt.noSubThenOff}" | 
|---|
|  |  |  | /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </config> | 
|---|