package com.iailab.module.model.mpk.common.utils;
|
|
import com.iail.IAILMDK;
|
import com.iail.model.IAILModel;
|
import org.springframework.stereotype.Component;
|
|
import java.io.File;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* @author PanZhibao
|
* @date 2021年09月08日 15:09
|
*/
|
@Component
|
public class IAILModelUtil {
|
|
/**
|
* 解析模型
|
*
|
* @param uploadDir
|
* @return
|
*/
|
public Map<String, Object> parseModel(String uploadDir) {
|
IAILModel newModelBean = IAILMDK.loadModel(new File(uploadDir));
|
Map<String, Object> params = new HashMap<>();
|
params.put("uploadDir", uploadDir);
|
params.put("paramPathList", newModelBean.getParamPathList());
|
params.put("className", newModelBean.getClassName());
|
params.put("methodName", newModelBean.getMethodName());
|
params.put("paramsArray", newModelBean.getParamsArray());
|
params.put("loadFieldSetList", newModelBean.getLoadFieldSetList());
|
params.put("paramsCount", getItemInNum(newModelBean.getParamsArray()));
|
params.put("settingConfigMap", newModelBean.getSettingConfigMap());
|
return params;
|
}
|
|
private static int getItemInNum(Class<?>[] paramClasses) {
|
if (paramClasses == null) {
|
return 0;
|
}
|
int inNum = 0;
|
for (int i = 0; i < paramClasses.length; i++) {
|
if (paramClasses[i].isArray()) {
|
++inNum;
|
}
|
}
|
return inNum;
|
}
|
}
|