From 5ec04f09b1569a3cc566657684a647f467b1e608 Mon Sep 17 00:00:00 2001
From: 张洋洋 <10611411+yang-yang-z@user.noreply.gitee.com>
Date: 星期四, 20 二月 2025 15:33:19 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/main/java/com/se/simu/service/UwService.java |   85 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 70 insertions(+), 15 deletions(-)

diff --git a/src/main/java/com/se/simu/service/UwService.java b/src/main/java/com/se/simu/service/UwService.java
index 19d48d8..c9ca4a6 100644
--- a/src/main/java/com/se/simu/service/UwService.java
+++ b/src/main/java/com/se/simu/service/UwService.java
@@ -13,12 +13,6 @@
 import javax.annotation.Resource;
 import java.io.*;
 
-/**
- * 鍐呮稘姹傝В鍣ㄦ湇鍔$被
- *
- * @author WWW
- * @date   2024-09-29
- */
 @Slf4j
 @Service
 @SuppressWarnings("ALL")
@@ -36,12 +30,6 @@
         return _rainfall;
     }
 
-    /**
-     * 鍒涘缓闄嶉洦鏂囦欢
-     * <p>
-     * https://blog.csdn.net/Dark_Drgon/article/details/139739924
-     * C:\Program Files\matlab\R2020a\runtime\win64
-     */
     public void createRainFile(DataPo data) throws Exception {
         String filePath = config.getInPath() + File.separator + data.getInPath() + File.separator + config.getRaingage();
         String startTime = StringHelper.YMDHMS_FORMAT.format(data.getStartTime());
@@ -79,7 +67,8 @@
     public String callExe(DataPo data) throws Exception {
         String cmd = String.format("%s %d %s", config.getSolverBat(), WebHelper.getCpuCores(), data.getInPath() + ".json");
 
-        return exec(cmd);
+        //return exec(cmd);
+        return execCmdLine(cmd);
     }
 
     private String exec(String cmd) throws Exception {
@@ -96,14 +85,14 @@
             StringBuilder sb = new StringBuilder();
             while ((line = nr.readLine()) != null) {
                 sb.append(line);
+                log.info(line);
             }
 
             String errorLine;
             while ((errorLine = er.readLine()) != null) {
-                log.warn(errorLine);
+                log.error(errorLine);
             }
 
-            // 绛夊緟绋嬪簭鎵ц缁撴潫骞惰緭鍑虹姸鎬�
             int exitCode = process.waitFor();
 
             return sb.toString();
@@ -136,6 +125,63 @@
         }
     }
 
+    private String execCmdLine(String cmd) throws IOException, InterruptedException {
+        Process process = Runtime.getRuntime().exec(cmd);
+
+        new Thread(() -> {
+            InputStreamReader ir = null;
+            BufferedReader br = null;
+            try {
+                ir = new InputStreamReader(process.getErrorStream(), "GBK");
+                br = new BufferedReader(ir);
+
+                String line;
+                while ((line = br.readLine()) != null) {
+                    log.error(line);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                try {
+                    if (null != br) br.close();
+                    if (null != ir) ir.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }).start();
+
+        StringBuilder sb = new StringBuilder();
+        //new Thread(() -> {
+            InputStreamReader ir = null;
+            BufferedReader br = null;
+            try {
+                ir = new InputStreamReader(process.getInputStream(), "GBK");
+                br = new BufferedReader(ir);
+
+                String line;
+                while ((line = br.readLine()) != null) {
+                    log.info(line);
+                    sb.append(line);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                try {
+                    if (null != br) br.close();
+                    if (null != ir) ir.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        //}).start();
+
+        process.waitFor();
+        process.destroy();
+
+        return sb.toString();
+    }
+
     public void copeWaterFiles() {
         //
     }
@@ -149,4 +195,13 @@
 
         return exec(cmd);
     }
+    public String copeSwwDrainFiles(DataPo data) throws Exception {
+        String time = StringHelper.YMDHMS_FORMAT.format(data.getStartTime());
+        String inPath = "H:\\simu\\semout";
+        String sww = "H:\\simu\\semout\\testsem\\.out\\" + "testsem.sww";
+
+        String cmd = config.getSww2tifBat() + " " + sww + " \"" + time + "\" " + data.getEpsg() + " " + inPath;
+
+        return exec(cmd);
+    }
 }

--
Gitblit v1.9.3