From 17a6e42c685b7aee80a953f182ab514db2643fe0 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期三, 11 十二月 2024 18:07:11 +0800
Subject: [PATCH] Merge branch 'master' of http://dlindusit.com:53929/r/shasteel

---
 shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java |   47 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ScheduleConsumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java
similarity index 63%
rename from shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ScheduleConsumer.java
rename to shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java
index 78a2acb..48fece0 100644
--- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ScheduleConsumer.java
+++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java
@@ -1,17 +1,14 @@
 package com.iailab.module.shasteel.mq.consumer;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-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.model.api.mdk.dto.MdkScheduleRespDTO;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
+import com.iailab.module.shasteel.mq.common.RoutingConstant;
+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.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
@@ -20,13 +17,15 @@
 import java.util.Map;
 
 /**
- * @author lirm
+ * 监听报警信息
+ *
+ * @author PanZhibao
  * @Description
- * @createTime 2024年11月27日
+ * @createTime 2024年12月11日
  */
+@Slf4j
 @Component
-@RabbitListener(queues = AlarmMessage.ALARM_ROUTING_KEY)
-public class ScheduleConsumer {
+public class ModelAlarmConsumer {
 
     @Resource
     private McsApi mcsApi;
@@ -34,10 +33,25 @@
     @Resource
     private MdkApi mdkApi;
 
-    @RabbitHandler
-    public void process(AlarmMessage alarmMessage) {
+    /**
+     * 事件标识
+     */
+    private final String EVENT_FLAG = "GasAlarm";
+
+    /**
+     * 监听报警信息,执行调度
+     *
+     * @param message
+     */
+    @RabbitListener(queues = QueueModelAlarmConfig.QUEUE_NAME)
+    public void listen(Message message) {
+        String routingKey = message.getMessageProperties().getReceivedRoutingKey();
+        log.info("routingKey:" + routingKey);
+        String messageBody = new String(message.getBody());
+        log.info("messageBody:" + messageBody);
+        // 查找需要执行的调度方案
         Map<String, Object> params = new HashMap<>();
-        params.put("trigger_condition", AlarmMessage.ALARM_ROUTING_KEY);
+        params.put("trigger_condition", routingKey);
         List<StScheduleSchemeDTO> scheduleSchemeList = mcsApi.listScheduleScheme(params);//根据触发条件获取调度方案列表
         for(StScheduleSchemeDTO stScheduleSchemeDTO : scheduleSchemeList){
             MdkScheduleReqDTO mdkScheduleReqDTO = new MdkScheduleReqDTO();
@@ -52,5 +66,8 @@
 //        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