提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mdk.factory; |
潘 |
2 |
|
|
3 |
import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity; |
|
4 |
import com.iailab.module.model.mcs.pre.service.MmItemOutputService; |
|
5 |
import com.iailab.module.model.mcs.pre.service.MmItemTypeService; |
|
6 |
import com.iailab.module.model.mcs.pre.service.MmPredictItemService; |
|
7 |
import com.iailab.module.model.mdk.vo.ItemVO; |
|
8 |
import com.iailab.module.model.mdk.vo.MergeItemVO; |
|
9 |
import com.iailab.module.model.mdk.vo.MmItemOutputVO; |
|
10 |
import org.springframework.beans.factory.annotation.Autowired; |
|
11 |
import org.springframework.stereotype.Component; |
|
12 |
|
|
13 |
import java.util.HashMap; |
|
14 |
import java.util.List; |
|
15 |
import java.util.Map; |
|
16 |
|
|
17 |
/** |
|
18 |
* 创建预测项对象的工厂 |
|
19 |
*/ |
|
20 |
@Component |
|
21 |
public class ItemEntityFactory { |
|
22 |
private HashMap<String, ItemVO> ItemVOHashMap = new HashMap<>(); |
|
23 |
private Map<String, MmItemTypeEntity> itemTypeMap = new HashMap<>(); |
|
24 |
private Map<String, MergeItemVO> mergeItemMap = new HashMap<>(); |
|
25 |
private Map<String, ItemVO> itemNoEntityMap = new HashMap<>(); |
|
26 |
private Map<String, List<MmItemOutputVO>> itemOutPutItemMap = new HashMap<>(); |
|
27 |
private Map<String, MmItemOutputVO> itemOutputMap = new HashMap<>(); |
|
28 |
|
|
29 |
@Autowired |
|
30 |
private MmPredictItemService mmPredictItemService; |
|
31 |
|
|
32 |
@Autowired |
|
33 |
private MmItemOutputService mmItemOutputService; |
|
34 |
|
|
35 |
@Autowired |
|
36 |
private MmItemTypeService mmItemTypeService; |
|
37 |
|
|
38 |
/** |
|
39 |
* 1.根据ITEMID,获取模型对应的MERGEITEM实体 |
|
40 |
* |
|
41 |
* @param itemId |
|
42 |
* @return |
|
43 |
*/ |
|
44 |
public MergeItemVO getMergeItem(String itemId) { |
|
45 |
MergeItemVO mergeItemVO = mmPredictItemService.getMergeItemByItemId(itemId); |
|
46 |
if (!mergeItemMap.containsKey(itemId)) { |
|
47 |
if (mergeItemVO != null) { |
|
48 |
mergeItemMap.put(itemId, mergeItemVO); |
|
49 |
} else { |
|
50 |
return null; |
|
51 |
} |
|
52 |
} |
|
53 |
return mergeItemVO; |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* 2.根据ITEMNO,获取模型对应的ITEM实体 |
|
58 |
* |
|
59 |
* @param itemNo |
|
60 |
* @return |
|
61 |
*/ |
|
62 |
public ItemVO getItemByItemNo(String itemNo) { |
|
63 |
ItemVO ItemVO = mmPredictItemService.getItemByItemNo(itemNo); |
|
64 |
if (!itemNoEntityMap.containsKey(itemNo)) { |
|
65 |
if (ItemVO != null) { |
|
66 |
itemNoEntityMap.put(itemNo, ItemVO); |
|
67 |
} else { |
|
68 |
return null; |
|
69 |
} |
|
70 |
} |
|
71 |
return ItemVO; |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* 3.根据ITEMID,获取模型对应的ITEM实体 |
|
76 |
* |
|
77 |
* @param itemId |
|
78 |
* @return |
|
79 |
*/ |
|
80 |
public ItemVO getItemById(String itemId) { |
|
81 |
ItemVO ItemVO = mmPredictItemService.getItemById(itemId); |
|
82 |
if (!ItemVOHashMap.containsKey(itemId)) { |
|
83 |
if (ItemVO != null) { |
|
84 |
ItemVOHashMap.put(itemId, ItemVO); |
|
85 |
} else { |
|
86 |
return null; |
|
87 |
} |
|
88 |
} |
|
89 |
return ItemVO; |
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* 4. 根据ITEMID,获取模型对应的ITEMOUTPUT实体 |
|
94 |
* |
|
95 |
* @param itemId |
|
96 |
* @return |
|
97 |
*/ |
|
98 |
public List<MmItemOutputVO> getOutPutByItemId(String itemId) { |
|
99 |
List<MmItemOutputVO> list = mmItemOutputService.getOutPutByItemId(itemId); |
|
100 |
if (!itemOutPutItemMap.containsKey(itemId)) { |
|
101 |
if (list != null) { |
|
102 |
itemOutPutItemMap.put(itemId, list); |
|
103 |
} else { |
|
104 |
return null; |
|
105 |
} |
|
106 |
} |
|
107 |
return list; |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* 5. |
|
112 |
* |
|
113 |
* @param outputId |
|
114 |
* @return |
|
115 |
*/ |
|
116 |
public MmItemOutputVO getItemOutPutById(String outputId) { |
|
117 |
if (!itemOutputMap.containsKey(outputId)) { |
|
118 |
MmItemOutputVO itemOutput = mmItemOutputService.getOutPutById(outputId); |
|
119 |
if (itemOutput != null) { |
|
120 |
itemOutputMap.put(outputId, itemOutput); |
|
121 |
} else { |
|
122 |
return null; |
|
123 |
} |
|
124 |
} |
|
125 |
return itemOutputMap.get(outputId); |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* 6.根据预测项ID,获取预测项对应的输出参数的维数 |
|
130 |
* |
|
131 |
* @param itemId |
|
132 |
* @return |
|
133 |
*/ |
|
134 |
public Integer getItemOutputCount(String itemId) { |
|
135 |
if (!itemOutPutItemMap.containsKey(itemId)) { |
|
136 |
List<MmItemOutputVO> list = mmItemOutputService.getOutPutByItemId(itemId); |
|
137 |
if (list != null) { |
|
138 |
itemOutPutItemMap.put(itemId, list); |
|
139 |
} else { |
|
140 |
return 0; |
|
141 |
} |
|
142 |
} |
|
143 |
return itemOutPutItemMap.get(itemId).size(); |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* 7.根据预测项ID,获取对应的MmItemTypeEntity实体 |
|
148 |
* |
|
149 |
* @param itemId |
|
150 |
* @return |
|
151 |
*/ |
|
152 |
public MmItemTypeEntity getMmItemTypeEntity(String itemId) { |
|
153 |
if (!itemTypeMap.containsKey(itemId)) { |
|
154 |
MmItemTypeEntity MmItemTypeEntity = mmItemTypeService.getItemTypeByItemId(itemId); |
|
155 |
if (MmItemTypeEntity != null) { |
|
156 |
itemTypeMap.put(itemId, MmItemTypeEntity); |
|
157 |
} else { |
|
158 |
return null; |
|
159 |
} |
|
160 |
} |
|
161 |
return itemTypeMap.get(itemId); |
|
162 |
} |
|
163 |
} |