增加报警记录表、逻辑、接口

This commit is contained in:
joylink_zhangsai 2023-07-25 17:23:38 +08:00
parent f4454c96c5
commit 2937319969
18 changed files with 326 additions and 151 deletions

View File

@ -1,21 +0,0 @@
package club.joylink.xiannccda.alert;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType;
import java.time.LocalDateTime;
public interface AlertDetail {
AlertType getAlertType();
LocalDateTime getAlertTime();
Integer getAlertTipId();
Integer getLineId();
String getAlertObject();
String getLocatorDeviceId();
boolean isMock();
}

View File

@ -24,9 +24,8 @@ public class AlertDetailFactory {
this.alertTipRepository = alertTipRepository;
}
public AlertDetail getAlertDetail(AlertType alertType, int lineId, boolean mock,
MessageOrBuilder messageOrBuilder) {
LocalDateTime now = LocalDateTime.now();
public NccAlertInfo getAlertDetail(LocalDateTime alertTime, AlertType alertType, int lineId,
boolean mock, MessageOrBuilder messageOrBuilder) {
Integer alertTipId;
String alertObject;
switch (alertType) {
@ -70,7 +69,7 @@ public class AlertDetailFactory {
locatorDeviceId = null;
}
return new AlertDetailImpl(alertType, now, alertTipId, lineId, alertObject, locatorDeviceId, mock);
return new NccAlertInfo(alertTime, alertType, alertTipId, lineId, alertObject, locatorDeviceId, mock);
}
private String getId(MessageOrBuilder messageOrBuilder) {

View File

@ -1,43 +0,0 @@
package club.joylink.xiannccda.alert;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* 西安三号线报警
*/
@Data
@AllArgsConstructor(access = AccessLevel.PACKAGE)
public class AlertDetailImpl implements AlertDetail {
private AlertType alertType;
private LocalDateTime alertTime;
private Integer alertTipId;
private Integer lineId;
private String alertObject;
private String locatorDeviceId;
private boolean mock;
@Override
public AlertType getAlertType() {
return alertType;
}
@Override
public LocalDateTime getAlertTime() {
return alertTime;
}
@Override
public Integer getAlertTipId() {
return alertTipId;
}
@Override
public boolean isMock() {
return mock;
}
}

View File

@ -1,10 +1,11 @@
package club.joylink.xiannccda.alert;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.entity.AlertRecord;
import club.joylink.xiannccda.event.Listener;
import club.joylink.xiannccda.repository.IAlertRecordRepository;
import club.joylink.xiannccda.ws.NccAlertMessageServer;
import club.joylink.xiannccda.ws.WsMessageServerManager;
import java.time.LocalDateTime;
import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
@ -15,15 +16,16 @@ import org.springframework.stereotype.Component;
@Component
public class AlertListenerJob implements ApplicationRunner {
private final WsMessageServerManager wsMessageServerManager;
private final IAlertRecordRepository alertRecordRepository;
public AlertListenerJob(WsMessageServerManager wsMessageServerManager) {
public AlertListenerJob(WsMessageServerManager wsMessageServerManager,
IAlertRecordRepository alertRecordRepository) {
this.wsMessageServerManager = wsMessageServerManager;
this.alertRecordRepository = alertRecordRepository;
}
@Override
public void run(ApplicationArguments args) throws Exception {
//添加报警细节事件监听器
addAlertDetailListeners();
//添加报警事件监听器
addAlertListeners();
//注册西安NCC的报警ws消息发送服务
@ -32,31 +34,34 @@ public class AlertListenerJob implements ApplicationRunner {
AlertManager.getDefault().taskStart();
}
public void addAlertDetailListeners() {
AlertManager alertManager = AlertManager.getDefault();
//报警监听
alertManager.on(new Listener<AlertDetail>() {
private final AtomicInteger idGenerator = new AtomicInteger(1);
@Override
public void accept(AlertDetail event) {
String id = String.valueOf(idGenerator.getAndIncrement());
LocalDateTime alertTime = event.getAlertTime();
NccAlertInfo<AlertDetail> nccAlertInfo = new NccAlertInfo<>(id, alertTime, event);
alertManager.emit(nccAlertInfo);
}
});
}
private void addAlertListeners() {
NccAlertMessageServer nccAlertMessageServer = NccAlertMessageServer.getDefault();
AlertManager alertManager = AlertManager.getDefault();
//添加消息
alertManager.on(new Listener<NccAlertInfo>() {
AtomicInteger idGenerator = new AtomicInteger(0);
@Override
public void accept(NccAlertInfo event) {
nccAlertMessageServer.addMsg(event);
public void accept(NccAlertInfo alertInfo) {
if (!alertInfo.isMock()) {
AlertRecord record = convertToRecord(alertInfo);
alertRecordRepository.save(record);
alertInfo.setId(record.getId());
} else {
alertInfo.setId(idGenerator.decrementAndGet());
}
nccAlertMessageServer.addMsg(alertInfo);
}
});
}
private AlertRecord convertToRecord(NccAlertInfo nccAlertInfo) {
AlertRecord record = new AlertRecord();
record.setAlertTime(nccAlertInfo.getAlertTime());
record.setAlertType(nccAlertInfo.getAlertType().name());
record.setAlertObject(nccAlertInfo.getAlertObject());
record.setLineId(nccAlertInfo.getLineId());
return record;
}
}

View File

@ -1,29 +1,41 @@
package club.joylink.xiannccda.alert;
import club.joylink.xiannccda.alert.core.AlertInfo;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType;
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
public class NccAlertInfo<D extends AlertDetail> implements AlertInfo {
@Getter
public class NccAlertInfo implements AlertInfo {
private String id;
@Setter
private Integer id;
private String level;
private LocalDateTime alertTime;
@Getter
private D detail;
private AlertType alertType;
private Integer alertTipId;
private Integer lineId;
private String alertObject;
private String locatorDeviceId;
private boolean mock;
public NccAlertInfo(@NonNull String id, @NonNull LocalDateTime alertTime, @NonNull D detail) {
this.id = id;
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType, Integer alertTipId,
Integer lineId, String alertObject, String locatorDeviceId, boolean mock) {
this.alertTime = alertTime;
this.detail = detail;
this.level = getLevelFromDetail();
this.alertType = alertType;
this.alertTipId = alertTipId;
this.lineId = lineId;
this.alertObject = alertObject;
this.locatorDeviceId = locatorDeviceId;
this.mock = mock;
this.level = buildLevel();
}
@Override
public String getId() {
return id;
return id == null ? "" : String.valueOf(id);
}
@Override
@ -41,8 +53,8 @@ public class NccAlertInfo<D extends AlertDetail> implements AlertInfo {
return "";
}
private String getLevelFromDetail() {
switch (detail.getAlertType()) {
private String buildLevel() {
switch (alertType) {
case UNKNOWN, UNRECOGNIZED -> {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception();
}
@ -53,7 +65,7 @@ public class NccAlertInfo<D extends AlertDetail> implements AlertInfo {
PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL, TRAIN_DELAY_10 -> {
return "I";
}
default -> throw new IllegalStateException("Unexpected value: " + detail.getAlertType());
default -> throw new IllegalStateException("Unexpected value: " + alertType);
}
}
}

View File

@ -30,12 +30,4 @@ public class AlertMockController {
public void setAlert(@RequestBody @Validated AlertMockDTO alertMockDTO) {
alertMockService.setAlert(alertMockDTO);
}
@SecurityRequirement(name = "jwt")
@Operation(summary = "清除模拟故障")
@ApiResponse(description = "清除模拟故障")
@PostMapping("/clear")
public void clearMockAlert() {
alertMockService.clearMockAlert();
}
}

View File

@ -0,0 +1,50 @@
package club.joylink.xiannccda.controller;
import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.dto.AlertRecordQueryDTO;
import club.joylink.xiannccda.entity.AlertRecord;
import club.joylink.xiannccda.repository.IAlertRecordRepository;
import club.joylink.xiannccda.service.AlertRecordService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 报警记录 前端控制器
*
* @author walker-sheng
* @since 2023-07-25
*/
@RestController
@RequestMapping("/api/alertRecord")
public class AlertRecordController {
private final IAlertRecordRepository alertRecordRepository;
private final AlertRecordService alertRecordService;
public AlertRecordController(IAlertRecordRepository alertRecordRepository,
AlertRecordService alertRecordService) {
this.alertRecordRepository = alertRecordRepository;
this.alertRecordService = alertRecordService;
}
@GetMapping("/page")
@SecurityRequirement(name = "jwt")
@Operation(summary = "分页查询报警记录")
@ApiResponse(description = "报警记录")
public Page<AlertRecord> pageQuery(AlertRecordQueryDTO queryDTO) {
return alertRecordRepository.page(queryDTO);
}
@GetMapping("/page/detail")
@SecurityRequirement(name = "jwt")
@Operation(summary = "分页查询报警记录详情")
@ApiResponse(description = "报警记录详情")
public Page<NccAlertInfo> pageQueryAlertDetail(AlertRecordQueryDTO queryDTO) {
return alertRecordService.pageQueryAlertDetail(queryDTO);
}
}

View File

@ -0,0 +1,13 @@
package club.joylink.xiannccda.dto;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType;
import club.joylink.xiannccda.entity.AlertRecord;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import lombok.Data;
@Data
public class AlertRecordQueryDTO extends PageDTO<AlertRecord> {
private AlertType alertType;
private Integer lineId;
}

View File

@ -0,0 +1,47 @@
package club.joylink.xiannccda.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
/**
* <p>
* 报警记录
* </p>
*
* @author walker-sheng
* @since 2023-07-25
*/
@Getter
@Setter
@Accessors(chain = true)
@TableName("alert_record")
@Schema(name = "AlertRecord", description = "$!{table.comment}")
public class AlertRecord {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String alertType;
private Integer lineId;
private String alertObject;
private LocalDateTime alertTime;
public static final String ID = "id";
public static final String ALERT_TYPE = "alert_type";
public static final String LINE_ID = "line_id";
public static final String ALERT_OBJECT = "alert_object";
public static final String ALERT_TIME = "alert_time";
}

View File

@ -0,0 +1,18 @@
package club.joylink.xiannccda.mapper;
import club.joylink.xiannccda.entity.AlertRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 报警记录 Mapper 接口
* </p>
*
* @author walker-sheng
* @since 2023-07-25
*/
@Mapper
public interface AlertRecordMapper extends BaseMapper<AlertRecord> {
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="club.joylink.xiannccda.mapper.AlertRecordMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="club.joylink.xiannccda.entity.AlertRecord">
<id column="id" property="id" />
<result column="alert_type" property="alertType" />
<result column="line_id" property="lineId" />
<result column="alert_object" property="alertObject" />
<result column="alert_time" property="alertTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, alert_type, line_id, alert_object, alert_time
</sql>
</mapper>

View File

@ -0,0 +1,18 @@
package club.joylink.xiannccda.repository;
import club.joylink.xiannccda.dto.AlertRecordQueryDTO;
import club.joylink.xiannccda.entity.AlertRecord;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 报警记录 服务类
* </p>
*
* @author walker-sheng
* @since 2023-07-25
*/
public interface IAlertRecordRepository extends IService<AlertRecord> {
Page<AlertRecord> page(AlertRecordQueryDTO queryDTO);
}

View File

@ -0,0 +1,35 @@
package club.joylink.xiannccda.repository.impl;
import club.joylink.xiannccda.dto.AlertRecordQueryDTO;
import club.joylink.xiannccda.entity.AlertRecord;
import club.joylink.xiannccda.mapper.AlertRecordMapper;
import club.joylink.xiannccda.repository.IAlertRecordRepository;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 报警记录 服务实现类
* </p>
*
* @author walker-sheng
* @since 2023-07-25
*/
@Service
public class AlertRecordRepository extends ServiceImpl<AlertRecordMapper, AlertRecord> implements IAlertRecordRepository {
@Override
public Page<AlertRecord> page(AlertRecordQueryDTO queryDTO) {
LambdaQueryWrapper<AlertRecord> queryWrapper = Wrappers.lambdaQuery(AlertRecord.class);
if (queryDTO.getAlertType() != null) {
queryWrapper.eq(AlertRecord::getAlertType, queryDTO.getAlertType().name());
}
if (queryDTO.getLineId() != null) {
queryWrapper.eq(AlertRecord::getLineId, queryDTO.getLineId());
}
return page(queryDTO, queryWrapper);
}
}

View File

@ -1,7 +1,7 @@
package club.joylink.xiannccda.service;
import club.joylink.xiannccda.alert.AlertDetail;
import club.joylink.xiannccda.alert.AlertDetailFactory;
import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
import club.joylink.xiannccda.dto.AlertMockDTO;
@ -9,8 +9,8 @@ import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Platform;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Station;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType;
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
import club.joylink.xiannccda.ws.NccAlertMessageServer;
import com.google.protobuf.MessageOrBuilder;
import java.time.LocalDateTime;
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -24,12 +24,12 @@ public class AlertMockService {
public void setAlert(AlertMockDTO alertMockDTO) {
int lineId = alertMockDTO.getLineId();
AlertType alertType = alertMockDTO.getAlertType();
AlertDetail alertDetail = buildAlertDetail(alertType, lineId);
NccAlertInfo alertDetail = buildNccAlert(alertType, lineId);
AlertManager alertManager = AlertManager.getDefault();
alertManager.emit(alertDetail);
}
private AlertDetail buildAlertDetail(AlertType alertType, int lineId) {
private NccAlertInfo buildNccAlert(AlertType alertType, int lineId) {
MessageOrBuilder messageOrBuilder;
switch (alertType) {
case BLUE_DISPLAY -> {
@ -49,10 +49,7 @@ public class AlertMockService {
}
default -> throw new IllegalStateException("Unexpected value: " + alertType);
}
return alertDetailFactory.getAlertDetail(alertType, lineId, true, messageOrBuilder);
}
public void clearMockAlert() {
NccAlertMessageServer.getDefault().clearMockAlert();
return alertDetailFactory.getAlertDetail(LocalDateTime.now(), alertType, lineId, true,
messageOrBuilder);
}
}

View File

@ -0,0 +1,44 @@
package club.joylink.xiannccda.service;
import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.dto.AlertRecordQueryDTO;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType;
import club.joylink.xiannccda.entity.AlertRecord;
import club.joylink.xiannccda.entity.AlertTip;
import club.joylink.xiannccda.repository.IAlertRecordRepository;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
@Service
public class AlertRecordService {
private final IAlertRecordRepository alertRecordRepository;
private final AlertTipService alertTipService;
public AlertRecordService(IAlertRecordRepository alertRecordRepository,
AlertTipService alertTipService) {
this.alertRecordRepository = alertRecordRepository;
this.alertTipService = alertTipService;
}
public Page<NccAlertInfo> pageQueryAlertDetail(AlertRecordQueryDTO queryDTO) {
Page<AlertRecord> recordPage = alertRecordRepository.page(queryDTO);
List<NccAlertInfo> collect = recordPage.getRecords().stream()
.map(record -> {
Optional<AlertTip> alertTip = alertTipService.queryOne(record.getAlertType());
Integer alertTipId = alertTip.map(AlertTip::getId).orElse(null);
NccAlertInfo nccAlertInfo = new NccAlertInfo(record.getAlertTime(),
AlertType.valueOf(record.getAlertType()), alertTipId, record.getLineId(),
record.getAlertObject(), "", false);
nccAlertInfo.setId(record.getId());
return nccAlertInfo;
}).collect(Collectors.toList());
Page<NccAlertInfo> nccPage = Page.of(recordPage.getCurrent(), recordPage.getSize(),
recordPage.getTotal());
nccPage.setRecords(collect);
return nccPage;
}
}

View File

@ -7,6 +7,7 @@ import club.joylink.xiannccda.repository.IAlertTipRepository;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import java.util.Optional;
import org.springframework.stereotype.Service;
@Service
@ -38,6 +39,15 @@ public class AlertTipService {
alertTipRepository.saveOrUpdate(saveEntity, updateWrapper);
}
public Optional<AlertTip> queryOne(String alertType) {
if (alertType == null) {
return Optional.empty();
}
LambdaQueryWrapper<AlertTip> queryWrapper = Wrappers.lambdaQuery(AlertTip.class)
.eq(AlertTip::getAlertType, alertType);
return Optional.ofNullable(alertTipRepository.getOne(queryWrapper, false));
}
private AlertTip convertToEntity(AlertTipSaveDTO saveDTO) {
AlertTip entity = new AlertTip();
entity.setAlertType(saveDTO.getAlertType().name());

View File

@ -5,11 +5,8 @@ import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMe
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.Builder;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.Message;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
@ -22,8 +19,8 @@ public class NccAlertMessageServer implements IMessageServer {
private String id;
private final String Destination = "/queue/xian/ncc/alert";
private final LinkedHashMap<String, NccAlertInfoMessage.Message> allMsg = new LinkedHashMap<>();
Queue<NccAlertInfo<?>> pendingMsgQueue = new ConcurrentLinkedQueue<>();
Queue<NccAlertInfo> pendingMsgQueue = new ConcurrentLinkedQueue<>();
@Override
public String getDestinationPattern() {
@ -32,11 +29,7 @@ public class NccAlertMessageServer implements IMessageServer {
@Override
public Object onSubscription(String destination, Map<String, String> paramMap) {
byte[] bytes = NccAlertInfoMessage.newBuilder()
.addAllMessages(allMsg.values())
.build()
.toByteArray();
return bytes.length == 0 ? null : bytes;
return null;
}
@Override
@ -47,11 +40,10 @@ public class NccAlertMessageServer implements IMessageServer {
@Override
public List<TopicMessage> onTick() {
Builder builder = NccAlertInfoMessage.newBuilder();
NccAlertInfo<?> alertInfo;
NccAlertInfo alertInfo;
for (int i = 0; i < 10; i++) { //加循环次数主要是为了防止while死循环
if ((alertInfo = pendingMsgQueue.poll()) != null) {
Message message = convertToMessage(alertInfo);
allMsg.put(message.getId(), message);
builder.addMessages(message);
} else {
break;
@ -80,34 +72,24 @@ public class NccAlertMessageServer implements IMessageServer {
return SERVER_MAP.remove(id);
}
public void addMsg(NccAlertInfo<?> alertInfo) {
public void addMsg(NccAlertInfo alertInfo) {
pendingMsgQueue.add(alertInfo);
}
public void clearMockAlert() {
Iterator<Entry<String, Message>> iterator = allMsg.entrySet().iterator();
for (int i = 0; iterator.hasNext() && i < 10000; i++) {
Entry<String, Message> next = iterator.next();
if (next.getValue().getMock()) {
iterator.remove();
}
}
}
private NccAlertInfoMessage.Message convertToMessage(NccAlertInfo<?> alertInfo) {
private NccAlertInfoMessage.Message convertToMessage(NccAlertInfo alertInfo) {
Message.Builder builder = Message.newBuilder()
.setId(alertInfo.getId())
.setLevel(alertInfo.getLevel())
.setAlertTime(alertInfo.getAlertTime().toString())
.setLineId(alertInfo.getDetail().getLineId())
.setAlertObject(alertInfo.getDetail().getAlertObject())
.setAlertType(alertInfo.getDetail().getAlertType())
.setMock(alertInfo.getDetail().isMock());
Integer alertTipId = alertInfo.getDetail().getAlertTipId();
.setLineId(alertInfo.getLineId())
.setAlertObject(alertInfo.getAlertObject())
.setAlertType(alertInfo.getAlertType())
.setMock(alertInfo.isMock());
Integer alertTipId = alertInfo.getAlertTipId();
if (alertTipId != null) {
builder.setAlertTipId(alertTipId);
}
String locatorDeviceId = alertInfo.getDetail().getLocatorDeviceId();
String locatorDeviceId = alertInfo.getLocatorDeviceId();
if (locatorDeviceId != null) {
builder.setLocatorDeviceId(locatorDeviceId);
}

View File

@ -20,8 +20,6 @@ public class AlertManagerTest {
manager.addTask(new TrainDelayAlertMonitoringTask(sid));
//可能报警事件监听器
manager.on(new SuppliesRemainInsufficientListener(sid));
//报警事件监听器
manager.on((Listener<AlertDetailImpl>) event -> System.out.println("列车延误报警"));
manager.taskStart();
manager.emit(new SuppliesCountUpdatedEvent(this, 2));