1、协议细化,处理小数;
2、水肥机、气象站、墒情站实体增加属性fboxId(FBox序列号);
18个文件已修改
23个文件已添加
2个文件已删除
1554 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Command.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/MqttTopic.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/CodeSdV1.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/ProtocolParserSdV1.java 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/downVos/ParamSetVo.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/upVos/ManureVo.java 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/upVos/SoilVo.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/upVos/WeatherVo.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/Command4MqttSv.java 137 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrStManure.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrStSoil.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrStWeather.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrStManureMapper.xml 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrStSoilMapper.xml 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrStWeatherMapper.xml 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/Dto4MqttBase.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/common/Cd4MqttParameter.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/common/Com4MqttCtrl.java 193 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/common/Com4MqttSv.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdCtrl.java 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdDto.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdParam.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdStartCtrl.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdStopCtrl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdSv.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/inject/CdCtrl.java 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/inject/CdDto.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/inject/CdParam.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/inject/CdSv.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/irr/CdCtrl.java 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/irr/CdDto.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/irr/CdParam.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/irr/CdSv.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/paramSet/CdCtrl.java 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/paramSet/CdDto.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/paramSet/CdParam.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/paramSet/CdSv.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/stir/CdCtrl.java 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/stir/CdDto.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/stir/CdParam.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/stir/CdSv.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/文档/水肥气象墒情/FlexManager软件配置参数.docx 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Command.java
@@ -41,7 +41,7 @@
    public Short protocolVersion;
    /**
     * RTU åœ°å€
     * RTU地址 å’Œ FBox设备号
     */
    public String rtuAddr ;
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/MqttTopic.java
@@ -16,7 +16,7 @@
    public String orgTag ;//组织标识
    public String protocol ;//协议名称
    public String devId ;//设备(FBox)ID
    public String type;//测站类型
    public String type;//数据(命令)类型
    public Integer no;//测站编号
    public boolean isEmpty(){
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/CodeSdV1.java
@@ -10,5 +10,18 @@
    public static final String cd_Stir = "01" ;//搅拌启停命令
    public static final String cd_Inject = "02" ;//注肥启停命令
    public static final String cd_Irr = "03" ;//灌溉启停命令
    public static final String cd_Param = "10" ;//设定参数
    public static final String cd_Param = "10" ;//设置参数
    public static String getCodeName(String code) {
        String name = (code.equals(cd_Fault) ? "故障解除" :
                (code.equals(cd_Stir) ? "搅拌启停" :
                (code.equals(cd_Inject) ? "注肥启停" :
                (code.equals(cd_Irr) ? "灌溉启停" :
                (code.equals(cd_Param) ? "设置参数" :
                 ""))))) ;
        if(name == null || name.equals("")){
            name = code ;
        }
        return name ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/ProtocolParserSdV1.java
@@ -32,22 +32,43 @@
        DevRunInfo stInfo = null ;
        switch (subTopic.type) {
            case ProtocolConstantSdV1.SubTopicWeather -> {
                vo = JSON.parseObject(strTxt, WeatherVo.class);
                WeatherVo wvo = JSON.parseObject(strTxt, WeatherVo.class);
                //调整小数
                wvo.airTemperature = (wvo.airTemperature == null ? null: (wvo.airTemperature / 10.0F)) ;
                wvo.airHumidity = (wvo.airHumidity == null ? null: (wvo.airHumidity / 10.0F)) ;
                wvo.rainfall = (wvo.rainfall == null ? null: (wvo.rainfall / 10.0F)) ;
                wvo.windSpeed = (wvo.windSpeed == null ? null: (wvo.windSpeed / 10.0F)) ;
                vo = wvo ;
                break;
            }
            case ProtocolConstantSdV1.SubTopicSoil -> {
                vo = JSON.parseObject(strTxt, SoilVo.class);
                SoilVo svo = JSON.parseObject(strTxt, SoilVo.class);
                //调整小数
                svo.soilHumidity1 = (svo.soilHumidity1 == null ? null: (svo.soilHumidity1 / 10.0F)) ;
                svo.soilHumidity2 = (svo.soilHumidity2 == null ? null: (svo.soilHumidity2 / 10.0F)) ;
                svo.soilHumidity3 = (svo.soilHumidity3 == null ? null: (svo.soilHumidity3 / 10.0F)) ;
                svo.soilHumidity4 = (svo.soilHumidity4 == null ? null: (svo.soilHumidity4 / 10.0F)) ;
                svo.soilHumidity5 = (svo.soilHumidity5 == null ? null: (svo.soilHumidity5 / 10.0F)) ;
                svo.soilTemperature1 = (svo.soilTemperature1 == null ? null: (svo.soilTemperature1 / 10.0F)) ;
                svo.soilTemperature2 = (svo.soilTemperature2 == null ? null: (svo.soilTemperature2 / 10.0F)) ;
                svo.soilTemperature3 = (svo.soilTemperature3 == null ? null: (svo.soilTemperature3 / 10.0F)) ;
                svo.soilTemperature4 = (svo.soilTemperature4 == null ? null: (svo.soilTemperature4 / 10.0F)) ;
                svo.soilTemperature5 = (svo.soilTemperature5 == null ? null: (svo.soilTemperature5 / 10.0F)) ;
                vo = svo ;
                break;
            }
            case ProtocolConstantSdV1.SubTopicManure -> {
                vo = JSON.parseObject(strTxt, ManureVo.class);
                ManureVo stVo = (ManureVo)vo ;
                ManureVo mvo = JSON.parseObject(strTxt, ManureVo.class);
                //调整小数
                mvo.manureFlow = (mvo.manureFlow == null ? null: (mvo.manureFlow / 10.0F)) ;
                vo = mvo ;
                stInfo = new DevRunInfo() ;
                stInfo.devId = msg.deviceId ;
                stInfo.stirRunning = (stVo.stirRunning==null?false:(stVo.stirRunning.byteValue()==1?true:false)) ; //搅拌运行 true是 false否
                stInfo.injectRunning = (stVo.injectRunning==null?false:(stVo.injectRunning.byteValue()==1?true:false)) ; //注肥运行 true是 false否
                stInfo.irrRunning = (stVo.irrRunning==null?false:(stVo.irrRunning.byteValue()==1?true:false)) ; //灌溉运行 true是 false否
                stInfo.alarm = (stVo.alarm==null?false:(stVo.alarm.byteValue()==1?true:false)) ; //报警 true是 false否
                stInfo.stirRunning = (mvo.stirRunning1 ==null?false:(mvo.stirRunning1.byteValue()==1?true:false)) ; //搅拌运行 true是 false否
                stInfo.injectRunning = (mvo.injectRunning==null?false:(mvo.injectRunning.byteValue()==1?true:false)) ; //注肥运行 true是 false否
                stInfo.irrRunning = (mvo.irrRunning==null?false:(mvo.irrRunning.byteValue()==1?true:false)) ; //灌溉运行 true是 false否
                stInfo.alarm = (mvo.alarm==null?false:(mvo.alarm.byteValue()==1?true:false)) ; //报警 true是 false否
                break;
            }
            default -> {
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/downVos/ParamSetVo.java
@@ -15,9 +15,15 @@
@NoArgsConstructor
@AllArgsConstructor
public class ParamSetVo implements Vo4Down {
    /**
     * å•位秒
     */
    @JSONField(name = "搅拌设定时间")
    public Integer stirDuration ;
    /**
     * å•位秒
     */
    @JSONField(name = "注肥设定时间")
    public Integer injectDuration ;
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/upVos/ManureVo.java
@@ -17,24 +17,60 @@
    public Integer no ;//测站编号,其不在JSON数据中,其在主题中
    @JSONField(name = "搅拌运行")
    public Byte stirRunning ;//搅拌运行
    /**
     * æ…拌机1是否运行;(水肥机还可存在搅拌机2、搅拌机3、搅拌机4 ......) è¿è¡Œæ—¶1,停止0.
     */
    @JSONField(name = "搅拌运行1")
    public Byte stirRunning1;//搅拌1运行状态
    /**
     * æ…拌机2是否运行;(水肥机还可存在搅拌机2、搅拌机3、搅拌机4 ......) è¿è¡Œæ—¶1,停止0.
     * (当前大禹应用不存在)
     */
    @JSONField(name = "搅拌运行2")
    public Byte stirRunning2;//搅拌2运行状态
    /**
     * æ…拌机3是否运行;(水肥机还可存在搅拌机2、搅拌机3、搅拌机4 ......) è¿è¡Œæ—¶1,停止0.
     * (当前大禹应用不存在)
     */
    @JSONField(name = "搅拌运行3")
    public Byte stirRunning3;//搅拌3运行状态
    /**
     * æ…拌机4是否运行;(水肥机还可存在搅拌机2、搅拌机3、搅拌机4 ......) è¿è¡Œæ—¶1,停止0.
     * (当前大禹应用不存在)
     */
    @JSONField(name = "搅拌运行4")
    public Byte stirRunning4;//搅拌4运行状态
    /**
     * ä¸€ä¸ªæ°´è‚¥æœºåªæœ‰ä¸€ä¸ªæ³¨è‚¥æ³µ
     */
    @JSONField(name = "注肥运行")
    public Byte injectRunning ;//注肥运行
    public Byte injectRunning ;//注肥运行状态
    @JSONField(name = "灌溉运行")
    public Byte irrRunning ;//灌溉运行
    public Byte irrRunning ;//灌溉运行状态
    /**
     *  1:注肥泵有故障。0:注肥泵没有故障
     */
    @JSONField(name = "报警")
    public Byte alarm ;//报警
    public Byte alarm ;//注肥泵故障
    /**
     * è‚¥æ–™æµé‡ï¼Œå•位升
     */
    @JSONField(name = "肥料流量")
    public Float manureFlow ;
    /**
     * å•位秒
     */
    @JSONField(name = "注肥经过时间")
    public Integer manureTime ;
    /**
     * å•位秒
     */
    @JSONField(name = "搅拌经过时间")
    public Integer stirTime ;
@@ -61,7 +97,7 @@
        StringBuilder sb = new StringBuilder();
        sb.append("水肥数据=>") ;
        sb.append(" æ¶ˆæ¯ID:" + messageId + ", ") ;
        sb.append(" æ…拌运行:" + stirRunning + ", ") ;
        sb.append(" æ…拌运行:" + stirRunning1 + ", ") ;
        sb.append(" æ³¨è‚¥è¿è¡Œï¼š" + injectRunning + ", ") ;
        sb.append(" çŒæº‰è¿è¡Œï¼š" + irrRunning + ", ") ;
        sb.append(" æŠ¥è­¦ï¼š" + alarm + ", ") ;
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/upVos/SoilVo.java
@@ -18,34 +18,34 @@
    public Integer no ;//测站编号,其不在JSON数据中,其在主题中
    @JSONField(name = "土壤湿度1")
    public Integer soilHumidity1 ;
    public Float soilHumidity1 ;
    @JSONField(name = "土壤湿度2")
    public Integer soilHumidity2 ;
    public Float soilHumidity2 ;
    @JSONField(name = "土壤湿度3")
    public Integer soilHumidity3 ;
    public Float soilHumidity3 ;
    @JSONField(name = "土壤湿度4")
    public Integer soilHumidity4 ;
    public Float soilHumidity4 ;
    @JSONField(name = "土壤湿度5")
    public Integer soilHumidity5 ;
    public Float soilHumidity5 ;
    @JSONField(name = "土壤湿度1")
    public Integer soilTemperature1 ;
    public Float soilTemperature1 ;
    @JSONField(name = "土壤温度2")
    public Integer soilTemperature2 ;
    public Float soilTemperature2 ;
    @JSONField(name = "土壤温度3")
    public Integer soilTemperature3 ;
    public Float soilTemperature3 ;
    @JSONField(name = "土壤温度4")
    public Integer soilTemperature4 ;
    public Float soilTemperature4 ;
    @JSONField(name = "土壤温度5")
    public Integer soilTemperature5 ;
    public Float soilTemperature5 ;
    @JSONField(name = "flexem_timestamp")
    public Long devDt ;//设备时间
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol4Mqtt/pSdV1/upVos/WeatherVo.java
@@ -25,10 +25,10 @@
    //public Integer atmosphericPressure ;
    @JSONField(name = "空气温度")
    public Integer airTemperature ;
    public Float airTemperature ;
    @JSONField(name = "空气湿度")
    public Integer airHumidity ;
    public Float airHumidity ;
    @JSONField(name = "紫外线")
    public Integer ultraviolet ;
@@ -37,10 +37,10 @@
    public Integer lightIntensity ;
    @JSONField(name = "雨量")
    public Integer rainfall ;
    public Float rainfall ;
    @JSONField(name = "风速")
    public Integer windSpeed ;
    public Float windSpeed ;
    @JSONField(name = "风向")
    public Integer windDirection ;
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/Command4MqttSv.java
New file
@@ -0,0 +1,137 @@
package com.dy.pipIrrGlobal.command;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol.CommandBackParam;
import com.dy.common.mw.protocol4Mqtt.pSdV1.CodeSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1;
import com.dy.common.webUtil.BaseResponse;
import com.dy.pipIrrGlobal.daoPr.PrStManureMapper;
import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper;
import com.dy.pipIrrGlobal.pojoPr.PrStManure;
import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw;
import java.util.Date;
/**
 * @Author: liurunyu
 * @Date: 2025/5/6 11:41
 * @Description
 */
public class Command4MqttSv extends Web2RtuMw {
    /**
     * ä»Žæ•°æ®åº“中查询水肥机对象
     * @param prStManureDao
     * @param manureId
     * @return
     */
    public PrStManure getManure(PrStManureMapper prStManureDao, Long manureId){
        return prStManureDao.selectByPrimaryKey(manureId);
    }
    /**
     * æ£€æŸ¥åè®®æ˜¯å¦æ”¯æŒ
     * @param ctrlPo
     * @return
     */
    public String checkProtocol(PrStManure ctrlPo){
        return null ;
    }
    /**
     * æ ¹æ®åè®®èŽ·å–å‘½ä»¤åç§°
     * @param nowComCode
     * @param protocol
     * @return
     */
    public String getCommandName(String nowComCode, String protocol, Short protocolVer){
        if(protocol.equals(ProtocolConstantSdV1.protocolName)
            && protocolVer.equals(ProtocolConstantSdV1.protocolVer)) {
            return CodeSdV1.getCodeName(nowComCode) ;
        }
        return null ;
    }
    /**
     * ä¿å­˜å‘½ä»¤åŽ†å²è®°å½•
     * @param rmCommandHistoryDao
     * @param comId
     * @param protocol
     * @param commandCode
     * @param commandName
     * @param manureId
     * @param rtuAddr
     * @param param
     * @param operator
     * @return
     */
    public RmCommandHistory saveComHistoryPo(RmCommandHistoryMapper rmCommandHistoryDao,
                                             Long comId,
                                             String protocol,
                                             String commandCode,
                                             String commandName,
                                             Long manureId,
                                             String rtuAddr,
                                             Object param,
                                             Long operator) {
        RmCommandHistory po = new RmCommandHistory();
        po.setComId(comId);
        po.setCommandCode(commandCode);
        po.setCommandName(commandName);
        po.setIntakeId(manureId);
        po.setRtuAddr(rtuAddr);
        po.setProtocol(protocol);
        po.setParam((JSONObject) JSON.toJSON(param));
        po.setSendTime(new Date());
        po.setOperator(operator);
        int count = rmCommandHistoryDao.insertSelective(po) ;
        if(count == 0){
            po = null ;
        }
        return po;
    }
    /**
     * å¤„理通信中间件返回的命令处理结果
     * @param res
     * @return
     */
    public String dealMwDealResponse(BaseResponse res){
        if(res != null){
            Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ;
            CommandBackParam bakParam = JSON.parseObject((reCom== null || reCom.param == null) ? null : JSON.toJSONString(reCom.param), CommandBackParam.class) ;
            if(res.isSuccess()){
                if(bakParam != null){
                    if(bakParam.getSuccess().booleanValue()){
                        //通信中间件成功处理了命令
                        //等待控制器接收并执行命令后的应答,然后通信中间件通知本模块
                        return null ;
                    }else{
                        return "通信中间件处理命令失败,失败信息:" + bakParam.getMessage();
                    }
                }else{
                    return "通信中间件返回命令结果中不包含CommandBackParam类型参数";
                }
            }else{
                if(bakParam != null){
                    if(bakParam.getSuccess().booleanValue()){
                        //通信中间件成功处理了命令
                        //等待控制器接收并执行命令后的应答,然后通信中间件通知本模块
                        return "通信中间件处理命令失败,失败信息:" + (res.getMsg() == null? "" : ("," + res.getMsg())) ;
                    }else{
                        return "通信中间件处理命令失败,失败信息:" + bakParam.getMessage();
                    }
                }else{
                    return "通信中间件处理命令失败,失败信息:" + (res.getMsg() == null? "" : ("," + res.getMsg())) ;
                }
            }
        }else{
            return "通信中间件返回命令结果为null";
        }
    }
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrStManure.java
@@ -37,6 +37,12 @@
    public Long id;
    /**
     * FBox序列号
     */
    @Schema(description = "FBox序列号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    public String fboxId ;
    /**
     * æ°´è‚¥ç«™ç¼–号
     */
    @Schema(description = "水肥站编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrStSoil.java
@@ -37,6 +37,12 @@
    public Long id;
    /**
     * FBox序列号
     */
    @Schema(description = "FBox序列号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    public String fboxId ;
    /**
     * å¢’情站编号
     */
    @Schema(description = "墒情站编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoPr/PrStWeather.java
@@ -37,6 +37,12 @@
    public Long id;
    /**
     * FBox序列号
     */
    @Schema(description = "FBox序列号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    public String fboxId ;
    /**
     * æ°”象站编号
     */
    @Schema(description = "气象站编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrStManureMapper.xml
@@ -6,6 +6,7 @@
    <!--@Table pr_st_manure-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="no" jdbcType="INTEGER" property="no" />
    <result column="fbox_id" jdbcType="VARCHAR" property="fboxId" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="lng" jdbcType="DOUBLE" property="lng" />
    <result column="lat" jdbcType="DOUBLE" property="lat" />
@@ -14,11 +15,11 @@
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, `no`, `name`, lng, lat, remark, deleted
    id, fbox_id,`no`, `name`, lng, lat, remark, deleted
  </sql>
  <sql id="part_Column_List">
    <!--@mbg.generated-->
    id, `no`, `name`, lng, lat, remark
    id, fbox_id, `no`, `name`, lng, lat, remark
  </sql>
  <sql id="simple_Column_List">
    <!--@mbg.generated-->
@@ -50,11 +51,11 @@
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStManure">
    <!--@mbg.generated-->
    insert into pr_st_manure (id, `no`, `name`, lng,
    insert into pr_st_manure (id, fbox_id, `no`, `name`, lng,
      lat, remark, deleted)
    values (#{id,jdbcType=BIGINT}, #{no,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
        #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, #{remark,jdbcType=VARCHAR},
        #{deleted,jdbcType=TINYINT})
    values (#{id,jdbcType=BIGINT}, #{fboxId,jdbcType=BIGINT}, #{no,jdbcType=INTEGER},
        #{name,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE},
        #{remark,jdbcType=VARCHAR},#{deleted,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStManure">
    <!--@mbg.generated-->
@@ -62,6 +63,9 @@
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="fboxId != null">
        fbox_id,
      </if>
      <if test="no != null">
        `no`,
@@ -85,6 +89,9 @@
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="fboxId != null">
        #{fboxId,jdbcType=BIGINT},
      </if>
      <if test="no != null">
        #{no,jdbcType=INTEGER},
@@ -110,6 +117,9 @@
    <!--@mbg.generated-->
    update pr_st_manure
    <set>
      <if test="fboxId != null">
        fbox_id = #{fboxId,jdbcType=BIGINT},
      </if>
      <if test="no != null">
        `no` = #{no,jdbcType=INTEGER},
      </if>
@@ -134,7 +144,8 @@
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStManure">
    <!--@mbg.generated-->
    update pr_st_manure
    set `no` = #{no,jdbcType=INTEGER},
    set fbox_id = #{fboxId,jdbcType=INTEGER},
      `no` = #{no,jdbcType=INTEGER},
      `name` = #{name,jdbcType=VARCHAR},
      lng = #{lng,jdbcType=DOUBLE},
      lat = #{lat,jdbcType=DOUBLE},
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrStSoilMapper.xml
@@ -6,6 +6,7 @@
    <!--@Table pr_st_soil-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="no" jdbcType="INTEGER" property="no" />
    <result column="fbox_id" jdbcType="VARCHAR" property="fboxId" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="lng" jdbcType="DOUBLE" property="lng" />
    <result column="lat" jdbcType="DOUBLE" property="lat" />
@@ -14,11 +15,11 @@
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, `no`, `name`, lng, lat, remark, deleted
    id, fbox_id,`no`, `name`, lng, lat, remark, deleted
  </sql>
  <sql id="part_Column_List">
    <!--@mbg.generated-->
    id, `no`, `name`, lng, lat, remark
    id, fbox_id, `no`, `name`, lng, lat, remark
  </sql>
  <sql id="simple_Column_List">
    <!--@mbg.generated-->
@@ -50,11 +51,11 @@
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStSoil">
    <!--@mbg.generated-->
    insert into pr_st_soil (id, `no`, `name`, lng,
    insert into pr_st_soil (id, fbox_id, `no`, `name`, lng,
    lat, remark, deleted)
    values (#{id,jdbcType=BIGINT}, #{no,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
    #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, #{remark,jdbcType=VARCHAR},
    #{deleted,jdbcType=TINYINT})
    values (#{id,jdbcType=BIGINT}, #{fboxId,jdbcType=BIGINT}, #{no,jdbcType=INTEGER},
    #{name,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE},
    #{remark,jdbcType=VARCHAR},#{deleted,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStSoil">
    <!--@mbg.generated-->
@@ -62,6 +63,9 @@
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="fboxId != null">
        fbox_id,
      </if>
      <if test="no != null">
        `no`,
@@ -85,6 +89,9 @@
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="fboxId != null">
        #{fboxId,jdbcType=BIGINT},
      </if>
      <if test="no != null">
        #{no,jdbcType=INTEGER},
@@ -110,6 +117,9 @@
    <!--@mbg.generated-->
    update pr_st_soil
    <set>
      <if test="fboxId != null">
        fbox_id = #{fboxId,jdbcType=BIGINT},
      </if>
      <if test="no != null">
        `no` = #{no,jdbcType=INTEGER},
      </if>
@@ -134,7 +144,8 @@
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStSoil">
    <!--@mbg.generated-->
    update pr_st_soil
    set `no` = #{no,jdbcType=INTEGER},
    set fbox_id = #{fboxId,jdbcType=INTEGER},
    `no` = #{no,jdbcType=INTEGER},
    `name` = #{name,jdbcType=VARCHAR},
    lng = #{lng,jdbcType=DOUBLE},
    lat = #{lat,jdbcType=DOUBLE},
pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrStWeatherMapper.xml
@@ -6,6 +6,7 @@
    <!--@Table pr_st_weather-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="no" jdbcType="INTEGER" property="no" />
    <result column="fbox_id" jdbcType="VARCHAR" property="fboxId" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="lng" jdbcType="DOUBLE" property="lng" />
    <result column="lat" jdbcType="DOUBLE" property="lat" />
@@ -14,11 +15,11 @@
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, `no`, `name`, lng, lat, remark, deleted
    id, fbox_id,`no`, `name`, lng, lat, remark, deleted
  </sql>
  <sql id="part_Column_List">
    <!--@mbg.generated-->
    id, `no`, `name`, lng, lat, remark
    id, fbox_id, `no`, `name`, lng, lat, remark
  </sql>
  <sql id="simple_Column_List">
    <!--@mbg.generated-->
@@ -50,11 +51,11 @@
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStWeather">
    <!--@mbg.generated-->
    insert into pr_st_weather (id, `no`, `name`, lng,
    insert into pr_st_weather (id, fbox_id, `no`, `name`, lng,
    lat, remark, deleted)
    values (#{id,jdbcType=BIGINT}, #{no,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
    #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE}, #{remark,jdbcType=VARCHAR},
    #{deleted,jdbcType=TINYINT})
    values (#{id,jdbcType=BIGINT}, #{fboxId,jdbcType=BIGINT}, #{no,jdbcType=INTEGER},
    #{name,jdbcType=VARCHAR}, #{lng,jdbcType=DOUBLE}, #{lat,jdbcType=DOUBLE},
    #{remark,jdbcType=VARCHAR},#{deleted,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStWeather">
    <!--@mbg.generated-->
@@ -62,6 +63,9 @@
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="fboxId != null">
        fbox_id,
      </if>
      <if test="no != null">
        `no`,
@@ -85,6 +89,9 @@
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="fboxId != null">
        #{fboxId,jdbcType=BIGINT},
      </if>
      <if test="no != null">
        #{no,jdbcType=INTEGER},
@@ -110,6 +117,9 @@
    <!--@mbg.generated-->
    update pr_st_weather
    <set>
      <if test="fboxId != null">
        fbox_id = #{fboxId,jdbcType=BIGINT},
      </if>
      <if test="no != null">
        `no` = #{no,jdbcType=INTEGER},
      </if>
@@ -134,7 +144,8 @@
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoPr.PrStWeather">
    <!--@mbg.generated-->
    update pr_st_weather
    set `no` = #{no,jdbcType=INTEGER},
    set fbox_id = #{fboxId,jdbcType=INTEGER},
    `no` = #{no,jdbcType=INTEGER},
    `name` = #{name,jdbcType=VARCHAR},
    lng = #{lng,jdbcType=DOUBLE},
    lat = #{lat,jdbcType=DOUBLE},
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
@@ -375,15 +375,15 @@
     * @return ç»“æžœ
     */
    private BaseResponse<Command> dealMqttCommand(Command command){
        String rtuAddr = command.getRtuAddr() ;
        String rtuAddr = command.getRtuAddr() ;//FBox设备号
        if(rtuAddr == null || rtuAddr.trim().equals("")){
            return BaseResponseUtils.buildError(ReturnCommand.errored("出错,设备ID为空!", command.getId(), command.getCode())) ;
            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())) ;
            return BaseResponseUtils.buildError(ReturnCommand.errored("出错,MQTT连接池未创建成功!", command.getId(), command.getCode())) ;
        }
        //生成异步任务
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/dto/Dto4MqttBase.java
New file
@@ -0,0 +1,33 @@
package com.dy.pipIrrRemote.common.dto;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
 * @author ZhuBaoMin
 * @date 2024-05-22 16:54
 * @LastEditTime 2024-05-22 16:54
 * @Description è®¾ç½®å‘½ä»¤åŸºç±»
 */
@Data
public class Dto4MqttBase {
    public static final long serialVersionUID = 202506201459001L;
    /**
     * æ°´è‚¥æœºID
     */
    @NotNull(message = "水肥机不能为空")
    public Long manureId;
    /**
     * æ°´è‚¥æœºåç§°
     */
    public String manureName;
    /**
     * æ“ä½œäºº
     */
    @NotNull(message = "操作人不能为空")
    public Long operator;
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/common/Cd4MqttParameter.java
New file
@@ -0,0 +1,16 @@
package com.dy.pipIrrRemote.monitor.common;
import lombok.Data;
import lombok.experimental.SuperBuilder;
/**
 * @Author: liurunyu
 * @Date: 2025/5/9 16:11
 * @Description
 */
@Data
@SuperBuilder
public class Cd4MqttParameter {
    //命令功能码
    public String commandCode;
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/common/Com4MqttCtrl.java
New file
@@ -0,0 +1,193 @@
package com.dy.pipIrrRemote.monitor.common;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.mw.protocol.Command;
import com.dy.common.util.Callback;
import com.dy.common.util.IDLongGenerator;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrGlobal.command.ComResultWait;
import com.dy.pipIrrGlobal.pojoPr.PrStManure;
import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
import com.dy.pipIrrRemote.common.dto.Dto4MqttBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.validation.BindingResult;
import org.springframework.web.client.RestTemplate;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
/**
 * @Author: liurunyu
 * @Date: 2025/5/9 14:53
 * @Description
 */
public abstract class Com4MqttCtrl {
    @Autowired
    protected Environment env ;
    @Autowired
    protected RestTemplate restTemplate ;
    @Value("${mw.waitMwRtnResultTimeout}")
    protected int waitMwRtnResultTimeout ;
    @Value("${mw.rtuCallbackUrl_rm}")
    protected String rtuResultSendWebUrl;
    //水肥机对象
    protected PrStManure ctrlPo ;
    //异步等待器
    protected CompletableFuture<JSONObject> feature;
    //命令名称
    protected String comName ;
    //命令日志id
    protected Long comId ;
    /**
     * å‘送命令前-1:验证
     * @param comSv
     * @param comCode
     * @param dto
     * @param bindingResult
     * @return
     */
    public BaseResponse<Object> pre1(Com4MqttSv comSv, String comCode, Dto4MqttBase dto, BindingResult bindingResult) {
        if (bindingResult != null && bindingResult.hasErrors()) {
            return BaseResponseUtils.buildError(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        String msg = this.checkDto(dto) ;
        if(msg != null){
            return BaseResponseUtils.buildError("服务端出错," + msg) ;
        }
        return  null ;
    }
    /**
     * å‘送命令前-2:获得数据
     * @param comSv
     * @param protocol
     * @param protocolVer
     * @param comCode
     * @param dto
     * @param bindingResult
     * @return
     */
    public BaseResponse<Object> pre2(Com4MqttSv comSv, String protocol, Short protocolVer, String comCode, Dto4MqttBase dto, BindingResult bindingResult) {
        //得到水肥机对象
        ctrlPo = comSv.getManure(dto.getManureId());
        if (ctrlPo == null) {
            return BaseResponseUtils.buildError("服务端出错,从数据库中未得到水肥机数据") ;
        }
        //检查协议
        String msg = comSv.checkProtocol(ctrlPo) ;
        if(msg != null) {
            return BaseResponseUtils.buildError("服务端出错," + msg) ;
        }
        //得到功能码对应的命令名称
        comName = comSv.getCommandName(comCode, protocol, protocolVer) ;
        if(comName == null) {
            return BaseResponseUtils.buildError("服务端出错,未得到功能码对应命令名称") ;
        }
        return  null ;
    }
    /**
     * å‘送命令前-3:保存命令日志
     * @param comSv sv对象
     * @param manureId æ°´è‚¥æœºID
     * @param operator å½“前用登录用户id(操作人)
     * @param protocol åè®®
     * @param protocolVerion åè®®
     * @param comCode åŠŸèƒ½ç 
     * @param param å‘½ä»¤å‚æ•°
     * @return
     */
    public BaseResponse<Object> pre3(Com4MqttSv comSv, Long manureId, Long operator, String protocol, Short protocolVerion, String comCode, Cd4MqttParameter param) {
        comId = new IDLongGenerator().generate();
        //生成并保存命令日志
        RmCommandHistory po = comSv.saveComHistoryPo(comId,
                protocol + protocolVerion ,
                comCode,
                comName,
                manureId,
                ctrlPo.fboxId ,
                param,
                operator);
        if(po == null){
            return BaseResponseUtils.buildError("服务端出错,未能生成并保存命令日志") ;
        }
        return  null ;
    }
    /**
     * å‘送命令前-4:准备Feature
     * @return
     */
    public void pre4() {
        feature = new CompletableFuture<>();
        ComResultWait.put(comId, feature);
    }
    /**
     * å‘送命令
     * @param comSv
     * @param com
     * @return
     */
    public BaseResponse<Object> doSend(Com4MqttSv comSv, Command com){
        //得到通信中间件发送命令的web URL
        String rqUrl = comSv.get2MwRequestUrl(env, comSv.ContextComSend) ;
        //向通信中间件发送web请求
        BaseResponse res = comSv.sendPostRequest2Mw(restTemplate, rqUrl, com) ;
        //处理通信中间件对web请求的响应
        String msg = comSv.dealMwDealResponse(res) ;
        if(msg != null) {
            return BaseResponseUtils.buildError(msg) ;
        }else{
            return null ;
        }
    }
    /**
     * å‘送命令后
     * @return
     */
    public BaseResponse<Object> after(String comCode, Callback callback) {
        try{
            //等待通信中间件通知水肥机执行命令上行数据(命令结果)
            JSONObject resultData = feature.get(waitMwRtnResultTimeout, TimeUnit.SECONDS);
            return BaseResponseUtils.buildSuccess(this.dealComResult(comCode, resultData, callback));
        }catch (Exception e){
            return BaseResponseUtils.buildFail("等待通信中间件通知命令结果超时");
        }
    }
    /**
     * å‘送命令最后
     * @return
     */
    public void end(){
        try {
            //最后清除CompletableFuture缓存
            if(ComResultWait.contain(comId)){
                ComResultWait.remove(comId);
            }
        }catch (Exception ee){}
    }
    /**
     * éªŒè¯
     * @param dto
     * @return
     */
    protected abstract String checkDto(Dto4MqttBase dto) ;
    /**
     * ç”Ÿæˆå‘½ä»¤è¿”回信息
     */
    protected abstract String dealComResult(String code, JSONObject resultData, Callback callback);
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/common/Com4MqttSv.java
New file
@@ -0,0 +1,50 @@
package com.dy.pipIrrRemote.monitor.common;
import com.dy.pipIrrGlobal.command.Command4MqttSv;
import com.dy.pipIrrGlobal.daoPr.PrStManureMapper;
import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper;
import com.dy.pipIrrGlobal.pojoPr.PrStManure;
import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
/**
 * @Author: liurunyu
 * @Date: 2025/5/9 14:45
 * @Description
 */
public class Com4MqttSv extends Command4MqttSv {
    @Autowired
    protected PrStManureMapper prStManureDao ;
    @Autowired
    protected RmCommandHistoryMapper rmCommandHistoryDao ;
    public PrStManure getManure(Long manureId){
        return this.getManure(prStManureDao, manureId);
    }
    /**
     * åˆ›å»ºå‘½ä»¤æ—¥å¿—对象
     *
     * @param comId       ä¸»é”®
     * @param commandCode åŠŸèƒ½ç 
     * @param rtuAddr     é˜€æŽ§å™¨åœ°å€
     * @param protocol    é€šè®¯åè®®åç§°
     * @param param       å‚数数据
     * @param operator    æ“ä½œå‘˜
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public RmCommandHistory saveComHistoryPo(Long comId,
                                             String protocol,
                                             String commandCode,
                                             String commandName,
                                             Long manureId,
                                             String rtuAddr,
                                             Object param,
                                             Long operator) {
        return this.saveComHistoryPo(rmCommandHistoryDao, comId, protocol, commandCode, commandName, manureId, rtuAddr, param, operator) ;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdCtrl.java
New file
@@ -0,0 +1,122 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.fault;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.aop.SsoAop;
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol4Mqtt.pSdV1.CodeSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.ManureVo;
import com.dy.common.util.Callback;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrRemote.common.dto.Dto4MqttBase;
import com.dy.pipIrrRemote.monitor.common.Com4MqttCtrl;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:35
 * @Description
 */
@Slf4j
@Tag(name = "远程命令", description = "清除故障")
@RestController("mqttSd1FaultCtrl")
@RequestMapping(path = "mqttSd1/faultCtrl")
@RequiredArgsConstructor
@Scope("prototype") //因为有对象类属性,所以采用原型模式,每次请求新建一个实例对象
public class CdCtrl extends Com4MqttCtrl {
    private static final String RtuSuccessMsg = "控制器接收并执行命令成功,无返回数据";
    private static final String Protocol = ProtocolConstantSdV1.protocolName ;
    private static final Short ProtocolVersion = ProtocolConstantSdV1.protocolVer ;
    private static final String ComCode = CodeSdV1.cd_Fault ;
    @Autowired
    private CdSv sv ;
    /**
     * å‘设备(Mqtt中间件->FBox)发送命令
     * @param dto å‰ç«¯å‘来的值对象
     * @param bindingResult å¯¹dto验证的结果
     * @return è¿”回前端
     */
    @PostMapping(path = "send", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoAop()
    public BaseResponse<Object> send(@RequestBody @Valid CdDto dto, BindingResult bindingResult) {
        BaseResponse<Object> res ;
        //发送命令前-1:验证
        res = super.pre1(sv, ComCode, dto, bindingResult);
        if(res == null) {
            //发送命令前-2:获得数据
            res = super.pre2(sv, Protocol, ProtocolVersion, ComCode, dto, bindingResult);
            if (res == null) {
                //发送命令前-3:保存命令日志
                CdParam comParam = CdParam.builder().commandCode(ComCode).build();
                res = super.pre3(sv, dto.manureId, dto.getOperator(), Protocol, ProtocolVersion, ComCode, comParam);
                if (res == null) {
                    //发送命令前-4:准备Feature
                    super.pre4();
                    try {
                        //创建外部命令(发给控制器)
                        Command com = sv.createOuterCommand(ctrlPo.fboxId, "" + comId, ComCode);
                        com.rtuResultSendWebUrl = rtuResultSendWebUrl;
                        com.param = comParam ;
                        //发送命令
                        res = super.doSend(sv, com);
                        if (res == null) {
                            //发送命令后
                            res = super.after(ComCode, null);
                        }
                    } catch (Exception e) {
                        res = BaseResponseUtils.buildFail("服务端构造并向通信中间件发送请求时异常" + (e.getMessage() == null ? "" : e.getMessage()));
                    } finally {
                        //最终
                        super.end();
                    }
                }
            }
        }
        return res ;
    }
    @Override
    protected String checkDto(Dto4MqttBase dto) {
        return null;
    }
    @Override
    protected String dealComResult(String code, JSONObject resultData, Callback callback){
        String msg;
        if(resultData != null){
            log.info(resultData.toString());
            JSONObject codeData = resultData.getJSONObject("data") ;
            if(codeData == null){
                msg = RtuSuccessMsg ;
            }else {
                String json = codeData.toJSONString();
                ManureVo cvo = JSON.parseObject(json, ManureVo.class) ;
                if(cvo != null){
                    msg = cvo.toString() ;
                }else{
                    msg = RtuSuccessMsg ;
                }
            }
        }else{
            msg = RtuSuccessMsg ;
        }
        return msg;
    }}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdDto.java
@@ -1,6 +1,6 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.fault;
import com.dy.pipIrrRemote.common.dto.DtoBase;
import com.dy.pipIrrRemote.common.dto.Dto4MqttBase;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -11,6 +11,6 @@
 */
@Data
@EqualsAndHashCode(callSuper=true)
public class CdDto extends DtoBase {
    public static final long serialVersionUID = 202506161739001L;
public class CdDto extends Dto4MqttBase {
    public static final long serialVersionUID = 202506501650001L;
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdParam.java
@@ -1,9 +1,19 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.fault;
import com.dy.pipIrrRemote.monitor.common.Cd4MqttParameter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
public class CdParam {
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public class CdParam extends Cd4MqttParameter {
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdStartCtrl.java
File was deleted
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdStopCtrl.java
File was deleted
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/fault/CdSv.java
@@ -1,6 +1,6 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.fault;
import com.dy.pipIrrRemote.monitor.common.ComSv;
import com.dy.pipIrrRemote.monitor.common.Com4MqttSv;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -10,6 +10,6 @@
 * @Description
 */
@Slf4j
@Service("faultSv")
public class CdSv extends ComSv {
@Service("mqttSd1FaultSv")
public class CdSv extends Com4MqttSv {
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/inject/CdCtrl.java
New file
@@ -0,0 +1,122 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.inject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.aop.SsoAop;
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol4Mqtt.pSdV1.CodeSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.ManureVo;
import com.dy.common.util.Callback;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrRemote.common.dto.Dto4MqttBase;
import com.dy.pipIrrRemote.monitor.common.Com4MqttCtrl;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:35
 * @Description
 */
@Slf4j
@Tag(name = "远程命令", description = "清除故障")
@RestController("mqttSd1InjectCtrl")
@RequestMapping(path = "mqttSd1/injectCtrl")
@RequiredArgsConstructor
@Scope("prototype") //因为有对象类属性,所以采用原型模式,每次请求新建一个实例对象
public class CdCtrl extends Com4MqttCtrl {
    private static final String RtuSuccessMsg = "控制器接收并执行命令成功,无返回数据";
    private static final String Protocol = ProtocolConstantSdV1.protocolName ;
    private static final Short ProtocolVersion = ProtocolConstantSdV1.protocolVer ;
    private static final String ComCode = CodeSdV1.cd_Inject ;
    @Autowired
    private CdSv sv ;
    /**
     * å‘设备(Mqtt中间件->FBox)发送命令
     * @param dto å‰ç«¯å‘来的值对象
     * @param bindingResult å¯¹dto验证的结果
     * @return è¿”回前端
     */
    @PostMapping(path = "send", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoAop()
    public BaseResponse<Object> send(@RequestBody @Valid CdDto dto, BindingResult bindingResult) {
        BaseResponse<Object> res ;
        //发送命令前-1:验证
        res = super.pre1(sv, ComCode, dto, bindingResult);
        if(res == null) {
            //发送命令前-2:获得数据
            res = super.pre2(sv, Protocol, ProtocolVersion, ComCode, dto, bindingResult);
            if (res == null) {
                //发送命令前-3:保存命令日志
                CdParam comParam = CdParam.builder().commandCode(ComCode).build();
                res = super.pre3(sv, dto.manureId, dto.getOperator(), Protocol, ProtocolVersion, ComCode, comParam);
                if (res == null) {
                    //发送命令前-4:准备Feature
                    super.pre4();
                    try {
                        //创建外部命令(发给控制器)
                        Command com = sv.createOuterCommand(ctrlPo.fboxId, "" + comId, ComCode);
                        com.rtuResultSendWebUrl = rtuResultSendWebUrl;
                        com.param = comParam ;
                        //发送命令
                        res = super.doSend(sv, com);
                        if (res == null) {
                            //发送命令后
                            res = super.after(ComCode, null);
                        }
                    } catch (Exception e) {
                        res = BaseResponseUtils.buildFail("服务端构造并向通信中间件发送请求时异常" + (e.getMessage() == null ? "" : e.getMessage()));
                    } finally {
                        //最终
                        super.end();
                    }
                }
            }
        }
        return res ;
    }
    @Override
    protected String checkDto(Dto4MqttBase dto) {
        return null;
    }
    @Override
    protected String dealComResult(String code, JSONObject resultData, Callback callback){
        String msg;
        if(resultData != null){
            log.info(resultData.toString());
            JSONObject codeData = resultData.getJSONObject("data") ;
            if(codeData == null){
                msg = RtuSuccessMsg ;
            }else {
                String json = codeData.toJSONString();
                ManureVo cvo = JSON.parseObject(json, ManureVo.class) ;
                if(cvo != null){
                    msg = cvo.toString() ;
                }else{
                    msg = RtuSuccessMsg ;
                }
            }
        }else{
            msg = RtuSuccessMsg ;
        }
        return msg;
    }}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/inject/CdDto.java
New file
@@ -0,0 +1,16 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.inject;
import com.dy.pipIrrRemote.common.dto.Dto4MqttBase;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Data
@EqualsAndHashCode(callSuper=true)
public class CdDto extends Dto4MqttBase {
    public static final long serialVersionUID = 202506201653001L;
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/inject/CdParam.java
New file
@@ -0,0 +1,19 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.inject;
import com.dy.pipIrrRemote.monitor.common.Cd4MqttParameter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public class CdParam extends Cd4MqttParameter {
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/inject/CdSv.java
New file
@@ -0,0 +1,15 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.inject;
import com.dy.pipIrrRemote.monitor.common.Com4MqttSv;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Slf4j
@Service("mqttSd1InjectSv")
public class CdSv extends Com4MqttSv {
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/irr/CdCtrl.java
New file
@@ -0,0 +1,122 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.irr;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.aop.SsoAop;
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol4Mqtt.pSdV1.CodeSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.ManureVo;
import com.dy.common.util.Callback;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrRemote.common.dto.Dto4MqttBase;
import com.dy.pipIrrRemote.monitor.common.Com4MqttCtrl;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:35
 * @Description
 */
@Slf4j
@Tag(name = "远程命令", description = "清除故障")
@RestController("mqttSd1IrrCtrl")
@RequestMapping(path = "mqttSd1/irrCtrl")
@RequiredArgsConstructor
@Scope("prototype") //因为有对象类属性,所以采用原型模式,每次请求新建一个实例对象
public class CdCtrl extends Com4MqttCtrl {
    private static final String RtuSuccessMsg = "控制器接收并执行命令成功,无返回数据";
    private static final String Protocol = ProtocolConstantSdV1.protocolName ;
    private static final Short ProtocolVersion = ProtocolConstantSdV1.protocolVer ;
    private static final String ComCode = CodeSdV1.cd_Irr ;
    @Autowired
    private CdSv sv ;
    /**
     * å‘设备(Mqtt中间件->FBox)发送命令
     * @param dto å‰ç«¯å‘来的值对象
     * @param bindingResult å¯¹dto验证的结果
     * @return è¿”回前端
     */
    @PostMapping(path = "send", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoAop()
    public BaseResponse<Object> send(@RequestBody @Valid CdDto dto, BindingResult bindingResult) {
        BaseResponse<Object> res ;
        //发送命令前-1:验证
        res = super.pre1(sv, ComCode, dto, bindingResult);
        if(res == null) {
            //发送命令前-2:获得数据
            res = super.pre2(sv, Protocol, ProtocolVersion, ComCode, dto, bindingResult);
            if (res == null) {
                //发送命令前-3:保存命令日志
                CdParam comParam = CdParam.builder().commandCode(ComCode).build();
                res = super.pre3(sv, dto.manureId, dto.getOperator(), Protocol, ProtocolVersion, ComCode, comParam);
                if (res == null) {
                    //发送命令前-4:准备Feature
                    super.pre4();
                    try {
                        //创建外部命令(发给控制器)
                        Command com = sv.createOuterCommand(ctrlPo.fboxId, "" + comId, ComCode);
                        com.rtuResultSendWebUrl = rtuResultSendWebUrl;
                        com.param = comParam ;
                        //发送命令
                        res = super.doSend(sv, com);
                        if (res == null) {
                            //发送命令后
                            res = super.after(ComCode, null);
                        }
                    } catch (Exception e) {
                        res = BaseResponseUtils.buildFail("服务端构造并向通信中间件发送请求时异常" + (e.getMessage() == null ? "" : e.getMessage()));
                    } finally {
                        //最终
                        super.end();
                    }
                }
            }
        }
        return res ;
    }
    @Override
    protected String checkDto(Dto4MqttBase dto) {
        return null;
    }
    @Override
    protected String dealComResult(String code, JSONObject resultData, Callback callback){
        String msg;
        if(resultData != null){
            log.info(resultData.toString());
            JSONObject codeData = resultData.getJSONObject("data") ;
            if(codeData == null){
                msg = RtuSuccessMsg ;
            }else {
                String json = codeData.toJSONString();
                ManureVo cvo = JSON.parseObject(json, ManureVo.class) ;
                if(cvo != null){
                    msg = cvo.toString() ;
                }else{
                    msg = RtuSuccessMsg ;
                }
            }
        }else{
            msg = RtuSuccessMsg ;
        }
        return msg;
    }}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/irr/CdDto.java
New file
@@ -0,0 +1,16 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.irr;
import com.dy.pipIrrRemote.common.dto.Dto4MqttBase;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Data
@EqualsAndHashCode(callSuper=true)
public class CdDto extends Dto4MqttBase {
    public static final long serialVersionUID = 202506201654001L;
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/irr/CdParam.java
New file
@@ -0,0 +1,19 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.irr;
import com.dy.pipIrrRemote.monitor.common.Cd4MqttParameter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public class CdParam extends Cd4MqttParameter {
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/irr/CdSv.java
New file
@@ -0,0 +1,15 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.irr;
import com.dy.pipIrrRemote.monitor.common.Com4MqttSv;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Slf4j
@Service("mqttSd1IrrSv")
public class CdSv extends Com4MqttSv {
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/paramSet/CdCtrl.java
New file
@@ -0,0 +1,122 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.paramSet;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.aop.SsoAop;
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol4Mqtt.pSdV1.CodeSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.ManureVo;
import com.dy.common.util.Callback;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrRemote.common.dto.Dto4MqttBase;
import com.dy.pipIrrRemote.monitor.common.Com4MqttCtrl;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:35
 * @Description
 */
@Slf4j
@Tag(name = "远程命令", description = "清除故障")
@RestController("mqttSd1ParamCtrl")
@RequestMapping(path = "mqttSd1/paramCtrl")
@RequiredArgsConstructor
@Scope("prototype") //因为有对象类属性,所以采用原型模式,每次请求新建一个实例对象
public class CdCtrl extends Com4MqttCtrl {
    private static final String RtuSuccessMsg = "控制器接收并执行命令成功,无返回数据";
    private static final String Protocol = ProtocolConstantSdV1.protocolName ;
    private static final Short ProtocolVersion = ProtocolConstantSdV1.protocolVer ;
    private static final String ComCode = CodeSdV1.cd_Param ;
    @Autowired
    private CdSv sv ;
    /**
     * å‘设备(Mqtt中间件->FBox)发送命令
     * @param dto å‰ç«¯å‘来的值对象
     * @param bindingResult å¯¹dto验证的结果
     * @return è¿”回前端
     */
    @PostMapping(path = "send", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoAop()
    public BaseResponse<Object> send(@RequestBody @Valid CdDto dto, BindingResult bindingResult) {
        BaseResponse<Object> res ;
        //发送命令前-1:验证
        res = super.pre1(sv, ComCode, dto, bindingResult);
        if(res == null) {
            //发送命令前-2:获得数据
            res = super.pre2(sv, Protocol, ProtocolVersion, ComCode, dto, bindingResult);
            if (res == null) {
                //发送命令前-3:保存命令日志
                CdParam comParam = CdParam.builder().commandCode(ComCode).build();
                res = super.pre3(sv, dto.manureId, dto.getOperator(), Protocol, ProtocolVersion, ComCode, comParam);
                if (res == null) {
                    //发送命令前-4:准备Feature
                    super.pre4();
                    try {
                        //创建外部命令(发给控制器)
                        Command com = sv.createOuterCommand(ctrlPo.fboxId, "" + comId, ComCode);
                        com.rtuResultSendWebUrl = rtuResultSendWebUrl;
                        com.param = comParam ;
                        //发送命令
                        res = super.doSend(sv, com);
                        if (res == null) {
                            //发送命令后
                            res = super.after(ComCode, null);
                        }
                    } catch (Exception e) {
                        res = BaseResponseUtils.buildFail("服务端构造并向通信中间件发送请求时异常" + (e.getMessage() == null ? "" : e.getMessage()));
                    } finally {
                        //最终
                        super.end();
                    }
                }
            }
        }
        return res ;
    }
    @Override
    protected String checkDto(Dto4MqttBase dto) {
        return null;
    }
    @Override
    protected String dealComResult(String code, JSONObject resultData, Callback callback){
        String msg;
        if(resultData != null){
            log.info(resultData.toString());
            JSONObject codeData = resultData.getJSONObject("data") ;
            if(codeData == null){
                msg = RtuSuccessMsg ;
            }else {
                String json = codeData.toJSONString();
                ManureVo cvo = JSON.parseObject(json, ManureVo.class) ;
                if(cvo != null){
                    msg = cvo.toString() ;
                }else{
                    msg = RtuSuccessMsg ;
                }
            }
        }else{
            msg = RtuSuccessMsg ;
        }
        return msg;
    }}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/paramSet/CdDto.java
New file
@@ -0,0 +1,16 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.paramSet;
import com.dy.pipIrrRemote.common.dto.Dto4MqttBase;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Data
@EqualsAndHashCode(callSuper=true)
public class CdDto extends Dto4MqttBase {
    public static final long serialVersionUID = 202506201656001L;
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/paramSet/CdParam.java
New file
@@ -0,0 +1,19 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.paramSet;
import com.dy.pipIrrRemote.monitor.common.Cd4MqttParameter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public class CdParam extends Cd4MqttParameter {
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/paramSet/CdSv.java
New file
@@ -0,0 +1,15 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.paramSet;
import com.dy.pipIrrRemote.monitor.common.Com4MqttSv;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Slf4j
@Service("mqttSd1ParamSv")
public class CdSv extends Com4MqttSv {
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/stir/CdCtrl.java
New file
@@ -0,0 +1,122 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.stir;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.aop.SsoAop;
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol4Mqtt.pSdV1.CodeSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.ProtocolConstantSdV1;
import com.dy.common.mw.protocol4Mqtt.pSdV1.upVos.ManureVo;
import com.dy.common.util.Callback;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pipIrrRemote.common.dto.Dto4MqttBase;
import com.dy.pipIrrRemote.monitor.common.Com4MqttCtrl;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:35
 * @Description
 */
@Slf4j
@Tag(name = "远程命令", description = "清除故障")
@RestController("mqttSd1StirCtrl")
@RequestMapping(path = "mqttSd1/stirCtrl")
@RequiredArgsConstructor
@Scope("prototype") //因为有对象类属性,所以采用原型模式,每次请求新建一个实例对象
public class CdCtrl extends Com4MqttCtrl {
    private static final String RtuSuccessMsg = "控制器接收并执行命令成功,无返回数据";
    private static final String Protocol = ProtocolConstantSdV1.protocolName ;
    private static final Short ProtocolVersion = ProtocolConstantSdV1.protocolVer ;
    private static final String ComCode = CodeSdV1.cd_Stir ;
    @Autowired
    private CdSv sv ;
    /**
     * å‘设备(Mqtt中间件->FBox)发送命令
     * @param dto å‰ç«¯å‘来的值对象
     * @param bindingResult å¯¹dto验证的结果
     * @return è¿”回前端
     */
    @PostMapping(path = "send", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoAop()
    public BaseResponse<Object> send(@RequestBody @Valid CdDto dto, BindingResult bindingResult) {
        BaseResponse<Object> res ;
        //发送命令前-1:验证
        res = super.pre1(sv, ComCode, dto, bindingResult);
        if(res == null) {
            //发送命令前-2:获得数据
            res = super.pre2(sv, Protocol, ProtocolVersion, ComCode, dto, bindingResult);
            if (res == null) {
                //发送命令前-3:保存命令日志
                CdParam comParam = CdParam.builder().commandCode(ComCode).build();
                res = super.pre3(sv, dto.manureId, dto.getOperator(), Protocol, ProtocolVersion, ComCode, comParam);
                if (res == null) {
                    //发送命令前-4:准备Feature
                    super.pre4();
                    try {
                        //创建外部命令(发给控制器)
                        Command com = sv.createOuterCommand(ctrlPo.fboxId, "" + comId, ComCode);
                        com.rtuResultSendWebUrl = rtuResultSendWebUrl;
                        com.param = comParam ;
                        //发送命令
                        res = super.doSend(sv, com);
                        if (res == null) {
                            //发送命令后
                            res = super.after(ComCode, null);
                        }
                    } catch (Exception e) {
                        res = BaseResponseUtils.buildFail("服务端构造并向通信中间件发送请求时异常" + (e.getMessage() == null ? "" : e.getMessage()));
                    } finally {
                        //最终
                        super.end();
                    }
                }
            }
        }
        return res ;
    }
    @Override
    protected String checkDto(Dto4MqttBase dto) {
        return null;
    }
    @Override
    protected String dealComResult(String code, JSONObject resultData, Callback callback){
        String msg;
        if(resultData != null){
            log.info(resultData.toString());
            JSONObject codeData = resultData.getJSONObject("data") ;
            if(codeData == null){
                msg = RtuSuccessMsg ;
            }else {
                String json = codeData.toJSONString();
                ManureVo cvo = JSON.parseObject(json, ManureVo.class) ;
                if(cvo != null){
                    msg = cvo.toString() ;
                }else{
                    msg = RtuSuccessMsg ;
                }
            }
        }else{
            msg = RtuSuccessMsg ;
        }
        return msg;
    }}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/stir/CdDto.java
New file
@@ -0,0 +1,16 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.stir;
import com.dy.pipIrrRemote.common.dto.Dto4MqttBase;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Data
@EqualsAndHashCode(callSuper=true)
public class CdDto extends Dto4MqttBase {
    public static final long serialVersionUID = 202506201655001L;
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/stir/CdParam.java
New file
@@ -0,0 +1,19 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.stir;
import com.dy.pipIrrRemote.monitor.common.Cd4MqttParameter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public class CdParam extends Cd4MqttParameter {
}
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/mqttSd1/stir/CdSv.java
New file
@@ -0,0 +1,15 @@
package com.dy.pipIrrRemote.monitor.mqttSd1.stir;
import com.dy.pipIrrRemote.monitor.common.Com4MqttSv;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
 * @Author: liurunyu
 * @Date: 2025/6/16 17:36
 * @Description
 */
@Slf4j
@Service("mqttSd1StirSv")
public class CdSv extends Com4MqttSv {
}
pipIrr-platform/Îĵµ/Ë®·ÊÆøÏóÉÊÇé/FlexManagerÈí¼þÅäÖòÎÊý.docx
Binary files differ