From 0cbbe2c1cbfbf73e02e1796d921c2911c96d370b Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 23 十二月 2024 11:46:31 +0800 Subject: [PATCH] Merge branch 'master' of http://dlindusit.com:53929/r/iailab-plat --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java | 49 +++++++++++++++++-------------------------------- 1 files changed, 17 insertions(+), 32 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java index ef3149a..025ce4e 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictItemNormalHandlerImpl.java @@ -1,9 +1,8 @@ package com.iailab.module.model.mdk.predict.impl; -import com.iailab.framework.common.util.collection.CollectionUtils; import com.iailab.module.model.mcs.pre.entity.MmPredictModelEntity; +import com.iailab.module.model.mcs.pre.enums.ItemRunStatusEnum; import com.iailab.module.model.mcs.pre.service.MmPredictModelService; -import com.iailab.module.model.mdk.common.enums.ItemPredictStatus; 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; @@ -13,12 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.sql.Timestamp; import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Calendar; import java.util.Date; -import java.util.List; +import java.util.Map; /** * @author PanZhibao @@ -34,41 +30,30 @@ @Autowired private PredictModelHandler predictModelHandler; + /** + * NormalItem预测 + * + * @param predictTime + * @param predictItemDto + * @return + * @throws ItemInvokeException + */ @Override - public PredictResultVO predict(Date predictTime, ItemVO predictItemDto) - throws ItemInvokeException{ - String itemId = predictItemDto.getId(); - ItemPredictStatus itemStatus = ItemPredictStatus.PREDICTING; - PredictResultVO finalResult = new PredictResultVO(); + public PredictResultVO predict(Date predictTime, ItemVO predictItemDto, Map<String, double[]> predictValueMap) throws ItemInvokeException { PredictResultVO predictResult = new PredictResultVO(); - List<PredictResultVO> predictResultList = new ArrayList<>(); + String itemId = predictItemDto.getId(); try { - // 获取预测项模型 - List<MmPredictModelEntity> predictModelList = mmPredictModelService.getActiveModelByItemId(itemId); - if (CollectionUtils.isAnyEmpty(predictModelList)) { + MmPredictModelEntity predictModel = mmPredictModelService.getActiveModelByItemId(itemId); + if (predictModel == null) { throw new ModelInvokeException(MessageFormat.format("{0},itemId={1}", ModelInvokeException.errorGetModelEntity, itemId)); } - for (MmPredictModelEntity predictModel : predictModelList) { - predictResult = predictModelHandler.predictByModel(predictTime, predictModel); - predictResult.setPredictId(itemId); - predictResultList.add(predictResult); - } - itemStatus = ItemPredictStatus.SUCCESS; - Calendar calendar = Calendar.getInstance(); - calendar.setTime(predictTime); - calendar.add(Calendar.MINUTE, predictResult.getPredictMatrix().length - 1); - Timestamp endTime = new Timestamp(calendar.getTime().getTime()); - finalResult = predictResultList.get(0); - + predictResult = predictModelHandler.predictByModel(predictTime, predictModel,predictItemDto.getItemName()); + predictResult.setPredictId(itemId); } catch (Exception ex) { - ex.printStackTrace(); - //预测项预测失败的状态 - itemStatus = ItemPredictStatus.FAILED; throw new ItemInvokeException(MessageFormat.format("{0},itemId={1}", ItemInvokeException.errorItemFailed, itemId)); } - - return finalResult; + return predictResult; } } \ No newline at end of file -- Gitblit v1.9.3