From ac87f61568a68501aa50d5c3f0d083e8ea36ebb3 Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期五, 29 十一月 2024 14:33:07 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java | 110 +++++++++++++++++++++++-------------------------------
1 files changed, 47 insertions(+), 63 deletions(-)
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/ToRtuMwCom.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java
similarity index 60%
rename from pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/ToRtuMwCom.java
rename to pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java
index ac71d4c..86fc954 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/ToRtuMwCom.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java
@@ -19,33 +19,71 @@
* @Date: 2024/10/23 11:45
* @Description
*/
-public abstract class ToRtuMwCom {
+public abstract class Web2RtuMw {
/**
* pro_mw锛氬睘鎬�
* tag浠庢帶鍒跺櫒涓幏鍙�
* key_mw锛歶rl鐨刱ey
*/
private static final String pro_mw = "mw";
- private static final String key_mw = "comSendUrl";
- private static final String keyUg_mw = "ugTaskSendUrl";
+ private static final String pro_url = "url";
+ protected static final String ContextComSend = "/rtuMw/com/send";
+ protected static final String ContextRtuLogFile = "/rtuMw/com/rtuLogFile";
+ protected static final String ContextRtuLogText = "/rtuMw/com/rtuLogText";
+
+ protected static final String ContextUgTaskSend = "/rtuMw/com/upgradeRtu";
+ protected static final String ContextUgForceOver = "/rtuMw/com/ugForceOver";
/**
* 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佹暟鎹殑URL
* @param env
* @return
*/
- protected String getToMwUrl(Environment env) {
- return env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw);
+ protected String get2MwUrl(Environment env) {
+ return env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + pro_url);
+ }
+ /**
+ * 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佸己鍒跺仠姝㈠崌绾х殑鍛戒护URL
+ * @param env
+ * @return
+ */
+ protected String get2MwRequestUrl(Environment env, String context) {
+ return get2MwUrl(env) + context;
}
+
/**
- * 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佹暟鎹殑URL
- * @param env
+ * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
+ * @param restTemplate SpringBoot鐨凴estTemplate
+ * @param toMwUrl 鍒伴�氫俊涓棿浠剁殑web璇锋眰Url
+ * @param param 璇锋眰鍙傛暟
* @return
*/
- protected String getToMwUgUrl(Environment env) {
- return env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + keyUg_mw);
+ protected BaseResponse sendRequest2Mw(RestTemplate restTemplate, String toMwUrl, Object param) {
+ 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);
+ }
+ ResponseEntity<BaseResponse> response = null;
+ try {
+ // 閫氳繃Post鏂瑰紡璋冪敤鎺ュ彛
+ response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
+ }
+ if(response == null){
+ return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
+ }else{
+ return response.getBody();
+ }
}
/**
@@ -74,58 +112,4 @@
return com ;
}
- /**
- * 鍙戦�佸懡浠�
- *
- * @return
- */
- protected BaseResponse sendCom2Mw(RestTemplate restTemplate, String comSendUrl, Command com) {
- String url = UriComponentsBuilder.fromUriString(comSendUrl)
- .build()
- .toUriString();
- HttpHeaders headers = new HttpHeaders();
- HttpEntity<Command> httpEntity = new HttpEntity<>(com, headers);
- ResponseEntity<BaseResponse> response = null;
- try {
- // 閫氳繃Post鏂瑰紡璋冪敤鎺ュ彛
- response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
- } catch (Exception e) {
- e.printStackTrace();
- return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
- }
- if(response == null){
- return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
- }else{
- return response.getBody();
- }
- }
-
-
- /**
- * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
- * @param restTemplate
- * @param comSendUrl
- * @param vo
- * @return
- */
- protected BaseResponse sendUpgradeTask2Mw(RestTemplate restTemplate, String comSendUrl, UpgradeTaskVo vo) {
- String url = UriComponentsBuilder.fromUriString(comSendUrl)
- .build()
- .toUriString();
- HttpHeaders headers = new HttpHeaders();
- HttpEntity<UpgradeTaskVo> httpEntity = new HttpEntity<>(vo, headers);
- ResponseEntity<BaseResponse> response = null;
- try {
- // 閫氳繃Post鏂瑰紡璋冪敤鎺ュ彛
- response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
- } catch (Exception e) {
- e.printStackTrace();
- return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
- }
- if(response == null){
- return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
- }else{
- return response.getBody();
- }
- }
}
--
Gitblit v1.8.0