From ea58523b67ad59002a1191c3c564258c5b81f6f2 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 06 五月 2025 17:35:16 +0800
Subject: [PATCH] Revert "1、实现万用token(0000-0000-1234-9876-5); 2、web端单独实现命令结果等待器,并修改相关部分; 3、web端实现透传命令; 4、修改一些不当注释; 5、优化一些代码。"
---
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java | 10 +
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/ReturnCommand.java | 24 ++--
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DataV1.java | 2
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java | 62 +++++-----
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data.java | 2
/dev/null | 16 --
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandResultCtrl.java | 11 -
pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java | 12 -
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.yml | 1
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandResultCtrl.java | 9
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransCtrl.java | 135 ----------------------
pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransSv.java | 47 ++-----
13 files changed, 77 insertions(+), 256 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data.java
index 1752c65..fae4d48 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data.java
@@ -18,7 +18,7 @@
public String protocol ;//鏁版嵁鎵�瀵瑰簲鐨勫崗璁悕绉�
public Short protocolVer;//鏁版嵁鎵�瀵瑰簲鐨勫崗璁増鏈彿锛�1~255锛�
public String code ;//鏁版嵁鎵�瀵瑰簲鐨勫姛鑳界爜:
- public Object subData ;//瀵瑰簲鍚勪釜鍗忚鏁版嵁
+ public Object subData ;//瀵瑰簲鍚勪釜鍔熻兘鐮佺殑鍏蜂綋鏁版嵁
public String hex ;//涓婃姤鏁版嵁鐨勫崄鍏繘鍒�
public String toString() {
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DataV1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DataV1.java
index 23e3ef1..d8b5251 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DataV1.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DataV1.java
@@ -9,7 +9,7 @@
public String rtuAddr ;//RtuAddr
- public Object subData ;//鍔熻兘鐮佹暟鎹�
+ public Object subData ;
public String dt ;//閫氫俊涓棿浠朵骇鐢熺殑鏀舵姤鏃堕棿(yyyy-MM-dd hh:mm:ss)
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComResultWait.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComResultWait.java
deleted file mode 100644
index 8cd8151..0000000
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComResultWait.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.dy.pipIrrGlobal.command;
-
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * @Author: liurunyu
- * @Date: 2025/5/6 16:33
- * @Description
- */
-public class ComResultWait {
-
- //ConcurrentHashMap鏄嚎绋嬪畨鍏ㄧ殑
- private static final Map<Long, CompletableFuture> features = new ConcurrentHashMap<>();
-
- public static void put(Long key, CompletableFuture value) {
- features.put(key, value);
- }
- public static CompletableFuture get(Long key) {
- return features.get(key);
- }
-
- public static void remove(Long key){
- features.remove(key) ;
- }
-
-}
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java
index a066651..646d9be 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java
@@ -66,6 +66,10 @@
protected String commandTypeOuter = CommandType.outerCommand;
+ // 瀛樺偍瀹炰緥鍖栫殑 CompletableFuture<Data> 瀵硅薄
+ protected static Map<Long, Object> features = new HashMap<>();
+ //protected static Boolean setuped = false;
+
@Autowired
private RestTemplate restTemplate;
@@ -208,19 +212,19 @@
*/
protected BaseResponse<Data> dealWithCallBack(Long comId, Command com) {
CompletableFuture<JSONObject> feature = new CompletableFuture<>();
- ComResultWait.put(comId, feature);
+ features.put(comId, feature);
try {
// 鍙戦�佸懡浠�
JSONObject response_SendCom = (JSONObject) JSON.toJSON(sendCom2Mw(com));
if (response_SendCom == null || !response_SendCom.getString("code").equals("0001")) {
// 璇锋眰澶辫触锛孯TU鏈笂绾匡紝娓呴櫎feature
- ComResultWait.remove(comId);
+ features.remove(comId);
JSONObject job_param = response_SendCom.getJSONObject("content").getJSONObject("param");
return BaseResponseUtils.buildErrorMsg(job_param.getString("message"));
}
JSONObject resultData = feature.get(180, TimeUnit.SECONDS);
- ComResultWait.remove(comId);
+ features.remove(comId);
Long commandId = resultData.getLong("commandId");
if (commandId.equals(comId)) {
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/CommandSv.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/CommandSv.java
deleted file mode 100644
index 9bf6199..0000000
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/CommandSv.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package com.dy.pipIrrGlobal.command;
-
-import com.alibaba.fastjson2.JSON;
-import com.alibaba.fastjson2.JSONObject;
-import com.dy.common.mw.protocol.Command;
-import com.dy.common.mw.protocol.CommandBackParam;
-import com.dy.common.mw.protocol.p206V1.CodeV1;
-import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1;
-import com.dy.common.mw.protocol.p206V2.CodeV2;
-import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2;
-import com.dy.common.mw.protocol.p206V202404.CodeV202404;
-import com.dy.common.mw.protocol.p206V202404.ProtocolConstantV206V202404;
-import com.dy.common.webUtil.BaseResponse;
-import com.dy.pipIrrGlobal.daoPr.PrControllerMapper;
-import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper;
-import com.dy.pipIrrGlobal.pojoPr.PrController;
-import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
-import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw;
-
-import java.util.Date;
-
-/**
- * @Author: liurunyu
- * @Date: 2025/5/6 11:41
- * @Description
- */
-public class CommandSv extends Web2RtuMw {
-
-
- /**
- * 浠庢暟鎹簱涓煡璇㈡帶鍒跺櫒瀵硅薄
- * @param prControllerDao
- * @param intakeId
- * @return
- */
- public PrController getRtu(PrControllerMapper prControllerDao, Long intakeId){
- return prControllerDao.getRtu(intakeId, null);
- }
-
- /**
- * 妫�鏌ュ崗璁槸鍚︽敮鎸�
- * @param ctrlPo
- * @return
- */
- public String checkProtocol(PrController ctrlPo){
- if(!ctrlPo.getProtocol().equals(ProtocolConstantV206V1.protocolName)
- && !ctrlPo.getProtocol().equals(ProtocolConstantV206V2.protocolName)
- && !ctrlPo.getProtocol().equals(ProtocolConstantV206V202404.protocolName)) {
- return "瀵瑰簲鎺у埗鍣ㄥ崗璁�" + ctrlPo.getProtocol() + "鏈疄鐜板懡浠ゅ彂閫侀�昏緫" ;
- }
- return null ;
- }
-
- /**
- * 鏍规嵁鍗忚鑾峰彇鍛戒护鍚嶇О
- * @param nowComCode
- * @param ctrlPo
- * @return
- */
- public String getCommandName(String nowComCode, PrController ctrlPo){
- if(ctrlPo.getProtocol().equals(ProtocolConstantV206V1.protocolName)) {
- return CodeV1.getCodeName(nowComCode) ;
- }else if(ctrlPo.getProtocol().equals(ProtocolConstantV206V2.protocolName)) {
- return CodeV2.getCodeName(nowComCode) ;
- }else if(ctrlPo.getProtocol().equals(ProtocolConstantV206V202404.protocolName)) {
- return CodeV202404.getCodeName(nowComCode) ;
- }
- return null ;
- }
-
- /**
- * 淇濆瓨鍛戒护鍘嗗彶璁板綍
- * @param rmCommandHistoryDao
- * @param comId
- * @param protocol
- * @param commandCode
- * @param commandName
- * @param intakeId
- * @param rtuAddr
- * @param param
- * @param operator
- * @return
- */
- public RmCommandHistory saveComHistoryPo(RmCommandHistoryMapper rmCommandHistoryDao,
- Long comId,
- String protocol,
- String commandCode,
- String commandName,
- Long intakeId,
- String rtuAddr,
- Object param,
- Long operator) {
- RmCommandHistory po = new RmCommandHistory();
- po.setComId(comId);
- po.setCommandCode(commandCode);
- po.setCommandName(commandName);
- po.setIntakeId(intakeId);
- po.setRtuAddr(rtuAddr);
- po.setProtocol(protocol);
- po.setParam((JSONObject) JSON.toJSON(param));
- po.setSendTime(new Date());
- po.setOperator(operator);
- rmCommandHistoryDao.insertSelective(po) ;
- return po;
- }
-
- /**
- * 澶勭悊閫氫俊涓棿浠惰繑鍥炵殑鍛戒护澶勭悊缁撴灉
- * @param res
- * @return
- */
- public String dealMwDealResponse(BaseResponse res){
- if(res != null){
- Command reCom = JSON.parseObject(res.getContent() == null ? null : JSON.toJSONString(res.getContent()), Command.class) ;
- CommandBackParam bakParam = JSON.parseObject((reCom== null || reCom.param == null) ? null : JSON.toJSONString(reCom.param), CommandBackParam.class) ;
- if(res.isSuccess()){
- if(bakParam != null){
- if(bakParam.getSuccess().booleanValue()){
- //閫氫俊涓棿浠舵垚鍔熷鐞嗕簡鍛戒护
- //绛夊緟鎺у埗鍣ㄦ帴鏀跺苟鎵ц鍛戒护鍚庣殑搴旂瓟锛岀劧鍚庨�氫俊涓棿浠堕�氱煡鏈ā鍧�
- return null ;
- }else{
- return "閫氫俊涓棿浠跺鐞嗗懡浠ゅけ璐ワ紝澶辫触淇℃伅锛�" + bakParam.getMessage();
- }
- }else{
- return "閫氫俊涓棿浠惰繑鍥炲懡浠ょ粨鏋滀腑涓嶅寘鍚獵ommandBackParam绫诲瀷鍙傛暟";
- }
- }else{
- if(bakParam != null){
- if(bakParam.getSuccess().booleanValue()){
- //閫氫俊涓棿浠舵垚鍔熷鐞嗕簡鍛戒护
- //绛夊緟鎺у埗鍣ㄦ帴鏀跺苟鎵ц鍛戒护鍚庣殑搴旂瓟锛岀劧鍚庨�氫俊涓棿浠堕�氱煡鏈ā鍧�
- return "閫氫俊涓棿浠跺鐞嗗懡浠ゅけ璐ワ紝澶辫触淇℃伅锛�" + (res.getMsg() == null? "" : ("锛�" + res.getMsg())) ;
- }else{
- return "閫氫俊涓棿浠跺鐞嗗懡浠ゅけ璐ワ紝澶辫触淇℃伅锛�" + bakParam.getMessage();
- }
- }else{
- return "閫氫俊涓棿浠跺鐞嗗懡浠ゅけ璐ワ紝澶辫触淇℃伅锛�" + (res.getMsg() == null? "" : ("锛�" + res.getMsg())) ;
- }
- }
- }else{
- return "閫氫俊涓棿浠惰繑鍥炲懡浠ょ粨鏋滀负null";
- }
- }
-
-}
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 42d074e..41de437 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
@@ -31,20 +31,20 @@
private static final String pro_mw = "mw";
private static final String pro_url = "url";
- public static final String ContextComSend = "/rtuMw/com/send";
+ protected static final String ContextComSend = "/rtuMw/com/send";
- public static final String ContextRtuLogFile = "/rtuMw/com/rtuLogFile";
- public static final String ContextRtuLogText = "/rtuMw/com/rtuLogText";
+ protected static final String ContextRtuLogFile = "/rtuMw/com/rtuLogFile";
+ protected static final String ContextRtuLogText = "/rtuMw/com/rtuLogText";
- public static final String ContextRegisterMsReceiverWebUrl = "/rtuMw/com/registerMsReceiverWebUrl";
- public static final String ContextUgTaskSend = "/rtuMw/com/upgradeRtu";
- public static final String ContextUgForceOver = "/rtuMw/com/ugForceOver";
+ protected static final String ContextRegisterMsReceiverWebUrl = "/rtuMw/com/registerMsReceiverWebUrl";
+ protected static final String ContextUgTaskSend = "/rtuMw/com/upgradeRtu";
+ protected static final String ContextUgForceOver = "/rtuMw/com/ugForceOver";
/**
* 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佹暟鎹殑URL
* @param env
* @return
*/
- public String get2MwUrl(Environment env) {
+ protected String get2MwUrl(Environment env) {
return env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + pro_url);
}
/**
@@ -53,76 +53,76 @@
* @param orgTag
* @return
*/
- public String get2MwUrl(Environment env, String orgTag) {
+ protected String get2MwUrl(Environment env, String orgTag) {
return env.getProperty(pro_mw + "." + orgTag + "." + pro_url);
}
/**
- * 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佹暟鎹殑URL
+ * 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佸己鍒跺仠姝㈠崌绾х殑鍛戒护URL
* @param env
* @param context
* @return
*/
- public String get2MwRequestUrl(Environment env, String context) {
+ protected String get2MwRequestUrl(Environment env, String context) {
return get2MwUrl(env) + context;
}
/**
- * 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佹暟鎹殑URL
+ * 寰楀埌鍚戦�氫俊涓棿浠跺彂閫佸己鍒跺仠姝㈠崌绾х殑鍛戒护URL
* @param env
* @param orgTag
* @param context
* @return
*/
- public String get2MwRequestUrl(Environment env, String orgTag, String context) {
+ protected String get2MwRequestUrl(Environment env, String orgTag, String context) {
return get2MwUrl(env, orgTag) + context;
}
/**
- * 鍚戦�氫俊涓棿浠跺彂閫丳ost璇锋眰
+ * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
* @param restTemplate SpringBoot鐨凴estTemplate
* @param toMwUrl 鍒伴�氫俊涓棿浠剁殑web璇锋眰Url
- * @param body 鏁版嵁
+ * @param body 璇锋眰鏁版嵁
* @return
*/
- public BaseResponse sendPostRequest2Mw(RestTemplate restTemplate, String toMwUrl, Object body) {
+ protected BaseResponse sendPostRequest2Mw(RestTemplate restTemplate, String toMwUrl, Object body) {
String url = UriComponentsBuilder.fromUriString(toMwUrl)
.build()
.toUriString();
HttpHeaders headers = new HttpHeaders();
HttpEntity<?> httpEntity = new HttpEntity<>(body, headers);
- ResponseEntity<BaseResponse> resEntity = null;
+ ResponseEntity<BaseResponse> response = null;
try {
// 閫氳繃Post鏂瑰紡璋冪敤鎺ュ彛
- resEntity = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
+ response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, BaseResponse.class);
} catch (Exception e) {
e.printStackTrace();
return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
}
- if(resEntity == null){
+ if(response == null){
return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屼腑闂翠欢璋冪敤寮傚父");
}else{
- return resEntity.getBody();
+ return response.getBody();
}
}
/**
- * 鍚戦�氫俊涓棿浠跺彂閫丟et璇锋眰
+ * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
* @param restTemplate SpringBoot鐨凴estTemplate
* @param toMwUrl 鍒伴�氫俊涓棿浠剁殑web璇锋眰Url
* @return
*/
- public BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl) {
+ protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl) {
return sendGetRequest2Mw(restTemplate, toMwUrl, null);
}
/**
- * 鍚戦�氫俊涓棿浠跺彂閫丟et璇锋眰
+ * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
* @param restTemplate SpringBoot鐨凴estTemplate
* @param toMwUrl 鍒伴�氫俊涓棿浠剁殑web璇锋眰Url
* @param paramName 鍙傛暟鍚嶇О
* @param paramValue 鍙傛暟
* @return
*/
- public BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl, String paramName, String paramValue) {
+ protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl, String paramName, String paramValue) {
String url = UriComponentsBuilder.fromUriString(toMwUrl)
.build()
.toUriString();
@@ -135,13 +135,13 @@
}
/**
- * 鍚戦�氫俊涓棿浠跺彂閫丟et璇锋眰
+ * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
* @param restTemplate SpringBoot鐨凴estTemplate
* @param toMwUrl 鍒伴�氫俊涓棿浠剁殑web璇锋眰Url
* @param params 鍙傛暟闆嗗悎锛屽弬鏁板悕绉版槸key锛屽弬鏁版槸value
* @return
*/
- public BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl, Map<String, String> params) {
+ protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, String toMwUrl, Map<String, String> params) {
String url = UriComponentsBuilder.fromUriString(toMwUrl)
.build()
.toUriString();
@@ -159,12 +159,12 @@
}
/**
- * 鍚戦�氫俊涓棿浠跺彂閫丟et璇锋眰
+ * 鍚戦�氫俊涓棿浠跺彂閫乺tu杩滅▼鍗囩骇浠诲姟
* @param restTemplate SpringBoot鐨凴estTemplate
* @param builder
* @return
*/
- public BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, UriComponentsBuilder builder) {
+ protected BaseResponse sendGetRequest2Mw(RestTemplate restTemplate, UriComponentsBuilder builder) {
ResponseEntity<BaseResponse> response;
try {
// 閫氳繃Get鏂瑰紡璋冪敤鎺ュ彛
@@ -188,7 +188,7 @@
* @param code 鍛戒护code
* @return
*/
- public Command createOuterCommand(String comId, String code) {
+ protected Command createOuterCommand(String comId, String code) {
Command com = new Command();
com.id = comId;
com.code = code ;
@@ -201,7 +201,7 @@
* @param code 鍛戒护code
* @return
*/
- public Command createOuterTransparentCommand(String comId, String code) {
+ protected Command createOuterTransparentCommand(String comId, String code) {
Command com = new Command();
com.id = comId;
com.code = code ;
@@ -210,11 +210,11 @@
}
/**
- * 鍒涘缓鍐呴儴鍛戒护
+ * 鍒涘缓鍐呴儴
* @param code 鍛戒护code
* @return
*/
- public Command createInnerCommand(String code) {
+ protected Command createInnerCommand(String code) {
Command com = new Command();
com.id = Command.defaultId;
com.code = code ;
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 89434e4..0c1679a 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -365,7 +365,6 @@
ugCallbackUrl_rm: "http://127.0.0.1:8081/remote/rtuUpgradeStateReceiver/receive"
#寰俊灏忕▼搴忓簲鐢ㄤ腑Rtu杩滅▼鍛戒护缁撴灉鍥炶皟鍦板潃
rtuCallbackUrl_wx: "http://127.0.0.1:8087/wx/comRes/receive"
- waitMwRtnResultTimeout: 60 #绛夊緟涓棿浠惰繑鍥炵粨鏋滆秴鏃舵椂闂达紝鍗曚綅绉掗挓
#涓嶈繘琛寀serToken杩囨护鐨刄RL锛孈ConfigurationProperties瑕佹眰tokennofilter涓墍鏈夊瓧姣嶉兘灏忓啓
tokennofilter:
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/ReturnCommand.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/ReturnCommand.java
index 3a80412..f07c999 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/ReturnCommand.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/local/ReturnCommand.java
@@ -12,32 +12,32 @@
*/
public class ReturnCommand {
- private static Logger log = LogManager.getLogger(ReturnCommand.class);
+ private static Logger log = LogManager.getLogger(ReturnCommand.class) ;
/**
* 澶勭悊鍛戒护鎴愬姛
* @param message
*/
- public static Command successed(String message, String commandId, String code, Object attachment) {
- log.info(message);
- Command command = new Command().createReturnSuccessCommand(message, commandId, code);
- command.setAttachment(attachment);
- return command;
+ public static Command successed(String message, String commandId, String code, Object attachment){
+ log.info(message) ;
+ Command command = new Command().createReturnSuccessCommand(message, commandId, code) ;
+ command.setAttachment(attachment) ;
+ return command ;
}
/**
* 澶勭悊鍛戒护鎴愬姛
* @param message
*/
- public static Command successed(String message, String commandId, String code) {
- log.info(message);
- return new Command().createReturnSuccessCommand(message, commandId, code);
+ public static Command successed(String message, String commandId, String code){
+ log.info(message) ;
+ return new Command().createReturnSuccessCommand(message, commandId, code) ;
}
/**
* 澶勭悊鍛戒护鍙戠敓閿欒
* @param message
*/
- public static Command errored(String message, String commandId, String code) {
- log.error(message);
- return new Command().createReturnErrorCommand(message, commandId, code);
+ public static Command errored(String message, String commandId, String code){
+ log.error(message) ;
+ return new Command().createReturnErrorCommand(message, commandId, code) ;
}
}
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 5b26ebc..3c4781f 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
@@ -330,7 +330,7 @@
CoreUnit.getInstance().pushCoreTask(task);
}catch(Exception e){
log.error(e.getMessage(), e);
- return BaseResponseUtils.buildError(ReturnCommand.errored("閫忎紶鍛戒护澶勭悊澶辫触" + e.getMessage(), command.getId(), command.getCode())) ;
+ return BaseResponseUtils.buildError(ReturnCommand.successed("閫忎紶鍛戒护澶勭悊澶辫触" + e.getMessage(), command.getId(), command.getCode())) ;
}
return BaseResponseUtils.buildSuccess(ReturnCommand.successed("閫忎紶鍛戒护宸叉帴鍙楋紝鍗冲皢鏋勯�犲苟涓嬪彂鍛戒护銆�", command.getId(), command.getCode()));
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandResultCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandResultCtrl.java
index a6dbe37..21d02e1 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandResultCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandResultCtrl.java
@@ -3,7 +3,6 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.mw.protocol.Data;
-import com.dy.pipIrrGlobal.command.ComResultWait;
import com.dy.pipIrrGlobal.command.ComSupport;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
@@ -28,7 +27,7 @@
@PostMapping(path = "receive", consumes = MediaType.APPLICATION_JSON_VALUE)
public void receive(@RequestBody Data data) {
JSONObject job_data = (JSONObject) JSON.toJSON(data);
- //String job_dataS = job_data.toJSONString();
+ String job_dataS = job_data.toJSONString();
JSONObject job_subData = job_data.getJSONObject("subData").getJSONObject("subData");
JSONObject job_response = new JSONObject();
@@ -36,11 +35,11 @@
job_response.put("commandCode", job_data.getString("code"));
job_response.put("commandId", job_data.getString("commandId"));
- CompletableFuture<JSONObject> feature = (CompletableFuture<JSONObject>) ComResultWait.get(job_data.getLong("commandId"));
+ CompletableFuture<JSONObject> feature = (CompletableFuture<JSONObject>) features.get(job_data.getLong("commandId"));
if(feature != null) {
feature.complete(job_response);
- }//else{
- // feature.complete(new JSONObject());
- //}
+ }else{
+ feature.complete(new JSONObject());
+ }
}
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransCtrl.java
index 2c87d06..a1e4b11 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransCtrl.java
@@ -1,32 +1,10 @@
package com.dy.pipIrrRemote.monitor;
-import com.alibaba.fastjson2.JSONObject;
-import com.dy.common.aop.SsoAop;
-import com.dy.common.mw.protocol.Command;
-import com.dy.common.util.IDLongGenerator;
-import com.dy.common.util.NumUtil;
-import com.dy.common.webUtil.BaseResponse;
-import com.dy.common.webUtil.BaseResponseUtils;
-import com.dy.pipIrrGlobal.command.ComResultWait;
-import com.dy.pipIrrGlobal.pojoPr.PrController;
import io.swagger.v3.oas.annotations.tags.Tag;
-import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.core.env.Environment;
-import org.springframework.http.MediaType;
-import org.springframework.validation.BindingResult;
-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 org.springframework.web.client.RestTemplate;
-
-import java.util.Objects;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
/**
* @Author: liurunyu
@@ -37,120 +15,11 @@
@Slf4j
@Tag(name = "杩滅▼閫忎紶鍛戒护", description = "杩滅▼閫忎紶鍛戒护")
@RestController
-@RequestMapping(path = "comTrans")
+@RequestMapping(path = "command")
@RequiredArgsConstructor
public class ComTransCtrl {
- @Autowired
- private Environment env ;
+ private final ComTransSv comSv;
- @Autowired
- private RestTemplate restTemplate ;
-
- @Value("${mw.waitMwRtnResultTimeout}")
- private int waitMwRtnResultTimeout ;
-
- @Value("${mw.rtuCallbackUrl_rm}")
- private String rtuResultSendWebUrl;
-
- @Autowired
- private ComTransSv comSv;
-
- /**
- * 鍚戣澶囷紙鎺у埗鍣級鍙戦�侀�忎紶鍛戒护
- * @param dto 鍓嶇鍙戞潵鐨勫�煎璞�
- * @param bindingResult 瀵筪to楠岃瘉鐨勭粨鏋�
- * @return 杩斿洖鍓嶇
- */
- @PostMapping(path = "send", consumes = MediaType.APPLICATION_JSON_VALUE)
- @SsoAop()
- public BaseResponse<Object> send(@RequestBody @Valid ComTransDto dto, BindingResult bindingResult) {
- if (bindingResult != null && bindingResult.hasErrors()) {
- return BaseResponseUtils.buildError(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
- }
- String msg = this.checkDto(dto) ;
- if(msg != null){
- return BaseResponseUtils.buildError(msg) ;
- }
- //寰楀埌鎺у埗鍣ㄥ璞�
- PrController ctrlPo = comSv.getRtu(dto.getIntakeId());
- if (ctrlPo == null) {
- return BaseResponseUtils.buildError("浠庢暟鎹簱涓湭寰楀埌鎺у埗鍣ㄦ暟鎹�") ;
- }
- //妫�鏌ュ崗璁�
- msg = comSv.checkProtocol(ctrlPo) ;
- if(msg != null) {
- return BaseResponseUtils.buildError(msg) ;
- }
- //寰楀埌鍔熻兘鐮佸搴旂殑鍛戒护鍚嶇О
- String comName = comSv.getCommandName(dto.comCode, ctrlPo) ;
- if(comName == null) {
- return BaseResponseUtils.buildError("鏈緱鍒板姛鑳界爜瀵瑰簲鍛戒护鍚嶇О") ;
- }
- Long comId = new IDLongGenerator().generate();
- String comData = dto.comData.toUpperCase() ;
- //鐢熸垚骞朵繚瀛樺懡浠ゆ棩蹇�
- comSv.saveComHistoryPo(comId, ctrlPo.getProtocol(), dto.comCode, "閫忎紶锛�" + comName + "锛�",
- dto.getIntakeId(), ctrlPo.getRtuAddr(), new ComTransParam(dto.comCode, comData), dto.getOperator());
- try{
- CompletableFuture<JSONObject> feature = new CompletableFuture<>();
- ComResultWait.put(comId, feature);
- //鍒涘缓澶栭儴閫忎紶鍛戒护锛堝彂缁欐帶鍒跺櫒锛�
- Command com = comSv.createOuterTransparentCommand("" + comId, dto.comCode);
- com.rtuAddr = ctrlPo.getRtuAddr() ;
- com.attachment = comData ;
- com.rtuResultSendWebUrl = rtuResultSendWebUrl;
- //寰楀埌閫氫俊涓棿浠跺彂閫佸懡浠ょ殑web URL
- String rqUrl = comSv.get2MwRequestUrl(this.env, comSv.ContextComSend) ;
- //鍚戦�氫俊涓棿浠跺彂閫亀eb璇锋眰
- BaseResponse res = comSv.sendPostRequest2Mw(restTemplate, rqUrl, com) ;
- //澶勭悊閫氫俊涓棿浠跺web璇锋眰鐨勫搷搴�
- msg = comSv.dealMwDealResponse(res) ;
- if(msg != null) {
- return BaseResponseUtils.buildError(msg) ;
- }else{
- try{
- //绛夊緟閫氫俊涓棿浠堕�氱煡鎺у埗鍣ㄦ墽琛屽懡浠や笂琛屾暟鎹紙鍛戒护缁撴灉锛�
- JSONObject resultData = feature.get(waitMwRtnResultTimeout, TimeUnit.SECONDS);
- Long commandId = resultData.getLong("commandId");
- if (commandId.equals(comId)) {
- return BaseResponseUtils.buildSuccess(resultData);
- } else {
- return BaseResponseUtils.buildSuccess("鎺у埗鍣ㄦ墽琛屽懡浠ゆ垚鍔�");
- }
- }catch (Exception e){
- return BaseResponseUtils.buildFail("绛夊緟閫氫俊涓棿浠堕�氱煡鍛戒护缁撴灉瓒呮椂鎴栧紓甯�");
- }
- }
- }catch (Exception e){
- return BaseResponseUtils.buildFail("鏈嶅姟绔瀯閫犲苟鍚戦�氫俊涓棿浠跺彂閫佽姹傛椂寮傚父" + (e.getMessage() == null?"":e.getMessage())) ;
- }finally {
- try {
- //鏈�鍚庢竻闄ompletableFuture缂撳瓨
- ComResultWait.remove(comId);
- }catch (Exception ee){}
- }
- }
-
- /**
- * 楠岃瘉
- * @param dto
- * @return
- */
- private String checkDto(ComTransDto dto){
- if(!NumUtil.isHex(dto.comCode)){
- return "鍛戒护鍔熻兘鐮佷笉鏄崄鍏繘鍒舵暟";
- }
- if(!NumUtil.isHex(dto.comData)){
- return "鍛戒护鏁版嵁涓嶆槸鍗佸叚杩涘埗鏁�";
- }
- if(dto.comData.length() % 2 != 0){
- return "鍛戒护鏁版嵁涓嶅畬澶囷紙闀垮害涓嶆槸鍋舵暟锛�";
- }
- if(!dto.comData.contains(dto.comCode)){
- return "鍛戒护鏁版嵁涓笉鍖呭惈鍔熻兘鐮�";
- }
- return null ;
- }
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransDto.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransDto.java
deleted file mode 100644
index ef5d3b2..0000000
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransDto.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.dy.pipIrrRemote.monitor;
-
-import com.dy.pipIrrRemote.common.dto.DtoBase;
-import jakarta.validation.constraints.NotEmpty;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-/**
- * @Author: liurunyu
- * @Date: 2025/5/6 10:21
- * @Description
- */
-
-@Data
-@EqualsAndHashCode(callSuper=true)
-public class ComTransDto extends DtoBase {
- public static final long serialVersionUID = 202505061021001L;
-
- @NotEmpty(message = "鍛戒护鍔熻兘鐮佷笉鑳戒负绌�")
- public String comCode ;//鍛戒护鍔熻兘鐮侊紝瑕佹眰鏄崄鍏繘鍒�
-
- @NotEmpty(message = "鍛戒护鏁版嵁涓嶈兘涓虹┖")
- public String comData ;//鍛戒护鏁版嵁锛岃姹傛槸鍗佸叚杩涘埗
-}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransParam.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransParam.java
deleted file mode 100644
index 6e3b665..0000000
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransParam.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.dy.pipIrrRemote.monitor;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-
-/**
- * @Author: liurunyu
- * @Date: 2025/5/6 11:36
- * @Description
- */
-@Data
-@AllArgsConstructor
-public class ComTransParam {
- public String commandCode;
- public String data ;
-}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransSv.java
index 50898f8..2c49714 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/monitor/ComTransSv.java
@@ -1,14 +1,12 @@
package com.dy.pipIrrRemote.monitor;
-import com.dy.pipIrrGlobal.command.CommandSv;
-import com.dy.pipIrrGlobal.daoPr.PrControllerMapper;
-import com.dy.pipIrrGlobal.daoRm.RmCommandHistoryMapper;
-import com.dy.pipIrrGlobal.pojoPr.PrController;
-import com.dy.pipIrrGlobal.pojoRm.RmCommandHistory;
+import com.dy.pipIrrGlobal.daoPr.PrIntakeMapper;
+import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.client.RestTemplate;
/**
* @Author: liurunyu
@@ -17,36 +15,15 @@
*/
@Slf4j
@Service
-public class ComTransSv extends CommandSv {
+public class ComTransSv extends Web2RtuMw {
@Autowired
- private PrControllerMapper prControllerDao ;
- @Autowired
- private RmCommandHistoryMapper rmCommandHistoryDao ;
+ private PrIntakeMapper prIntakeMapper;
- public PrController getRtu(Long intakeId){
- return this.getRtu(prControllerDao, intakeId);
- }
- /**
- * 鍒涘缓鍛戒护鏃ュ織瀵硅薄
- *
- * @param comId 涓婚敭
- * @param commandCode 鍔熻兘鐮�
- * @param rtuAddr 闃�鎺у櫒鍦板潃
- * @param protocol 閫氳鍗忚鍚嶇О
- * @param param 鍙傛暟鏁版嵁
- * @param operator 鎿嶄綔鍛�
- * @return
- */
- @Transactional(rollbackFor = Exception.class)
- public RmCommandHistory saveComHistoryPo(Long comId,
- String protocol,
- String commandCode,
- String commandName,
- Long intakeId,
- String rtuAddr,
- Object param,
- Long operator) {
- return this.saveComHistoryPo(rmCommandHistoryDao, comId, protocol, commandCode, commandName, intakeId, rtuAddr, param, operator) ;
- }
+ @Autowired
+ private Environment env;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
index 0825495..f475e27 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
@@ -39,8 +39,6 @@
@RequestMapping(path="sso")
@SuppressWarnings("unchecked")//java鐗堟湰瓒婇珮锛屽娉涘瀷绾︽潫瓒婁弗锛屾墍浠ラ厤缃甋uppressWarnings("unchecked")
public class SsoCtrl {
- //涓囩敤token
- private static final String UniversalUserToken = "0000-0000-1234-9876-5";
//鍦ㄥ睘鎬т笂娉ㄨВ@Autowired鏃讹紝浼氳鍛� Field injection is not recommended锛堜笉鍐嶆帹鑽愪娇鐢ㄥ瓧娈垫敞鍏ワ級
private SsoSv sv ;
@@ -263,15 +261,7 @@
@Hidden
@GetMapping(path = "ssoCheck")
public SsoVo ssoCheck(String token){
- BaUser userPo = null ;
- if(token.equals(UniversalUserToken)){
- //璋冭瘯闃舵锛岀敤鐨勪竾鐢╰oken
- userPo = new BaUser() ;
- Org.OrgVo orgVo = Org.OrgList.get(0) ;
- userPo.orgTag = orgVo.tag ;
- }else{
- userPo = this.sv.getByUuid(token) ;
- }
+ BaUser userPo = this.sv.getByUuid(token) ;
SsoVo vo = new SsoVo();
if(userPo != null){
vo.dataSourceName = userPo.orgTag ;
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandResultCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandResultCtrl.java
index 76c8f2f..493625f 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandResultCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandResultCtrl.java
@@ -3,7 +3,6 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.dy.common.mw.protocol.Data;
-import com.dy.pipIrrGlobal.command.ComResultWait;
import com.dy.pipIrrGlobal.command.ComSupport;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
@@ -36,11 +35,11 @@
job_response.put("commandCode", job_data.getString("code"));
job_response.put("commandId", job_data.getString("commandId"));
- CompletableFuture<JSONObject> feature = (CompletableFuture<JSONObject>) ComResultWait.get(job_data.getLong("commandId"));
+ CompletableFuture<JSONObject> feature = (CompletableFuture<JSONObject>) features.get(job_data.getLong("commandId"));
if(feature != null) {
feature.complete(job_response);
- }//else{
- // feature.complete(new JSONObject());
- //}
+ }else{
+ feature.complete(new JSONObject());
+ }
}
}
--
Gitblit v1.8.0