package com.iailab.module.model.mdk.factory;
|
|
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 com.iailab.module.model.mdk.vo.MmItemOutputVO;
|
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<MmItemOutputVO>> itemOutPutItemMap = new HashMap<>();
|
private Map<String, MmItemOutputVO> itemOutputMap = 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<MmItemOutputVO> getOutPutByItemId(String itemId) {
|
List<MmItemOutputVO> list = mmItemOutputService.getOutPutByItemId(itemId);
|
if (!itemOutPutItemMap.containsKey(itemId)) {
|
if (list != null) {
|
itemOutPutItemMap.put(itemId, list);
|
} else {
|
return null;
|
}
|
}
|
return list;
|
}
|
|
/**
|
* 5.
|
*
|
* @param outputId
|
* @return
|
*/
|
public MmItemOutputVO getItemOutPutById(String outputId) {
|
if (!itemOutputMap.containsKey(outputId)) {
|
MmItemOutputVO itemOutput = mmItemOutputService.getOutPutById(outputId);
|
if (itemOutput != null) {
|
itemOutputMap.put(outputId, itemOutput);
|
} else {
|
return null;
|
}
|
}
|
return itemOutputMap.get(outputId);
|
}
|
|
/**
|
* 6.根据预测项ID,获取预测项对应的输出参数的维数
|
*
|
* @param itemId
|
* @return
|
*/
|
public Integer getItemOutputCount(String itemId) {
|
if (!itemOutPutItemMap.containsKey(itemId)) {
|
List<MmItemOutputVO> list = mmItemOutputService.getOutPutByItemId(itemId);
|
if (list != null) {
|
itemOutPutItemMap.put(itemId, list);
|
} else {
|
return 0;
|
}
|
}
|
return itemOutPutItemMap.get(itemId).size();
|
}
|
|
/**
|
* 7.根据预测项ID,获取对应的MmItemTypeEntity实体
|
*
|
* @param itemId
|
* @return
|
*/
|
public MmItemTypeEntity getMmItemTypeEntity(String itemId) {
|
if (!itemTypeMap.containsKey(itemId)) {
|
MmItemTypeEntity MmItemTypeEntity = mmItemTypeService.getItemTypeByItemId(itemId);
|
if (MmItemTypeEntity != null) {
|
itemTypeMap.put(itemId, MmItemTypeEntity);
|
} else {
|
return null;
|
}
|
}
|
return itemTypeMap.get(itemId);
|
}
|
}
|