应急ws调整
This commit is contained in:
parent
6d37169068
commit
6a0a8477f2
@ -30,7 +30,7 @@ public class TrainPositionService {
|
||||
public void initTrainOrUpdate(String mapName,String json){
|
||||
TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
|
||||
tp.setReceiveTime(System.currentTimeMillis());
|
||||
log.info(json);
|
||||
log.debug(json);
|
||||
// SocketMessageVO<TrainPosition> vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
|
||||
// this.messageService.send(vo);
|
||||
this.timeOverService.addTrainAccept(mapName,tp);
|
||||
|
@ -44,17 +44,22 @@ public class EnvLoggerFileTest {
|
||||
}
|
||||
});
|
||||
}
|
||||
public List<TrainPosition> query(List<TrainPosition> list, List<String> groups){
|
||||
List<TrainPosition> newList = list.stream().filter(d->groups.contains(d.getGroupNum()) ).collect(Collectors.toList());
|
||||
|
||||
return newList;
|
||||
}
|
||||
public List<TrainPosition> query(List<TrainPosition> list, List<String> groups, Section.SectionRoadType roadType){
|
||||
List<TrainPosition> newList = list.stream().filter(d->groups.contains(d.getGroupNum()) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
|
||||
return newList;
|
||||
}
|
||||
|
||||
public List<TrainPosition> query(List<TrainPosition> list, String groupNum, Section.SectionRoadType roadType){
|
||||
List<TrainPosition> newList = list.stream().filter(d-> Objects.equals(d.getGroupNum(),groupNum) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
|
||||
return newList;
|
||||
}
|
||||
public List<TrainPosition> query(List<TrainPosition> list,String groupNum){
|
||||
List<TrainPosition> newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum)).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
|
||||
List<TrainPosition> newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum)).collect(Collectors.toList());
|
||||
return newList;
|
||||
}
|
||||
|
||||
|
@ -40,10 +40,11 @@ public class StompTest {
|
||||
e.printStackTrace();
|
||||
}
|
||||
EnvLoggerFileTest lt = new EnvLoggerFileTest();
|
||||
List<TrainPosition> list = lt.readFile("d:\\spring.log2");
|
||||
List<TrainPosition> list = lt.readFile("d:\\spring.log");
|
||||
// List<TrainPosition> list = lt.readSource("d:\\t.txt");
|
||||
// runToLeft(stompSession,"001");
|
||||
// runToRight(stompSession,"002");
|
||||
// list = lt.query(list,"031");
|
||||
// list = lt.query(list,"004", Section.SectionRoadType.LEFT);
|
||||
// list = lt.query(list, Lists.newArrayList("015","037"), Section.SectionRoadType.RIGHT);
|
||||
send(stompSession,list);
|
||||
@ -87,7 +88,7 @@ public class StompTest {
|
||||
}
|
||||
public static void send(StompSession stompSession,List<TrainPosition> list){
|
||||
|
||||
for (int i = 25; i < list.size(); i++) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
// for (int i = 22; i < 23; i++) {
|
||||
TrainPosition tp = list.get(i);
|
||||
tp.setCloseDoor(false);
|
||||
@ -95,21 +96,21 @@ public class StompTest {
|
||||
tp.setSpeed(Float.valueOf(i));
|
||||
// tp.setLocation(tp.getLocation() - 500);
|
||||
String val = JsonUtils.writeValueNullableFieldAsString(tp);
|
||||
Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
|
||||
ZoneId zone = ZoneId.systemDefault();
|
||||
String d = LocalDateTime.ofInstant(instant, zone).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
System.out.println(d + " ->" + i +" ->" + val);
|
||||
// Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
|
||||
// ZoneId zone = ZoneId.systemDefault();
|
||||
// String d = LocalDateTime.ofInstant(instant, zone).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
System.out.println(i +" ->" + val);
|
||||
stompSession.send("/app/武汉8号线/trainPosition",val.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
if(i > 0){
|
||||
TrainPosition old = list.get(i - 1);
|
||||
try {
|
||||
long sleepTime = (tp.getReceiveTime() - old.getReceiveTime());
|
||||
if(sleepTime > 10000){
|
||||
sleepTime = sleepTime / 1000;
|
||||
}
|
||||
System.out.println("index:" + i + "sleep:"+sleepTime);
|
||||
TimeUnit.MILLISECONDS.sleep(sleepTime);
|
||||
// long sleepTime = (tp.getReceiveTime() - old.getReceiveTime());
|
||||
// if(sleepTime > 10000){
|
||||
// sleepTime = sleepTime / 1000;
|
||||
// }
|
||||
// System.out.println("index:" + i + "sleep:"+sleepTime);
|
||||
TimeUnit.MILLISECONDS.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user