From 79914dabac38d83676ea16ff65da8d941a099285 Mon Sep 17 00:00:00 2001 From: Jay <csj123456> Date: 星期二, 08 十月 2024 10:38:01 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java index cdeb74e..a33aa2e 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java +++ b/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; @@ -123,6 +124,8 @@ public void save(MpkFileDTO dto) { MpkFileEntity entity = ConvertUtils.sourceToTarget(dto, MpkFileEntity.class); entity.setId(UUID.randomUUID().toString()); + entity.setPkgName(dto.getPkgName().trim()); + entity.setFilePath(dto.getFilePath().trim()); entity.setCreator(SecurityFrameworkUtils.getLoginUserId()); entity.setCreateDate(new Date()); insert(entity); @@ -189,9 +192,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 +280,7 @@ try { FileUtils.deleteDirectory(dirPath); } catch (IOException e) { - throw new RuntimeException("删除临时文件异常"); + throw new RuntimeException("删除临时文件异常",e); } return bytes; } @@ -289,9 +296,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 +445,7 @@ // 等待命令执行完成 process.waitFor(); } catch (Exception e) { - throw new RuntimeException("执行cmd命令生成dll异常"); + throw new RuntimeException("执行cmd命令生成dll异常",e); } } @@ -492,7 +503,7 @@ process.waitFor(); return jarSavePath; } catch (InterruptedException e) { - throw new RuntimeException("执行cmd命令打jar包异常"); + throw new RuntimeException("执行cmd命令打jar包异常",e); } } @@ -513,7 +524,7 @@ Process process = RuntimeUtil.exec(sb.toString()); process.waitFor(); } catch (InterruptedException e) { - throw new RuntimeException("执行cmd命令生成class异常"); + throw new RuntimeException("执行cmd命令生成class异常",e); } } } \ No newline at end of file -- Gitblit v1.9.3