package com.iailab.module.shasteel.mq.consumer; import com.iailab.module.model.api.mcs.McsApi; 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.enums.ScheduleTriggerMethodEnum; import com.iailab.module.shasteel.mq.common.constant.CommonConstant; import com.iailab.module.shasteel.mq.config.QueuePredictFinishConfig; import lombok.extern.slf4j.Slf4j; 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; /** * @description: * @author: dzd * @date: 2025/1/17 17:41 **/ @Slf4j @Component public class ModelElecPredictFinishConsumer { @Resource private McsApi mcsApi; @Resource private MdkApi mdkApi; /** * 监听电力预测完成,执行电力调度 * * @param message */ @RabbitListener(queues = QueuePredictFinishConfig.QUEUE_NAME) public void listen(Message message) { String messageBody = new String(message.getBody()); log.info("开始执行电力调度,messageBody:" + messageBody); // 查找需要执行的电力调度方案 List scheduleSchemeList = mcsApi.listScheduleScheme(ScheduleTriggerMethodEnum.EVENT.getCode(), CommonConstant.TRIGGER_CONDITION_ELEC); // 电力预测完成,执行电力调度模型 Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.HOUR_OF_DAY, 0); Date scheduleTime = calendar.getTime(); for (StScheduleSchemeDTO stScheduleSchemeDTO : scheduleSchemeList) { MdkScheduleReqDTO mdkScheduleReqDTO = new MdkScheduleReqDTO(); mdkScheduleReqDTO.setScheduleCode(stScheduleSchemeDTO.getCode()); mdkScheduleReqDTO.setScheduleTime(scheduleTime); mdkApi.doSchedule(mdkScheduleReqDTO); } } }