dengzedong
2024-09-30 912a1e5f0b4537902b97ff81594611a8b6b3a853
动态加载、卸载 jar、dll
模型测试运行
替换临时文件夹
已修改6个文件
已删除5个文件
已添加5个文件
11300 ■■■■■ 文件已修改
iailab-module-model/.flattened-pom.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-api/.flattened-pom.xml 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/.flattened-pom.xml 179 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/DllUtils.java 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/GenUtils.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/Readtxt.java 52 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MdkController.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/IAILMDK/common/Environment.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/IAILMDK/utils/AlgsUtils.java 172 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/IAIL.MDK.Mid.Windows.dll 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/status_code.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/version.xml 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
logs/log-debug.2024-09-30.log 10518 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/.flattened-pom.xml
对比新文件
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.iailab</groupId>
    <artifactId>iailab-plat</artifactId>
    <version>0.0.1</version>
  </parent>
  <groupId>com.iailab</groupId>
  <artifactId>iailab-module-model</artifactId>
  <version>0.0.1</version>
  <packaging>pom</packaging>
  <modules>
    <module>iailab-module-model-biz</module>
    <module>iailab-module-model-api</module>
  </modules>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>
</project>
iailab-module-model/iailab-module-model-api/.flattened-pom.xml
对比新文件
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.iailab</groupId>
    <artifactId>iailab-module-model</artifactId>
    <version>0.0.1</version>
  </parent>
  <groupId>com.iailab</groupId>
  <artifactId>iailab-module-model-api</artifactId>
  <version>0.0.1</version>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-ui</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-validation</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-openfeign</artifactId>
      <optional>true</optional>
    </dependency>
  </dependencies>
</project>
iailab-module-model/iailab-module-model-biz/.flattened-pom.xml
对比新文件
@@ -0,0 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.iailab</groupId>
    <artifactId>iailab-module-model</artifactId>
    <version>0.0.1</version>
  </parent>
  <groupId>com.iailab</groupId>
  <artifactId>iailab-module-model-biz</artifactId>
  <version>0.0.1</version>
  <properties>
    <mdk.version>MDK.taisteel.202308231710</mdk.version>
    <easypoi.version>4.1.0</easypoi.version>
    <commons.io.version>2.11.0</commons.io.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>8</maven.compiler.source>
    <velocity.version>1.7</velocity.version>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-env</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-module-data-api</artifactId>
      <version>${revision}</version>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-module-infra-api</artifactId>
      <version>${revision}</version>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-module-system-api</artifactId>
      <version>${revision}</version>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-biz-data-permission</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-biz-tenant</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-biz-ip</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-module-model-api</artifactId>
      <version>${revision}</version>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-security</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-mybatis</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-rpc</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-monitor</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-biz-data-permission</artifactId>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.iailab</groupId>
      <artifactId>iailab-common-excel</artifactId>
    </dependency>
    <dependency>
      <groupId>com.alibaba.cloud</groupId>
      <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
    </dependency>
    <dependency>
      <groupId>com.alibaba.cloud</groupId>
      <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>4.1.1</version>
    </dependency>
    <dependency>
      <groupId>com.iail</groupId>
      <artifactId>IAILMDK</artifactId>
      <version>0.94.9</version>
    </dependency>
    <dependency>
      <groupId>com.iail</groupId>
      <artifactId>MDK</artifactId>
      <version>${mdk.version}</version>
    </dependency>
    <dependency>
      <groupId>cn.afterturn</groupId>
      <artifactId>easypoi-base</artifactId>
      <version>${easypoi.version}</version>
    </dependency>
    <dependency>
      <groupId>cn.afterturn</groupId>
      <artifactId>easypoi-web</artifactId>
      <version>${easypoi.version}</version>
    </dependency>
    <dependency>
      <groupId>cn.afterturn</groupId>
      <artifactId>easypoi-annotation</artifactId>
      <version>${easypoi.version}</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>${commons.io.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.velocity</groupId>
      <artifactId>velocity</artifactId>
      <version>${velocity.version}</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>${spring.boot.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>flatten-maven-plugin</artifactId>
        <version>1.1.0</version>
        <executions>
          <execution>
            <id>flatten</id>
            <phase>process-resources</phase>
            <goals>
              <goal>flatten</goal>
            </goals>
          </execution>
          <execution>
            <id>flatten.clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <updatePomFile>true</updatePomFile>
          <flattenMode>resolveCiFriendliesOnly</flattenMode>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java
@@ -1,10 +1,13 @@
package com.iailab;
import iail.mdk.model.common.Environment;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import java.io.File;
import java.io.InputStream;
import java.util.Properties;
@EnableAsync
@@ -15,13 +18,17 @@
        //加载动态链接库
        try {
            Properties properties = new Properties();
//            InputStream in = ModelServiceApplication.class.getClassLoader().getResourceAsStream("iailmdk.properties");
//            properties.load(in);
//            String mdkInitPath = properties.getProperty("mdk-init-path");
//            System.out.println("mdkInitPath=" + mdkInitPath);
//            System.load(mdkInitPath + File.separator + "IAIL.MDK.Mid.Windows.dll");
//            Environment env = new Environment();
//            env.init();
            InputStream in = ModelServiceApplication.class.getClassLoader().getResourceAsStream("iailmdk.properties");
            properties.load(in);
            String mdkInitPath = properties.getProperty("mdk-init-path");
            System.out.println("mdkInitPath=" + mdkInitPath);
            File file = new File(mdkInitPath + File.separator + "IAIL.MDK.Mid.Windows.dll");
            if (!file.exists()) {
                throw new RuntimeException("动态链接库IAIL.MDK.Mid.Windows.dll文件不存在," + file.getAbsolutePath());
            }
            System.load(file.getAbsolutePath());
            Environment env = new Environment();
            env.init();
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("动态链接库IAIL.MDK.Mid.Windows.dll初始化失败");
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/DllUtils.java
对比新文件
@@ -0,0 +1,128 @@
package com.iailab.module.model.mpk.common.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import sun.misc.URLClassPath;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Iterator;
import java.util.Vector;
@Slf4j
public class DllUtils {
    /**
     * @description: 加载dll到指定class下
     * @author: dzd
     * @date: 2024/9/30 14:27
     **/
    public static void loadDll(Class<?> clazz, String dllPath) {
        try {
            Method method = Runtime.class.getDeclaredMethod("load0", Class.class,String.class);
            boolean accessible = method.isAccessible();
            method.setAccessible(true);
            method.invoke(Runtime.getRuntime(), clazz,dllPath);
            method.setAccessible(accessible);
            log.info("成功加载dll:"+ dllPath);
        } catch (Exception e) {
            throw new RuntimeException("加载dll异常",e);
        }
    }
    /**
     * @description: 卸载classLoader下全部dll
     * @author: dzd
     * @date: 2024/9/30 14:31
     **/
    public static synchronized void uploadDll(URLClassLoader classLoader) {
        try {
            Field field = ClassLoader.class.getDeclaredField("nativeLibraries");
            field.setAccessible(true);
            Vector<Object> libs = (Vector<Object>) field.get(classLoader);
            Iterator<Object> it = libs.iterator();
            Object o;
            while (it.hasNext()) {
                o = it.next();
                Method method = o.getClass().getDeclaredMethod("finalize");
                boolean accessible = method.isAccessible();
                method.setAccessible(true);
                method.invoke(o);
                method.setAccessible(accessible);
                Field nameDield = o.getClass().getDeclaredField("name");
                nameDield.setAccessible(true);
                String name = (String) nameDield.get(o);
                log.info("成功卸载dll:" + name);
            }
        } catch (Exception e) {
            throw new RuntimeException("卸载dll异常",e);
        }
    }
    /**
     * @description: 从classLoader中卸载dll,如果dllName传null,则默认删除全部dll
     * @author: dzd
     * @date: 2024/9/30 14:52
     **/
    public static synchronized void uploadDllName(URLClassLoader classLoader,String dllName) {
        try {
            Field field = ClassLoader.class.getDeclaredField("nativeLibraries");
            field.setAccessible(true);
            Vector<Object> libs = (Vector<Object>) field.get(classLoader);
            Iterator<Object> it = libs.iterator();
            Object o;
            while (it.hasNext()) {
                o = it.next();
                Field nameDield = o.getClass().getDeclaredField("name");
                nameDield.setAccessible(true);
                String name = (String) nameDield.get(o);
                // dllName不为null 并且 不等于name,跳出(dllName为null默认全部删除)
                if (StringUtils.isNotEmpty(dllName) && !dllName.equals(name)) {
                    return;
                }
                Method method = o.getClass().getDeclaredMethod("finalize");
                boolean accessible = method.isAccessible();
                method.setAccessible(true);
                method.invoke(o);
                method.setAccessible(accessible);
                log.info("成功卸载dll:" + name);
            }
        } catch (Exception e) {
            throw new RuntimeException("卸载dll异常",e);
        }
    }
    /**
     * @description: 加载jar到特定的URLClassLoader,并返回URLClassLoader
     * @author: dzd
     * @date: 2024/9/30 14:20
     **/
    public static synchronized URLClassLoader loadJar(String jarPath) {
        File jarFile = new File(jarPath);
        if (!jarFile.exists()) {
            throw new RuntimeException("jar沒有找到!");
        } else {
            try {
                URLClassLoader urlClassLoader = new URLClassLoader(new URL[]{jarFile.toURI().toURL()});
                log.info("成功加载jar包:"+ jarFile.getAbsolutePath());
                return urlClassLoader;
            } catch (Exception e) {
                throw new RuntimeException("加载jar异常",e);
            }
        }
    }
    public static synchronized void uploadJar(URLClassLoader urlClassLoader) {
        try {
            urlClassLoader.close();
            log.info("成功卸载jar包。");
        } catch (Exception e) {
            throw new RuntimeException("卸载jar异常",e);
        }
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/GenUtils.java
@@ -59,7 +59,7 @@
            FileUtil.writeUtf8String(writer.toString(),toFile);
            IOUtils.closeQuietly(writer);
        } catch (IOException e) {
            throw new RuntimeException("模板渲染异常");
            throw new RuntimeException("模板渲染异常",e);
        }
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/common/utils/Readtxt.java
@@ -110,32 +110,36 @@
    }
    public static List<double[][]> readMethodExcel(MultipartFile file) throws IOException {
        Workbook workbook = WorkbookFactory.create(file.getInputStream());
        //获取工作薄里面sheet的个数
        int sheetNum = workbook.getNumberOfSheets();
        List<double[][]> datas = new ArrayList<>(sheetNum - 1);
        //从第二个sheet开始读,第一个为示例
        for (int i = 1; i < sheetNum; i++) {
            Sheet sheet = workbook.getSheetAt(i);
            //获取sheet中有数据的行数
            int rows = sheet.getPhysicalNumberOfRows();
            double[][] doubles2 = new double[rows][];
            for (int j = 0; j < rows; j++) {
                //获取每一行的数据
                Row row = sheet.getRow(j);
                //得到每一行中有效单元格的数据
                short cells = row.getLastCellNum();
                //定义一个doubles数组用来存储读取单元格的数据
                double[] doubles1 = new double[cells];
                //遍历每一个有效的单元格数据
                for (int k = 0; k < cells; k++) {
                    //获取每一个单元格的数据
                    Cell cell = row.getCell(k, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                    doubles1[k] = cell.getNumericCellValue();
        List<double[][]> datas;
        try (Workbook workbook = WorkbookFactory.create(file.getInputStream())) {
            //获取工作薄里面sheet的个数
            int sheetNum = workbook.getNumberOfSheets();
            datas = new ArrayList<>(sheetNum - 1);
            //从第二个sheet开始读,第一个为示例
            for (int i = 1; i < sheetNum; i++) {
                Sheet sheet = workbook.getSheetAt(i);
                //获取sheet中有数据的行数
                int rows = sheet.getPhysicalNumberOfRows();
                double[][] doubles2 = new double[rows][];
                for (int j = 0; j < rows; j++) {
                    //获取每一行的数据
                    Row row = sheet.getRow(j);
                    //得到每一行中有效单元格的数据
                    short cells = row.getLastCellNum();
                    //定义一个doubles数组用来存储读取单元格的数据
                    double[] doubles1 = new double[cells];
                    //遍历每一个有效的单元格数据
                    for (int k = 0; k < cells; k++) {
                        //获取每一个单元格的数据
                        Cell cell = row.getCell(k, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
                        doubles1[k] = cell.getNumericCellValue();
                    }
                    doubles2[j] = doubles1;
                }
                doubles2[j] = doubles1;
                datas.add(doubles2);
            }
            datas.add(doubles2);
        } catch (Exception e) {
            throw new RuntimeException("解析Excel异常",e);
        }
        return datas;
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MdkController.java
@@ -5,17 +5,17 @@
import com.iailab.framework.common.exception.enums.GlobalErrorCodeConstants;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.module.model.mpk.common.MdkConstant;
import com.iailab.module.model.mpk.common.utils.DllUtils;
import com.iailab.module.model.mpk.common.utils.Readtxt;
import com.iailab.module.model.mpk.dto.MdkDTO;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.HashMap;
@@ -30,6 +30,7 @@
 * @createTime 2024年08月08日
 */
@RestController
@Slf4j
@RequestMapping("/model/mpk/api")
public class MdkController {
    @Value("${mpk.bak-file-path}")
@@ -38,7 +39,8 @@
    @PostMapping("run")
    public CommonResult<String> run(@RequestBody MdkDTO dto) {
        Class<?> clazz;
        URLClassLoader classLoader;
        try {
            File jarFile = new File(mpkBakFilePath + File.separator + MdkConstant.JAR + File.separator + dto.getPyName() + ".jar");
            if (!jarFile.exists()) {
@@ -46,13 +48,16 @@
            }
            File dllFile = new File(mpkBakFilePath + File.separator + MdkConstant.DLL + File.separator + dto.getPyName() + ".dll");
            if (!dllFile.exists()) {
                throw new RuntimeException("dllw文件不存在,请先生成代码。dllPath:" + dllFile.getAbsolutePath());
                throw new RuntimeException("dll文件不存在,请先生成代码。dllPath:" + dllFile.getAbsolutePath());
            }
            // 加载jar包
            loadJar(jarFile.getAbsolutePath());
            // 加载dll
            System.load(dllFile.getAbsolutePath());
            classLoader = DllUtils.loadJar(jarFile.getAbsolutePath());
            // 实现类
            clazz = classLoader.loadClass(dto.getClassName());
            // 加载dll到实现类
            DllUtils.loadDll(clazz,dllFile.getAbsolutePath());
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("加载运行环境失败。");
        }
@@ -92,14 +97,16 @@
                paramsArray[datas.size()] = HashMap.class;
            }
            Class<?> clazz = Class.forName(dto.getClassName());
            Method method = clazz.getMethod(dto.getMethodName(), paramsArray);
            HashMap result = (HashMap)method.invoke(clazz.newInstance(), paramsValueArray);
            HashMap result = (HashMap) clazz.getDeclaredMethod(dto.getMethodName(), paramsArray).invoke(clazz.newInstance(), paramsValueArray);
            return success(JSON.toJSONString(result));
        } catch (Exception ex) {
            ex.printStackTrace();
            return error(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"运行异常");
        } finally {
            if (classLoader != null) {
                DllUtils.uploadDll(classLoader);
                DllUtils.uploadJar(classLoader);
            }
            System.gc();
        }
    }
@@ -117,20 +124,5 @@
            }
        }
        return success(result);
    }
    private void loadJar(String jarPath) throws Exception {
        File jarFile = new File(jarPath);
        if (!jarFile.exists()) {
            throw new Exception("jar沒有找到!");
        } else {
            Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
            boolean accessible = method.isAccessible();
            method.setAccessible(true);
            URLClassLoader classLoader = (URLClassLoader)ClassLoader.getSystemClassLoader();
            URL url = jarFile.toURI().toURL();
            method.invoke(classLoader, url);
            method.setAccessible(accessible);
        }
    }
}
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/controller/admin/MpkFileController.java
@@ -102,7 +102,7 @@
            IOUtils.write(data, response.getOutputStream());
        } catch (Exception e) {
            throw new RuntimeException("代码生成异常");
            throw new RuntimeException("代码生成异常",e);
        }
    }
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);
        }
    }
}
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/IAILMDK/common/Environment.java
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/IAILMDK/utils/AlgsUtils.java
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/IAIL.MDK.Mid.Windows.dll
Binary files differ
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/status_code.xml
文件已删除
iailab-module-model/iailab-module-model-biz/src/main/resources/bak/libs/version.xml
文件已删除
logs/log-debug.2024-09-30.log
对比新文件
文件太大