dengzedong
6 天以前 2475fd10f497a8a0594aab70a2ee40ff92daa44d
添加c++日志
已修改1个文件
16 ■■■■■ 文件已修改
iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-model/iailab-module-model-biz/src/main/resources/template/cpp.vm
@@ -37,6 +37,7 @@
            cout << "model error" << endl;
            throw "模块调用失败!";
        }
        cout << "load pymodel finished" << endl;
        //*************导入函数******************
        PyObject* pFunc = PyObject_GetAttrString(pModule, "${entity.methodName}");
@@ -45,6 +46,7 @@
            cout << "func error" << endl;
            throw "函数调用失败!";
        }
        cout << "load pyfunc finished" << endl;
#{foreach} ($column in [1..$entity.dataLength])
        PyObject* data_${column} = ConvertJdarrToPydarr(env, data${column});
#{end}
@@ -84,6 +86,18 @@
            cout << "return error" << endl;
            throw "函数返回值异常!";
        }
        cout << "load pyreturn finished" << endl;
        PyObject* json_module = create_py_module("json");
        PyObject* dumps_func = PyObject_GetAttrString(json_module, "dumps");
        PyObject* json_str = PyObject_CallObject(dumps_func, PyTuple_Pack(1, pReturn));
        if (json_str == NULL) {
        cout << "json_str is null" << endl;
        PyErr_Print();
        return NULL;
        }
        const char* json_cstr = PyUnicode_AsUTF8(json_str);
        cout << "pyreturn" << json_cstr << endl;
        //*******************返回数据封装************************
       // 开辟返回数据内存空间,转换数据,拆分数据
@@ -92,7 +106,7 @@
        if (result == NULL)
        {
            cout << "ConvertPydictToJhmap error" << endl;
            throw "函数返回值异常!";
            throw "函数返回值解析异常!";
        }
        return result;