From a6874344d96b58312337225cb62b2927162bb626 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期一, 02 十二月 2024 16:41:05 +0800
Subject: [PATCH] 重构添加巡检轨迹接口,如果巡检已存在,返回巡检员ID对应的巡检ID
---
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java | 38 ++++++++++++++++++++++++++++++--------
1 files changed, 30 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..e4f1d05 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,33 @@
}
/**
+ * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
+ * @param restTemplate SpringBoot鐨凴estTemplate
+ * @param toMwUrl 鍒伴�氫俊涓棿浠剁殑web璇锋眰Url
+ * @return
+ */
+ protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl) {
+ String url = UriComponentsBuilder.fromUriString(toMwUrl)
+ .build()
+ .toUriString();
+ HttpHeaders headers = new HttpHeaders();
+ HttpEntity<?> httpEntity = new HttpEntity<>(headers);
+ ResponseEntity<BaseResponse> response = null;
+ try {
+ // 閫氳繃Post鏂瑰紡璋冪敤鎺ュ彛
+ response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, 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