返回数据调整
This commit is contained in:
parent
f7879fe0d7
commit
9cedb63b0e
@ -70,21 +70,20 @@ public class LineDeviceMessageServer implements IMessageServer {
|
||||
@Override
|
||||
public List<TopicMessage> onTick() {
|
||||
if (this.lineIdSet.isEmpty()) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<TopicMessage> messages = Lists.newArrayList();
|
||||
for (String lineId : this.lineIdSet) {
|
||||
DeviceStatusData deviceDataSource = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.DEVICE);
|
||||
if (!deviceDataSource.isStatusVOEmpty()) {
|
||||
WsLineMessage.Builder msg = WsLineMessage.newBuilder();
|
||||
fillBuilderFunction((field) -> deviceDataSource.getStatusVOMap().get(field), msg);
|
||||
DeviceStatusDataOperate.clearStatusVOMap(DeviceStatusDataRepository.getDeviceStatusData(lineId));
|
||||
String destination = this.createPlace("lineId", lineId);
|
||||
messages.add(new TopicMessage(destination, msg.build().toByteArray()));
|
||||
String destination = this.createPlace("lineId", lineId);
|
||||
if (deviceDataSource.isStatusVOEmpty()) {
|
||||
messages.add(new TopicMessage(destination, null));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(messages)) {
|
||||
return null;
|
||||
WsLineMessage.Builder msg = WsLineMessage.newBuilder();
|
||||
fillBuilderFunction((field) -> deviceDataSource.getStatusVOMap().get(field), msg);
|
||||
DeviceStatusDataOperate.clearStatusVOMap(DeviceStatusDataRepository.getDeviceStatusData(lineId));
|
||||
messages.add(new TopicMessage(destination, msg.build().toByteArray()));
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
@ -53,37 +53,29 @@ public class LineTrainMessageServer implements IMessageServer {
|
||||
@Override
|
||||
public List<TopicMessage> onTick() {
|
||||
if (this.lineIdSet.isEmpty()) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<TopicMessage> messages = Lists.newArrayList();
|
||||
for (String lineId : this.lineIdSet) {
|
||||
String destination = this.createPlace("lineId", lineId);
|
||||
TrainDataSource trainInfoData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.TRAIN);
|
||||
WsLineTrainMessage.Builder trainMessage = WsLineTrainMessage.newBuilder();
|
||||
if (!CollectionUtils.isEmpty(trainInfoData.getAllTrain())) {
|
||||
for (TrainInfo.Builder trainInfo : trainInfoData.getAllTrain()) {
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainBlock", "block");
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainRemove", "remove");
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainRecord", "record");
|
||||
trainInfoData.reput(trainInfo);
|
||||
trainMessage.addTrainInfo(trainInfo);
|
||||
}
|
||||
String destination = this.createPlace("lineId", lineId);
|
||||
messages.add(new TopicMessage(destination, trainMessage.build().toByteArray()));
|
||||
if (CollectionUtils.isEmpty(trainInfoData.getAllTrain())) {
|
||||
messages.add(new TopicMessage(destination, null));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(messages)) {
|
||||
return null;
|
||||
WsLineTrainMessage.Builder trainMessage = WsLineTrainMessage.newBuilder();
|
||||
for (TrainInfo.Builder trainInfo : trainInfoData.getAllTrain()) {
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainBlock", "block");
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainRemove", "remove");
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainRecord", "record");
|
||||
trainInfoData.reput(trainInfo);
|
||||
trainMessage.addTrainInfo(trainInfo);
|
||||
}
|
||||
|
||||
messages.add(new TopicMessage(destination, trainMessage.build().toByteArray()));
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
WsLineTrainMessage.Builder trainMessage = WsLineTrainMessage.newBuilder();
|
||||
trainMessage.addTrainInfo(TrainInfo.newBuilder());
|
||||
Map<FieldDescriptor, Object> maper = trainMessage.getAllFields();
|
||||
System.out.println(maper);
|
||||
maper.forEach((k, v) -> {
|
||||
System.out.println(k.getName());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 9a7b4b7a3a912970197155a149a9da463d2a68fc
|
||||
Subproject commit 549aa2ec10bffe292a1a68e278ae824a8502db0b
|
Loading…
Reference in New Issue
Block a user