提交 c2abc5e9 authored 作者: 艾庆国's avatar 艾庆国

线路预警

上级 596f7c51
package com.clx.performance.param.mq.linewarn;
import com.clx.performance.enums.linewarn.LineWarnConfigEnum;
import lombok.*;
import java.util.Arrays;
import java.util.Optional;
/**
* @Author: aiqingguo
* @Description: 通知
* @Date: 2023-10-19 15:45:25
* @Version: 1.0
*/
@Setter
@Getter
@ToString
@NoArgsConstructor
public class LineWarnLineReportMqParam {
private Integer sendSystemAddressId;
private Integer receiveSystemAddressId;
private Integer reportType; //1线路异常 2拥堵预警
@Getter
@AllArgsConstructor
public enum ReportType {
LINE(1, "线路异常"),
JAM(2, "拥堵预警"),
;
private final Integer code;
private final String msg;
public static Optional<ReportType> getByCode(int code) {
return Arrays.stream(values()).filter(e -> e.code == code).findFirst();
}
public static String getMsgByCode(int code) {
return getByCode(code).map(ReportType::getMsg).orElse(null);
}
}
}
......@@ -84,4 +84,16 @@ public class RabbitLineWarnConfig {
return BindingBuilder.bind(lineWarnNoticeQueue()).to(lineWarnDefaultExchange()).with(RabbitKeyLineWarnConstants.LINE_WARN_NOTICE_ROUTING_KEY);
}
/**
* 线路上报
*/
@Bean
public Queue lineWarnLineReportQueue() {
return new Queue(RabbitKeyLineWarnConstants.LINE_WARN_LINE_REPORT_QUEUE);
}
@Bean
public Binding lineWarnLineReportQueueBinding() {
return BindingBuilder.bind(lineWarnNoticeQueue()).to(lineWarnDefaultExchange()).with(RabbitKeyLineWarnConstants.LINE_WARN_LINE_REPORT_ROUTING_KEY);
}
}
......@@ -51,4 +51,10 @@ public class RabbitKeyLineWarnConstants {
public static final String LINE_WARN_NOTICE_QUEUE = PREFIX +"lineWarn.notice"+QUEUE;
public static final String LINE_WARN_NOTICE_ROUTING_KEY = PREFIX +"lineWarn.notice"+QUEUE_ROUTING_KEY;
/**
* 线路上报
*/
public static final String LINE_WARN_LINE_REPORT_QUEUE = PREFIX +"lineWarn.lineReport"+QUEUE;
public static final String LINE_WARN_LINE_REPORT_ROUTING_KEY = PREFIX +"lineWarn.lineReport"+QUEUE_ROUTING_KEY;
}
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.clx.performance.common.MqDelay;
import com.clx.performance.common.MqWrapper;
import com.clx.performance.constant.RabbitKeyLineWarnConstants;
import com.clx.performance.param.mq.linewarn.LineWarnLineReportMqParam;
import com.clx.performance.param.mq.linewarn.LineWarnLineWarnMqParam;
import com.clx.performance.param.mq.linewarn.LineWarnNoticeMqParam;
import com.clx.performance.param.mq.linewarn.LineWarnOrderGoodsAddMqParam;
......@@ -55,4 +56,17 @@ public class LineWarnMqServiceImpl implements LineWarnMqService {
rabbitTemplate.send(RabbitKeyLineWarnConstants.DEFAULT_EXCHANGE, RabbitKeyLineWarnConstants.DEFAULT_DELAY_ROUTING_KEY, message);
}
@Override
public void lineReport(Integer sendSystemAddressId, Integer receiveSystemAddressId, Integer reportType) {
LineWarnLineReportMqParam mq = new LineWarnLineReportMqParam();
mq.setSendSystemAddressId(sendSystemAddressId);
mq.setReceiveSystemAddressId(receiveSystemAddressId);
mq.setReportType(reportType);
MqDelay delay = new MqDelay<>(RabbitKeyLineWarnConstants.DEFAULT_EXCHANGE, RabbitKeyLineWarnConstants.LINE_WARN_LINE_REPORT_ROUTING_KEY, new MqWrapper<>(mq));
Message message = MessageBuilder.withBody(JSON.toJSONString(new MqWrapper<>(delay)).getBytes()).build();
message.getMessageProperties().setExpiration("5000");
rabbitTemplate.send(RabbitKeyLineWarnConstants.DEFAULT_EXCHANGE, RabbitKeyLineWarnConstants.DEFAULT_DELAY_ROUTING_KEY, message);
}
}
......@@ -7,4 +7,6 @@ public interface LineWarnMqService {
void lineWarn(String childNo);
void lineWarnNotice(Integer infoId);
void lineReport(Integer sendSystemAddressId, Integer receiveSystemAddressId, Integer reportType);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论