package com.iailab.module.model.mdk.predict.impl;
|
|
import com.iailab.module.model.mcs.pre.entity.MmPredictModelEntity;
|
import com.iailab.module.model.mcs.pre.service.MmPredictModelService;
|
import com.iailab.module.model.mdk.common.exceptions.ItemInvokeException;
|
import com.iailab.module.model.mdk.common.exceptions.ModelInvokeException;
|
import com.iailab.module.model.mdk.predict.PredictItemHandler;
|
import com.iailab.module.model.mdk.predict.PredictModelHandler;
|
import com.iailab.module.model.mdk.vo.ItemVO;
|
import com.iailab.module.model.mdk.vo.PredictResultVO;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.text.MessageFormat;
|
import java.util.Date;
|
import java.util.Map;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年09月01日
|
*/
|
@Component
|
public class PredictItemNormalHandlerImpl implements PredictItemHandler {
|
|
@Autowired
|
private MmPredictModelService mmPredictModelService;
|
|
@Autowired
|
private PredictModelHandler predictModelHandler;
|
|
/**
|
* NormalItem预测
|
*
|
* @param predictTime
|
* @param predictItemDto
|
* @return
|
* @throws ItemInvokeException
|
*/
|
@Override
|
public PredictResultVO predict(Date predictTime, ItemVO predictItemDto, Map<String, double[]> predictValueMap) throws ItemInvokeException {
|
PredictResultVO predictResult = new PredictResultVO();
|
String itemId = predictItemDto.getId();
|
try {
|
MmPredictModelEntity predictModel = mmPredictModelService.getActiveModelByItemId(itemId);
|
if (predictModel == null) {
|
throw new ModelInvokeException(MessageFormat.format("{0},itemId={1}",
|
ModelInvokeException.errorGetModelEntity, itemId));
|
}
|
predictResult = predictModelHandler.predictByModel(predictTime, predictModel,predictItemDto.getItemName());
|
predictResult.setPredictId(itemId);
|
} catch (Exception ex) {
|
throw new ItemInvokeException(MessageFormat.format("{0},itemId={1}",
|
ItemInvokeException.errorItemFailed, itemId));
|
}
|
return predictResult;
|
}
|
}
|