| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.iailab.framework.common.exception.enums.GlobalErrorCodeConstants; |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.tenant.core.context.TenantContextHolder; |
| | | 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; |
| | |
| | | |
| | | @PostMapping("run") |
| | | public CommonResult<String> run(@RequestBody MdkDTO dto) { |
| | | Long tenantId = TenantContextHolder.getTenantId(); |
| | | // 备份文件 租户隔离 |
| | | String mpkTenantBakFilePath = mpkBakFilePath + File.separator + tenantId; |
| | | |
| | | Class<?> clazz; |
| | | URLClassLoader classLoader; |
| | | try { |
| | | File jarFile = new File(mpkBakFilePath + File.separator + MdkConstant.JAR + File.separator + dto.getPyName() + ".jar"); |
| | | File jarFile = new File(mpkTenantBakFilePath + File.separator + MdkConstant.JAR + File.separator + dto.getPyName() + ".jar"); |
| | | if (!jarFile.exists()) { |
| | | throw new RuntimeException("jar包不存在,请先生成代码。jarPath:" + jarFile.getAbsolutePath()); |
| | | } |
| | | File dllFile = new File(mpkBakFilePath + File.separator + MdkConstant.DLL + File.separator + dto.getPyName() + ".dll"); |
| | | File dllFile = new File(mpkTenantBakFilePath + File.separator + MdkConstant.DLL + File.separator + dto.getPyName() + ".dll"); |
| | | if (!dllFile.exists()) { |
| | | throw new RuntimeException("dll文件不存在,请先生成代码。dllPath:" + dllFile.getAbsolutePath()); |
| | | } |
| | |
| | | return error(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"运行异常"); |
| | | } finally { |
| | | if (classLoader != null) { |
| | | DllUtils.uploadDll(classLoader); |
| | | DllUtils.uploadJar(classLoader); |
| | | DllUtils.unloadDll(classLoader); |
| | | DllUtils.unloadJar(classLoader); |
| | | } |
| | | System.gc(); |
| | | } |