From c9ff6a7f2e89f751e2eec68ec02fa93919d05296 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期三, 11 十二月 2024 13:56:59 +0800 Subject: [PATCH] 监听报警信息 --- /dev/null | 33 ----------- shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java | 13 ++-- shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java | 46 +++++++++++++++ shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/RoutingConstant.java | 3 shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueueModelAlarmConfig.java | 3 shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueuePredictFinishConfig.java | 3 shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java | 35 ++++++----- shasteel-biz/src/main/resources/application.yaml | 2 8 files changed, 76 insertions(+), 62 deletions(-) diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java index 9306023..4675dd5 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java @@ -3,7 +3,7 @@ import com.iailab.module.model.api.mdk.MdkApi; import com.iailab.module.model.api.mdk.dto.MdkPredictModuleRespDTO; import com.iailab.module.model.api.mdk.dto.MdkPredictReqDTO; -import com.iailab.module.shasteel.mq.consumer.PredictFinishMessage; +import com.iailab.module.shasteel.mq.common.RoutingConstant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.amqp.rabbit.core.RabbitTemplate; @@ -14,7 +14,6 @@ /** * 执行模块预测定时任务 - * */ @Component("runPredictModuleTask") public class RunPredictModuleTask implements ITask { @@ -22,24 +21,24 @@ @Autowired private MdkApi mdkApi; + @Autowired private RabbitTemplate rabbitTemplate; - @Override public void run(String params) { - logger.info("runPredictModuleTask定时任务正在执行,参数为:{}",params ); + logger.info("runPredictModuleTask定时任务正在执行,参数为:{}", params); try { Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.SECOND,0); - calendar.set(Calendar.MILLISECOND,0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); MdkPredictReqDTO dto = new MdkPredictReqDTO(); dto.setPredictTime(calendar.getTime()); dto.setModuleType(params); MdkPredictModuleRespDTO mdkPredictModuleRespDTO = mdkApi.predictModule(dto); logger.info(params + "模块预测完成," + mdkPredictModuleRespDTO); - rabbitTemplate.convertAndSend(PredictFinishMessage.EXCHANGE, PredictFinishMessage.PREDICTFINISH_ROUTING_KEY, mdkPredictModuleRespDTO); + rabbitTemplate.convertAndSend(RoutingConstant.EXCHANGE, RoutingConstant.Iailab_Model_PredictFinish, mdkPredictModuleRespDTO); } catch (Exception ex) { logger.error("runPredictModuleTask运行异常"); diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/RoutingConstant.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/RoutingConstant.java index b7981e2..e53fee3 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/RoutingConstant.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/common/RoutingConstant.java @@ -2,10 +2,11 @@ public interface RoutingConstant { + String EXCHANGE = "FastShasteel"; + // 预测模型完成路由 String Iailab_Model_PredictFinish = "Iailab.Model.PredictFinish"; //预警消息路由 String Iailab_Model_Alarm = "Iailab.Model.Alarm"; - } \ No newline at end of file diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueueModelAlarmConfig.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueueModelAlarmConfig.java index 1208ed0..45edacc 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueueModelAlarmConfig.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueueModelAlarmConfig.java @@ -1,7 +1,6 @@ package com.iailab.module.shasteel.mq.config; import com.iailab.module.shasteel.mq.common.RoutingConstant; -import com.iailab.module.shasteel.mq.consumer.AlarmMessage; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.BindingBuilder; import org.springframework.amqp.core.Queue; @@ -28,7 +27,7 @@ @Bean TopicExchange alarmExchange() { - return new TopicExchange(AlarmMessage.EXCHANGE); + return new TopicExchange(RoutingConstant.EXCHANGE); } // 注意通配符*和#的用法 diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueuePredictFinishConfig.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueuePredictFinishConfig.java index 96f2350..148bcc4 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueuePredictFinishConfig.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueuePredictFinishConfig.java @@ -1,7 +1,6 @@ package com.iailab.module.shasteel.mq.config; import com.iailab.module.shasteel.mq.common.RoutingConstant; -import com.iailab.module.shasteel.mq.consumer.PredictFinishMessage; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.BindingBuilder; import org.springframework.amqp.core.Queue; @@ -26,7 +25,7 @@ @Bean TopicExchange predictFinishExchange() { - return new TopicExchange(PredictFinishMessage.EXCHANGE); + return new TopicExchange(RoutingConstant.EXCHANGE); } // 注意通配符*和#的用法 diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/AlarmConsumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/AlarmConsumer.java deleted file mode 100644 index af5c1c3..0000000 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/AlarmConsumer.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.iailab.module.shasteel.mq.consumer; - -import com.alibaba.fastjson.JSONObject; -import com.iailab.framework.common.util.date.DateUtils; -import com.iailab.module.model.api.mcs.McsApi; -import com.iailab.module.model.api.mcs.dto.AlarmConfigRespDTO; -import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; -import com.iailab.module.model.api.mcs.dto.PreDataJsonReqVO; -import org.springframework.amqp.rabbit.annotation.RabbitHandler; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author lirm - * @Description - * @createTime 2024年11月27日 - */ -@Component -@RabbitListener(queues = AlarmMessage.ALARM_ROUTING_KEY) -public class AlarmConsumer { - - @Resource - private RabbitTemplate rabbitTemplate; - - public void process(AlarmMessage alarmMessage) throws InterruptedException { - rabbitTemplate.convertAndSend(AlarmMessage.EXCHANGE, AlarmMessage.ALARM_ROUTING_KEY, alarmMessage); - } -} diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/AlarmMessage.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/AlarmMessage.java deleted file mode 100644 index 2587386..0000000 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/AlarmMessage.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.iailab.module.shasteel.mq.consumer; - -import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; -import com.iailab.module.shasteel.mq.common.RoutingConstant; -import lombok.Data; - -import java.io.Serializable; - -@Data -public class AlarmMessage implements Serializable { - - public static final String EXCHANGE = "predict-alarm-exchange"; - - public static final String ALARM_ROUTING_KEY = RoutingConstant.Iailab_Model_Alarm; - // 预警消息DTO - private AlarmMessageRespDTO alarmMessageRespDTO; -} \ No newline at end of file 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 new file mode 100644 index 0000000..7c6c315 --- /dev/null +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelAlarmConsumer.java @@ -0,0 +1,46 @@ +package com.iailab.module.shasteel.mq.consumer; + +import com.iailab.module.model.api.mcs.McsApi; +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 javax.annotation.Resource; + +/** + * 监听报警信息 + * + * @author PanZhibao + * @Description + * @createTime 2024年12月11日 + */ +@Slf4j +@Component +public class ModelAlarmConsumer { + + @Resource + private McsApi mcsApi; + + /** + * 事件标识 + */ + private final String EVENT_FLAG = "GasAlarm"; + + /** + * 监听报警信息,执行调度 + * + * @param message + */ + @RabbitListener(queues = QueueModelAlarmConfig.QUEUE_NAME) + public void listen(Message message) { + // 查找需要执行的调度方案 + + + // 开始执行调度方案 + + // 根据模型返回结果,保存调度建议 + + } +} \ No newline at end of file diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java index 971d2a9..0bee1be 100644 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java +++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java @@ -6,10 +6,12 @@ import com.iailab.module.model.api.mcs.dto.AlarmConfigRespDTO; import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; import com.iailab.module.model.api.mcs.dto.PreDataJsonReqVO; +import com.iailab.module.shasteel.mq.common.RoutingConstant; 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.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -21,6 +23,8 @@ import java.util.Map; /** + * 监听预测完成 + * * @author PanZhibao * @Description * @createTime 2024年12月11日 @@ -33,8 +37,13 @@ private McsApi mcsApi; @Resource - private AlarmConsumer alarmConsumer; + private RabbitTemplate rabbitTemplate; + /** + * 监听预测完成,产生预警消息 + * + * @param message + */ @RabbitListener(queues = QueuePredictFinishConfig.QUEUE_NAME) public void listen(Message message) { String routingKey = message.getMessageProperties().getReceivedRoutingKey(); @@ -68,29 +77,23 @@ for (Object[] data : predictList) { BigDecimal dataValue = new BigDecimal(Double.parseDouble(data[1].toString())).setScale(2, BigDecimal.ROUND_HALF_UP); if (!(dataValue.compareTo(item.getLowerLimit()) >= 0 && dataValue.compareTo(item.getUpperLimit()) <= 0)) { - AlarmMessage alarmMessage = new AlarmMessage(); - AlarmMessageRespDTO alarmMessageRespDTO = new AlarmMessageRespDTO(); - alarmMessageRespDTO.setConfigId(item.getId()); + AlarmMessageRespDTO alarmMessage = new AlarmMessageRespDTO(); + alarmMessage.setConfigId(item.getId()); if (dataValue.compareTo(item.getLowerLimit()) < 0) { - alarmMessageRespDTO.setAlarmType("1");//超下限 + alarmMessage.setAlarmType("1");//超下限 } else if (dataValue.compareTo(item.getUpperLimit()) > 0) { - alarmMessageRespDTO.setAlarmType("2");//超上限 + alarmMessage.setAlarmType("2");//超上限 } - alarmMessageRespDTO.setAlarmTime(DateUtils.parse(data[0].toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); + alarmMessage.setAlarmTime(DateUtils.parse(data[0].toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); JSONObject content = new JSONObject(); content.put("alarmObj", item.getAlarmObj()); - content.put("alarmType", alarmMessageRespDTO.getAlarmType()); + content.put("alarmType", alarmMessage.getAlarmType()); content.put("unit", item.getUnit()); content.put("overLimitTime", data[0]); content.put("overLimitValue", dataValue); - alarmMessageRespDTO.setContent(JSONObject.toJSONString(content)); - System.out.println("预警消息=" + alarmMessageRespDTO); - alarmMessage.setAlarmMessageRespDTO(alarmMessageRespDTO); - try { - alarmConsumer.process(alarmMessage); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + alarmMessage.setContent(JSONObject.toJSONString(content)); + System.out.println("预警消息=" + alarmMessage); + rabbitTemplate.convertAndSend(RoutingConstant.EXCHANGE, RoutingConstant.Iailab_Model_Alarm, alarmMessage); break; } } diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/PredictFinishConsumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/PredictFinishConsumer.java deleted file mode 100644 index 3256ea9..0000000 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/PredictFinishConsumer.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.iailab.module.shasteel.mq.consumer; - -import com.alibaba.fastjson.JSONObject; -import com.iailab.framework.common.util.date.DateUtils; -import com.iailab.module.model.api.mcs.McsApi; -import com.iailab.module.model.api.mcs.dto.AlarmConfigRespDTO; -import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; -import com.iailab.module.model.api.mcs.dto.PreDataJsonReqVO; -import org.springframework.amqp.rabbit.annotation.RabbitHandler; -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author lirm - * @Description - * @createTime 2024年11月27日 - */ -@Component -@RabbitListener(queues = PredictFinishMessage.PREDICTFINISH_ROUTING_KEY) -public class PredictFinishConsumer { - - @Resource - private McsApi mcsApi; - - @Resource - private AlarmConsumer alarmConsumer; - - @RabbitHandler - public void process(JSONObject json) throws InterruptedException { - System.out.println("测试消费模型预测完成RabbitMQ消息----------------------"); - Thread.sleep(5000); - List<AlarmConfigRespDTO> configList = mcsApi.listAlarmConfig(new HashMap<String, Object>()); - if (CollectionUtils.isEmpty(configList)) { - return; - } - List<String> OutputIdList = new ArrayList<>(); - configList.forEach(item -> { - OutputIdList.add(item.getOutId()); - }); - configList.forEach(item -> { - PreDataJsonReqVO reqVO = new PreDataJsonReqVO(); - reqVO.setPredictTime(DateUtils.parse(json.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - reqVO.setOutputIdList(OutputIdList); - Map<String, List<Object[]>> preData = mcsApi.getPreDataCur(reqVO); - if (CollectionUtils.isEmpty(preData)) { - return; - } - List<Object[]> result = preData.get(item.getOutId()); - int toIndex = result.size(); - if (toIndex <= 0) { - return; - } - int fromIndex = result.size() - item.getCompLength(); - List<Object[]> predictList = result.subList(fromIndex, toIndex); - for (Object[] data : predictList) { - BigDecimal dataValue = new BigDecimal(Double.parseDouble(data[1].toString())).setScale(2, BigDecimal.ROUND_HALF_UP); - if (!(dataValue.compareTo(item.getLowerLimit()) >= 0 && dataValue.compareTo(item.getUpperLimit()) <= 0)) { - AlarmMessage alarmMessage = new AlarmMessage(); - AlarmMessageRespDTO alarmMessageRespDTO = new AlarmMessageRespDTO(); - alarmMessageRespDTO.setConfigId(item.getId()); - if (dataValue.compareTo(item.getLowerLimit()) < 0) { - alarmMessageRespDTO.setAlarmType("1");//超下限 - } else if (dataValue.compareTo(item.getUpperLimit()) > 0) { - alarmMessageRespDTO.setAlarmType("2");//超上限 - } - alarmMessageRespDTO.setAlarmTime(DateUtils.parse(data[0].toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)); - JSONObject content = new JSONObject(); - content.put("alarmObj", item.getAlarmObj()); - content.put("alarmType", alarmMessageRespDTO.getAlarmType()); - content.put("unit", item.getUnit()); - content.put("overLimitTime", data[0]); - content.put("overLimitValue", dataValue); - alarmMessageRespDTO.setContent(JSONObject.toJSONString(content)); - System.out.println("预警消息=" + alarmMessageRespDTO); - alarmMessage.setAlarmMessageRespDTO(alarmMessageRespDTO); - try { - alarmConsumer.process(alarmMessage); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - break; - } - } - System.out.println(preData); - }); - } -} diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/PredictFinishMessage.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/PredictFinishMessage.java deleted file mode 100644 index 4bf1c36..0000000 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/PredictFinishMessage.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.iailab.module.shasteel.mq.consumer; - -import com.iailab.module.shasteel.mq.common.RoutingConstant; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -@Data -public class PredictFinishMessage implements Serializable { - - public static final String EXCHANGE = "predict-finish-exchange"; - - public static final String PREDICTFINISH_ROUTING_KEY = RoutingConstant.Iailab_Model_PredictFinish; - // 预测时间 - private Date predictTime; -} \ No newline at end of file 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/ScheduleConsumer.java deleted file mode 100644 index 78a2acb..0000000 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ScheduleConsumer.java +++ /dev/null @@ -1,56 +0,0 @@ -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 org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author lirm - * @Description - * @createTime 2024年11月27日 - */ -@Component -@RabbitListener(queues = AlarmMessage.ALARM_ROUTING_KEY) -public class ScheduleConsumer { - - @Resource - private McsApi mcsApi; - - @Resource - private MdkApi mdkApi; - - @RabbitHandler - public void process(AlarmMessage alarmMessage) { - Map<String, Object> params = new HashMap<>(); - params.put("trigger_condition", AlarmMessage.ALARM_ROUTING_KEY); - 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); - } -// AlarmMessageRespDTO alarmMessageRespDTO = alarmMessage.getAlarmMessageRespDTO(); -// JSONObject contentJson = JSONObject.parseObject(alarmMessageRespDTO.getContent()); -// String overLimitTime = contentJson.get("overLimitTime").toString(); - } -} diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ScheduleMessage.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ScheduleMessage.java deleted file mode 100644 index b5e9a8a..0000000 --- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ScheduleMessage.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.iailab.module.shasteel.mq.consumer; - -import com.iailab.module.shasteel.mq.common.RoutingConstant; -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; - -@Data -public class ScheduleMessage implements Serializable { - - public static final String EXCHANGE = "schedule-exchange"; - - public static final String SCHEDULE_ROUTING_KEY = RoutingConstant.Iailab_Model_PredictFinish; - // 预测时间 - private Date predictTime; -} \ No newline at end of file diff --git a/shasteel-biz/src/main/resources/application.yaml b/shasteel-biz/src/main/resources/application.yaml index d96caf2..392f692 100644 --- a/shasteel-biz/src/main/resources/application.yaml +++ b/shasteel-biz/src/main/resources/application.yaml @@ -4,7 +4,7 @@ name: shasteel-server profiles: - active: dev + active: prod cloud: nacos: diff --git a/shasteel-biz/src/test/java/com/iailab/module/data/controller/RabbitMQTest.java b/shasteel-biz/src/test/java/com/iailab/module/data/controller/RabbitMQTest.java deleted file mode 100644 index 29d86fe..0000000 --- a/shasteel-biz/src/test/java/com/iailab/module/data/controller/RabbitMQTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.iailab.module.data.controller; - -import com.alibaba.fastjson.JSONObject; -import com.iailab.framework.common.util.date.DateUtils; -import com.iailab.framework.test.core.ut.BaseMockitoUnitTest; -import com.iailab.module.shasteel.ShasteelServerApplication; -import com.iailab.module.shasteel.mq.consumer.PredictFinishMessage; -import org.junit.jupiter.api.Test; -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.boot.test.context.SpringBootTest; - -import javax.annotation.Resource; -import java.util.Date; - -/** - * @author lirm - * @Description - * @createTime 2024年11月27日 - */ -@SpringBootTest(classes = ShasteelServerApplication.class) -public class RabbitMQTest extends BaseMockitoUnitTest { - - @Resource - private RabbitTemplate rabbitTemplate; - - @Test - public void testProducer() { - JSONObject content = new JSONObject(); - content.put("moduleType", "NET_LDG"); - content.put("predictTime", "2024-12-04 06:30:00"); - rabbitTemplate.convertAndSend(PredictFinishMessage.EXCHANGE, PredictFinishMessage.PREDICTFINISH_ROUTING_KEY, content); - } -} -- Gitblit v1.9.3