微信小程序后端模块(子系统)增加接收农业综合站(水肥、气象、墒情)接收命令结果的业务逻辑
1个文件已添加
2个文件已修改
42 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/MqttResultCtrl.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/common/Com4MqttCtrl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -378,6 +378,8 @@
    ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive"
    #微信小程序应用中Rtu远程命令结果回调地址
    rtuCallbackUrl_wx: "http://127.0.0.1:8087/wx/comRes/receive"
    #MQTT远程命令结果回调地址
    mqttCallbackUrl_wx: "http://127.0.0.1:8087/wx/mqttRes/receive"
    waitMwRtnResultTimeout: 10 #等待中间件返回结果超时时间,单位秒钟
#不进行userToken过滤的URL,@ConfigurationProperties要求tokennofilter中所有字母都小写
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/MqttResultCtrl.java
New file
@@ -0,0 +1,38 @@
package com.dy.pipIrrWechat.command;
import com.dy.common.mw.protocol4Mqtt.MqttSubMsg;
import com.dy.pipIrrGlobal.command.ComResultWait;
import com.dy.pipIrrGlobal.command.ComSupport;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
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;
import java.util.concurrent.CompletableFuture;
/**
 * @author ZhuBaoMin
 * @date 2025/8/21 14:50
 * @Description
 */
@Slf4j
@RestController
@RequestMapping(path="mqttRes")
public class MqttResultCtrl extends ComSupport {
    @PostMapping(path = "receive", consumes = MediaType.APPLICATION_JSON_VALUE)
    public void receive(@RequestBody MqttSubMsg subMsg) {
        if(subMsg != null){
            CompletableFuture<MqttSubMsg> feature = (CompletableFuture<MqttSubMsg>) ComResultWait.get(Long.parseLong(subMsg.commandId));
            if(feature != null) {
                feature.complete(subMsg);
            }else{
                //超时,feature被清除了
            }
        }else{
            log.error("mqtt协议消息为空");
        }
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/common/Com4MqttCtrl.java
@@ -36,7 +36,7 @@
    @Value("${mw.waitMwRtnResultTimeout}")
    protected int waitMwRtnResultTimeout ;
    @Value("${mw.mqttCallbackUrl_rm}")
    @Value("${mw.mqttCallbackUrl_wx}")
    protected String mqttResultSendWebUrl;
    //水肥机对象