From e48d097ca0532090a7a109af4c2c9c6e1b288a34 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 05 十二月 2024 15:06:43 +0800
Subject: [PATCH] 优化代码

---
 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuLogCtrl.java |   22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuLogCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuLogCtrl.java
index f886f04..84a72ae 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuLogCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/rtu/RtuLogCtrl.java
@@ -1,9 +1,9 @@
 package com.dy.pipIrrRemote.rtu;
 
 import com.dy.common.aop.SsoAop;
-import com.dy.common.multiDataSource.DataSourceContext;
 import com.dy.common.webUtil.BaseResponse;
 import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.pipIrrGlobal.rtuMw.Web2RtuMw;
 import jakarta.servlet.ServletOutputStream;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
@@ -32,11 +32,7 @@
 @Slf4j
 @RestController
 @RequestMapping(path="rtuLog")
-public class RtuLogCtrl {
-
-    private static final String pro_mw = "mw";
-    private static final String key_mw_file = "rtuLogFileUrl";
-    private static final String key_mw_text = "rtuLogTextUrl";
+public class RtuLogCtrl extends Web2RtuMw {
 
     private Environment env ;
     private RestTemplate restTemplate;
@@ -55,10 +51,10 @@
     @GetMapping(path = "file")
     @SsoAop()
     public BaseResponse<List<String>> rtuLogFile(String rtuAddr, HttpServletRequest req, HttpServletResponse rep){
-        String mwUrlRtuLogFile = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw_file);
+        String rqUrl = this.get2MwRequestUrl(this.env, ContextRtuLogFile) ;
         ServletOutputStream out = null ;
         try{
-            byte[] bs = this.requestMw4File(rtuAddr, mwUrlRtuLogFile) ;
+            byte[] bs = this.requestMw4File(rtuAddr, rqUrl) ;
             if(bs != null && bs.length > 0){
                 String fileReName = rtuAddr + ".log" ;
                 //URLEncoder.encode鍙互闃叉涓枃涔辩爜
@@ -91,18 +87,17 @@
     @GetMapping(path="text")
     @SsoAop()
     public BaseResponse<List<String>> rtuLogText(String rtuAddr){
-        String mwUrlRtuLogText = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw_text);
-        BaseResponse<List<String>> text = this.requestMw4Text(rtuAddr, mwUrlRtuLogText);
+        String rqUrl = this.get2MwRequestUrl(this.env, ContextRtuLogText) ;
+        //String mwUrlRtuLogText = env.getProperty(pro_mw + "." + DataSourceContext.get() + "." + key_mw_text);
+        BaseResponse<List<String>> text = this.requestMw4Text(rtuAddr, rqUrl);
         if (text != null){
-
             if (text.getContent().get(0).contains("鎺у埗鍣�")){
-                return BaseResponseUtils.buildErrorMsg(""+text+"") ;
+                return BaseResponseUtils.buildErrorMsg(""+text.getContent().get(0)+"") ;
             }
             return text ;
         }else {
             return BaseResponseUtils.buildErrorMsg("鑾峰彇鏃ュ織鏂囦欢涓簄ull") ;
         }
-//        return this.requestMw4Text(rtuAddr, mwUrlRtuLogText) ;
     }
 
 
@@ -142,5 +137,4 @@
 
         return (response==null?null:response.getBody());
     }
-
 }

--
Gitblit v1.8.0