dengzedong
2024-09-30 912a1e5f0b4537902b97ff81594611a8b6b3a853
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java
@@ -36,6 +36,7 @@
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.nio.file.Files;
import java.util.*;
import java.util.stream.Collectors;
@@ -189,9 +190,13 @@
        VelocityContext dataContext = new VelocityContext(map);
        //临时文件夹
        File dirPath = new File("D:/DLUT/tmp/");
        dirPath.deleteOnExit();
        dirPath.mkdirs();
        File dirPath = null;
        try {
            dirPath = Files.createTempDirectory("generatorCodeTmp").toFile();
            log.info("生成临时文件夹," + dirPath.getAbsolutePath());
        } catch (IOException e) {
            throw new RuntimeException("创建临时文件夹异常",e);
        }
        List<String> javaFilePaths = new ArrayList<>();
        List<String> cppFilePaths = new ArrayList<>();
@@ -273,7 +278,7 @@
        try {
            FileUtils.deleteDirectory(dirPath);
        } catch (IOException e) {
            throw new RuntimeException("删除临时文件异常");
            throw new RuntimeException("删除临时文件异常",e);
        }
        return bytes;
    }
@@ -289,9 +294,13 @@
//        VelocityContext context = new VelocityContext(map);
        //临时文件夹
        File dirPath = new File("D:/DLUT/tmp/");
        dirPath.deleteOnExit();
        dirPath.mkdirs();
        File dirPath = null;
        try {
            dirPath = Files.createTempDirectory("packageModelTmp").toFile();
            log.info("生成临时文件夹," + dirPath.getAbsolutePath());
        } catch (IOException e) {
            throw new RuntimeException("创建临时文件夹异常",e);
        }
        //设置velocity资源加载器
        Properties prop = new Properties();
@@ -434,7 +443,7 @@
            // 等待命令执行完成
            process.waitFor();
        } catch (Exception e) {
            throw new RuntimeException("执行cmd命令生成dll异常");
            throw new RuntimeException("执行cmd命令生成dll异常",e);
        }
    }
@@ -492,7 +501,7 @@
            process.waitFor();
            return jarSavePath;
        } catch (InterruptedException e) {
            throw new RuntimeException("执行cmd命令打jar包异常");
            throw new RuntimeException("执行cmd命令打jar包异常",e);
        }
    }
@@ -513,7 +522,7 @@
            Process process = RuntimeUtil.exec(sb.toString());
            process.waitFor();
        } catch (InterruptedException e) {
            throw new RuntimeException("执行cmd命令生成class异常");
            throw new RuntimeException("执行cmd命令生成class异常",e);
        }
    }
}