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.line3.MessageCons;
|
||||
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 java.util.Objects;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 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
|
||||
@Setter
|
||||
public static class TrainCell {
|
||||
|
@ -12,12 +12,14 @@ import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 2.7.9列车信息全体消息
|
||||
@ -58,29 +60,31 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
||||
if (trainCell.getRtuId() != null) {
|
||||
builder.setRtuId(trainCell.getRtuId());
|
||||
}
|
||||
if (trainCell.getNccWindow() != null) {
|
||||
NccWindow.Builder window = NccWindow.newBuilder();
|
||||
if (trainCell.getNccWindow() != null) {
|
||||
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) {
|
||||
builder.setDevType(DeviceStatusProto.DeviceType.forNumber(trainCell.getDevType().getVal()));
|
||||
}
|
||||
builder.setDevName(trainCell.getDevName());
|
||||
builder.setTrainIndex(trainCell.getTrainIndex());
|
||||
builder.setGroupId(trainCell.getGroupId());
|
||||
builder.setTrainId(trainCell.getTrainId());
|
||||
if (trainCell.getGlobalId() != null) {
|
||||
builder.setGlobalId(trainCell.getGlobalId());
|
||||
}
|
||||
builder.setDevName(StringUtils.defaultString(trainCell.getDevName(), ""));
|
||||
|
||||
builder.setTrainIndex(StringUtils.defaultString(trainCell.getTrainIndex(), ""));
|
||||
builder.setGroupId(StringUtils.defaultString(trainCell.getGroupId(), ""));
|
||||
builder.setTrainId(StringUtils.defaultString(trainCell.getTrainId(), ""));
|
||||
|
||||
builder.setGlobalId(StringUtils.defaultString(trainCell.getGlobalId(), ""));
|
||||
|
||||
if (trainCell.getDestinationId() != null) {
|
||||
builder.setDestinationId(trainCell.getDestinationId());
|
||||
}
|
||||
builder.setRollingStock(trainCell.getRollingStock());
|
||||
if (trainCell.getDriverId() != null) {
|
||||
builder.setDriverId(trainCell.getDriverId());
|
||||
}
|
||||
builder.setDriverId(StringUtils.defaultString(trainCell.getDriverId(), ""));
|
||||
|
||||
if (trainCell.getOtpTime() != null) {
|
||||
builder.setOtpTime(trainCell.getOtpTime());
|
||||
}
|
||||
|
@ -9,8 +9,10 @@ import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 2.7.11 列车信息删除消息
|
||||
@ -77,16 +79,27 @@ public class TrainIndicationRemoveResponse extends MessageResponse {
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
TrainRemove.Builder trainRemove = TrainRemove.newBuilder();
|
||||
if (Objects.nonNull(this.lineId)) {
|
||||
trainRemove.setLineId(this.lineId);
|
||||
}
|
||||
if (Objects.nonNull(this.rtuId)) {
|
||||
trainRemove.setRtuId(this.rtuId);
|
||||
}
|
||||
NccWindow.Builder window = NccWindow.newBuilder();
|
||||
if (Objects.nonNull(this.nccWindow)) {
|
||||
window.setNccWindow(this.nccWindow);
|
||||
}
|
||||
if (Objects.nonNull(this.nccWindowOffset)) {
|
||||
window.setNccWinOffset(this.nccWindowOffset);
|
||||
}
|
||||
trainRemove.setWindow(window);
|
||||
if (Objects.nonNull(this.devType)) {
|
||||
trainRemove.setDeviceType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
||||
trainRemove.setDevName(this.devName);
|
||||
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);
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,11 @@ import io.netty.buffer.ByteBuf;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 2.7.10 列车信息更新消息[增加/更新]
|
||||
@ -125,19 +128,24 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
TrainProto.TrainInfo.Builder train = TrainInfo.newBuilder();
|
||||
|
||||
train.setLineId(this.lineId);
|
||||
train.setType(this.type);
|
||||
train.setRtuId(this.rtuId);
|
||||
NccWindow.Builder window = NccWindow.newBuilder();
|
||||
if (Objects.nonNull(this.nccWindow)) {
|
||||
window.setNccWindow(this.nccWindow);
|
||||
}
|
||||
if (Objects.nonNull(this.nccWindowOffset)) {
|
||||
window.setNccWinOffset(this.nccWindowOffset);
|
||||
}
|
||||
|
||||
train.setWindow(window);
|
||||
|
||||
if (Objects.nonNull(this.devType)) {
|
||||
train.setDevType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
||||
train.setDevName(this.devName);
|
||||
}
|
||||
train.setDevName(StringUtils.defaultString(this.devName, ""));
|
||||
|
||||
train.setTrainIndex(this.trainIndex);
|
||||
train.setTrainIndex(StringUtils.defaultString(this.trainIndex, ""));
|
||||
train.setRollingStock(this.getRollingStock());
|
||||
train.setOtpTime(this.optTime);
|
||||
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);
|
||||
train.setMode(trainMode.build());
|
||||
train.setSpeed(this.speed);
|
||||
if (Objects.nonNull(this.rate)) {
|
||||
train.setRate(this.rate);
|
||||
|
||||
}
|
||||
if (Objects.nonNull(this.routeId)) {
|
||||
train.setRouteId(this.routeId);
|
||||
train.setDriverId(this.driverId);
|
||||
|
||||
}
|
||||
train.setDriverId(StringUtils.defaultString(this.driverId, ""));
|
||||
if (Objects.nonNull(this.destinationId)) {
|
||||
train.setDestinationId(this.destinationId);
|
||||
train.setGroupId(this.groupId);
|
||||
train.setGlobalId(this.globalId);
|
||||
train.setTrainId(this.trainId);
|
||||
}
|
||||
train.setGroupId(StringUtils.defaultString(this.groupId, ""));
|
||||
train.setGlobalId(StringUtils.defaultString(this.globalId, ""));
|
||||
train.setTrainId(StringUtils.defaultString(this.trainId, ""));
|
||||
return Lists.newArrayList(train);
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,12 @@ import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 2.7.8列车报点消息
|
||||
@ -130,11 +132,17 @@ public class TrainRecordResponse extends MessageResponse {
|
||||
@Override
|
||||
public List<Builder> generateProto() {
|
||||
TrainRecord.Builder builder = TrainRecord.newBuilder();
|
||||
if (Objects.nonNull(this.lineId)) {
|
||||
builder.setLineId(this.getLineId());
|
||||
builder.setTrainId(this.getTrainId());
|
||||
builder.setGlobalId(this.getGlobalId());
|
||||
builder.setLocalSubId(this.getLocalSubId());
|
||||
builder.setGroupId(this.getGroupId());
|
||||
}
|
||||
builder.setTrainId(StringUtils.defaultString(this.trainId, ""));
|
||||
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) {
|
||||
builder.setDestinationId(this.getDestinationId());
|
||||
}
|
||||
@ -150,7 +158,8 @@ public class TrainRecordResponse extends MessageResponse {
|
||||
if (this.getSideId() != null) {
|
||||
builder.setSideId(this.getSideId());
|
||||
}
|
||||
builder.setTrackName(this.getTrackName());
|
||||
;
|
||||
builder.setTrackName(StringUtils.defaultString(this.trackName, ""));
|
||||
if (this.getRecordType() != null) {
|
||||
builder.setRecordType(this.getRecordType());
|
||||
}
|
||||
|
@ -156,6 +156,7 @@ public class MockDeviceController {
|
||||
Object v = jo2.get(s1);
|
||||
this.setVal(cloneBuilder, s1, v);
|
||||
}
|
||||
this.setVal(builder, s, cloneBuilder.build());
|
||||
}
|
||||
}
|
||||
DeviceDataRepository.add(lineId, List.of(builder), dataType);
|
||||
|
@ -177,7 +177,7 @@ public class Status {
|
||||
|
||||
String groupId;
|
||||
NccWindow window;
|
||||
TrainMode trainMode;
|
||||
TrainMode mode;
|
||||
@Schema(description = "设备类型 DEVICE_TYPE_UNKNOW;\n"
|
||||
+ " DEVICE_TYPE_RTU;\n"
|
||||
+ " DEVICE_TYPE_STATION;\n"
|
||||
|
@ -52,7 +52,7 @@ public class LineDeviceStatusService {
|
||||
|
||||
@PostConstruct
|
||||
public void deviceStatusRefresh() {
|
||||
// this.createDataConvertor();
|
||||
this.createDataConvertor();
|
||||
// 设备状态数据集合
|
||||
DeviceStatusData deviceStatusData = DeviceStatusDataRepository.getDeviceStatusData(DATA_KEY);
|
||||
// 添加初始化转换方法
|
||||
|
Loading…
Reference in New Issue
Block a user