| package com.dy.rtuMw.server.tasks; | 
|   | 
| import com.dy.common.mw.core.CoreTask; | 
| import com.dy.common.mw.protocol.Command; | 
| import com.dy.common.mw.protocol.Driver; | 
| import com.dy.common.mw.protocol.MidResult; | 
| import com.dy.common.mw.protocol.ProtocolCache; | 
| import com.dy.common.mw.protocol4Mqtt.MqttMsgParser; | 
| import com.dy.common.mw.protocol4Mqtt.MqttPubMsg; | 
| import com.dy.rtuMw.server.ServerProperties; | 
| import com.dy.rtuMw.server.forTcp.TcpSessionCache; | 
| import com.dy.rtuMw.server.mqtt.MqttPubMsgCache; | 
| import org.apache.logging.log4j.LogManager; | 
| import org.apache.logging.log4j.Logger; | 
|   | 
| /** | 
|  * @Author: liurunyu | 
|  * @Date: 2025/6/5 15:42 | 
|  * @Description | 
|  */ | 
|   | 
| public class WebDownCom4MqttTask extends CoreTask { | 
|   | 
|     private static Logger log = LogManager.getLogger(WebDownCom4MqttTask.class.getName()); | 
|   | 
|     @Override | 
|     public Integer execute() { | 
|         Command com = (Command)this.data ; | 
|         try { | 
|             log.info("下发MQTT命令" + com.getCode() + "的核心任务开始执行"); | 
|             this.deal(com); | 
|         } catch (Exception e) { | 
|             log.error("处理下行MQTT命令出错" + (e.getMessage()==null?"!":("," + e.getMessage())) ,e); | 
|         } | 
|         return null ; | 
|     } | 
|   | 
|     /** | 
|      * 处理命令 | 
|      * @param com 命令 | 
|      * @throws Exception | 
|      */ | 
|     private void deal(Command com) throws Exception{ | 
|         MqttMsgParser parser = new MqttMsgParser() ; | 
|         MqttPubMsg pubMsg = parser.createPubMsg(ServerProperties.orgTag, com) ; | 
|         if(pubMsg != null){ | 
|             MqttPubMsgCache.cacheCommand(pubMsg); | 
|         } | 
|     } | 
|   | 
| } |