|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 处理发向RTU的外部命令 | 
|---|
|  |  |  | * 处理发向MQTT的外部命令 | 
|---|
|  |  |  | * @return 结果 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private BaseResponse<Command> dealMqttCommand(Command command){ | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 处理发向MQTT的内部部命令 | 
|---|
|  |  |  | * @return 结果 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private BaseResponse<Command> dealMqttInnerCommand(Command command){ | 
|---|
|  |  |  | String mqttDevId = command.getRtuAddr() ;//FBox设备号 | 
|---|
|  |  |  | if(mqttDevId == null || mqttDevId.trim().equals("")){ | 
|---|
|  |  |  | return BaseResponseUtils.buildError(ReturnCommand.errored("出错,FBox设备ID为空!", command.getId(), command.getCode())) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!ServerProperties.mqttUnitEnable.booleanValue()){ | 
|---|
|  |  |  | return BaseResponseUtils.buildError(ReturnCommand.errored("出错,MQTT连接模块配置未启动!", command.getId(), command.getCode())) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(MqttManager.getInstance().poolIsClose()){ | 
|---|
|  |  |  | return BaseResponseUtils.buildError(ReturnCommand.errored("出错,MQTT连接池未创建成功!", command.getId(), command.getCode())) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!DevStatusDealer.oneOnLine(mqttDevId)){ | 
|---|
|  |  |  | return BaseResponseUtils.buildError(ReturnCommand.errored("出错,FBox设备未在线!", command.getId(), command.getCode())) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //生成异步任务 | 
|---|
|  |  |  | WebDownCom4MqttTask task = new WebDownCom4MqttTask() ; | 
|---|
|  |  |  | task.data = command ; | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | log.info("构造下发MQTT命令" + command.getCode() + "的核心任务,并放入任务队列中"); | 
|---|
|  |  |  | CoreUnit.getInstance().pushCoreTask(task); | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | log.error(e.getMessage(), e); | 
|---|
|  |  |  | return BaseResponseUtils.buildError(ReturnCommand.successed("MQTT命令处理失败" + e.getMessage(), command.getId(), command.getCode())) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return BaseResponseUtils.buildSuccess(ReturnCommand.successed("MQTT命令已接受,即将构造并下发命令。", command.getId(), command.getCode())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|