From 142bcd3bd15e9ba6176bb2093eee22040da9bd8c Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 03 三月 2025 16:08:44 +0800 Subject: [PATCH] 保留3位小数 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/matlab/common/utils/MatlabUtils.java | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/matlab/common/utils/MatlabUtils.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/matlab/common/utils/MatlabUtils.java index 13281e3..4ffbcd2 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/matlab/common/utils/MatlabUtils.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/matlab/common/utils/MatlabUtils.java @@ -11,6 +11,7 @@ import com.mathworks.toolbox.javabuilder.*; import com.mathworks.toolbox.javabuilder.internal.MWFunctionSignature; import lombok.extern.slf4j.Slf4j; +import org.springframework.util.CollectionUtils; import java.io.File; import java.io.IOException; @@ -183,7 +184,7 @@ } /** - * @description: 项目启动加载已发布的dll和jar + * @description: 项目启动加载已发布的jar * @author: dzd * @date: 2024/10/10 11:58 **/ @@ -192,23 +193,32 @@ if (dir.exists() && dir.isDirectory()) { File[] files = dir.listFiles(); if (null != files && files.length > 0) { + HashMap<String,List<String>> projectIdJarFilePaths = new HashMap<>(); for (File file : files) { String fileName = file.getName(); if (fileName.endsWith(".jar")) { String[] split = fileName.split(MdkConstant.SPLIT); String projectId = split[0]; - - URLClassLoader urlClassLoader = null; - try { - // 加载新的jar - urlClassLoader = loadJar(projectId,file.getAbsolutePath()); - } catch (Exception e) { - throw new RuntimeException("加载jar异常", e); + if (projectId != null) { + if (projectIdJarFilePaths.containsKey(projectId)) { + projectIdJarFilePaths.get(projectId).add(file.getAbsolutePath()); + } else { + projectIdJarFilePaths.put(projectId,new ArrayList<String>(){{add(file.getAbsolutePath());}}); + } } - // 成功后加入缓存 - addClassLoaderCache(projectId, urlClassLoader); } } + + try { + if (!CollectionUtils.isEmpty(projectIdJarFilePaths)) { + for (Map.Entry<String, List<String>> entry : projectIdJarFilePaths.entrySet()) { + // 加载新的jar + loadJar(entry.getKey(),entry.getValue().toArray(new String[0])); + } + } + } catch (Exception e) { + throw new RuntimeException("加载jar异常", e); + } } } -- Gitblit v1.9.3