返回数据调整

This commit is contained in:
tiger_zhou 2023-06-30 17:14:23 +08:00
parent f7879fe0d7
commit 9cedb63b0e
3 changed files with 26 additions and 35 deletions

View File

@ -70,22 +70,21 @@ 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()) {
String destination = this.createPlace("lineId", lineId);
if (deviceDataSource.isStatusVOEmpty()) {
messages.add(new TopicMessage(destination, null));
continue;
}
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()));
}
}
if (CollectionUtils.isEmpty(messages)) {
return null;
}
return messages;
}

View File

@ -53,13 +53,17 @@ 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);
if (CollectionUtils.isEmpty(trainInfoData.getAllTrain())) {
messages.add(new TopicMessage(destination, null));
continue;
}
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");
@ -67,23 +71,11 @@ public class LineTrainMessageServer implements IMessageServer {
trainInfoData.reput(trainInfo);
trainMessage.addTrainInfo(trainInfo);
}
String destination = this.createPlace("lineId", lineId);
messages.add(new TopicMessage(destination, trainMessage.build().toByteArray()));
}
}
if (CollectionUtils.isEmpty(messages)) {
return null;
}
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