From 271fed395d4d3e4ab8cdb44ccf466859ba485e46 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期四, 09 一月 2025 17:45:33 +0800
Subject: [PATCH] Merge branch 'master' of http://dlindusit.com:53929/r/iailab-plat

---
 iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm |   43 +++++++++++++++----------------------------
 1 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm b/iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm
index eeb2f81..722a8de 100644
--- a/iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm
+++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm
@@ -17,7 +17,21 @@
 	{
 
 		PyGILThreadLock lock;
-		PyObject* pModule = create_py_module("${pyModule}.${pyName}");
+
+		jclass hashmapClass = env->FindClass("java/util/HashMap");
+		jmethodID getMID = env->GetMethodID(hashmapClass, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
+		jstring keyJString = env->NewStringUTF("pyFile");
+		jobject javaValueObj = env->CallObjectMethod(settings, getMID, keyJString);
+		jstring javaStringValue = (jstring)javaValueObj;
+		const char* strValue = env->GetStringUTFChars(javaStringValue, NULL);
+		//*************导入模型******************
+		PyObject* pModule = create_py_module(strValue);
+		// 释放java占用内存
+		env->ReleaseStringUTFChars(javaStringValue, strValue);
+		env->DeleteLocalRef(javaStringValue);
+		env->DeleteLocalRef(javaValueObj);
+		env->DeleteLocalRef(keyJString);
+		env->DeleteLocalRef(hashmapClass);
 		if (pModule == NULL)
 		{
 			cout << "model error" << endl;
@@ -80,33 +94,6 @@
 			cout << "ConvertPydictToJhmap error" << endl;
 			throw "函数返回值异常!";
 		}
-		delete pModule;
-		pModule = nullptr;
-		delete pModule;
-
-		delete pFunc;
-		pFunc = nullptr;
-		delete pFunc;
-
-#{foreach} ($column in [1..$entity.dataLength])
-		delete[] data_${column};
-		data_${column} = nullptr;
-		delete data_${column};
-
-#{end}
-#{if}($entity.model==1)
-		delete model_path;
-		model_path = nullptr;
-		delete model_path;
-#{end}
-
-		delete settings_1;
-		settings_1 = nullptr;
-		delete settings_1;
-
-		delete[] pArg;
-		pArg = nullptr;
-		delete pArg;
 
 		return result;
 	}

--
Gitblit v1.9.3