From c314c7f4898e368202ddbdfaf026678a2d37b94b Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期三, 18 十二月 2024 11:08:32 +0800
Subject: [PATCH] 实现接口 aPP修改取水口经纬度

---
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java |   44 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 36 insertions(+), 8 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..c4318f7 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
@@ -57,20 +57,15 @@
      * 鍚戦�氫俊涓棿浠跺彂閫乺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 +82,39 @@
     }
 
     /**
+     * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
+     * @param restTemplate SpringBoot鐨凴estTemplate
+     * @param toMwUrl 鍒伴�氫俊涓棿浠剁殑web璇锋眰Url
+     * @return
+     */
+    protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl) {
+        String url = UriComponentsBuilder.fromUriString(toMwUrl)
+                .build()
+                .toUriString();
+
+        //UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
+        //        .queryParam("test", test);
+        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ;
+
+        ResponseEntity<BaseResponse> response = null;
+        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