diff --git a/src/main/java/club/joylink/xiannccda/ws/LineDeviceMessageServer.java b/src/main/java/club/joylink/xiannccda/ws/LineDeviceMessageServer.java index 404103a..8461490 100644 --- a/src/main/java/club/joylink/xiannccda/ws/LineDeviceMessageServer.java +++ b/src/main/java/club/joylink/xiannccda/ws/LineDeviceMessageServer.java @@ -70,21 +70,20 @@ public class LineDeviceMessageServer implements IMessageServer { @Override public List onTick() { if (this.lineIdSet.isEmpty()) { - return null; + return Collections.emptyList(); } List 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; } diff --git a/src/main/java/club/joylink/xiannccda/ws/LineTrainMessageServer.java b/src/main/java/club/joylink/xiannccda/ws/LineTrainMessageServer.java index 8cd75c4..9d1f830 100644 --- a/src/main/java/club/joylink/xiannccda/ws/LineTrainMessageServer.java +++ b/src/main/java/club/joylink/xiannccda/ws/LineTrainMessageServer.java @@ -53,37 +53,29 @@ public class LineTrainMessageServer implements IMessageServer { @Override public List onTick() { if (this.lineIdSet.isEmpty()) { - return null; + return Collections.emptyList(); } List 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 maper = trainMessage.getAllFields(); - System.out.println(maper); - maper.forEach((k, v) -> { - System.out.println(k.getName()); - }); - } + } diff --git a/xian-ncc-da-message b/xian-ncc-da-message index 9a7b4b7..549aa2e 160000 --- a/xian-ncc-da-message +++ b/xian-ncc-da-message @@ -1 +1 @@ -Subproject commit 9a7b4b7a3a912970197155a149a9da463d2a68fc +Subproject commit 549aa2ec10bffe292a1a68e278ae824a8502db0b