Merge branch 'master' of https://git.code.tencent.com/xian-ncc-da/xian-ncc-da-server
This commit is contained in:
commit
7f21bb2281
@ -40,9 +40,8 @@ public class AlertListenerJob implements ApplicationRunner {
|
||||
@Override
|
||||
public void accept(AlertDetail event) {
|
||||
String id = String.valueOf(idGenerator.getAndIncrement());
|
||||
String level = "III";
|
||||
LocalDateTime alertTime = event.getAlertTime();
|
||||
NccAlertInfo<AlertDetail> nccAlertInfo = new NccAlertInfo<>(id, level, alertTime, event);
|
||||
NccAlertInfo<AlertDetail> nccAlertInfo = new NccAlertInfo<>(id, alertTime, event);
|
||||
alertManager.emit(nccAlertInfo);
|
||||
}
|
||||
});
|
||||
|
@ -1,18 +1,26 @@
|
||||
package club.joylink.xiannccda.alert;
|
||||
|
||||
import club.joylink.xiannccda.alert.core.AlertInfo;
|
||||
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class NccAlertInfo<D extends AlertDetail> implements AlertInfo {
|
||||
|
||||
private String id;
|
||||
private String level;
|
||||
private LocalDateTime alertTime;
|
||||
@Getter
|
||||
private D detail;
|
||||
|
||||
public NccAlertInfo(@NonNull String id, @NonNull LocalDateTime alertTime, @NonNull D detail) {
|
||||
this.id = id;
|
||||
this.alertTime = alertTime;
|
||||
this.detail = detail;
|
||||
this.level = getLevelFromDetail();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
@ -32,4 +40,20 @@ public class NccAlertInfo<D extends AlertDetail> implements AlertInfo {
|
||||
public String getInfo() {
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getLevelFromDetail() {
|
||||
switch (detail.getAlertType()) {
|
||||
case UNKNOWN, UNRECOGNIZED -> {
|
||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception();
|
||||
}
|
||||
case TRAIN_DELAY_2 -> {
|
||||
return "III";
|
||||
}
|
||||
case BLUE_DISPLAY, PLATFORM_DOOR_CANNOT_CLOSE, PLATFORM_DOOR_CANNOT_OPEN,
|
||||
PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL, TRAIN_DELAY_10 -> {
|
||||
return "I";
|
||||
}
|
||||
default -> throw new IllegalStateException("Unexpected value: " + detail.getAlertType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user