| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | |
| | | @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(); |
| | | BigDecimal firstAdjustValue = new BigDecimal(reqDTO.getModelResult().get(firstOutKey.trim()).toString().trim()); |
| | | if (BigDecimal.ZERO.compareTo(firstAdjustValue) == 0) { |
| | | log.info("adjustValue = 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().trim())) { |
| | | adjustValue = new BigDecimal(reqDTO.getModelResult().get(det.getOutKey().trim()).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; |
| | | } |