From a440ec3bfaa1363f5841100b8948d852971a2eb1 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 10 十二月 2024 13:19:58 +0800
Subject: [PATCH] MmPredictAlarmConfigService

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java |   55 ++++++++++++++++++++++++++++++-------------------------
 1 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java
index df28449..07d569d 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java
+++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/ModelServiceApplication.java
@@ -1,55 +1,60 @@
 package com.iailab;
 
+import com.iailab.module.model.mpk.common.MdkConstant;
+import com.iailab.module.model.mpk.common.utils.DllUtils;
+import iail.mdk.model.common.Environment;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import com.iail.IAILMDK;
-import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.scheduling.annotation.EnableAsync;
 
+import javax.annotation.PostConstruct;
 import java.io.File;
 import java.io.InputStream;
-import java.util.Objects;
 import java.util.Properties;
 
 @EnableAsync
 @SpringBootApplication
+@Slf4j
 public class ModelServiceApplication implements CommandLineRunner {
 
-    /*static {
+    @Value("${mpk.bak-file-path}")
+    private String mpkBakFilePath;
+
+    @PostConstruct
+    void init() {
         //加载动态链接库
         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);
-            IAILMDK.initWithBean(mdkInitPath, false);
-        } catch (Exception e) {
-            e.printStackTrace();
-            System.out.println("动态链接库IAILMDK初始化失败");
-        }
-
-        try {
-            System.out.println("动态加载dll");
-            String dllDir = Objects.requireNonNull(ModelServiceApplication.class.getClassLoader().getResource("dll")).getPath();
-            File dir = new File(dllDir);
-            if (dir.exists()) {
-                File[] files = dir.listFiles();
-                if (files.length > 0) {
-                    for (File file : files) {
-                        System.out.println("加载:" + file.getAbsolutePath());
-                        System.load(file.getAbsolutePath());
-                    }
-                }
+            log.info("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("动态加载dll失败");
+            log.error("动态链接库IAIL.MDK.Mid.Windows.dll初始化失败");
         }
 
+        //加载项目已发布的dll和jar
+        try {
+            log.info("************开始加载项目已发布的dll和jar**************");
+            DllUtils.loadProjectPublish(mpkBakFilePath + File.separator + MdkConstant.PROJECT_PUBLISH);
+            log.info("************加载项目已发布的dll和jar结束**************");
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("加载项目已发布的dll和jar失败");
+        }
     }
-*/
+
 
     public static void main(String[] args) {
         SpringApplication.run(ModelServiceApplication.class, args);

--
Gitblit v1.9.3