allen преди 6 месеца
родител
ревизия
28f0ce3918
променени са 2 файла, в които са добавени 82 реда и са изтрити 1 реда
  1. 81 0
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/utils/MatlabUtils.java
  2. 1 1
      sql/update20241206.sql

+ 81 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/biz/utils/MatlabUtils.java

@@ -0,0 +1,81 @@
+package com.pdaaphm.biz.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+public class MatlabUtils {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+    public void runMatExe(String url) {
+        logger.info("exe 运行开始,url:{}", url);
+        try {
+            // 启动程序
+            Process process = Runtime.getRuntime().exec(url);
+            process.waitFor();  // 等待进程结束
+            logger.info("exe 运行结束,url:{}", url);
+        } catch (IOException | InterruptedException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+//    public static void main(String[] args) {
+//        String url = "D:\\pdaaphm\\algorithm_exe\\KNN\\bq_linear.exe";
+//        try {
+//            // 指定要执行的外部程序和参数
+//            ProcessBuilder processBuilder = new ProcessBuilder(url);
+//            // 启动外部程序
+//            Process process = processBuilder.start();
+//
+//            // Thread to handle the output stream.
+//            Thread outputThread = new Thread(() -> {
+//                try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
+//                    String line;
+//                    while ((line = reader.readLine()) != null) {
+//                    }
+//                } catch (IOException e) {
+//                    e.printStackTrace();
+//                }
+//            });
+//
+//            // Thread to handle the error stream.
+//            Thread errorThread = new Thread(() -> {
+//                try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()))) {
+//                    String line;
+//                    while ((line = reader.readLine()) != null) {
+//                    }
+//                } catch (IOException e) {
+//                    e.printStackTrace();
+//                }
+//            });
+//
+//            outputThread.start();
+//            errorThread.start();
+//
+//            // Wait for the external process to finish.
+//            int exitCode = process.waitFor();
+//
+//            // Optionally, wait for the threads to finish reading.
+//            outputThread.join();
+//            errorThread.join();
+//        } catch (IOException | InterruptedException e) {
+//            e.printStackTrace();
+//        }
+//    }
+
+    public static void main(String[] args) {
+        try {
+            // 指定 exe 文件的路径
+            String exePath = "D:\\pdaaphm\\algorithm_exe\\KNN\\bq_linear.exe";
+            // 启动程序
+            Process process = Runtime.getRuntime().exec(exePath);
+            process.waitFor();  // 等待进程结束
+            System.out.println("Program executed successfully");
+        } catch (IOException | InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 1 - 1
sql/update20241206.sql

@@ -8,4 +8,4 @@ ALTER TABLE `pdaaphm`.`t_data`
 ADD COLUMN `txt_path` varchar(255) NULL COMMENT '文本路径' AFTER `image_path`;
 
 ALTER TABLE `pdaaphm`.`t_alg_config`
-MODIFY COLUMN `fixed` varchar(16) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 否 COMMENT '是否固定输入输出' AFTER `alg_lang`;
+MODIFY COLUMN `fixed` varchar(16) DEFAULT '' COMMENT '是否固定输入输出';