This commit is contained in:
weizhihong 2023-06-30 17:18:01 +08:00
commit 4c1c7ff020
3 changed files with 26 additions and 35 deletions

View File

@ -70,22 +70,21 @@ public class LineDeviceMessageServer implements IMessageServer {
@Override @Override
public List<TopicMessage> onTick() { public List<TopicMessage> onTick() {
if (this.lineIdSet.isEmpty()) { if (this.lineIdSet.isEmpty()) {
return null; return Collections.emptyList();
} }
List<TopicMessage> messages = Lists.newArrayList(); List<TopicMessage> messages = Lists.newArrayList();
for (String lineId : this.lineIdSet) { for (String lineId : this.lineIdSet) {
DeviceStatusData deviceDataSource = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.DEVICE); 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(); WsLineMessage.Builder msg = WsLineMessage.newBuilder();
fillBuilderFunction((field) -> deviceDataSource.getStatusVOMap().get(field), msg); fillBuilderFunction((field) -> deviceDataSource.getStatusVOMap().get(field), msg);
DeviceStatusDataOperate.clearStatusVOMap(DeviceStatusDataRepository.getDeviceStatusData(lineId)); DeviceStatusDataOperate.clearStatusVOMap(DeviceStatusDataRepository.getDeviceStatusData(lineId));
String destination = this.createPlace("lineId", lineId);
messages.add(new TopicMessage(destination, msg.build().toByteArray())); messages.add(new TopicMessage(destination, msg.build().toByteArray()));
} }
}
if (CollectionUtils.isEmpty(messages)) {
return null;
}
return messages; return messages;
} }

View File

@ -53,13 +53,17 @@ public class LineTrainMessageServer implements IMessageServer {
@Override @Override
public List<TopicMessage> onTick() { public List<TopicMessage> onTick() {
if (this.lineIdSet.isEmpty()) { if (this.lineIdSet.isEmpty()) {
return null; return Collections.emptyList();
} }
List<TopicMessage> messages = Lists.newArrayList(); List<TopicMessage> messages = Lists.newArrayList();
for (String lineId : this.lineIdSet) { for (String lineId : this.lineIdSet) {
String destination = this.createPlace("lineId", lineId);
TrainDataSource trainInfoData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.TRAIN); TrainDataSource trainInfoData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.TRAIN);
if (CollectionUtils.isEmpty(trainInfoData.getAllTrain())) {
messages.add(new TopicMessage(destination, null));
continue;
}
WsLineTrainMessage.Builder trainMessage = WsLineTrainMessage.newBuilder(); WsLineTrainMessage.Builder trainMessage = WsLineTrainMessage.newBuilder();
if (!CollectionUtils.isEmpty(trainInfoData.getAllTrain())) {
for (TrainInfo.Builder trainInfo : trainInfoData.getAllTrain()) { for (TrainInfo.Builder trainInfo : trainInfoData.getAllTrain()) {
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainBlock", "block"); trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainBlock", "block");
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainRemove", "remove"); trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainRemove", "remove");
@ -67,23 +71,11 @@ public class LineTrainMessageServer implements IMessageServer {
trainInfoData.reput(trainInfo); trainInfoData.reput(trainInfo);
trainMessage.addTrainInfo(trainInfo); trainMessage.addTrainInfo(trainInfo);
} }
String destination = this.createPlace("lineId", lineId);
messages.add(new TopicMessage(destination, trainMessage.build().toByteArray())); messages.add(new TopicMessage(destination, trainMessage.build().toByteArray()));
} }
}
if (CollectionUtils.isEmpty(messages)) {
return null;
}
return messages; 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