报警记录增加报警地点数据;AlertType和AlertLocation使用proto文件定义

This commit is contained in:
joylink_zhangsai 2023-07-26 09:56:56 +08:00
parent 9de0a24573
commit 138099b302
20 changed files with 544 additions and 329 deletions

View File

@ -1,15 +1,14 @@
package club.joylink.xiannccda.alert;
import club.joylink.xiannccda.alert.util.AlertUtil;
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.CommonInfo;
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.entity.AlertTip;
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
import club.joylink.xiannccda.repository.IAlertTipRepository;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import club.joylink.xiannccda.service.AlertTipService;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.MessageOrBuilder;
import java.time.LocalDateTime;
@ -18,45 +17,35 @@ import org.springframework.stereotype.Component;
@Component
public class AlertDetailFactory {
private IAlertTipRepository alertTipRepository;
private final AlertTipService alertTipService;
public AlertDetailFactory(IAlertTipRepository alertTipRepository) {
this.alertTipRepository = alertTipRepository;
public AlertDetailFactory(AlertTipService alertTipService) {
this.alertTipService = alertTipService;
}
public NccAlertInfo getAlertDetail(LocalDateTime alertTime, AlertType alertType, int lineId,
boolean mock, MessageOrBuilder messageOrBuilder) {
Integer alertTipId;
String alertObject;
String alertLocationName = null;
switch (alertType) {
case BLUE_DISPLAY -> {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
messageOrBuilder instanceof Station);
Station rtu = (Station) messageOrBuilder;
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(rtu.getConcentrationStations(),
"参数错误:非集中站");
LambdaQueryWrapper<AlertTip> queryWrapper = Wrappers.lambdaQuery(AlertTip.class)
.eq(AlertTip::getAlertType, alertType)
.eq(AlertTip::getLocationType, rtu.getCode());
AlertTip alertTip = alertTipRepository.getOne(queryWrapper);
alertTipId = alertTip == null ? null : alertTip.getId();
alertLocationName = AlertUtil.findLocationByRtuCode(rtu.getCode())
.map(Enum::name).orElse(null);
alertObject = getInterlockName(rtu);
}
case TRAIN_DELAY_2, TRAIN_DELAY_10 -> {
LambdaQueryWrapper<AlertTip> queryWrapper = Wrappers.lambdaQuery(AlertTip.class)
.eq(AlertTip::getAlertType, alertType);
AlertTip alertTip = alertTipRepository.getOne(queryWrapper);
alertTipId = alertTip == null ? null : alertTip.getId();
alertObject = "列车001";
}
case PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL, PLATFORM_DOOR_CANNOT_CLOSE, PLATFORM_DOOR_CANNOT_OPEN -> {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
messageOrBuilder instanceof Platform);
Platform platform = (Platform) messageOrBuilder;
LambdaQueryWrapper<AlertTip> queryWrapper = Wrappers.lambdaQuery(AlertTip.class)
.eq(AlertTip::getAlertType, alertType);
AlertTip alertTip = alertTipRepository.getOne(queryWrapper);
alertTipId = alertTip == null ? null : alertTip.getId();
alertObject = getPlatformDesc(lineId, platform);
}
default -> throw new IllegalStateException("Unexpected value: " + alertType);
@ -69,7 +58,11 @@ public class AlertDetailFactory {
locatorDeviceId = null;
}
return new NccAlertInfo(alertTime, alertType, alertTipId, lineId, alertObject, locatorDeviceId, mock);
Integer alertTipId = alertTipService.queryOne(alertType.name(), alertLocationName)
.map(AlertTip::getId).orElse(null);
return new NccAlertInfo(alertTime, alertType, alertTipId, lineId, alertObject, locatorDeviceId,
null, mock);
}
private String getId(MessageOrBuilder messageOrBuilder) {
@ -85,8 +78,7 @@ public class AlertDetailFactory {
}
/**
* 获取集中站的联锁区描述
* 例如鱼化寨站的联锁区叫鱼化寨联锁区
* 获取集中站的联锁区描述 例如鱼化寨站的联锁区叫鱼化寨联锁区
*/
private String getInterlockName(Station rtu) {
int index = rtu.getName().length() - 1;

View File

@ -62,6 +62,7 @@ public class AlertListenerJob implements ApplicationRunner {
record.setAlertType(nccAlertInfo.getAlertType().name());
record.setAlertObject(nccAlertInfo.getAlertObject());
record.setLineId(nccAlertInfo.getLineId());
record.setAlertLocation(nccAlertInfo.getAlertLocationName());
return record;
}
}

View File

@ -1,38 +0,0 @@
package club.joylink.xiannccda.alert;
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
import java.util.Arrays;
import lombok.Getter;
@Getter
public enum AlertTipLocationType {
/**
* 全线
*/
QX(0, 0, "全线"),
/**
* 鱼化寨联锁区
*/
YHZ_LSQ(3, 1, "鱼化寨联锁区"),
;
private short lineId;
private short rtuId;
private String desc;
AlertTipLocationType(int lineId, int rtuId, String desc) {
this.lineId = (short) lineId;
this.rtuId = (short) rtuId;
this.desc = desc;
}
public static AlertTipLocationType getByLineIdAndRtuId(short lineId, short rtuId) {
return Arrays.stream(AlertTipLocationType.values())
.filter(type -> lineId == type.lineId && rtuId == type.rtuId)
.findFirst()
.orElseThrow(() -> BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(
String.format("[%s:%s]未定义联锁区", lineId, rtuId)));
}
}

View File

@ -1,11 +1,7 @@
package club.joylink.xiannccda.alert;
import club.joylink.xiannccda.alert.core.AlertMonitoringTask;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType;
import club.joylink.xiannccda.entity.AlertTip;
import club.joylink.xiannccda.repository.IAlertTipRepository;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Component;
@Component
@ -53,12 +49,4 @@ public class BlueDisplayAlertMonitoringTask implements AlertMonitoringTask {
// });
// }
}
private Integer getAlertTipId(AlertType alertType, AlertTipLocationType locationType) {
LambdaQueryWrapper<AlertTip> queryWrapper = Wrappers.lambdaQuery(AlertTip.class);
queryWrapper.eq(AlertTip::getAlertType, alertType)
.eq(AlertTip::getLocationType, locationType);
AlertTip alertTip = alertTipRepository.getOne(queryWrapper);
return alertTip == null ? null : alertTip.getId();
}
}

View File

@ -1,7 +1,8 @@
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.dto.protos.AlertConstProto.AlertLocation;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
import java.time.LocalDateTime;
import lombok.Getter;
@ -19,16 +20,19 @@ public class NccAlertInfo implements AlertInfo {
private Integer lineId;
private String alertObject;
private String locatorDeviceId;
private AlertLocation alertLocation;
private boolean mock;
public NccAlertInfo(LocalDateTime alertTime, AlertType alertType, Integer alertTipId,
Integer lineId, String alertObject, String locatorDeviceId, boolean mock) {
Integer lineId, String alertObject, String locatorDeviceId,
AlertLocation alertLocation, boolean mock) {
this.alertTime = alertTime;
this.alertType = alertType;
this.alertTipId = alertTipId;
this.lineId = lineId;
this.alertObject = alertObject;
this.locatorDeviceId = locatorDeviceId;
this.alertLocation = alertLocation;
this.mock = mock;
this.level = buildLevel();
}
@ -53,9 +57,13 @@ public class NccAlertInfo implements AlertInfo {
return "";
}
public String getAlertLocationName() {
return alertLocation == null ? null : alertLocation.name();
}
private String buildLevel() {
switch (alertType) {
case UNKNOWN, UNRECOGNIZED -> {
case ALERT_TYPE_UNKNOWN, UNRECOGNIZED -> {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception();
}
case TRAIN_DELAY_2 -> {

View File

@ -0,0 +1,25 @@
package club.joylink.xiannccda.alert.util;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
import java.util.Optional;
public class AlertUtil {
public static Optional<AlertLocation> findLocationByRtuCode(String rtuCode) {
switch (rtuCode) {
case "01" -> {
return Optional.of(AlertLocation.YHZ_LSQ);
}
case "09" -> {
return Optional.of(AlertLocation.BCT_LSQ);
}
case "15" -> {
return Optional.of(AlertLocation.HJM_LSQ);
}
case "26" -> {
return Optional.of(AlertLocation.BSQ_LSQ);
}
}
return Optional.empty();
}
}

View File

@ -9,6 +9,7 @@ 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 io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -19,6 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author walker-sheng
* @since 2023-07-25
*/
@Tag(name = "报警记录接口")
@RestController
@RequestMapping("/api/alertRecord")
public class AlertRecordController {

View File

@ -9,6 +9,7 @@ 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 io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author walker-sheng
* @since 2023-06-21
*/
@Tag(name = "报警决策信息管理接口")
@RestController
@RequestMapping("/api/alertTip")
public class AlertTipController {

View File

@ -1,6 +1,6 @@
package club.joylink.xiannccda.dto;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

View File

@ -1,6 +1,6 @@
package club.joylink.xiannccda.dto;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.entity.AlertRecord;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import lombok.Data;

View File

@ -1,8 +1,8 @@
package club.joylink.xiannccda.dto.alertTip;
import club.joylink.xiannccda.alert.AlertTipLocationType;
import club.joylink.xiannccda.alert.AlertTipTimeType;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.entity.AlertTip;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import lombok.Getter;
@ -15,5 +15,5 @@ import lombok.Setter;
public class AlertTipQueryDTO extends PageDTO<AlertTip> {
private AlertType alertType;
private AlertTipTimeType timeType;
private AlertTipLocationType locationType;
private AlertLocation locationType;
}

View File

@ -1,8 +1,8 @@
package club.joylink.xiannccda.dto.alertTip;
import club.joylink.xiannccda.alert.AlertTipLocationType;
import club.joylink.xiannccda.alert.AlertTipTimeType;
import club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertLocation;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@ -14,7 +14,7 @@ public class AlertTipSaveDTO {
private AlertTipTimeType timeType;
private AlertTipLocationType locationType;
private AlertLocation locationType;
/**
* 行车方面提示信息

View File

@ -0,0 +1,429 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: alertConst.proto
package club.joylink.xiannccda.dto.protos;
public final class AlertConstProto {
private AlertConstProto() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions(
(com.google.protobuf.ExtensionRegistryLite) registry);
}
/**
* Protobuf enum {@code alert.AlertLocation}
*/
public enum AlertLocation
implements com.google.protobuf.ProtocolMessageEnum {
/**
* <code>ALERT_LOCATION_UNKNOWN = 0;</code>
*/
ALERT_LOCATION_UNKNOWN(0),
/**
* <pre>
*全线
* </pre>
*
* <code>QX = 1;</code>
*/
QX(1),
/**
* <pre>
*鱼化寨联锁区
* </pre>
*
* <code>YHZ_LSQ = 2;</code>
*/
YHZ_LSQ(2),
/**
* <pre>
*胡家庙联锁区
* </pre>
*
* <code>HJM_LSQ = 3;</code>
*/
HJM_LSQ(3),
/**
* <pre>
*北池头联锁区
* </pre>
*
* <code>BCT_LSQ = 4;</code>
*/
BCT_LSQ(4),
/**
* <pre>
*保税区联锁区
* </pre>
*
* <code>BSQ_LSQ = 5;</code>
*/
BSQ_LSQ(5),
UNRECOGNIZED(-1),
;
/**
* <code>ALERT_LOCATION_UNKNOWN = 0;</code>
*/
public static final int ALERT_LOCATION_UNKNOWN_VALUE = 0;
/**
* <pre>
*全线
* </pre>
*
* <code>QX = 1;</code>
*/
public static final int QX_VALUE = 1;
/**
* <pre>
*鱼化寨联锁区
* </pre>
*
* <code>YHZ_LSQ = 2;</code>
*/
public static final int YHZ_LSQ_VALUE = 2;
/**
* <pre>
*胡家庙联锁区
* </pre>
*
* <code>HJM_LSQ = 3;</code>
*/
public static final int HJM_LSQ_VALUE = 3;
/**
* <pre>
*北池头联锁区
* </pre>
*
* <code>BCT_LSQ = 4;</code>
*/
public static final int BCT_LSQ_VALUE = 4;
/**
* <pre>
*保税区联锁区
* </pre>
*
* <code>BSQ_LSQ = 5;</code>
*/
public static final int BSQ_LSQ_VALUE = 5;
public final int getNumber() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalArgumentException(
"Can't get the number of an unknown enum value.");
}
return value;
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static AlertLocation valueOf(int value) {
return forNumber(value);
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
*/
public static AlertLocation forNumber(int value) {
switch (value) {
case 0: return ALERT_LOCATION_UNKNOWN;
case 1: return QX;
case 2: return YHZ_LSQ;
case 3: return HJM_LSQ;
case 4: return BCT_LSQ;
case 5: return BSQ_LSQ;
default: return null;
}
}
public static com.google.protobuf.Internal.EnumLiteMap<AlertLocation>
internalGetValueMap() {
return internalValueMap;
}
private static final com.google.protobuf.Internal.EnumLiteMap<
AlertLocation> internalValueMap =
new com.google.protobuf.Internal.EnumLiteMap<AlertLocation>() {
public AlertLocation findValueByNumber(int number) {
return AlertLocation.forNumber(number);
}
};
public final com.google.protobuf.Descriptors.EnumValueDescriptor
getValueDescriptor() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalStateException(
"Can't get the descriptor of an unrecognized enum value.");
}
return getDescriptor().getValues().get(ordinal());
}
public final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptorForType() {
return getDescriptor();
}
public static final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptor() {
return club.joylink.xiannccda.dto.protos.AlertConstProto.getDescriptor().getEnumTypes().get(0);
}
private static final AlertLocation[] VALUES = values();
public static AlertLocation valueOf(
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
if (desc.getType() != getDescriptor()) {
throw new java.lang.IllegalArgumentException(
"EnumValueDescriptor is not for this type.");
}
if (desc.getIndex() == -1) {
return UNRECOGNIZED;
}
return VALUES[desc.getIndex()];
}
private final int value;
private AlertLocation(int value) {
this.value = value;
}
// @@protoc_insertion_point(enum_scope:alert.AlertLocation)
}
/**
* Protobuf enum {@code alert.AlertType}
*/
public enum AlertType
implements com.google.protobuf.ProtocolMessageEnum {
/**
* <code>ALERT_TYPE_UNKNOWN = 0;</code>
*/
ALERT_TYPE_UNKNOWN(0),
/**
* <pre>
*蓝显
* </pre>
*
* <code>BLUE_DISPLAY = 1;</code>
*/
BLUE_DISPLAY(1),
/**
* <pre>
*列车延误2分钟
* </pre>
*
* <code>TRAIN_DELAY_2 = 2;</code>
*/
TRAIN_DELAY_2(2),
/**
* <pre>
*列车延误10分钟
* </pre>
*
* <code>TRAIN_DELAY_10 = 3;</code>
*/
TRAIN_DELAY_10(3),
/**
* <pre>
*整侧站台门无关闭锁紧信号
* </pre>
*
* <code>PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL = 4;</code>
*/
PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL(4),
/**
* <pre>
*整侧站台门无法打开
* </pre>
*
* <code>PLATFORM_DOOR_CANNOT_OPEN = 5;</code>
*/
PLATFORM_DOOR_CANNOT_OPEN(5),
/**
* <pre>
*整侧站台门无法关闭
* </pre>
*
* <code>PLATFORM_DOOR_CANNOT_CLOSE = 6;</code>
*/
PLATFORM_DOOR_CANNOT_CLOSE(6),
UNRECOGNIZED(-1),
;
/**
* <code>ALERT_TYPE_UNKNOWN = 0;</code>
*/
public static final int ALERT_TYPE_UNKNOWN_VALUE = 0;
/**
* <pre>
*蓝显
* </pre>
*
* <code>BLUE_DISPLAY = 1;</code>
*/
public static final int BLUE_DISPLAY_VALUE = 1;
/**
* <pre>
*列车延误2分钟
* </pre>
*
* <code>TRAIN_DELAY_2 = 2;</code>
*/
public static final int TRAIN_DELAY_2_VALUE = 2;
/**
* <pre>
*列车延误10分钟
* </pre>
*
* <code>TRAIN_DELAY_10 = 3;</code>
*/
public static final int TRAIN_DELAY_10_VALUE = 3;
/**
* <pre>
*整侧站台门无关闭锁紧信号
* </pre>
*
* <code>PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL = 4;</code>
*/
public static final int PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL_VALUE = 4;
/**
* <pre>
*整侧站台门无法打开
* </pre>
*
* <code>PLATFORM_DOOR_CANNOT_OPEN = 5;</code>
*/
public static final int PLATFORM_DOOR_CANNOT_OPEN_VALUE = 5;
/**
* <pre>
*整侧站台门无法关闭
* </pre>
*
* <code>PLATFORM_DOOR_CANNOT_CLOSE = 6;</code>
*/
public static final int PLATFORM_DOOR_CANNOT_CLOSE_VALUE = 6;
public final int getNumber() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalArgumentException(
"Can't get the number of an unknown enum value.");
}
return value;
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static AlertType valueOf(int value) {
return forNumber(value);
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
*/
public static AlertType forNumber(int value) {
switch (value) {
case 0: return ALERT_TYPE_UNKNOWN;
case 1: return BLUE_DISPLAY;
case 2: return TRAIN_DELAY_2;
case 3: return TRAIN_DELAY_10;
case 4: return PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL;
case 5: return PLATFORM_DOOR_CANNOT_OPEN;
case 6: return PLATFORM_DOOR_CANNOT_CLOSE;
default: return null;
}
}
public static com.google.protobuf.Internal.EnumLiteMap<AlertType>
internalGetValueMap() {
return internalValueMap;
}
private static final com.google.protobuf.Internal.EnumLiteMap<
AlertType> internalValueMap =
new com.google.protobuf.Internal.EnumLiteMap<AlertType>() {
public AlertType findValueByNumber(int number) {
return AlertType.forNumber(number);
}
};
public final com.google.protobuf.Descriptors.EnumValueDescriptor
getValueDescriptor() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalStateException(
"Can't get the descriptor of an unrecognized enum value.");
}
return getDescriptor().getValues().get(ordinal());
}
public final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptorForType() {
return getDescriptor();
}
public static final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptor() {
return club.joylink.xiannccda.dto.protos.AlertConstProto.getDescriptor().getEnumTypes().get(1);
}
private static final AlertType[] VALUES = values();
public static AlertType valueOf(
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
if (desc.getType() != getDescriptor()) {
throw new java.lang.IllegalArgumentException(
"EnumValueDescriptor is not for this type.");
}
if (desc.getIndex() == -1) {
return UNRECOGNIZED;
}
return VALUES[desc.getIndex()];
}
private final int value;
private AlertType(int value) {
this.value = value;
}
// @@protoc_insertion_point(enum_scope:alert.AlertType)
}
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
return descriptor;
}
private static com.google.protobuf.Descriptors.FileDescriptor
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\020alertConst.proto\022\005alert*g\n\rAlertLocati" +
"on\022\032\n\026ALERT_LOCATION_UNKNOWN\020\000\022\006\n\002QX\020\001\022\013" +
"\n\007YHZ_LSQ\020\002\022\013\n\007HJM_LSQ\020\003\022\013\n\007BCT_LSQ\020\004\022\013\n" +
"\007BSQ_LSQ\020\005*\304\001\n\tAlertType\022\026\n\022ALERT_TYPE_U" +
"NKNOWN\020\000\022\020\n\014BLUE_DISPLAY\020\001\022\021\n\rTRAIN_DELA" +
"Y_2\020\002\022\022\n\016TRAIN_DELAY_10\020\003\022\'\n#PLATFORM_DO" +
"OR_WITHOUT_LOCKED_SIGNAL\020\004\022\035\n\031PLATFORM_D" +
"OOR_CANNOT_OPEN\020\005\022\036\n\032PLATFORM_DOOR_CANNO" +
"T_CLOSE\020\006B4\n!club.joylink.xiannccda.dto." +
"protosB\017AlertConstProtob\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
});
}
// @@protoc_insertion_point(outer_class_scope)
}

View File

@ -78,207 +78,6 @@ public final class NccAlertInfoMessageProto {
club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.class, club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.Builder.class);
}
/**
* Protobuf enum {@code alert.NccAlertInfoMessage.AlertType}
*/
public enum AlertType
implements com.google.protobuf.ProtocolMessageEnum {
/**
* <code>UNKNOWN = 0;</code>
*/
UNKNOWN(0),
/**
* <pre>
*蓝显
* </pre>
*
* <code>BLUE_DISPLAY = 1;</code>
*/
BLUE_DISPLAY(1),
/**
* <pre>
*列车延误2分钟
* </pre>
*
* <code>TRAIN_DELAY_2 = 2;</code>
*/
TRAIN_DELAY_2(2),
/**
* <pre>
*列车延误10分钟
* </pre>
*
* <code>TRAIN_DELAY_10 = 3;</code>
*/
TRAIN_DELAY_10(3),
/**
* <pre>
*整侧站台门无关闭锁紧信号
* </pre>
*
* <code>PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL = 4;</code>
*/
PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL(4),
/**
* <pre>
*整侧站台门无法打开
* </pre>
*
* <code>PLATFORM_DOOR_CANNOT_OPEN = 5;</code>
*/
PLATFORM_DOOR_CANNOT_OPEN(5),
/**
* <pre>
*整侧站台门无法关闭
* </pre>
*
* <code>PLATFORM_DOOR_CANNOT_CLOSE = 6;</code>
*/
PLATFORM_DOOR_CANNOT_CLOSE(6),
UNRECOGNIZED(-1),
;
/**
* <code>UNKNOWN = 0;</code>
*/
public static final int UNKNOWN_VALUE = 0;
/**
* <pre>
*蓝显
* </pre>
*
* <code>BLUE_DISPLAY = 1;</code>
*/
public static final int BLUE_DISPLAY_VALUE = 1;
/**
* <pre>
*列车延误2分钟
* </pre>
*
* <code>TRAIN_DELAY_2 = 2;</code>
*/
public static final int TRAIN_DELAY_2_VALUE = 2;
/**
* <pre>
*列车延误10分钟
* </pre>
*
* <code>TRAIN_DELAY_10 = 3;</code>
*/
public static final int TRAIN_DELAY_10_VALUE = 3;
/**
* <pre>
*整侧站台门无关闭锁紧信号
* </pre>
*
* <code>PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL = 4;</code>
*/
public static final int PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL_VALUE = 4;
/**
* <pre>
*整侧站台门无法打开
* </pre>
*
* <code>PLATFORM_DOOR_CANNOT_OPEN = 5;</code>
*/
public static final int PLATFORM_DOOR_CANNOT_OPEN_VALUE = 5;
/**
* <pre>
*整侧站台门无法关闭
* </pre>
*
* <code>PLATFORM_DOOR_CANNOT_CLOSE = 6;</code>
*/
public static final int PLATFORM_DOOR_CANNOT_CLOSE_VALUE = 6;
public final int getNumber() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalArgumentException(
"Can't get the number of an unknown enum value.");
}
return value;
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static AlertType valueOf(int value) {
return forNumber(value);
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
*/
public static AlertType forNumber(int value) {
switch (value) {
case 0: return UNKNOWN;
case 1: return BLUE_DISPLAY;
case 2: return TRAIN_DELAY_2;
case 3: return TRAIN_DELAY_10;
case 4: return PLATFORM_DOOR_WITHOUT_LOCKED_SIGNAL;
case 5: return PLATFORM_DOOR_CANNOT_OPEN;
case 6: return PLATFORM_DOOR_CANNOT_CLOSE;
default: return null;
}
}
public static com.google.protobuf.Internal.EnumLiteMap<AlertType>
internalGetValueMap() {
return internalValueMap;
}
private static final com.google.protobuf.Internal.EnumLiteMap<
AlertType> internalValueMap =
new com.google.protobuf.Internal.EnumLiteMap<AlertType>() {
public AlertType findValueByNumber(int number) {
return AlertType.forNumber(number);
}
};
public final com.google.protobuf.Descriptors.EnumValueDescriptor
getValueDescriptor() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalStateException(
"Can't get the descriptor of an unrecognized enum value.");
}
return getDescriptor().getValues().get(ordinal());
}
public final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptorForType() {
return getDescriptor();
}
public static final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptor() {
return club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.getDescriptor().getEnumTypes().get(0);
}
private static final AlertType[] VALUES = values();
public static AlertType valueOf(
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
if (desc.getType() != getDescriptor()) {
throw new java.lang.IllegalArgumentException(
"EnumValueDescriptor is not for this type.");
}
if (desc.getIndex() == -1) {
return UNRECOGNIZED;
}
return VALUES[desc.getIndex()];
}
private final int value;
private AlertType(int value) {
this.value = value;
}
// @@protoc_insertion_point(enum_scope:alert.NccAlertInfoMessage.AlertType)
}
public interface MessageOrBuilder extends
// @@protoc_insertion_point(interface_extends:alert.NccAlertInfoMessage.Message)
com.google.protobuf.MessageOrBuilder {
@ -344,15 +143,15 @@ public final class NccAlertInfoMessageProto {
getAlertObjectBytes();
/**
* <code>.alert.NccAlertInfoMessage.AlertType alert_type = 7;</code>
* <code>.alert.AlertType alert_type = 7;</code>
* @return The enum numeric value on the wire for alertType.
*/
int getAlertTypeValue();
/**
* <code>.alert.NccAlertInfoMessage.AlertType alert_type = 7;</code>
* <code>.alert.AlertType alert_type = 7;</code>
* @return The alertType.
*/
club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType getAlertType();
club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType getAlertType();
/**
* <code>string locator_device_id = 8;</code>
@ -594,19 +393,19 @@ public final class NccAlertInfoMessageProto {
public static final int ALERT_TYPE_FIELD_NUMBER = 7;
private int alertType_ = 0;
/**
* <code>.alert.NccAlertInfoMessage.AlertType alert_type = 7;</code>
* <code>.alert.AlertType alert_type = 7;</code>
* @return The enum numeric value on the wire for alertType.
*/
@java.lang.Override public int getAlertTypeValue() {
return alertType_;
}
/**
* <code>.alert.NccAlertInfoMessage.AlertType alert_type = 7;</code>
* <code>.alert.AlertType alert_type = 7;</code>
* @return The alertType.
*/
@java.lang.Override public club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType getAlertType() {
club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType result = club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType.forNumber(alertType_);
return result == null ? club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType.UNRECOGNIZED : result;
@java.lang.Override public club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType getAlertType() {
club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType result = club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType.forNumber(alertType_);
return result == null ? club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType.UNRECOGNIZED : result;
}
public static final int LOCATOR_DEVICE_ID_FIELD_NUMBER = 8;
@ -691,7 +490,7 @@ public final class NccAlertInfoMessageProto {
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(alertObject_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 6, alertObject_);
}
if (alertType_ != club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType.UNKNOWN.getNumber()) {
if (alertType_ != club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType.ALERT_TYPE_UNKNOWN.getNumber()) {
output.writeEnum(7, alertType_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(locatorDeviceId_)) {
@ -729,7 +528,7 @@ public final class NccAlertInfoMessageProto {
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(alertObject_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, alertObject_);
}
if (alertType_ != club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType.UNKNOWN.getNumber()) {
if (alertType_ != club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType.ALERT_TYPE_UNKNOWN.getNumber()) {
size += com.google.protobuf.CodedOutputStream
.computeEnumSize(7, alertType_);
}
@ -1495,14 +1294,14 @@ public final class NccAlertInfoMessageProto {
private int alertType_ = 0;
/**
* <code>.alert.NccAlertInfoMessage.AlertType alert_type = 7;</code>
* <code>.alert.AlertType alert_type = 7;</code>
* @return The enum numeric value on the wire for alertType.
*/
@java.lang.Override public int getAlertTypeValue() {
return alertType_;
}
/**
* <code>.alert.NccAlertInfoMessage.AlertType alert_type = 7;</code>
* <code>.alert.AlertType alert_type = 7;</code>
* @param value The enum numeric value on the wire for alertType to set.
* @return This builder for chaining.
*/
@ -1513,20 +1312,20 @@ public final class NccAlertInfoMessageProto {
return this;
}
/**
* <code>.alert.NccAlertInfoMessage.AlertType alert_type = 7;</code>
* <code>.alert.AlertType alert_type = 7;</code>
* @return The alertType.
*/
@java.lang.Override
public club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType getAlertType() {
club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType result = club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType.forNumber(alertType_);
return result == null ? club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType.UNRECOGNIZED : result;
public club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType getAlertType() {
club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType result = club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType.forNumber(alertType_);
return result == null ? club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType.UNRECOGNIZED : result;
}
/**
* <code>.alert.NccAlertInfoMessage.AlertType alert_type = 7;</code>
* <code>.alert.AlertType alert_type = 7;</code>
* @param value The alertType to set.
* @return This builder for chaining.
*/
public Builder setAlertType(club.joylink.xiannccda.dto.protos.NccAlertInfoMessageProto.NccAlertInfoMessage.AlertType value) {
public Builder setAlertType(club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType value) {
if (value == null) {
throw new NullPointerException();
}
@ -1536,7 +1335,7 @@ public final class NccAlertInfoMessageProto {
return this;
}
/**
* <code>.alert.NccAlertInfoMessage.AlertType alert_type = 7;</code>
* <code>.alert.AlertType alert_type = 7;</code>
* @return This builder for chaining.
*/
public Builder clearAlertType() {
@ -2418,25 +2217,21 @@ public final class NccAlertInfoMessageProto {
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\017alertInfo.proto\022\005alert\"\342\003\n\023NccAlertInf" +
"oMessage\0224\n\010messages\030\001 \003(\0132\".alert.NccAl" +
"ertInfoMessage.Message\032\330\001\n\007Message\022\n\n\002id" +
"\030\001 \001(\t\022\r\n\005level\030\002 \001(\t\022\022\n\nalert_time\030\003 \001(" +
"\t\022\024\n\014alert_tip_id\030\004 \001(\005\022\017\n\007line_id\030\005 \001(\005" +
"\022\024\n\014alert_object\030\006 \001(\t\0228\n\nalert_type\030\007 \001" +
"(\0162$.alert.NccAlertInfoMessage.AlertType" +
"\022\031\n\021locator_device_id\030\010 \001(\t\022\014\n\004mock\030\t \001(" +
"\010\"\271\001\n\tAlertType\022\013\n\007UNKNOWN\020\000\022\020\n\014BLUE_DIS" +
"PLAY\020\001\022\021\n\rTRAIN_DELAY_2\020\002\022\022\n\016TRAIN_DELAY" +
"_10\020\003\022\'\n#PLATFORM_DOOR_WITHOUT_LOCKED_SI" +
"GNAL\020\004\022\035\n\031PLATFORM_DOOR_CANNOT_OPEN\020\005\022\036\n" +
"\032PLATFORM_DOOR_CANNOT_CLOSE\020\006B=\n!club.jo" +
"ylink.xiannccda.dto.protosB\030NccAlertInfo" +
"MessageProtob\006proto3"
"\n\017alertInfo.proto\022\005alert\032\020alertConst.pro" +
"to\"\222\002\n\023NccAlertInfoMessage\0224\n\010messages\030\001" +
" \003(\0132\".alert.NccAlertInfoMessage.Message" +
"\032\304\001\n\007Message\022\n\n\002id\030\001 \001(\t\022\r\n\005level\030\002 \001(\t\022" +
"\022\n\nalert_time\030\003 \001(\t\022\024\n\014alert_tip_id\030\004 \001(" +
"\005\022\017\n\007line_id\030\005 \001(\005\022\024\n\014alert_object\030\006 \001(\t" +
"\022$\n\nalert_type\030\007 \001(\0162\020.alert.AlertType\022\031" +
"\n\021locator_device_id\030\010 \001(\t\022\014\n\004mock\030\t \001(\010B" +
"=\n!club.joylink.xiannccda.dto.protosB\030Nc" +
"cAlertInfoMessageProtob\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
club.joylink.xiannccda.dto.protos.AlertConstProto.getDescriptor(),
});
internal_static_alert_NccAlertInfoMessage_descriptor =
getDescriptor().getMessageTypes().get(0);
@ -2450,6 +2245,7 @@ public final class NccAlertInfoMessageProto {
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_alert_NccAlertInfoMessage_Message_descriptor,
new java.lang.String[] { "Id", "Level", "AlertTime", "AlertTipId", "LineId", "AlertObject", "AlertType", "LocatorDeviceId", "Mock", });
club.joylink.xiannccda.dto.protos.AlertConstProto.getDescriptor();
}
// @@protoc_insertion_point(outer_class_scope)

View File

@ -35,6 +35,8 @@ public class AlertRecord {
private LocalDateTime alertTime;
private String alertLocation;
public static final String ID = "id";
public static final String ALERT_TYPE = "alert_type";
@ -44,4 +46,6 @@ public class AlertRecord {
public static final String ALERT_OBJECT = "alert_object";
public static final String ALERT_TIME = "alert_time";
public static final String ALERT_LOCATION = "alert_location";
}

View File

@ -9,11 +9,12 @@
<result column="line_id" property="lineId" />
<result column="alert_object" property="alertObject" />
<result column="alert_time" property="alertTime" />
<result column="alert_location" property="alertLocation" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, alert_type, line_id, alert_object, alert_time
id, alert_type, line_id, alert_object, alert_time, alert_location
</sql>
</mapper>

View File

@ -5,9 +5,9 @@ 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;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
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 com.google.protobuf.MessageOrBuilder;
import java.time.LocalDateTime;

View File

@ -2,7 +2,7 @@ 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.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.entity.AlertRecord;
import club.joylink.xiannccda.entity.AlertTip;
import club.joylink.xiannccda.repository.IAlertRecordRepository;
@ -28,11 +28,11 @@ public class AlertRecordService {
Page<AlertRecord> recordPage = alertRecordRepository.page(queryDTO);
List<NccAlertInfo> collect = recordPage.getRecords().stream()
.map(record -> {
Optional<AlertTip> alertTip = alertTipService.queryOne(record.getAlertType());
Optional<AlertTip> alertTip = alertTipService.queryOne(record.getAlertType(), record.getAlertLocation());
Integer alertTipId = alertTip.map(AlertTip::getId).orElse(null);
NccAlertInfo nccAlertInfo = new NccAlertInfo(record.getAlertTime(),
AlertType.valueOf(record.getAlertType()), alertTipId, record.getLineId(),
record.getAlertObject(), "", false);
record.getAlertObject(), "", null, false);
nccAlertInfo.setId(record.getId());
return nccAlertInfo;
}).collect(Collectors.toList());

View File

@ -39,12 +39,17 @@ public class AlertTipService {
alertTipRepository.saveOrUpdate(saveEntity, updateWrapper);
}
public Optional<AlertTip> queryOne(String alertType) {
public Optional<AlertTip> queryOne(String alertType, String alertLocation) {
if (alertType == null) {
return Optional.empty();
}
LambdaQueryWrapper<AlertTip> queryWrapper = Wrappers.lambdaQuery(AlertTip.class)
.eq(AlertTip::getAlertType, alertType);
if (alertLocation != null) {
queryWrapper.eq(AlertTip::getLocationType, alertLocation);
} else {
queryWrapper.isNull(AlertTip::getLocationType);
}
return Optional.ofNullable(alertTipRepository.getOne(queryWrapper, false));
}

@ -1 +1 @@
Subproject commit c9a07e75f06e8247d33f9e08c52d5045f1db2bc2
Subproject commit 7567e2953eae654a6de703b6b1dfaedcc53d0e84