From c67c538d20e482beb7867de611c47c3815070fce Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 29 十月 2024 09:01:39 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV

---
 pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/web/com/CommandCtrl.java |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

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 0dcd9cc..520cfe3 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
@@ -20,7 +20,10 @@
 
 import java.io.*;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 
 /**
@@ -102,18 +105,26 @@
      */
     @GetMapping("/rtuLogText")
     public BaseResponse<List<String>> rtuLogText(String rtuAddr){
-        List<String> list = new ArrayList() ;
+        List<String> list ;
         File logFile = ResourceUnit.getInstance().getLogFile(rtuAddr + ".log") ;
         if(logFile != null && logFile.exists()){
             BufferedReader reader = null ;
             try {
                 reader = new BufferedReader(new FileReader(logFile)) ;
+                //鏂扮殑瀹炵幇鏂规硶
+                Stream<String> linesStream = reader.lines() ;
+                //list = linesStream.toList() ; //鎸夊師鏉ラ『搴�
+                list = linesStream.sorted(Comparator.reverseOrder()).collect(Collectors.toList()) ;//鍊掑簭
+                /* 鍘熸潵鐨勫疄鐜版柟娉�
+                list = new ArrayList() ;
                 String line ;
                 while((line = reader.readLine()) != null){
                     list.add(line) ;
                 }
+                */
                 return BaseResponseUtils.buildSuccess(list);
             } catch (Exception e) {
+                list = new ArrayList() ;
                 list.add("璇诲彇鎺у埗鍣紙" + rtuAddr + "锛夌殑鏃ュ織鏂囦欢寮傚父锛�" + (e.getMessage() == null?"":("锛�" + e.getMessage()))) ;
                 return BaseResponseUtils.buildSuccess(list);
             }finally{
@@ -125,6 +136,7 @@
                 }
             }
         }else{
+            list = new ArrayList() ;
             list.add("鏈緱鍒版帶鍒跺櫒锛�" + rtuAddr + "锛夌殑鏃ュ織鏂囦欢") ;
             return BaseResponseUtils.buildSuccess(list);
         }
@@ -189,7 +201,7 @@
     }
 
     /**
-     * 鏈湴璋冪敤锛屼緥濡傞噸浠诲姟鏍戜腑鏌愪釜浠诲姟涓嬪彂鐨勫懡浠わ紙濡傛竻绌哄懡浠わ級
+     * 鏈湴璋冪敤锛屼緥濡備换鍔℃爲涓煇涓换鍔′笅鍙戠殑鍛戒护锛堝娓呯┖鍛戒护锛�
      * @param com
      * @return
      */

--
Gitblit v1.8.0