From eaf30840a1db2ed08da8803190dc6b90b0e53574 Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Fri, 9 Sep 2022 08:51:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF=E5=88=97?= =?UTF-8?q?=E8=BD=A6=E4=BD=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/service/TrainPositionService.java | 4 +++- src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java index 2cdeae904..c0ba6839a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/TrainPositionService.java @@ -36,6 +36,8 @@ public class TrainPositionService { */ public void initTrainOrUpdate(String mapName,String json){ TrainPosition tp = JsonUtils.read(json, TrainPosition.class); + tp.setReceiveTime(System.currentTimeMillis()); + log.info(tp.toString()); List simulationList = this.findSimulationList(mapName); if(Objects.equals(true, CollectionUtils.isEmpty(simulationList))){ log.error("未找到对应的类型的仿真,无法渲染列车位置 param:{}",json); @@ -92,7 +94,7 @@ public class TrainPositionService { list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin())) .sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList()); -// simulationManager.putSectionDirCache(key,list); + simulationManager.putSectionDirCache(key,list); } return list; } diff --git a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java index f71b8eee4..9062b33e6 100644 --- a/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java +++ b/src/main/java/club/joylink/rtss/vo/ws/TrainPosition.java @@ -1,13 +1,14 @@ package club.joylink.rtss.vo.ws; import club.joylink.rtss.simulation.cbtc.data.map.Section; +import club.joylink.rtss.util.JsonUtils; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; @Data @NoArgsConstructor -@ToString + public class TrainPosition { private String groupNum; /** @@ -15,7 +16,7 @@ public class TrainPosition { */ private int direction; private float location; - + private Long receiveTime; public Section.SectionRoadType getRoadType(){ Section.SectionRoadType type = Section.SectionRoadType.LEFT; if(this.direction == 1){ @@ -26,4 +27,8 @@ public class TrainPosition { public boolean isRight(){ return this.direction == 1; } + @Override + public String toString(){ + return JsonUtils.writeValueNullableFieldAsString(this); + } }