From 81698fd94ab04361303dfa637e1c56f510d99dcf Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 12 十一月 2024 14:50:37 +0800
Subject: [PATCH] 实现web端向通信中间件发布RTU升级任务功能,以通信中间件回调回传升级状态数据功能。
---
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java | 119 +++++++++++++++++
pipIrr-platform/pipIrr-global/src/main/resources/application-global(test测试系统).yml | 6
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeTaskVo.java | 1
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java | 39 +++++
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/ToRtuMwCom.java | 35 +++++
pipIrr-platform/pipIrr-global/src/main/resources/application-global(sp沙盘系统).yml | 6
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/UgRtuControllerMapper.java | 8 +
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeState.java | 14 ++
pipIrr-platform/pipIrr-global/src/main/resources/application-global(ym元谋系统).yml | 6
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeSv.java | 54 +++++++
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/webRequest/WebRequestDeal.java | 13 +
pipIrr-platform/pipIrr-global/src/main/resources/mapper/UgRtuControllerMapper.xml | 8 +
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml | 8 +
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeInfo.java | 9 +
pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml | 4
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java | 34 ++++
16 files changed, 357 insertions(+), 7 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeInfo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeInfo.java
index 7102291..0f3437b 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeInfo.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeInfo.java
@@ -17,4 +17,13 @@
public UpgradeState ugOverallState;
//鍗囩骇浠诲姟RTU鐘舵�佸垪琛�
public List<UpgradeRtu> ugRtuStateList;
+
+ public String toString(){
+ StringBuilder sb = new StringBuilder() ;
+ sb.append("RTU杩滅▼鍗囩骇鐘舵�侊細") ;
+ sb.append(" \n浠诲姟id锛�" + ugTaskId) ;
+ sb.append(" \n" + ugOverallState.toString()) ;
+ //sb.append(" \n鍗囩骇鐨勬帶鍒跺櫒鎬绘暟锛�" + ugRtuStateList.size()) ;
+ return sb.toString() ;
+ }
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java
index 0c9b42b..e7ee7f7 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeRtu.java
@@ -39,6 +39,40 @@
public int reTryTimes ;//鍗囩骇涓嶆垚鍔燂紝閲嶈瘯娆℃暟
public boolean isOver ;
+ public String toString(){
+ StringBuilder sb = new StringBuilder();
+ sb.append("RTU锛�" + rtuAddr + "锛夊崌绾х姸鎬侊細") ;
+ sb.append(" \n褰� 鍓� 鐘� 鎬侊細" + getStateName(state)) ;
+ sb.append(" \n闇�涓嬪彂鏁版嵁鍖呮�绘暟锛�" + totalPackage) ;
+ sb.append(" \n褰撳墠涓嬪彂鍗囩骇鍖呮暟锛�" + currentPackage) ;
+ sb.append(" \n褰撳墠涓嬪彂瀛樺偍鍦板潃锛�" + currentRamAddr) ;
+ sb.append(" \n褰撳墠涓嬪彂鏁版嵁鏃堕棿锛�" + lastDownDt) ;
+ sb.append(" \n鍗囩骇澶辫触閲嶈瘯娆℃暟锛�" + reTryTimes) ;
+ sb.append(" \n鍗囩骇杩囩▼鏄惁缁撴潫锛�" + (isOver?"鏄�":"鍚�")) ;
+ return sb.toString() ;
+ }
+
+ public String getStateName(int state){
+ switch (state) {
+ case STATE_OFFLINE:
+ return "绂荤嚎";
+ case STATE_UNSTART:
+ return "鏈紑濮�";
+ case STATE_RUNNING:
+ return "鍗囩骇涓�";
+ case STATE_SUCCESS:
+ return "鍗囩骇鎴愬姛";
+ case STATE_FAILONE:
+ return "鍗囩骇澶辫触锛�1鍖呮锛�";
+ case STATE_FAIL:
+ return "鍗囩骇澶辫触锛堥潪1鍖呮锛�";
+ case STATE_FAILOFFLINE:
+ return "鍗囩骇澶辫触锛堢绾匡級";
+ default:
+ return "鏈煡";
+ }
+ }
+
/**
* 瑙﹀彂鍗囩骇
* @param code
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeState.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeState.java
index 6e354ce..cc1c4b1 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeState.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeState.java
@@ -29,5 +29,19 @@
this.failTotal = 0;
}
+ public String toString(){
+ StringBuilder sb = new StringBuilder() ;
+ sb.append("鍗囩骇鐘舵��") ;
+ sb.append(" \n璁剧疆RTU鎬绘暟锛�" + rtuTotal) ;
+ sb.append(" \n绂荤嚎RTU鎬绘暟锛�" + offLineTotal) ;
+ sb.append(" \n鏈紑濮嬫�绘暟锛�" + unStartTotal) ;
+ sb.append(" \n姝e崌绾ф�绘暟锛�" + runningTotal) ;
+ sb.append(" \n宸茬粨鏉熸�绘暟锛�" + overTotal) ;
+ sb.append(" \n鎴愬姛鎬绘暟锛�" + successTotal) ;
+ sb.append(" \n澶辫触鎬绘暟锛�" + failTotal) ;
+ sb.append(" \n1鍖呮鎬绘暟锛�" + failOneTotal) ;
+ return sb.toString() ;
+ }
+
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeTaskVo.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeTaskVo.java
index 172cae9..b4d0d16 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeTaskVo.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/softUpgrade/state/UpgradeTaskVo.java
@@ -33,4 +33,5 @@
" 鍗囩骇鎺у埗鍣ㄦ暟閲�=" + rtuAddrList.size() + "\n" +
" 鍗囩骇鐘舵�侀�氱煡URL=" + callbackWebUrl + "\n" ;
}
+
}
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/UgRtuControllerMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/UgRtuControllerMapper.java
index 732c8a7..270dc86 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/UgRtuControllerMapper.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/UgRtuControllerMapper.java
@@ -72,6 +72,14 @@
List<UgRtuController> selectAllConByTask(Long taskId) ;
/**
+ * 寰楀埌鍗囩骇浠诲姟鐨勬墍鏈夊璞℃帶鍒跺櫒
+ *
+ * @param taskId 鍗囩骇浠诲姟id
+ * @return object by primary key
+ */
+ List<String> selectAllRtuAddrByTask(Long taskId) ;
+
+ /**
* 鏍规嵁浠诲姟id鍜屾帶鍒跺櫒id鏌ヨ鏁伴噺
*
* @param taskId 鍗囩骇浠诲姟id
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/ToRtuMwCom.java
index 74099ea..dbe7d40 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/ToRtuMwCom.java
@@ -3,6 +3,7 @@
import com.dy.common.multiDataSource.DataSourceContext;
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol.CommandType;
+import com.dy.common.softUpgrade.state.UpgradeTaskVo;
import com.dy.common.webUtil.BaseResponse;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpEntity;
@@ -25,6 +26,7 @@
*/
private static final String pro_mw = "mw";
private static final String key_mw = "comSendUrl";
+ private static final String keyUg_mw = "ugTaskSendUrl";
/**
@@ -34,6 +36,15 @@
*/
protected String getToMwUrl(Environment env) {
return env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw);
+ }
+
+ /**
+ * 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佹暟鎹殑URL
+ * @param env
+ * @return
+ */
+ protected String getToMwUgUrl(Environment env) {
+ return env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + keyUg_mw);
}
/**
@@ -82,4 +93,28 @@
}
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 response.getBody();
+ }
}
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml b/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml
index ed9eb26..80e789b 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml
@@ -5,9 +5,9 @@
#name: ym
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
-# url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
+ url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
# url: jdbc:mysql://8.130.130.233:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
- url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
+# url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username: root
password: dysql,;.abc!@#
druid:
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 9c53577..d814934 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"
@@ -313,18 +313,23 @@
#鍛戒护鍙戦�佸湴鍧�(涓紑鏄満鏋則ag锛屽叾涔熸槸鏁版嵁婧愬悗缂�鍚嶇О)
ym:
comSendUrl: "http://127.0.0.1:8070/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8070/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogText"
sp:
comSendUrl: "http://127.0.0.1:8073/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8073/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogText"
test:
comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8072/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogText"
#鐩戞祴鎺у埗妯″潡鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
+ #rtu杩滅▼鍗囩骇妯″潡鍥炶皟鍦板潃
+ ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive
#寰俊灏忕▼搴忓洖璋冨湴鍧�
rtuCallbackUrl_wx: "http://127.0.0.1:8087/wx/comRes/receive"
@@ -333,6 +338,7 @@
urls:
- /sso/sso
- /remote/comRes/receive
+ - /remote/rtuUpgradeStateReceiver/receive
- /wx/comRes/receive
- /app/captcha/get
- /file/file #web鍒嗗竷寮忔枃浠剁郴缁�
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 d0bc938..ee69901 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"
@@ -313,18 +313,23 @@
#鍛戒护鍙戦�佸湴鍧�(涓紑鏄満鏋則ag锛屽叾涔熸槸鏁版嵁婧愬悗缂�鍚嶇О)
ym:
comSendUrl: "http://127.0.0.1:8070/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8070/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogText"
sp:
comSendUrl: "http://127.0.0.1:8073/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8073/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogText"
test:
comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8072/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogText"
#鐩戞祴鎺у埗妯″潡鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
+ #rtu杩滅▼鍗囩骇妯″潡鍥炶皟鍦板潃
+ ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive
#寰俊灏忕▼搴忓洖璋冨湴鍧�
rtuCallbackUrl_wx: "http://127.0.0.1:8087/wx/comRes/receive"
@@ -333,6 +338,7 @@
urls:
- /sso/sso
- /remote/comRes/receive
+ - /remote/rtuUpgradeStateReceiver/receive
- /wx/comRes/receive
- /app/captcha/get
- /file/file #web鍒嗗竷寮忔枃浠剁郴缁�
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 7564bf5..b3b02d6 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"
@@ -313,18 +313,23 @@
#鍛戒护鍙戦�佸湴鍧�(涓紑鏄満鏋則ag锛屽叾涔熸槸鏁版嵁婧愬悗缂�鍚嶇О)
ym:
comSendUrl: "http://127.0.0.1:8070/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8070/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogText"
sp:
comSendUrl: "http://127.0.0.1:8073/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8073/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogText"
test:
comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8072/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogText"
#鐩戞祴鎺у埗妯″潡鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
+ #rtu杩滅▼鍗囩骇妯″潡鍥炶皟鍦板潃
+ ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive
#寰俊灏忕▼搴忓洖璋冨湴鍧�
rtuCallbackUrl_wx: "http://127.0.0.1:8087/wx/comRes/receive"
@@ -333,6 +338,7 @@
urls:
- /sso/sso
- /remote/comRes/receive
+ - /remote/rtuUpgradeStateReceiver/receive
- /wx/comRes/receive
- /app/captcha/get
- /file/file #web鍒嗗竷寮忔枃浠剁郴缁�
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 7564bf5..c3e6b55 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -77,7 +77,7 @@
pipIrr:
global:
- dev: false #鏄惁寮�鍙戦樁娈碉紝true鎴杅alse
+ dev: true #鏄惁寮�鍙戦樁娈碉紝true鎴杅alse
dsName: ym #寮�鍙戦樁娈碉紝璁剧疆涓存椂鐨勬暟鎹簱鍚嶇О
nginx:
webPort: 54321
@@ -313,18 +313,23 @@
#鍛戒护鍙戦�佸湴鍧�(涓紑鏄満鏋則ag锛屽叾涔熸槸鏁版嵁婧愬悗缂�鍚嶇О)
ym:
comSendUrl: "http://127.0.0.1:8070/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8070/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8070/rtuMw/com/rtuLogText"
sp:
comSendUrl: "http://127.0.0.1:8073/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8073/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8073/rtuMw/com/rtuLogText"
test:
comSendUrl: "http://127.0.0.1:8072/rtuMw/com/send"
+ ugTaskSendUrl: "http://127.0.0.1:8072/rtuMw/com/upgradeRtu"
rtuLogFileUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogFile"
rtuLogTextUrl: "http://127.0.0.1:8072/rtuMw/com/rtuLogText"
#鐩戞祴鎺у埗妯″潡鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
+ #rtu杩滅▼鍗囩骇妯″潡鍥炶皟鍦板潃
+ ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive
#寰俊灏忕▼搴忓洖璋冨湴鍧�
rtuCallbackUrl_wx: "http://127.0.0.1:8087/wx/comRes/receive"
@@ -333,6 +338,7 @@
urls:
- /sso/sso
- /remote/comRes/receive
+ - /remote/rtuUpgradeStateReceiver/receive
- /wx/comRes/receive
- /app/captcha/get
- /file/file #web鍒嗗竷寮忔枃浠剁郴缁�
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/UgRtuControllerMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/UgRtuControllerMapper.xml
index 7618f96..48a02fb 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/UgRtuControllerMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/UgRtuControllerMapper.xml
@@ -94,6 +94,14 @@
where task_id = #{taskId,jdbcType=BIGINT}
</select>
+ <select id="selectAllRtuAddrByTask" parameterType="java.lang.Long" resultType="java.lang.String">
+ <!--@mbg.generated-->
+ select
+ rtu_addr
+ from ug_rtu_controller
+ where task_id = #{taskId,jdbcType=BIGINT}
+ </select>
+
<select id="selectCountByTaskAndCon" resultType="java.lang.Long">
<!--@mbg.generated-->
select
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/webRequest/WebRequestDeal.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/webRequest/WebRequestDeal.java
index 5a422e2..a371bde 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/webRequest/WebRequestDeal.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/webRequest/WebRequestDeal.java
@@ -1,7 +1,7 @@
package com.dy.rtuMw.web.webRequest;
import com.dy.common.mw.protocol.Command;
-import com.dy.rtuMw.web.comResult.WebResponseVo;
+import com.dy.common.webUtil.BaseResponse;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -16,7 +16,7 @@
/**
* @Author: liurunyu
* @Date: 2024/11/11 16:29
- * @Description
+ * @Description 閫氫俊涓棿浠跺澶栧彂鍑虹殑web璇锋眰
*/
@Component()
public class WebRequestDeal {
@@ -30,6 +30,11 @@
this.restTemplate = restTemplate ;
}
+ /**
+ * 澶勭悊涓棿浠朵富鍔ㄥ彂璧风殑web璇锋眰
+ * @param webUrl
+ * @param obj
+ */
public void deal(String webUrl, Object obj) {
if (webUrl != null
&& !webUrl.trim().equals("")
@@ -41,10 +46,10 @@
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
HttpEntity<?> httpEntity = new HttpEntity<>(obj, headers);
- ResponseEntity<WebResponseVo> response = null;
+ ResponseEntity<BaseResponse> response = null;
try {
// 閫氳繃Post鏂瑰紡璋冪敤鎺ュ彛
- response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, WebResponseVo.class);
+ response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
} catch (Exception e) {
log.error("web璁块棶璇锋眰鍙戠敓寮傚父", e);
}
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
new file mode 100644
index 0000000..c8436a0
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeCtrl.java
@@ -0,0 +1,119 @@
+package com.dy.pipIrrRemote.rtuUpgrage;
+
+import com.dy.common.aop.SsoAop;
+import com.dy.common.multiDataSource.DataSourceContext;
+import com.dy.common.softUpgrade.state.UpgradeTaskVo;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.ResultCodeMsg;
+import com.dy.pipIrrGlobal.pojoRm.UgRtuProgram;
+import com.dy.pipIrrGlobal.pojoRm.UgRtuTask;
+import com.dy.pipIrrGlobal.rtuMw.ToRtuMwCom;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+import java.util.List;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/11/12 8:33
+ * @Description
+ */
+@Slf4j
+@Tag(name = "rtu杩滅▼鍗囩骇浠诲姟", description = "rtu杩滅▼鍗囩骇浠诲姟鐩稿叧鎿嶄綔")
+@RestController
+@RequestMapping(path = "rtuUpgrade")
+public class RtuUpgradeCtrl extends ToRtuMwCom {
+ @Autowired
+ private RtuUpgradeSv sv ;
+
+ @Autowired
+ private Environment env;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ /**
+ * 涓嬪彂rtu杩滅▼鍗囩骇浠诲姟
+ * @param id 浠诲姟id
+ * @return 鎿嶄綔缁撴灉
+ */
+ @Operation(summary = "涓嬪彂rtu杩滅▼鍗囩骇浠诲姟", description = "涓嬪彂rtu杩滅▼鍗囩骇浠诲姟")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "杩斿洖鎿嶄綔鎴愬姛涓庡惁鏁版嵁锛圔aseResponse.content:Boolean锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
+ @GetMapping(path = "/issuedTask")
+ @SsoAop()
+ public BaseResponse<Boolean> issuedTask(String id){
+ if(id == null || !id.trim().equals("")){
+ return BaseResponseUtils.buildError("浠诲姟id涓嶈兘涓虹┖") ;
+ }
+ UgRtuTask tpo = this.sv.selectTaskById(id) ;
+ if(tpo == null){
+ return BaseResponseUtils.buildError("浠诲姟涓嶅瓨鍦�") ;
+ }
+ if(tpo.isExecute == 1){
+ return BaseResponseUtils.buildError("浠诲姟宸蹭笅鍙戯紝涓嶈兘閲嶅涓嬪彂浠诲姟") ;
+ }
+ UgRtuProgram ppo = this.sv.selectProgramById(tpo.programId) ;
+ if(ppo == null){
+ return BaseResponseUtils.buildError("浠诲姟瀵瑰簲鐨勭▼搴忎笉瀛樺湪") ;
+ }
+
+ List<String> taskRtuAddrs = this.sv.selectAllRtuAddrByTask(id) ;
+ if(taskRtuAddrs == null || taskRtuAddrs.size() == 0){
+ return BaseResponseUtils.buildError("浠诲姟鎵�娑夊強鐨勬帶鍒跺櫒杩樻湭璁剧疆") ;
+ }
+
+ String ugCallbackUrl_rm = env.getProperty("mw." + DataSourceContext.get() + ".ugCallbackUrl_rm" );
+ if(ugCallbackUrl_rm == null || ugCallbackUrl_rm.trim().equals("")){
+ return BaseResponseUtils.buildError("鏈厤缃崌绾т换鍔″洖璋冪綉鍧�") ;
+ }
+
+ UpgradeTaskVo vo = new UpgradeTaskVo() ;
+ this.valueFromPo(vo, tpo, ppo) ;
+ vo.rtuAddrList = taskRtuAddrs ;
+ vo.callbackWebUrl = ugCallbackUrl_rm ;
+
+ String ugSendUrl = this.getToMwUgUrl(this.env) ;
+ BaseResponse res = sendUpgradeTask2Mw(restTemplate, ugSendUrl, vo) ;
+ if(res != null){
+ if(res.isSuccess()){
+ return BaseResponseUtils.buildSuccess(true) ;
+ }else{
+ log.error("閫氫俊涓棿浠舵墽琛屼笅鍙戝崌绾т换鍔″け璐�" + (res.getMsg() == null? "" : ("锛�" + res.getMsg()))) ;
+ return BaseResponseUtils.buildFail("閫氫俊涓棿浠舵墽琛屽け璐�" + (res.getMsg() == null? "" : ("锛�" + res.getMsg()))) ;
+ }
+ }else{
+ log.error("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
+ return BaseResponseUtils.buildFail("閫氫俊涓棿浠惰繑鍥炵粨鏋滀负null") ;
+ }
+ }
+
+ private void valueFromPo(UpgradeTaskVo vo, UgRtuTask tpo, UgRtuProgram ppo){
+ vo.id = "" + tpo.id ;
+ vo.softFileName = ppo.hexFileName ;
+ vo.softStoreAddr = ppo.storeRamAddr ;
+ vo.softStartAddr = ppo.startRamAddr ;
+ vo.softFileData = ppo.programBytes ;
+ vo.softBytesCalculate = ppo.programCalculateBytes ;
+ vo.softByteSrc16 = ppo.programCrc16 ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java
new file mode 100644
index 0000000..8032651
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeStateReceiverCtrl.java
@@ -0,0 +1,39 @@
+package com.dy.pipIrrRemote.rtuUpgrage;
+
+import com.dy.common.softUpgrade.state.UpgradeInfo;
+import com.dy.common.softUpgrade.state.UpgradeRtu;
+import com.dy.common.webUtil.BaseResponse;
+import io.swagger.v3.oas.annotations.Hidden;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/11/12 9:24
+ * @Description
+ */
+@Slf4j
+@Tag(name = "rtu杩滅▼鍗囩骇浠诲姟閫氫俊涓棿浠舵墽琛屾儏鍐电粺璁″洖鏀�", description = "rtu杩滅▼鍗囩骇浠诲姟閫氫俊涓棿浠舵墽琛屾儏鍐电粺璁″洖鏀�")
+@RestController
+@RequestMapping(path = "rtuUpgradeStateReceiver")
+public class RtuUpgradeStateReceiverCtrl {
+ /**
+ * rtu杩滅▼鍗囩骇浠诲姟閫氫俊涓棿浠舵墽琛屾儏鍐电粺璁″洖鏀�
+ * @param vo 鏁版嵁
+ * @return 鎿嶄綔缁撴灉
+ */
+ @Hidden //涓嶅叕寮�鎺ュ彛锛屽叾鍙湁閫氫俊涓棿浠惰皟鐢�
+ @PostMapping(path = "/receive")
+ public BaseResponse<Boolean> receive(@RequestBody UpgradeInfo vo){
+ log.info("鎺ユ敹鍒扮殑RTU杩滅▼鍗囩骇鐘舵�佹暟鎹负锛歿}",vo.toString());
+ if(vo.ugRtuStateList != null && vo.ugRtuStateList.size() > 0){
+ if(vo.ugRtuStateList.size() < 10){
+ for (UpgradeRtu upgradeRtu : vo.ugRtuStateList) {
+ log.info(upgradeRtu.toString());
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeSv.java
new file mode 100644
index 0000000..59aa42f
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtuUpgrage/RtuUpgradeSv.java
@@ -0,0 +1,54 @@
+package com.dy.pipIrrRemote.rtuUpgrage;
+
+import com.dy.pipIrrGlobal.daoRm.UgRtuControllerMapper;
+import com.dy.pipIrrGlobal.daoRm.UgRtuProgramMapper;
+import com.dy.pipIrrGlobal.daoRm.UgRtuTaskMapper;
+import com.dy.pipIrrGlobal.pojoRm.UgRtuProgram;
+import com.dy.pipIrrGlobal.pojoRm.UgRtuTask;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/11/12 8:33
+ * @Description
+ */
+@Slf4j
+@Service
+public class RtuUpgradeSv {
+ @Autowired
+ private UgRtuTaskMapper tdao ;
+ @Autowired
+ private UgRtuProgramMapper pdao ;
+ @Autowired
+ private UgRtuControllerMapper cdao ;
+
+ /**
+ * 閫氫俊涓婚敭鏌ヨ涓�涓崌绾т换鍔�
+ * @param id 涓婚敭
+ * @return
+ */
+ public UgRtuTask selectTaskById(String taskId){
+ return tdao.selectByPrimaryKey(Long.valueOf(taskId));
+ }
+
+ /**
+ * 閫氫俊涓婚敭鏌ヨ涓�涓崌绾х▼搴�
+ * @param id 涓婚敭
+ * @return
+ */
+ public UgRtuProgram selectProgramById(Long id){
+ return pdao.selectByPrimaryKey(id);
+ }
+
+ /**
+ * 鏌ヨ涓�涓崌绾т换鍔℃墍鏈夋帶鍒跺櫒鍦板潃
+ * @return 涓�浜涗竴浜涙帶鍒跺櫒鍦板潃
+ */
+ public List<String> selectAllRtuAddrByTask(String taskId){
+ return this.cdao.selectAllRtuAddrByTask(Long.valueOf(taskId)) ;
+ }
+}
--
Gitblit v1.8.0