From 4513ef24bf9b188c2a77d6ce94f1a6b7e9ebf0e6 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期日, 27 四月 2025 20:40:19 +0800
Subject: [PATCH] fix(irrigatePlan): 修正灌溉计划开始时间逻辑

---
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java |  119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 108 insertions(+), 11 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java
index 86fc954..d56a6d3 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java
@@ -3,9 +3,9 @@
 import com.dy.common.multiDataSource.DataSourceContext;
 import com.dy.common.mw.protocol.Command;
 import com.dy.common.mw.protocol.CommandType;
-import com.dy.common.softUpgrade.state.UpgradeTaskVo;
 import com.dy.common.webUtil.BaseResponse;
 import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.pipIrrGlobal.util.OrgListenerSupport;
 import org.springframework.core.env.Environment;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
@@ -14,12 +14,15 @@
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.util.UriComponentsBuilder;
 
+import java.util.Iterator;
+import java.util.Map;
+
 /**
  * @Author: liurunyu
  * @Date: 2024/10/23 11:45
  * @Description
  */
-public abstract class Web2RtuMw {
+public abstract class Web2RtuMw extends OrgListenerSupport {
     /**
      * pro_mw锛氬睘鎬�
      * tag浠庢帶鍒跺櫒涓幏鍙�
@@ -33,6 +36,7 @@
     protected static final String ContextRtuLogFile = "/rtuMw/com/rtuLogFile";
     protected static final String ContextRtuLogText = "/rtuMw/com/rtuLogText";
 
+    protected static final String ContextRegisterMsReceiverWebUrl = "/rtuMw/com/registerMsReceiverWebUrl";
     protected static final String ContextUgTaskSend = "/rtuMw/com/upgradeRtu";
     protected static final String ContextUgForceOver = "/rtuMw/com/ugForceOver";
     /**
@@ -44,33 +48,47 @@
         return env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + pro_url);
     }
     /**
+     * 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佹暟鎹殑URL
+     * @param env
+     * @param orgTag
+     * @return
+     */
+    protected String get2MwUrl(Environment env, String orgTag) {
+        return env.getProperty(pro_mw + "." + orgTag + "." + pro_url);
+    }
+    /**
      * 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佸己鍒跺仠姝㈠崌绾х殑鍛戒护URL
      * @param env
+     * @param context
      * @return
      */
     protected String get2MwRequestUrl(Environment env, String context) {
         return get2MwUrl(env) + context;
     }
-
+    /**
+     * 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佸己鍒跺仠姝㈠崌绾х殑鍛戒护URL
+     * @param env
+     * @param orgTag
+     * @param context
+     * @return
+     */
+    protected String get2MwRequestUrl(Environment env, String orgTag, String context) {
+        return get2MwUrl(env, orgTag) + context;
+    }
 
     /**
      * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
      * @param restTemplate SpringBoot鐨凴estTemplate
      * @param toMwUrl 鍒伴�氫俊涓棿浠剁殑web璇锋眰Url
-     * @param param 璇锋眰鍙傛暟
+     * @param body 璇锋眰鏁版嵁
      * @return
      */
-    protected BaseResponse sendRequest2Mw(RestTemplate restTemplate, String toMwUrl, Object param) {
+    protected BaseResponse sendPostRequest2Mw(RestTemplate restTemplate, String toMwUrl, Object body) {
         String url = UriComponentsBuilder.fromUriString(toMwUrl)
                 .build()
                 .toUriString();
         HttpHeaders headers = new HttpHeaders();
-        HttpEntity<?> httpEntity ;
-        if(param != null){
-            httpEntity = new HttpEntity<>(param, headers);
-        }else{
-            httpEntity = new HttpEntity<>(headers);
-        }
+        HttpEntity<?> httpEntity = new HttpEntity<>(body, headers);
         ResponseEntity<BaseResponse> response = null;
         try {
             // 閫氳繃Post鏂瑰紡璋冪敤鎺ュ彛
@@ -87,6 +105,85 @@
     }
 
     /**
+     * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
+     * @param restTemplate SpringBoot鐨凴estTemplate
+     * @param toMwUrl 鍒伴�氫俊涓棿浠剁殑web璇锋眰Url
+     * @return
+     */
+    protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl) {
+        return sendGetRequest2Mw(restTemplate, toMwUrl, null);
+    }
+
+    /**
+     * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
+     * @param restTemplate SpringBoot鐨凴estTemplate
+     * @param toMwUrl 鍒伴�氫俊涓棿浠剁殑web璇锋眰Url
+     * @param paramName 鍙傛暟鍚嶇О
+     * @param paramValue 鍙傛暟
+     * @return
+     */
+    protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl, String paramName, String paramValue) {
+        String url = UriComponentsBuilder.fromUriString(toMwUrl)
+                .build()
+                .toUriString();
+
+        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ;
+        if(paramName != null && !paramName.trim().equals("")){
+            builder.queryParam(paramName, paramValue==null?"":paramValue) ;
+        }
+        return sendGetRequest2Mw(restTemplate, builder);
+    }
+
+    /**
+     * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
+     * @param restTemplate SpringBoot鐨凴estTemplate
+     * @param toMwUrl 鍒伴�氫俊涓棿浠剁殑web璇锋眰Url
+     * @param params 鍙傛暟闆嗗悎锛屽弬鏁板悕绉版槸key锛屽弬鏁版槸value
+     * @return
+     */
+    protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl, Map<String, String> params) {
+        String url = UriComponentsBuilder.fromUriString(toMwUrl)
+                .build()
+                .toUriString();
+
+        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ;
+        if(params != null && params.size() > 0){
+            Iterator<String> it = params.keySet().iterator() ;
+            String key ;
+            while (it.hasNext()){
+                key = it.next() ;
+                builder.queryParam(key, params.get(key)) ;
+            }
+        }
+        return sendGetRequest2Mw(restTemplate, builder);
+    }
+
+    /**
+     * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
+     * @param restTemplate SpringBoot鐨凴estTemplate
+     * @param builder
+     * @return
+     */
+    protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, UriComponentsBuilder builder) {
+        ResponseEntity<BaseResponse> response;
+        try {
+            // 閫氳繃Get鏂瑰紡璋冪敤鎺ュ彛
+            response = restTemplate.exchange(builder.toUriString(),
+                    HttpMethod.GET,
+                    new HttpEntity<>(new HttpHeaders()),
+                    BaseResponse.class);
+        } catch (Exception e) {
+            //e.printStackTrace();
+            return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
+        }
+        if(response == null){
+            return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
+        }else{
+            return response.getBody();
+        }
+    }
+
+    /**
      * 鍒涘缓澶栭儴鍛戒护锛堝彂缁欐帶鍒跺櫒锛�
      * @param code 鍛戒护code
      * @return

--
Gitblit v1.8.0