提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mdk.factory; |
潘 |
2 |
|
|
3 |
import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity; |
|
4 |
import lombok.extern.slf4j.Slf4j; |
|
5 |
import org.springframework.beans.factory.annotation.Autowired; |
|
6 |
import org.springframework.context.ApplicationContext; |
|
7 |
import org.springframework.stereotype.Component; |
|
8 |
|
|
9 |
/** |
|
10 |
* 创建预测项对象的工厂 |
|
11 |
*/ |
|
12 |
@Slf4j |
|
13 |
@Component |
|
14 |
public class PredictItemFactory { |
|
15 |
|
|
16 |
@Autowired |
|
17 |
private ApplicationContext applicationContext; |
|
18 |
|
|
19 |
@Autowired |
|
20 |
private ItemEntityFactory itemEntityFactory; |
|
21 |
|
|
22 |
/** |
|
23 |
* 根据预测项实体创建对应的预测项对象 |
|
24 |
* |
|
25 |
* @param itemId |
|
26 |
* @return |
|
27 |
*/ |
|
28 |
public Object create(String itemId) { |
|
29 |
MmItemTypeEntity itemTypeEntity = itemEntityFactory.getMmItemTypeEntity(itemId); |
|
30 |
//获取预测项的预测程序的类 |
|
31 |
Object itemObject = null; |
|
32 |
try { |
|
33 |
Class clazz = Class.forName(itemTypeEntity.getItemclasstype()); |
|
34 |
itemObject = applicationContext.getBean(clazz); |
|
35 |
} catch (Exception e) { |
|
36 |
log.error("exception message : {}", e.getMessage()); |
|
37 |
} |
|
38 |
return itemObject; |
|
39 |
} |
|
40 |
} |