提交 | 用户 | 时间
|
137356
|
1 |
package com.iailab.module.model.mpk.common.utils; |
潘 |
2 |
|
|
3 |
import com.iail.IAILMDK; |
|
4 |
import com.iail.model.IAILModel; |
|
5 |
import org.springframework.stereotype.Component; |
|
6 |
|
|
7 |
import java.io.File; |
|
8 |
import java.util.HashMap; |
|
9 |
import java.util.Map; |
|
10 |
|
|
11 |
/** |
|
12 |
* @author PanZhibao |
|
13 |
* @date 2021年09月08日 15:09 |
|
14 |
*/ |
|
15 |
@Component |
|
16 |
public class IAILModelUtil { |
|
17 |
|
|
18 |
/** |
|
19 |
* 解析模型 |
|
20 |
* |
|
21 |
* @param uploadDir |
|
22 |
* @return |
|
23 |
*/ |
|
24 |
public Map<String, Object> parseModel(String uploadDir) { |
|
25 |
IAILModel newModelBean = IAILMDK.loadModel(new File(uploadDir)); |
|
26 |
Map<String, Object> params = new HashMap<>(); |
|
27 |
params.put("uploadDir", uploadDir); |
|
28 |
params.put("paramPathList", newModelBean.getParamPathList()); |
|
29 |
params.put("className", newModelBean.getClassName()); |
|
30 |
params.put("methodName", newModelBean.getMethodName()); |
|
31 |
params.put("paramsArray", newModelBean.getParamsArray()); |
|
32 |
params.put("loadFieldSetList", newModelBean.getLoadFieldSetList()); |
|
33 |
params.put("paramsCount", getItemInNum(newModelBean.getParamsArray())); |
|
34 |
params.put("settingConfigMap", newModelBean.getSettingConfigMap()); |
|
35 |
return params; |
|
36 |
} |
|
37 |
|
|
38 |
private static int getItemInNum(Class<?>[] paramClasses) { |
|
39 |
if (paramClasses == null) { |
|
40 |
return 0; |
|
41 |
} |
|
42 |
int inNum = 0; |
|
43 |
for (int i = 0; i < paramClasses.length; i++) { |
|
44 |
if (paramClasses[i].isArray()) { |
|
45 |
++inNum; |
|
46 |
} |
|
47 |
} |
|
48 |
return inNum; |
|
49 |
} |
|
50 |
} |