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