From 053d5042846ae96c9c7ba031bae9d9221745cd7f Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 29 十一月 2024 15:20:58 +0800
Subject: [PATCH] 向通信中间件请求,有参数时用post,无参数时用Get.
---
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoUgResult.java | 2 +-
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java | 4 ++--
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java | 8 ++++----
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java | 2 +-
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java | 38 ++++++++++++++++++++++++++++++--------
5 files changed, 38 insertions(+), 16 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
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoUgResult.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoUgResult.java
index 3b23cda..971f711 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoUgResult.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voUg/VoUgResult.java
@@ -67,7 +67,7 @@
*/
@Schema(description = "鍗囩骇鏄惁缁撴潫" )
@ExcelProperty("鍗囩骇缁撴潫")
- @ColumnWidth(10)
+ @ColumnWidth(14)
@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER, verticalAlignment = VerticalAlignmentEnum.CENTER)
public String isOverStr;
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
index 675f636..2a4f64c 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java
@@ -165,7 +165,7 @@
* 鎺ユ敹web绯荤粺鍙戞潵寮哄埗缁撴潫鍗囩骇浠诲姟
* @return
*/
- @PostMapping(path = "ugForceOver", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @GetMapping(path = "ugForceOver", consumes = MediaType.APPLICATION_JSON_VALUE)
public BaseResponse<String> ugForceOver() {
log.info("鏀跺埌鍋滄RTU鍗囩骇浠诲姟鍛戒护") ;
try{
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java
index a4f1e1f..803cf39 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/MonitorSv.java
@@ -77,7 +77,7 @@
Command com = this.createInnerCommand(CodeLocal.onLinePart);
com.setParam(rtuAddrs) ;
String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ;
- BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, com) ;
+ BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, com) ;
if(res != null){
if(res.isSuccess()){
Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ;
@@ -115,7 +115,7 @@
//鍚戦�氫俊涓棿浠跺彂鍏冲懡浠わ紝鏌ヨ閮ㄥ垎RTU鍦ㄧ嚎鎯呭喌
Command com = this.createInnerCommand(CodeLocal.onLineAll);
String rqUrl = this.get2MwRequestUrl(this.env, ContextComSend) ;
- BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, com) ;
+ BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, com) ;
if(res != null){
if(res.isSuccess()){
Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ;
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java
index 63053ca..a618170 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java
@@ -106,7 +106,7 @@
vo.callbackWebUrl = ugCallbackUrl_rm ;
String rqUrl = this.get2MwRequestUrl(this.env, ContextUgTaskSend) ;
- BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, vo) ;
+ BaseResponse res = sendPostRequest2Mw(restTemplate, rqUrl, vo) ;
if(res != null){
if(res.isSuccess()){
this.sv.setUpgradeTaskExecuted(id);
@@ -116,8 +116,8 @@
if(msg == null){
msg = res.getMsg() ;
}
- log.error("閫氫俊涓棿浠舵墽琛屼笅鍙戝崌绾т换鍔″け璐�" + msg) ;
- return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠舵墽琛屽け璐�" + msg) ;
+ log.error("閫氫俊涓棿浠舵墽琛屼笅鍙戝崌绾т换鍔″け璐ワ紝" + msg) ;
+ return BaseResponseUtils.buildErrorMsg("閫氫俊涓棿浠舵墽琛屽け璐ワ紝" + msg) ;
}
}else{
log.error("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
@@ -141,7 +141,7 @@
@SsoAop()
public BaseResponse<String> forceOver() {
String rqUrl = this.get2MwRequestUrl(this.env, ContextUgForceOver) ;
- BaseResponse res = sendRequest2Mw(restTemplate, rqUrl, null) ;
+ BaseResponse res = sendGetRequest2Mw(restTemplate, rqUrl) ;
if(res != null){
if(res.isSuccess()){
return BaseResponseUtils.buildSuccess(true) ;
--
Gitblit v1.8.0