package com.iailab.common.utils; import cn.hutool.core.util.ReflectUtil; import com.iailab.module.model.IAILModel; import lombok.extern.slf4j.Slf4j; import java.lang.reflect.Method; import java.util.HashMap; /** * @author PanZhibao * @Description * @createTime 2023年01月11日 11:03:00 */ @Slf4j public class MatlabUtil { public static HashMap execML(IAILModel model, Object[] paramValues) { //获取预测项的预测程序的类 HashMap tMap = null; try { // double[][] realTimeData ={{12.1,5.1,1.45},{12.2,5.2,1.43},{12,3,5.3,1.425},{13.4,5.4,1.46},{14.5,5.5,1.48},{11.6,5.6,1.5},{12.7,5.7,1.47},{12.8,5.8,1.45},{12.9,5.9,1.43},{12.6,6,1.425},{12.1,5.1,1.46},{12.2,5.2,1.47} ,{12.3,5.3,1.5},{13.4,5.4,1.47},{14.5,5.5,1.45},{11.6,5.6,1.43},{12.7,5.7,1.425}, {12.8,5.8,1.46},{12.9,5.9,1.48},{12.6,6,1.5},{12.1,5.1,1.47},{12.2,5.2,1.45},{12.3,5.3,1.43},{13.4,5.4,1.425},{14.5,5.5,1.46},{11.6,5.6,1.47},{12.7,5.7,1.5},{12.8,5.8,1.47},{12.9,5.9,1.45},{12.6,6,1.45}}; Class clazz = Class.forName(model.getClassName()); Method method = ReflectUtil.getPublicMethod(clazz, model.getMethodName(), model.getParamsArray()); //tMap = ReflectUtil.invoke(clazz.newInstance(), method, paramValues); tMap = (HashMap) method.invoke(clazz.newInstance(), paramValues); } catch (Exception e) { e.printStackTrace(); log.error("exception message : {}", e.getMessage()); } return tMap; } }