上传项目设计图,将项目设计图dxf文件转化为geojson文件并将存储信息保存到数据库
This commit is contained in:
@ -76,9 +76,9 @@ spring:
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件大小
|
||||
max-file-size: 10MB
|
||||
max-file-size: 100MB
|
||||
# 设置总上传的文件大小
|
||||
max-request-size: 20MB
|
||||
max-request-size: 200MB
|
||||
mvc:
|
||||
# 设置静态资源路径 防止所有请求都去查静态资源
|
||||
static-path-pattern: /static/**
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
package org.dromara.test;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/4/23 10:15
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class CmdTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
// 获取当前项目根目录
|
||||
String projectRoot = System.getProperty("user.dir");
|
||||
// EXE 和参数
|
||||
String exePath = projectRoot + File.separator + "file" + File.separator + "resource" + File.separator + "dxf" + File.separator + "main.exe";
|
||||
String inputDXF = "file/resource/dxf/1897160897167638529/桩点图.dxf";
|
||||
String outputJSON = "file/resource/dxf/1897160897167638529/output.json";
|
||||
String sourceEPSG = "4524";
|
||||
String targetEPSG = "4326";
|
||||
|
||||
// 构造命令行
|
||||
List<String> command = Arrays.asList(
|
||||
exePath,
|
||||
inputDXF,
|
||||
outputJSON,
|
||||
sourceEPSG,
|
||||
targetEPSG
|
||||
);
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(command);
|
||||
builder.redirectErrorStream(true); // 合并标准错误和输出
|
||||
|
||||
try {
|
||||
Process process = builder.start();
|
||||
|
||||
// 读取输出
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(process.getInputStream(), "GBK")
|
||||
);
|
||||
String line;
|
||||
System.out.println("程序输出:");
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
|
||||
int exitCode = process.waitFor();
|
||||
System.out.println("程序退出码:" + exitCode);
|
||||
|
||||
reader.close();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user