Merge branch 'master' of https://git.code.tencent.com/xian-ncc-da/xian-ncc-da-server
This commit is contained in:
commit
8c2519e3a6
@ -3,12 +3,19 @@ package club.joylink.xiannccda.ats.message.line3.rep;
|
|||||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||||
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
||||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||||
|
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||||
|
import club.joylink.xiannccda.dto.protos.TrainProto.TrainBlock;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.protobuf.GeneratedMessageV3;
|
||||||
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import java.util.Objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 2.7.13 列车阻塞消息
|
* 2.7.13 列车阻塞消息
|
||||||
@ -40,6 +47,41 @@ public class TrainBlockInfoResponse extends MessageResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Builder> generateProto() {
|
||||||
|
List<GeneratedMessageV3.Builder> builders = Lists.newArrayList();
|
||||||
|
for (TrainCell train : this.trains) {
|
||||||
|
TrainBlock.Builder builder = TrainBlock.newBuilder();
|
||||||
|
builder.setLineId(this.getLineId());
|
||||||
|
builder.setGroupId(StringUtils.defaultString(train.getGroupId(), ""));
|
||||||
|
builder.setTrainId(StringUtils.defaultString(train.getTrainId(), ""));
|
||||||
|
|
||||||
|
if (Objects.nonNull(train.getDirection())) {
|
||||||
|
builder.setDirection(train.getDirection().value);
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(train.getStationIdInUpSide())) {
|
||||||
|
builder.setStationIDInUpSide(train.getStationIdInUpSide());
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(train.getStationIdInDownSide())) {
|
||||||
|
builder.setStationIDInUpSide(train.getStationIdInDownSide());
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(train.getRtuId())) {
|
||||||
|
builder.setRtuId(train.getRtuId());
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(train.getDevType())) {
|
||||||
|
DeviceStatusProto.DeviceType dtProto = DeviceStatusProto.DeviceType.forNumber(train.getDevType().getVal());
|
||||||
|
builder.setDeviceType(dtProto);
|
||||||
|
}
|
||||||
|
builder.setDevName(StringUtils.defaultString(train.getDevName(), ""));
|
||||||
|
|
||||||
|
if (Objects.nonNull(train.getBlockFlag())) {
|
||||||
|
builder.setBlockFlag(train.getBlockFlag() ? 1 : 0);
|
||||||
|
}
|
||||||
|
builders.add(builder);
|
||||||
|
}
|
||||||
|
return builders;
|
||||||
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public static class TrainCell {
|
public static class TrainCell {
|
||||||
@ -129,9 +171,9 @@ public class TrainBlockInfoResponse extends MessageResponse {
|
|||||||
|
|
||||||
public static DirectionEnum of(final int value) {
|
public static DirectionEnum of(final int value) {
|
||||||
for (final DirectionEnum direction : values()) {
|
for (final DirectionEnum direction : values()) {
|
||||||
if (direction.value == value) {
|
if (direction.value == value) {
|
||||||
return direction;
|
return direction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DirectionEnum.Unknown;
|
return DirectionEnum.Unknown;
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,14 @@ import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import java.util.Objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 2.7.9列车信息全体消息
|
* 2.7.9列车信息全体消息
|
||||||
@ -58,29 +60,31 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
|||||||
if (trainCell.getRtuId() != null) {
|
if (trainCell.getRtuId() != null) {
|
||||||
builder.setRtuId(trainCell.getRtuId());
|
builder.setRtuId(trainCell.getRtuId());
|
||||||
}
|
}
|
||||||
|
NccWindow.Builder window = NccWindow.newBuilder();
|
||||||
if (trainCell.getNccWindow() != null) {
|
if (trainCell.getNccWindow() != null) {
|
||||||
NccWindow.Builder window = NccWindow.newBuilder();
|
|
||||||
window.setNccWindow(trainCell.getNccWindow());
|
window.setNccWindow(trainCell.getNccWindow());
|
||||||
window.setNccWinOffset(trainCell.getNccWindowOffset());
|
|
||||||
builder.setWindow(window);
|
|
||||||
}
|
}
|
||||||
|
if (Objects.nonNull(trainCell.getNccWindowOffset())) {
|
||||||
|
window.setNccWinOffset(trainCell.getNccWindowOffset());
|
||||||
|
}
|
||||||
|
builder.setWindow(window);
|
||||||
if (trainCell.getDevType() != null) {
|
if (trainCell.getDevType() != null) {
|
||||||
builder.setDevType(DeviceStatusProto.DeviceType.forNumber(trainCell.getDevType().getVal()));
|
builder.setDevType(DeviceStatusProto.DeviceType.forNumber(trainCell.getDevType().getVal()));
|
||||||
}
|
}
|
||||||
builder.setDevName(trainCell.getDevName());
|
builder.setDevName(StringUtils.defaultString(trainCell.getDevName(), ""));
|
||||||
builder.setTrainIndex(trainCell.getTrainIndex());
|
|
||||||
builder.setGroupId(trainCell.getGroupId());
|
builder.setTrainIndex(StringUtils.defaultString(trainCell.getTrainIndex(), ""));
|
||||||
builder.setTrainId(trainCell.getTrainId());
|
builder.setGroupId(StringUtils.defaultString(trainCell.getGroupId(), ""));
|
||||||
if (trainCell.getGlobalId() != null) {
|
builder.setTrainId(StringUtils.defaultString(trainCell.getTrainId(), ""));
|
||||||
builder.setGlobalId(trainCell.getGlobalId());
|
|
||||||
}
|
builder.setGlobalId(StringUtils.defaultString(trainCell.getGlobalId(), ""));
|
||||||
|
|
||||||
if (trainCell.getDestinationId() != null) {
|
if (trainCell.getDestinationId() != null) {
|
||||||
builder.setDestinationId(trainCell.getDestinationId());
|
builder.setDestinationId(trainCell.getDestinationId());
|
||||||
}
|
}
|
||||||
builder.setRollingStock(trainCell.getRollingStock());
|
builder.setRollingStock(trainCell.getRollingStock());
|
||||||
if (trainCell.getDriverId() != null) {
|
builder.setDriverId(StringUtils.defaultString(trainCell.getDriverId(), ""));
|
||||||
builder.setDriverId(trainCell.getDriverId());
|
|
||||||
}
|
|
||||||
if (trainCell.getOtpTime() != null) {
|
if (trainCell.getOtpTime() != null) {
|
||||||
builder.setOtpTime(trainCell.getOtpTime());
|
builder.setOtpTime(trainCell.getOtpTime());
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,10 @@ import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
|
|||||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 2.7.11 列车信息删除消息
|
* 2.7.11 列车信息删除消息
|
||||||
@ -77,16 +79,27 @@ public class TrainIndicationRemoveResponse extends MessageResponse {
|
|||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto() {
|
||||||
TrainRemove.Builder trainRemove = TrainRemove.newBuilder();
|
TrainRemove.Builder trainRemove = TrainRemove.newBuilder();
|
||||||
trainRemove.setLineId(this.lineId);
|
if (Objects.nonNull(this.lineId)) {
|
||||||
trainRemove.setRtuId(this.rtuId);
|
trainRemove.setLineId(this.lineId);
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(this.rtuId)) {
|
||||||
|
trainRemove.setRtuId(this.rtuId);
|
||||||
|
}
|
||||||
NccWindow.Builder window = NccWindow.newBuilder();
|
NccWindow.Builder window = NccWindow.newBuilder();
|
||||||
window.setNccWindow(this.nccWindow);
|
if (Objects.nonNull(this.nccWindow)) {
|
||||||
window.setNccWinOffset(this.nccWindowOffset);
|
window.setNccWindow(this.nccWindow);
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(this.nccWindowOffset)) {
|
||||||
|
window.setNccWinOffset(this.nccWindowOffset);
|
||||||
|
}
|
||||||
trainRemove.setWindow(window);
|
trainRemove.setWindow(window);
|
||||||
trainRemove.setDeviceType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
if (Objects.nonNull(this.devType)) {
|
||||||
trainRemove.setDevName(this.devName);
|
trainRemove.setDeviceType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
||||||
trainRemove.setTrainIndex(this.trainIndex);
|
}
|
||||||
trainRemove.setGroupId(this.groupId);
|
trainRemove.setDevName(StringUtils.defaultString(this.devName, ""));
|
||||||
|
trainRemove.setTrainIndex(StringUtils.defaultString(this.trainIndex, ""));
|
||||||
|
trainRemove.setGroupId(StringUtils.defaultString(this.groupId, ""));
|
||||||
|
|
||||||
return List.of(trainRemove);
|
return List.of(trainRemove);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,11 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 2.7.10 列车信息更新消息[增加/更新]
|
* 2.7.10 列车信息更新消息[增加/更新]
|
||||||
@ -125,19 +128,24 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
|
|||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto() {
|
||||||
TrainProto.TrainInfo.Builder train = TrainInfo.newBuilder();
|
TrainProto.TrainInfo.Builder train = TrainInfo.newBuilder();
|
||||||
|
|
||||||
train.setLineId(this.lineId);
|
train.setLineId(this.lineId);
|
||||||
train.setType(this.type);
|
train.setType(this.type);
|
||||||
train.setRtuId(this.rtuId);
|
train.setRtuId(this.rtuId);
|
||||||
NccWindow.Builder window = NccWindow.newBuilder();
|
NccWindow.Builder window = NccWindow.newBuilder();
|
||||||
window.setNccWindow(this.nccWindow);
|
if (Objects.nonNull(this.nccWindow)) {
|
||||||
window.setNccWinOffset(this.nccWindowOffset);
|
window.setNccWindow(this.nccWindow);
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(this.nccWindowOffset)) {
|
||||||
|
window.setNccWinOffset(this.nccWindowOffset);
|
||||||
|
}
|
||||||
|
|
||||||
train.setWindow(window);
|
train.setWindow(window);
|
||||||
|
if (Objects.nonNull(this.devType)) {
|
||||||
|
train.setDevType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
||||||
|
}
|
||||||
|
train.setDevName(StringUtils.defaultString(this.devName, ""));
|
||||||
|
|
||||||
train.setDevType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
train.setTrainIndex(StringUtils.defaultString(this.trainIndex, ""));
|
||||||
train.setDevName(this.devName);
|
|
||||||
|
|
||||||
train.setTrainIndex(this.trainIndex);
|
|
||||||
train.setRollingStock(this.getRollingStock());
|
train.setRollingStock(this.getRollingStock());
|
||||||
train.setOtpTime(this.optTime);
|
train.setOtpTime(this.optTime);
|
||||||
train.setArriveTime(this.arriveTime.toEpochSecond(ZoneOffset.ofHours(8)));
|
train.setArriveTime(this.arriveTime.toEpochSecond(ZoneOffset.ofHours(8)));
|
||||||
@ -146,13 +154,21 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
|
|||||||
DeviceStatusConvertor.convert(DeviceStatus.TRAIN_MODE.class, this.mode);
|
DeviceStatusConvertor.convert(DeviceStatus.TRAIN_MODE.class, this.mode);
|
||||||
train.setMode(trainMode.build());
|
train.setMode(trainMode.build());
|
||||||
train.setSpeed(this.speed);
|
train.setSpeed(this.speed);
|
||||||
train.setRate(this.rate);
|
if (Objects.nonNull(this.rate)) {
|
||||||
train.setRouteId(this.routeId);
|
train.setRate(this.rate);
|
||||||
train.setDriverId(this.driverId);
|
|
||||||
train.setDestinationId(this.destinationId);
|
}
|
||||||
train.setGroupId(this.groupId);
|
if (Objects.nonNull(this.routeId)) {
|
||||||
train.setGlobalId(this.globalId);
|
train.setRouteId(this.routeId);
|
||||||
train.setTrainId(this.trainId);
|
|
||||||
|
}
|
||||||
|
train.setDriverId(StringUtils.defaultString(this.driverId, ""));
|
||||||
|
if (Objects.nonNull(this.destinationId)) {
|
||||||
|
train.setDestinationId(this.destinationId);
|
||||||
|
}
|
||||||
|
train.setGroupId(StringUtils.defaultString(this.groupId, ""));
|
||||||
|
train.setGlobalId(StringUtils.defaultString(this.globalId, ""));
|
||||||
|
train.setTrainId(StringUtils.defaultString(this.trainId, ""));
|
||||||
return Lists.newArrayList(train);
|
return Lists.newArrayList(train);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,10 +13,12 @@ import com.google.protobuf.GeneratedMessageV3.Builder;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 2.7.8列车报点消息
|
* 2.7.8列车报点消息
|
||||||
@ -130,11 +132,17 @@ public class TrainRecordResponse extends MessageResponse {
|
|||||||
@Override
|
@Override
|
||||||
public List<Builder> generateProto() {
|
public List<Builder> generateProto() {
|
||||||
TrainRecord.Builder builder = TrainRecord.newBuilder();
|
TrainRecord.Builder builder = TrainRecord.newBuilder();
|
||||||
builder.setLineId(this.getLineId());
|
if (Objects.nonNull(this.lineId)) {
|
||||||
builder.setTrainId(this.getTrainId());
|
builder.setLineId(this.getLineId());
|
||||||
builder.setGlobalId(this.getGlobalId());
|
}
|
||||||
builder.setLocalSubId(this.getLocalSubId());
|
builder.setTrainId(StringUtils.defaultString(this.trainId, ""));
|
||||||
builder.setGroupId(this.getGroupId());
|
builder.setGlobalId(StringUtils.defaultString(this.globalId, ""));
|
||||||
|
|
||||||
|
if (Objects.nonNull(this.localSubId)) {
|
||||||
|
builder.setLocalSubId(this.localSubId);
|
||||||
|
}
|
||||||
|
builder.setGlobalId(StringUtils.defaultString(this.groupId, ""));
|
||||||
|
|
||||||
if (this.getDestinationId() != null) {
|
if (this.getDestinationId() != null) {
|
||||||
builder.setDestinationId(this.getDestinationId());
|
builder.setDestinationId(this.getDestinationId());
|
||||||
}
|
}
|
||||||
@ -150,7 +158,8 @@ public class TrainRecordResponse extends MessageResponse {
|
|||||||
if (this.getSideId() != null) {
|
if (this.getSideId() != null) {
|
||||||
builder.setSideId(this.getSideId());
|
builder.setSideId(this.getSideId());
|
||||||
}
|
}
|
||||||
builder.setTrackName(this.getTrackName());
|
;
|
||||||
|
builder.setTrackName(StringUtils.defaultString(this.trackName, ""));
|
||||||
if (this.getRecordType() != null) {
|
if (this.getRecordType() != null) {
|
||||||
builder.setRecordType(this.getRecordType());
|
builder.setRecordType(this.getRecordType());
|
||||||
}
|
}
|
||||||
|
@ -156,6 +156,7 @@ public class MockDeviceController {
|
|||||||
Object v = jo2.get(s1);
|
Object v = jo2.get(s1);
|
||||||
this.setVal(cloneBuilder, s1, v);
|
this.setVal(cloneBuilder, s1, v);
|
||||||
}
|
}
|
||||||
|
this.setVal(builder, s, cloneBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeviceDataRepository.add(lineId, List.of(builder), dataType);
|
DeviceDataRepository.add(lineId, List.of(builder), dataType);
|
||||||
|
@ -177,7 +177,7 @@ public class Status {
|
|||||||
|
|
||||||
String groupId;
|
String groupId;
|
||||||
NccWindow window;
|
NccWindow window;
|
||||||
TrainMode trainMode;
|
TrainMode mode;
|
||||||
@Schema(description = "设备类型 DEVICE_TYPE_UNKNOW;\n"
|
@Schema(description = "设备类型 DEVICE_TYPE_UNKNOW;\n"
|
||||||
+ " DEVICE_TYPE_RTU;\n"
|
+ " DEVICE_TYPE_RTU;\n"
|
||||||
+ " DEVICE_TYPE_STATION;\n"
|
+ " DEVICE_TYPE_STATION;\n"
|
||||||
|
@ -52,7 +52,7 @@ public class LineDeviceStatusService {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void deviceStatusRefresh() {
|
public void deviceStatusRefresh() {
|
||||||
// this.createDataConvertor();
|
this.createDataConvertor();
|
||||||
// 设备状态数据集合
|
// 设备状态数据集合
|
||||||
DeviceStatusData deviceStatusData = DeviceStatusDataRepository.getDeviceStatusData(DATA_KEY);
|
DeviceStatusData deviceStatusData = DeviceStatusDataRepository.getDeviceStatusData(DATA_KEY);
|
||||||
// 添加初始化转换方法
|
// 添加初始化转换方法
|
||||||
|
Loading…
Reference in New Issue
Block a user