From cf56ebbecf2c8fc695e95c4d84949182260ee082 Mon Sep 17 00:00:00 2001 From: liriming <1343021927@qq.com> Date: 星期五, 20 十二月 2024 10:27:51 +0800 Subject: [PATCH] 调度建议与预警信息 --- shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-) diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java index 48fece0..4621a2b 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java @@ -1,15 +1,19 @@ package com.iailab.module.shasteel.mq.consumer; +import com.alibaba.fastjson.JSONObject; import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; 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.shasteel.mq.common.RoutingConstant; +import com.iailab.module.model.api.mdk.dto.MdkScheduleRespDTO; +import com.iailab.module.shasteel.mq.common.enums.TriggerConditionEnum; import com.iailab.module.shasteel.mq.config.QueueModelAlarmConfig; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.Message; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.HashMap; @@ -49,25 +53,26 @@ log.info("routingKey:" + routingKey); String messageBody = new String(message.getBody()); log.info("messageBody:" + messageBody); + JSONObject messageJson = JSONObject.parseObject(messageBody); + if (CollectionUtils.isEmpty(messageJson)) { + return; + } // 查找需要执行的调度方案 Map<String, Object> params = new HashMap<>(); + params.put("trigger_method", TriggerConditionEnum.EVENT); params.put("trigger_condition", routingKey); List<StScheduleSchemeDTO> scheduleSchemeList = mcsApi.listScheduleScheme(params);//根据触发条件获取调度方案列表 for(StScheduleSchemeDTO stScheduleSchemeDTO : scheduleSchemeList){ MdkScheduleReqDTO mdkScheduleReqDTO = new MdkScheduleReqDTO(); mdkScheduleReqDTO.setScheduleCode(stScheduleSchemeDTO.getCode()); mdkScheduleReqDTO.setScheduleTime(stScheduleSchemeDTO.getScheduleTime()); -// MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(mdkScheduleReqDTO);//执行调度方案 -// String result = mdkScheduleRespDTO.getResult().toString(); -// System.out.println(result); -// AlarmMessageRespDTO alarmMessageRespDTO = new AlarmMessageRespDTO(); -// mcsApi.createAlarmMessage(alarmMessageRespDTO); + MdkScheduleRespDTO mdkScheduleRespDTO = mdkApi.doSchedule(mdkScheduleReqDTO);//执行调度方案 + String result = mdkScheduleRespDTO.getResult().toString(); + System.out.println(result); + AlarmMessageRespDTO alarmMessageRespDTO = (AlarmMessageRespDTO)messageJson.get("AlarmMessageRespDTO"); + alarmMessageRespDTO.setContent(result); + // 根据模型返回结果,保存调度建议 + mcsApi.createAlarmMessage(alarmMessageRespDTO); } -// AlarmMessageRespDTO alarmMessageRespDTO = alarmMessage.getAlarmMessageRespDTO(); -// JSONObject contentJson = JSONObject.parseObject(alarmMessageRespDTO.getContent()); -// String overLimitTime = contentJson.get("overLimitTime").toString(); - - // 根据模型返回结果,保存调度建议 - } } \ No newline at end of file -- Gitblit v1.9.3