From bb015596297586342fc6c3e5a5df7c4a55a426a5 Mon Sep 17 00:00:00 2001
From: dengzedong <dengzedong@email>
Date: 星期一, 14 十月 2024 14:36:42 +0800
Subject: [PATCH] 模型新增修改时 替换环境变量MDK_PKGS下的py文件

---
 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 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 f37fa61..84d5eb6 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
@@ -130,6 +130,12 @@
         entity.setCreateDate(new Date());
         insert(entity);
         modelMethodService.insertList(dto.getModelMethods(), entity.getId());
+
+        // 替换环境变量MDK_PKGS下的py文件
+        String mdkPkgs = System.getenv("MDK_PKGS");
+        String pyFilePath = mdkPkgs + File.separator + entity.getPyModule().replace(".", File.separator) + File.separator + entity.getPyName() + ".pyd";
+        FileUtil.mkParentDirs(pyFilePath);
+        FileUtil.copy(entity.getFilePath(), pyFilePath, true);
     }
 
     @Override
@@ -141,6 +147,12 @@
         updateById(entity);
         modelMethodService.deleteModelMethod(entity.getId());
         modelMethodService.insertList(dto.getModelMethods(), entity.getId());
+
+        // 替换环境变量MDK_PKGS下的py文件
+        String mdkPkgs = System.getenv("MDK_PKGS");
+        String pyFilePath = mdkPkgs + File.separator + entity.getPyModule().replace(".", File.separator) + File.separator + entity.getPyName() + ".pyd";
+        FileUtil.mkParentDirs(pyFilePath);
+        FileUtil.copy(entity.getFilePath(), pyFilePath, true);
     }
 
     @Override

--
Gitblit v1.9.3