package com.iailab.module.model.mdk.factory;
|
|
import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity;
|
import com.iailab.module.model.mcs.pre.entity.MmItemTypeEntity;
|
import com.iailab.module.model.mcs.pre.service.MmItemOutputService;
|
import com.iailab.module.model.mcs.pre.service.MmItemTypeService;
|
import com.iailab.module.model.mcs.pre.service.MmPredictItemService;
|
import com.iailab.module.model.mdk.vo.ItemVO;
|
import com.iailab.module.model.mdk.vo.MergeItemVO;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 创建预测项对象的工厂
|
*/
|
@Component
|
public class ItemEntityFactory {
|
private HashMap<String, ItemVO> ItemVOHashMap = new HashMap<>();
|
private Map<String, MmItemTypeEntity> itemTypeMap = new HashMap<>();
|
private Map<String, MergeItemVO> mergeItemMap = new HashMap<>();
|
private Map<String, ItemVO> itemNoEntityMap = new HashMap<>();
|
private Map<String, List<MmItemOutputEntity>> itemOutPutItemMap = new HashMap<>();
|
|
@Autowired
|
private MmPredictItemService mmPredictItemService;
|
|
@Autowired
|
private MmItemOutputService mmItemOutputService;
|
|
@Autowired
|
private MmItemTypeService mmItemTypeService;
|
|
/**
|
* 1.根据ITEMID,获取模型对应的MERGEITEM实体
|
*
|
* @param itemId
|
* @return
|
*/
|
public MergeItemVO getMergeItem(String itemId) {
|
MergeItemVO mergeItemVO = mmPredictItemService.getMergeItemByItemId(itemId);
|
if (!mergeItemMap.containsKey(itemId)) {
|
if (mergeItemVO != null) {
|
mergeItemMap.put(itemId, mergeItemVO);
|
} else {
|
return null;
|
}
|
}
|
return mergeItemVO;
|
}
|
|
/**
|
* 2.根据ITEMNO,获取模型对应的ITEM实体
|
*
|
* @param itemNo
|
* @return
|
*/
|
public ItemVO getItemByItemNo(String itemNo) {
|
ItemVO ItemVO = mmPredictItemService.getItemByItemNo(itemNo);
|
if (!itemNoEntityMap.containsKey(itemNo)) {
|
if (ItemVO != null) {
|
itemNoEntityMap.put(itemNo, ItemVO);
|
} else {
|
return null;
|
}
|
}
|
return ItemVO;
|
}
|
|
/**
|
* 3.根据ITEMID,获取模型对应的ITEM实体
|
*
|
* @param itemId
|
* @return
|
*/
|
public ItemVO getItemById(String itemId) {
|
ItemVO ItemVO = mmPredictItemService.getItemById(itemId);
|
if (!ItemVOHashMap.containsKey(itemId)) {
|
if (ItemVO != null) {
|
ItemVOHashMap.put(itemId, ItemVO);
|
} else {
|
return null;
|
}
|
}
|
return ItemVO;
|
}
|
|
/**
|
* 4. 根据ITEMID,获取模型对应的ITEMOUTPUT实体
|
*
|
* @param itemId
|
* @return
|
*/
|
public List<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity> getOutPutByItemId(String itemId) {
|
List<com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity> list = mmItemOutputService.getByItemid(itemId);
|
if (!itemOutPutItemMap.containsKey(itemId)) {
|
if (list != null) {
|
itemOutPutItemMap.put(itemId, list);
|
} else {
|
return null;
|
}
|
}
|
return list;
|
}
|
|
}
|