From 2256fcb096ae51044dc6a1e792f9e28fb53598af Mon Sep 17 00:00:00 2001 From: dongyukun <1208714201@qq.com> Date: 星期二, 01 四月 2025 18:53:29 +0800 Subject: [PATCH] 天粒度模型运行时间改为第二天 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java | 67 +++++++++++++++++++++++---------- 1 files changed, 46 insertions(+), 21 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java index 334d710..2df511e 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java @@ -1,6 +1,7 @@ package com.iailab.module.model.api; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.iailab.module.data.api.point.DataPointApi; import com.iailab.module.data.api.point.dto.ApiPointValueWriteDTO; import com.iailab.module.model.api.mcs.dto.StScheduleModelOutDTO; @@ -14,6 +15,7 @@ import com.iailab.module.model.mcs.pre.service.DmModuleService; import com.iailab.module.model.mcs.pre.service.MmPredictItemService; import com.iailab.module.model.mcs.sche.entity.StAdjustConfigDetEntity; +import com.iailab.module.model.mcs.sche.entity.StAdjustConfigEntity; import com.iailab.module.model.mcs.sche.entity.StScheduleSchemeEntity; import com.iailab.module.model.mcs.sche.service.StAdjustConfigService; import com.iailab.module.model.mcs.sche.service.StScheduleModelOutService; @@ -196,30 +198,53 @@ @Override public Boolean predictSimAdjust(MdkPredictSimAdjustReqDTO reqDTO) { + log.info("开始模拟调整"); + log.info("ModelResult:" + JSONObject.toJSONString(reqDTO.getModelResult())); StScheduleSchemeEntity scheduleScheme = stScheduleSchemeService.getByCode(reqDTO.getScheduleCode()); - List<StAdjustConfigDetEntity> detList = stAdjustConfigService.getDetByModelId(scheduleScheme.getModelId()); - if (CollectionUtils.isEmpty(detList)) { + Map<StAdjustConfigEntity, List<StAdjustConfigDetEntity>> configMap = stAdjustConfigService.getAdjustConfigMap(scheduleScheme.getModelId()); + if (CollectionUtils.isEmpty(configMap)) { return Boolean.FALSE; } - for (StAdjustConfigDetEntity det : detList) { - ItemVO predictItem = mmPredictItemService.getItemById(det.getPredictItemId()); - List<StAdjustDeviationDTO> deviationList = new ArrayList<>(); - switch (PredictItemTypeEnum.getEumById(det.getItemTypeId())) { - case NormalItem: - double adjustValue = new BigDecimal(reqDTO.getModelResult().get(det.getOutKey()).toString()).doubleValue(); - StAdjustDeviationDTO deviationItem = new StAdjustDeviationDTO(); - deviationItem.setPortIdx(det.getModelParamPortOrder()); - deviationItem.setParamIdx(det.getModelParamPortOrder()); - deviationItem.setValue(adjustValue); - deviationList.add(deviationItem); - break; - case MergeItem: - break; - default: - break; + for (Map.Entry<StAdjustConfigEntity, List<StAdjustConfigDetEntity>> entry : configMap.entrySet()) { + log.info("AdjustConfigID=" + entry.getKey().getId()); + if (CollectionUtils.isEmpty(entry.getValue())) { + continue; } - // 开始预测 - predictModuleHandler.predictAdjust(predictItem, reqDTO.getPredictTime(), deviationList, scheduleScheme.getModelId(), det.getConfigId()); + String firstOutKey = entry.getValue().get(0).getOutKey(); + if(StringUtils.isBlank(firstOutKey)) { + continue; + } + if(reqDTO.getModelResult().get(firstOutKey) == null || StringUtils.isBlank(reqDTO.getModelResult().get(firstOutKey).toString())) { + continue; + } + BigDecimal firstAdjustValue = new BigDecimal(reqDTO.getModelResult().get(firstOutKey.trim()).toString().trim()); + if (BigDecimal.ZERO.compareTo(firstAdjustValue) == 0) { + log.info("firstAdjustValue = ZERO"); + continue; + } + for (StAdjustConfigDetEntity det : entry.getValue()) { + ItemVO predictItem = mmPredictItemService.getItemById(det.getPredictItemId()); + List<StAdjustDeviationDTO> deviationList = new ArrayList<>(); + switch (PredictItemTypeEnum.getEumById(det.getItemTypeId())) { + case NormalItem: + double adjustValue = 0; + if (StringUtils.isNotBlank(det.getOutKey())) { + adjustValue = new BigDecimal(reqDTO.getModelResult().get(det.getOutKey()).toString()).doubleValue(); + } + StAdjustDeviationDTO deviationItem = new StAdjustDeviationDTO(); + deviationItem.setPortIdx(det.getModelParamPortOrder() == null ? 0 : det.getModelParamPortOrder()); + deviationItem.setParamIdx(det.getModelParamOrder() == null ? 0 : det.getModelParamOrder()); + deviationItem.setValue(adjustValue); + deviationList.add(deviationItem); + break; + case MergeItem: + break; + default: + break; + } + // 开始预测 + predictModuleHandler.predictAdjust(predictItem, reqDTO.getPredictTime(), deviationList, scheduleScheme.getModelId(), det.getConfigId()); + } } return Boolean.TRUE; } @@ -258,7 +283,7 @@ resp.setResult(scheduleResult.getResult()); stScheduleRecordService.create(scheduleResult); stScheduleSchemeService.updateTime(scheduleResult.getSchemeId(), scheduleResult.getScheduleTime(), scheduleResult.getResultCode()); - log.info("预测计算结束: " + System.currentTimeMillis()); + log.info("调度计算结束: " + System.currentTimeMillis()); } catch (Exception ex) { log.info("调度计算异常: " + System.currentTimeMillis()); ex.printStackTrace(); -- Gitblit v1.9.3