From 24f53bb77f9ac80feb2e62e8ee670be4aa5f3c6e Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 13 二月 2025 11:56:42 +0800
Subject: [PATCH] 1、远程模块remote模块实现: (1、系统启动时向通信中间件注册消息接收者; (2、消息接收者ctr实现(测试阶段); 2、在配置文件增加配置Springboot RestTemplate网络请求超时时长; 3、其他一些测试与优化。
---
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java | 2
pipIrr-platform/pipIrr-global/src/main/resources/application-global(test测试系统).yml | 8 +
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/OrgListenerSupport.java | 54 +++++++
pipIrr-platform/pipIrr-global/src/main/resources/application-global(mq民勤系统).yml | 8 +
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/Register2MwMsCenterListener.java | 97 +++++++++++++
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java | 80 ++++++++++
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java | 61 ++++++++
pipIrr-platform/pipIrr-global/src/main/resources/application-global(sp沙盘系统).yml | 8 +
pipIrr-platform/pipIrr-global/src/main/resources/application-global(166web文件花生壳).yml | 8 +
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/PipIrrMwRtuApplication.java | 2
pipIrr-platform/pipIrr-global/src/main/resources/application-global(ym元谋系统).yml | 8 +
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_83_Up.java | 3
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/msCenter/TestMsResource.java | 3
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java | 2
pipIrr-platform/pipIrr-global/src/main/resources/application-global(mj梅江系统).yml | 8 +
pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java | 2
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml | 10 +
17 files changed, 353 insertions(+), 11 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_83_Up.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_83_Up.java
index 20f4131..5a9f2bc 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_83_Up.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/Cd_83_Up.java
@@ -216,7 +216,8 @@
Cd_83_Up obj = new Cd_83_Up() ;
//涓嬮潰涓ゆ潯涓婃姤鏁版嵁锛孖C鍗$紪鐮侀兘鏄潪BCD缂栫爜鑰屽紓甯�
//String hex = "683C68B08485353448830200000000001000282353FE739444000001000313000101211615000101210000000000000000000200019000011518000101210A7B16";
- String hex = "683C68B05301154CEA8306001000000004343638483BBBB9E0001000001603000101215907000101210000000000000000000500019000015308000101210AF716";
+ //String hex = "683C68B05301154CEA8306001000000004343638483BBBB9E0001000001603000101215907000101210000000000000000000500019000015308000101210AF716";
+ String hex = "683868B0532328B90083074065840000FE00061010282353535B7F7691590100404022231024737F3F3F1FFF957296944239050000390001900000F916";
byte[] bs = ByteUtil.hex2Bytes(hex) ;
Data data = new Data() ;
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 728a1ae..8029774 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
@@ -5,6 +5,7 @@
import com.dy.common.mw.protocol.CommandType;
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;
@@ -13,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浠庢帶鍒跺櫒涓幏鍙�
@@ -32,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";
/**
@@ -43,14 +48,33 @@
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杩滅▼鍗囩骇浠诲姟
@@ -87,15 +111,61 @@
* @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)
- // .queryParam("test", test);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ;
+ if(paramName != null && !paramName.trim().equals("")){
+ builder.queryParam(paramName, paramValue==null?"":paramValue) ;
+ }
+ return sendGetRequest2Mw(restTemplate, builder);
+ }
- ResponseEntity<BaseResponse> response = null;
+ /**
+ * 鍚戦�氫俊涓棿浠跺彂閫乺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(),
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/OrgListenerSupport.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/OrgListenerSupport.java
index 10b769a..233e6f8 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/OrgListenerSupport.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/OrgListenerSupport.java
@@ -4,6 +4,9 @@
import org.jdom2.Document;
import org.springframework.core.io.ResourceLoader;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @Author: liurunyu
* @Date: 2024/7/24 13:41
@@ -52,4 +55,55 @@
}
}
}
+
+
+ /////////////////////////////////
+ // 寰楀埌
+ ////////////////////////////////
+ /**
+ * 瀹炲鍖�
+ */
+ @SuppressWarnings("unused ")
+ protected List<Org.OrgVo> get(ResourceLoader resourceLoader) {
+ return this.doGet(resourceLoader);
+ }
+
+ /**
+ * 瀹炲鍖�
+ */
+ @SuppressWarnings("unused ")
+ protected List<Org.OrgVo> doGet(ResourceLoader resourceLoader) {
+ List<Org.OrgVo> list = null ;
+ try {
+ ConfigXml4Springboot configXml = new ConfigXml4Springboot() ;
+ Document doc = configXml.createDom(resourceLoader, "init-config.xml") ;
+ list = this.doGet(configXml, doc);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return list ;
+ }
+
+ private List<Org.OrgVo> doGet(ConfigXml4Springboot configXml, Document doc) throws Exception {
+ List<Org.OrgVo> list = null ;
+ if (configXml != null && doc != null) {
+ list = new ArrayList<>();
+ for (int num = 1; num <= 10000; num++) {
+ if (configXml.existElement(doc, "config.orgs.org" + num)) {
+ String orgTag = configXml.getSetAttrTxt(doc, "config.orgs.org" + num, "tag", null, false, null);
+ String orgName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num, "name", null, false, null);
+ Boolean enable = configXml.getSetAttrBoolean(doc, "config.orgs.org" + num, "enable", null, null);
+ if(enable != null && enable.booleanValue()){
+ Org.OrgVo vo = new Org().new OrgVo() ;
+ vo.tag = orgTag ;
+ vo.name = orgName ;
+ list.add(vo) ;
+ }
+ }else{
+ break ;
+ }
+ }
+ }
+ return list ;
+ }
}
diff --git "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050166web\346\226\207\344\273\266\350\212\261\347\224\237\345\243\263\051.yml" "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050166web\346\226\207\344\273\266\350\212\261\347\224\237\345\243\263\051.yml"
index 59cb80b..7e9473f 100644
--- "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050166web\346\226\207\344\273\266\350\212\261\347\224\237\345\243\263\051.yml"
+++ "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050166web\346\226\207\344\273\266\350\212\261\347\224\237\345\243\263\051.yml"
@@ -4,6 +4,11 @@
# 鍓嶇涓婁紶鏂囦欢锛岄檺鍒跺崟涓枃浠剁殑澶у皬鍜岄檺鍒舵墍鏈夋枃浠剁殑澶у皬
max-file-size: 500MB
max-request-size: 5000MB
+ http:
+ client:
+ # spring restTemplate 瀵瑰http璁块棶鏃�
+ connect-timeout: 3000 # 杩炴帴瓒呮椂鏃堕棿
+ read-timeout: 3000 # 璇诲彇瓒呮椂鏃堕棿
logging:
charset:
console: UTF-8
@@ -337,6 +342,8 @@
comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
#Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
+ #鎺ユ敹閫氫俊涓棿浠舵秷鎭腑蹇冩秷鎭殑鍦板潃
+ mwMsCenterReceiveUrl_rm: "http://127.0.0.1:8081/remote/msCenter/receive"
#rtu杩滅▼鍗囩骇鐘舵�佷俊鎭洖璋冨湴鍧�
ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive"
#寰俊灏忕▼搴忓簲鐢ㄤ腑Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
@@ -347,6 +354,7 @@
urls:
- /sso/sso
- /remote/comRes/receive
+ - /remote/msCenter/receive
- /remote/rtuUpgradeStateReceiver/receive
- /remote/websocket
- /wx/comRes/receive
diff --git "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050mj\346\242\205\346\261\237\347\263\273\347\273\237\051.yml" "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050mj\346\242\205\346\261\237\347\263\273\347\273\237\051.yml"
index b20aa9a..6dc9732 100644
--- "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050mj\346\242\205\346\261\237\347\263\273\347\273\237\051.yml"
+++ "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050mj\346\242\205\346\261\237\347\263\273\347\273\237\051.yml"
@@ -4,6 +4,11 @@
# 鍓嶇涓婁紶鏂囦欢锛岄檺鍒跺崟涓枃浠剁殑澶у皬鍜岄檺鍒舵墍鏈夋枃浠剁殑澶у皬
max-file-size: 500MB
max-request-size: 5000MB
+ http:
+ client:
+ # spring restTemplate 瀵瑰http璁块棶鏃�
+ connect-timeout: 3000 # 杩炴帴瓒呮椂鏃堕棿
+ read-timeout: 3000 # 璇诲彇瓒呮椂鏃堕棿
logging:
charset:
console: UTF-8
@@ -337,6 +342,8 @@
comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
#Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
+ #鎺ユ敹閫氫俊涓棿浠舵秷鎭腑蹇冩秷鎭殑鍦板潃
+ mwMsCenterReceiveUrl_rm: "http://127.0.0.1:8081/remote/msCenter/receive"
#rtu杩滅▼鍗囩骇鐘舵�佷俊鎭洖璋冨湴鍧�
ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive"
#寰俊灏忕▼搴忓簲鐢ㄤ腑Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
@@ -347,6 +354,7 @@
urls:
- /sso/sso
- /remote/comRes/receive
+ - /remote/msCenter/receive
- /remote/rtuUpgradeStateReceiver/receive
- /remote/websocket
- /wx/comRes/receive
diff --git "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050mq\346\260\221\345\213\244\347\263\273\347\273\237\051.yml" "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050mq\346\260\221\345\213\244\347\263\273\347\273\237\051.yml"
index d08a7d8..a054371 100644
--- "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050mq\346\260\221\345\213\244\347\263\273\347\273\237\051.yml"
+++ "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050mq\346\260\221\345\213\244\347\263\273\347\273\237\051.yml"
@@ -4,6 +4,11 @@
# 鍓嶇涓婁紶鏂囦欢锛岄檺鍒跺崟涓枃浠剁殑澶у皬鍜岄檺鍒舵墍鏈夋枃浠剁殑澶у皬
max-file-size: 500MB
max-request-size: 5000MB
+ http:
+ client:
+ # spring restTemplate 瀵瑰http璁块棶鏃�
+ connect-timeout: 3000 # 杩炴帴瓒呮椂鏃堕棿
+ read-timeout: 3000 # 璇诲彇瓒呮椂鏃堕棿
logging:
charset:
console: UTF-8
@@ -337,6 +342,8 @@
comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
#Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
+ #鎺ユ敹閫氫俊涓棿浠舵秷鎭腑蹇冩秷鎭殑鍦板潃
+ mwMsCenterReceiveUrl_rm: "http://127.0.0.1:8081/remote/msCenter/receive"
#rtu杩滅▼鍗囩骇鐘舵�佷俊鎭洖璋冨湴鍧�
ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive"
#寰俊灏忕▼搴忓簲鐢ㄤ腑Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
@@ -347,6 +354,7 @@
urls:
- /sso/sso
- /remote/comRes/receive
+ - /remote/msCenter/receive
- /remote/rtuUpgradeStateReceiver/receive
- /remote/websocket
- /wx/comRes/receive
diff --git "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050sp\346\262\231\347\233\230\347\263\273\347\273\237\051.yml" "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050sp\346\262\231\347\233\230\347\263\273\347\273\237\051.yml"
index f9bc310..88d1599 100644
--- "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050sp\346\262\231\347\233\230\347\263\273\347\273\237\051.yml"
+++ "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050sp\346\262\231\347\233\230\347\263\273\347\273\237\051.yml"
@@ -4,6 +4,11 @@
# 鍓嶇涓婁紶鏂囦欢锛岄檺鍒跺崟涓枃浠剁殑澶у皬鍜岄檺鍒舵墍鏈夋枃浠剁殑澶у皬
max-file-size: 500MB
max-request-size: 5000MB
+ http:
+ client:
+ # spring restTemplate 瀵瑰http璁块棶鏃�
+ connect-timeout: 3000 # 杩炴帴瓒呮椂鏃堕棿
+ read-timeout: 3000 # 璇诲彇瓒呮椂鏃堕棿
logging:
charset:
console: UTF-8
@@ -337,6 +342,8 @@
comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
#Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
+ #鎺ユ敹閫氫俊涓棿浠舵秷鎭腑蹇冩秷鎭殑鍦板潃
+ mwMsCenterReceiveUrl_rm: "http://127.0.0.1:8081/remote/msCenter/receive"
#rtu杩滅▼鍗囩骇鐘舵�佷俊鎭洖璋冨湴鍧�
ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive"
#寰俊灏忕▼搴忓簲鐢ㄤ腑Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
@@ -347,6 +354,7 @@
urls:
- /sso/sso
- /remote/comRes/receive
+ - /remote/msCenter/receive
- /remote/rtuUpgradeStateReceiver/receive
- /remote/websocket
- /wx/comRes/receive
diff --git "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050test\346\265\213\350\257\225\347\263\273\347\273\237\051.yml" "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050test\346\265\213\350\257\225\347\263\273\347\273\237\051.yml"
index c6509d1..422f3ae 100644
--- "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050test\346\265\213\350\257\225\347\263\273\347\273\237\051.yml"
+++ "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050test\346\265\213\350\257\225\347\263\273\347\273\237\051.yml"
@@ -4,6 +4,11 @@
# 鍓嶇涓婁紶鏂囦欢锛岄檺鍒跺崟涓枃浠剁殑澶у皬鍜岄檺鍒舵墍鏈夋枃浠剁殑澶у皬
max-file-size: 500MB
max-request-size: 5000MB
+ http:
+ client:
+ # spring restTemplate 瀵瑰http璁块棶鏃�
+ connect-timeout: 3000 # 杩炴帴瓒呮椂鏃堕棿
+ read-timeout: 3000 # 璇诲彇瓒呮椂鏃堕棿
logging:
charset:
console: UTF-8
@@ -337,6 +342,8 @@
comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
#Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
+ #鎺ユ敹閫氫俊涓棿浠舵秷鎭腑蹇冩秷鎭殑鍦板潃
+ mwMsCenterReceiveUrl_rm: "http://127.0.0.1:8081/remote/msCenter/receive"
#rtu杩滅▼鍗囩骇鐘舵�佷俊鎭洖璋冨湴鍧�
ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive"
#寰俊灏忕▼搴忓簲鐢ㄤ腑Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
@@ -347,6 +354,7 @@
urls:
- /sso/sso
- /remote/comRes/receive
+ - /remote/msCenter/receive
- /remote/rtuUpgradeStateReceiver/receive
- /remote/websocket
- /wx/comRes/receive
diff --git "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050ym\345\205\203\350\260\213\347\263\273\347\273\237\051.yml" "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050ym\345\205\203\350\260\213\347\263\273\347\273\237\051.yml"
index 4a53de7..ae76e9e 100644
--- "a/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050ym\345\205\203\350\260\213\347\263\273\347\273\237\051.yml"
+++ "b/pipIrr-platform/pipIrr-global/src/main/resources/application-global\050ym\345\205\203\350\260\213\347\263\273\347\273\237\051.yml"
@@ -4,6 +4,11 @@
# 鍓嶇涓婁紶鏂囦欢锛岄檺鍒跺崟涓枃浠剁殑澶у皬鍜岄檺鍒舵墍鏈夋枃浠剁殑澶у皬
max-file-size: 500MB
max-request-size: 5000MB
+ http:
+ client:
+ # spring restTemplate 瀵瑰http璁块棶鏃�
+ connect-timeout: 3000 # 杩炴帴瓒呮椂鏃堕棿
+ read-timeout: 3000 # 璇诲彇瓒呮椂鏃堕棿
logging:
charset:
console: UTF-8
@@ -337,6 +342,8 @@
comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
#Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
+ #鎺ユ敹閫氫俊涓棿浠舵秷鎭腑蹇冩秷鎭殑鍦板潃
+ mwMsCenterReceiveUrl_rm: "http://127.0.0.1:8081/remote/msCenter/receive"
#rtu杩滅▼鍗囩骇鐘舵�佷俊鎭洖璋冨湴鍧�
ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive"
#寰俊灏忕▼搴忓簲鐢ㄤ腑Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
@@ -347,6 +354,7 @@
urls:
- /sso/sso
- /remote/comRes/receive
+ - /remote/msCenter/receive
- /remote/rtuUpgradeStateReceiver/receive
- /remote/websocket
- /wx/comRes/receive
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
index 07abef9..7e9473f 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -4,6 +4,11 @@
# 鍓嶇涓婁紶鏂囦欢锛岄檺鍒跺崟涓枃浠剁殑澶у皬鍜岄檺鍒舵墍鏈夋枃浠剁殑澶у皬
max-file-size: 500MB
max-request-size: 5000MB
+ http:
+ client:
+ # spring restTemplate 瀵瑰http璁块棶鏃�
+ connect-timeout: 3000 # 杩炴帴瓒呮椂鏃堕棿
+ read-timeout: 3000 # 璇诲彇瓒呮椂鏃堕棿
logging:
charset:
console: UTF-8
@@ -83,7 +88,7 @@
nginx:
root: E:/apps/pipIrr/nginx-1.27.0
webPort: 54321
- webFilePort: 64321
+ webFilePort: 19913
mw:
webPort: 8070 #閫氫俊涓棿浠朵腑搴旂敤锛屼笉鑳藉湪web妯″潡绯荤粺涓簲鐢�
actutorPort: 9070 #閫氫俊涓棿浠朵腑搴旂敤锛屼笉鑳藉湪web妯″潡绯荤粺涓簲鐢�
@@ -337,6 +342,8 @@
comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
#Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
+ #鎺ユ敹閫氫俊涓棿浠舵秷鎭腑蹇冩秷鎭殑鍦板潃
+ mwMsCenterReceiveUrl_rm: "http://127.0.0.1:8081/remote/msCenter/receive"
#rtu杩滅▼鍗囩骇鐘舵�佷俊鎭洖璋冨湴鍧�
ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive"
#寰俊灏忕▼搴忓簲鐢ㄤ腑Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
@@ -347,6 +354,7 @@
urls:
- /sso/sso
- /remote/comRes/receive
+ - /remote/msCenter/receive
- /remote/rtuUpgradeStateReceiver/receive
- /remote/websocket
- /wx/comRes/receive
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/PipIrrMwRtuApplication.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/PipIrrMwRtuApplication.java
index 7e89fd0..8af9b06 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/PipIrrMwRtuApplication.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/PipIrrMwRtuApplication.java
@@ -8,7 +8,9 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.FilterType;
+import org.springframework.scheduling.annotation.EnableScheduling;
+@EnableScheduling
@SpringBootApplication
@EnableAspectJAutoProxy
@ComponentScan(basePackages = {"com.dy.common", "com.dy.pipIrrGlobal", "com.dy.rtuMw"},
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/msCenter/TestMsResource.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/msCenter/TestMsResource.java
index f0b09af..79430cb 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/msCenter/TestMsResource.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/msCenter/TestMsResource.java
@@ -1,6 +1,7 @@
package com.dy.rtuMw.server.msCenter;
import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
/**
* @Author: liurunyu
@@ -8,7 +9,7 @@
* @Description
*/
//浣胯捣浣滅敤锛屾湰绫绘敞瑙Component锛屽苟鍦≒ipIrrMwRtuApplication娉ㄨВ@EnableScheduling
-//@Component
+@Component
public class TestMsResource {
// 璁剧疆瀹氭椂鍗佺涓�娆�
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 877113e..f50db60 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
@@ -153,7 +153,7 @@
* @return
*/
@GetMapping("/registerMsReceiverWebUrl")
- public BaseResponse<List<String>> registerMsReceiverWebUrl(String msReceiverWebUrl){
+ public BaseResponse<Boolean> registerMsReceiverWebUrl(String msReceiverWebUrl){
try{
MsCenterUnit.getInstance().registerMsReceiver(msReceiverWebUrl);
}catch (Exception e){
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java
new file mode 100644
index 0000000..f4705ec
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/CenterMsReceiveCtrl.java
@@ -0,0 +1,61 @@
+package com.dy.pipIrrRemote.msCenter;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.dy.common.contant.Constant;
+import com.dy.common.multiDataSource.DataSourceContext;
+import com.dy.common.webUtil.BaseResponse;
+import io.swagger.v3.oas.annotations.Hidden;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2025/2/12 17:34
+ * @Description
+ */
+
+@Slf4j
+@Tag(name = "閫氫俊涓棿娑堟伅涓績鎺ㄩ�佹秷鎭帴鏀舵柟", description = "閫氫俊涓棿娑堟伅涓績鎺ㄩ�佹秷鎭帴鏀舵柟")
+@RestController
+@RequestMapping(path="msCenter")
+public class CenterMsReceiveCtrl{
+
+ /**
+ * 閫氫俊涓棿娑堟伅涓績鎺ㄩ�佹秷鎭帴鏀�
+ * @param list 娑堟伅闆嗗悎
+ * @return 鎿嶄綔缁撴灉
+ */
+ @Hidden //涓嶅叕寮�鎺ュ彛锛屽叾鍙湁閫氫俊涓棿浠惰皟鐢�
+ @PostMapping(path = "receive", consumes = MediaType.APPLICATION_JSON_VALUE)
+ public BaseResponse<Boolean> receive(@RequestBody List<JSONObject> list, HttpServletRequest req, HttpServletResponse rep) {
+ //閫氫俊涓棿浠朵紶杩囨潵鐨勬満鏋則ag锛屼互鐢ㄤ簬鏌ユ壘鏁版嵁婧�
+ String token = req.getHeader(Constant.UserTokenKeyInHeader);
+ DataSourceContext.set(token);
+
+ if(list != null && list.size() > 0){
+ for (JSONObject jo : list) {
+ if(jo != null){
+ log.info("----------------start " + token + " 娑堟伅鏁版嵁--------------") ;
+ Iterator<String> it = jo.keySet().iterator() ;
+ String key ;
+ while (it.hasNext()){
+ key = it.next() ;
+ log.info(key + "锛�" + jo.get(key));
+ }
+ log.info("----------------end " + token + " 娑堟伅鏁版嵁--------------") ;
+ }
+ }
+ }
+ return null ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/Register2MwMsCenterListener.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/Register2MwMsCenterListener.java
new file mode 100644
index 0000000..c7fcc00
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/msCenter/Register2MwMsCenterListener.java
@@ -0,0 +1,97 @@
+package com.dy.pipIrrRemote.msCenter;
+
+import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw;
+import com.dy.pipIrrGlobal.util.Org;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.core.env.Environment;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.lang.NonNull;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2025/2/13 9:47
+ * @Description
+ */
+@Slf4j
+@Component
+public class Register2MwMsCenterListener extends Web2RtuMw implements ApplicationListener<ApplicationReadyEvent> {
+ @Autowired
+ private Environment env;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ @Autowired
+ protected ResourceLoader resourceLoader;
+
+ @Value("${mw.mwMsCenterReceiveUrl_rm}")
+ protected String mwMsCenterReceiveUrl;//娑堟伅鎺ユ敹缃戝潃
+
+ private static final String mwParamName = "msReceiverWebUrl" ;
+
+ private List<Org.OrgVo> orgs;
+
+ private Timer timer;
+
+ /**
+ * SpringBoot瀹瑰櫒宸茬粡鍑嗗濂戒簡锛屾墽琛屼笅闈㈡柟娉�
+ *
+ * @param event 浜嬩欢
+ */
+ @Override
+ public void onApplicationEvent(@NonNull ApplicationReadyEvent event) {
+ try {
+ //绛�1绉掞紝绛夊緟com.alibaba.druid.pool.DruidDataSource瀹炲鍖栧畬鎴�
+ Thread.sleep(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ this.start(event);
+ } catch (Exception e) {
+ log.error("鍚戦�氫俊涓棿浠舵敞鍐屾秷鎭帴鏀惰�呭嚭閿�", e);
+ }
+ }
+ }
+
+ /**
+ * 鎵ц涓氬姟閫昏緫
+ * @param event
+ * @throws Exception
+ */
+ private void start(ApplicationReadyEvent event) throws Exception {
+ if(mwMsCenterReceiveUrl == null || mwMsCenterReceiveUrl.trim().equals("")){
+ throw new Exception("閫氫俊涓棿浠舵秷鎭帴鏀剁綉鍧�鏈厤缃�");
+ }
+ orgs = super.get(resourceLoader);
+ if(orgs != null && orgs.size() > 0) {
+ this.timer = new Timer();
+ this.timer.schedule(new TimerTask() {
+ public void run() {
+ register(event) ;
+ }
+ }, 100 , 5 * 60 * 1000);
+ }
+ }
+
+ /**
+ * 鍚戦�氫俊涓棿浠舵敞鍐屾秷鎭帴鏀惰��
+ * @param event
+ */
+ private void register(ApplicationReadyEvent event){
+ for (Org.OrgVo vo : this.orgs){
+ String rqUrl = this.get2MwRequestUrl(this.env, vo.tag, ContextRegisterMsReceiverWebUrl) ;
+ sendGetRequest2Mw(restTemplate, rqUrl, mwParamName, mwMsCenterReceiveUrl) ;
+ }
+ }
+}
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 77eb655..8bba068 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
@@ -51,7 +51,7 @@
private RtuUpgradeSv sv ;
@Autowired
- RtuUpgradeResSv resSv ;
+ private RtuUpgradeResSv resSv ;
@Autowired
private Environment env;
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java
index 53746fb..b313e63 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java
@@ -18,7 +18,7 @@
* @Author: liurunyu
* @Date: 2024/7/22 14:39
* @Description
- * 鐩戝惉鍣紝瀹炵幇鍔熻兘锛氬湪绯荤粺鍚姩鏃跺垵濮嬪寲锛屽悜鏁版嵁搴撲腑鎻掑叆鏁版嵁
+ * 鐩戝惉鍣紝瀹炵幇鍔熻兘锛氬惎鍔ㄦ棩缁熻瀹氭椂浠诲姟
* 鏈洃鍚櫒涓嶈兘閲囩敤ServletContextListener鏂瑰紡锛屽洜涓篠ervlet涓婁笅鏂嘋ontext鍒涘缓鍚�
* Spring瀹瑰櫒骞舵病鏈夊垱寤哄畬锛岃�屾湰绫讳腑鐢ㄤ簡Spring瀹瑰櫒涓殑Bean锛屽嵆*Dao 銆�
* 鎵�浠ラ噰鐢ㄤ簡Spring浜嬩欢鐩戝惉鍣ㄦ潵瀹炵幇
--
Gitblit v1.8.0