From 08565501239449cc1f686918135c23c0c98e5625 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 18 三月 2025 15:32:37 +0800 Subject: [PATCH] LDG产生预警消息 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelElecPredictFinishConsumer.java | 43 +++++++++++++++++++++++++++++++++++++------ 1 files changed, 37 insertions(+), 6 deletions(-) diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelElecPredictFinishConsumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelElecPredictFinishConsumer.java index c7da9d2..2faa438 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelElecPredictFinishConsumer.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelElecPredictFinishConsumer.java @@ -1,21 +1,22 @@ package com.iailab.module.shasteel.mq.consumer; import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.ScheduleSuggestRespDTO; import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; import com.iailab.module.model.api.mdk.MdkApi; import com.iailab.module.model.api.mdk.dto.MdkScheduleReqDTO; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; import com.iailab.module.model.enums.ScheduleTriggerMethodEnum; import com.iailab.module.shasteel.mq.common.constant.CommonConstant; -import com.iailab.module.shasteel.mq.config.QueueElecPredictFinishConfig; +import com.iailab.module.shasteel.mq.config.QueuePredictFinishConfig; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component; import javax.annotation.Resource; -import java.util.Calendar; -import java.util.Date; -import java.util.List; +import java.util.*; /** * @description: @@ -32,12 +33,23 @@ @Resource private MdkApi mdkApi; + //功率因数调度 code + private static final List<String> elecScheduleCodes = new ArrayList<String>(){{ + add("rejuandiaodu"); + add("leyangdiaodu"); + add("lengzhadiaodu"); + add("hailidiaodu"); + add("dongqudiaodu"); + }}; + + private static final String adviceKey = "advice"; + /** * 监听电力预测完成,执行电力调度 * * @param message */ - @RabbitListener(queues = QueueElecPredictFinishConfig.QUEUE_NAME) + @RabbitListener(queues = QueuePredictFinishConfig.QUEUE_NAME_ELEC) public void listen(Message message) { String messageBody = new String(message.getBody()); log.info("开始执行电力调度,messageBody:" + messageBody); @@ -54,7 +66,26 @@ MdkScheduleReqDTO mdkScheduleReqDTO = new MdkScheduleReqDTO(); mdkScheduleReqDTO.setScheduleCode(stScheduleSchemeDTO.getCode()); mdkScheduleReqDTO.setScheduleTime(scheduleTime); - mdkApi.doSchedule(mdkScheduleReqDTO); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(mdkScheduleReqDTO); + + //功率因数调度 保存调度建议 + if (elecScheduleCodes.contains(stScheduleSchemeDTO.getCode())) { + Map<String, Object> result = mdkScheduleRespDTO.getResult(); + if (result.containsKey(adviceKey)) { + String advice = result.get(adviceKey).toString().trim(); + if (StringUtils.isNotBlank(advice)) { + ScheduleSuggestRespDTO suggest = new ScheduleSuggestRespDTO(); + suggest.setTitle("电力调度建议"); + suggest.setContent(advice); + suggest.setSchemeId(stScheduleSchemeDTO.getId()); + suggest.setScheduleObj(stScheduleSchemeDTO.getScheduleObj()); + suggest.setScheduleTime(scheduleTime); + suggest.setSort(0); + mcsApi.createScheduleSuggest(suggest); + } + } + } + } -- Gitblit v1.9.3