Merge branch 'master' of https://git.code.tencent.com/xian-ncc-da/xian-ncc-da-server
# Conflicts: # src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationInitResponse.java # src/main/java/club/joylink/xiannccda/ats/message/line3/rep/TrainIndicationUpdateResponse.java # src/main/java/club/joylink/xiannccda/dto/protos/WsMessageProto.java
This commit is contained in:
commit
465bb1c96d
@ -5,20 +5,13 @@ import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor;
|
||||
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus.TRAIN_MODE;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.DeviceStatusBitmapResponse.DeviceTypeEntity;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.NccWindow;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
|
||||
import com.google.common.base.CaseFormat;
|
||||
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.Arrays;
|
||||
import java.util.Optional;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -84,17 +77,9 @@ public class TrainIndicationInitResponse extends MessageResponse {
|
||||
builder.setOtpTime(trainCell.getOtpTime());
|
||||
}
|
||||
if (trainCell.getMode() != null) {
|
||||
Optional<TRAIN_MODE> modeAttr =
|
||||
Arrays.stream(TRAIN_MODE.values()).filter(t -> t.is(trainCell.getMode())).findFirst();
|
||||
if (modeAttr.isPresent()) {
|
||||
String fieldName =
|
||||
CaseFormat.UPPER_UNDERSCORE.to(
|
||||
CaseFormat.LOWER_CAMEL, modeAttr.get().name().toLowerCase());
|
||||
TrainMode.Builder trainModeBuilder = TrainMode.newBuilder();
|
||||
trainModeBuilder.setField(
|
||||
trainModeBuilder.getDescriptorForType().findFieldByName(fieldName), true);
|
||||
builder.setMode(trainModeBuilder);
|
||||
}
|
||||
DeviceStatusProto.TrainMode.Builder trainMode =
|
||||
DeviceStatusConvertor.convert(DeviceStatus.TRAIN_MODE.class, trainCell.getMode());
|
||||
builder.setMode(trainMode.build());
|
||||
}
|
||||
if (trainCell.getArriveTime() != null) {
|
||||
builder.setArriveTime(trainCell.getArriveTime().getNano());
|
||||
|
@ -3,7 +3,12 @@ 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.NccWindow;
|
||||
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@ -68,4 +73,21 @@ public class TrainIndicationRemoveResponse extends MessageResponse {
|
||||
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET).trim();
|
||||
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Builder> generateProto() throws Exception {
|
||||
TrainRemove.Builder trainRemove = TrainRemove.newBuilder();
|
||||
trainRemove.setLineId(this.lineId);
|
||||
trainRemove.setRtuId(this.rtuId);
|
||||
NccWindow.Builder window = NccWindow.newBuilder();
|
||||
window.setNccWindow(this.nccWindow);
|
||||
window.setNccWinOffset(this.nccWindowOffset);
|
||||
trainRemove.setWindow(window);
|
||||
trainRemove.setDeviceType(DeviceStatusProto.DeviceType.forNumber(this.devType.getVal()));
|
||||
trainRemove.setDevName(this.devName);
|
||||
trainRemove.setTrainIndex(this.trainIndex);
|
||||
trainRemove.setGroupId(this.groupId);
|
||||
return List.of(trainRemove);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||
import club.joylink.xiannccda.ats.message.convertor.DeviceStatusConvertor;
|
||||
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
||||
@ -102,19 +103,9 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
|
||||
train.setOtpTime(this.optTime);
|
||||
train.setArriveTime(this.arriveTime.toEpochSecond(ZoneOffset.ofHours(8)) * 1000);
|
||||
train.setDepartTime(this.departTime.toEpochSecond(ZoneOffset.ofHours(8)) * 1000);
|
||||
if (this.mode != null) {
|
||||
Optional<TRAIN_MODE> modeAttr =
|
||||
Arrays.stream(TRAIN_MODE.values()).filter(t -> t.is(this.mode)).findFirst();
|
||||
if (modeAttr.isPresent()) {
|
||||
String fieldName =
|
||||
CaseFormat.UPPER_UNDERSCORE.to(
|
||||
CaseFormat.LOWER_CAMEL, modeAttr.get().name().toLowerCase());
|
||||
TrainMode.Builder trainModeBuilder = TrainMode.newBuilder();
|
||||
trainModeBuilder.setField(
|
||||
trainModeBuilder.getDescriptorForType().findFieldByName(fieldName), true);
|
||||
train.setMode(trainModeBuilder);
|
||||
}
|
||||
}
|
||||
DeviceStatusProto.TrainMode.Builder trainMode =
|
||||
DeviceStatusConvertor.convert(DeviceStatus.TRAIN_MODE.class, this.mode);
|
||||
train.setMode(trainMode.build());
|
||||
train.setSpeed(this.speed);
|
||||
train.setRate(this.rate);
|
||||
train.setRouteId(this.routeId);
|
||||
|
@ -11,6 +11,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
import com.google.protobuf.GeneratedMessageV3.Builder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
||||
@ -138,7 +139,7 @@ public class TrainRecordResponse extends MessageResponse {
|
||||
builder.setRecordType(this.getRecordType());
|
||||
}
|
||||
if (this.getRecordTime() != null) {
|
||||
builder.setRecordTime(this.getRecordTime().getNano());
|
||||
builder.setRecordTime(this.getRecordTime().toEpochSecond(ZoneOffset.ofHours(8)) * 1000);
|
||||
}
|
||||
return Lists.newArrayList(builder);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user