修改股道视图删除数据bug

This commit is contained in:
joylink_zhangsai 2022-07-08 17:29:57 +08:00
parent a8a5a4c884
commit dca02becfc
2 changed files with 10 additions and 15 deletions

View File

@ -103,9 +103,10 @@ public class CTCLogicLoop {
private void trackViewUpdate(Simulation simulation) {
CtcRepository ctcRepository = simulation.getCtcRepository();
for (TrackView trackView : ctcRepository.getTrackViewMap().values()) {
Set<String> deleteTripNumbers = new HashSet<>();
for (Map<String, TrackView.Line> lineMap : trackView.getTrackLineMap().values()) {
for (TrackView.Line line : lineMap.values()) {
Iterator<TrackView.Line> lineIterator = lineMap.values().iterator();
while (lineIterator.hasNext()) {
TrackView.Line line = lineIterator.next();
int remain = line.getRemain2Delete();
if (remain == -1) {
TrackView.Process process = line.getProcess();
@ -115,16 +116,13 @@ public class CTCLogicLoop {
} else {
remain -= LOGIC_RATE;
if (remain <= 0) {
deleteTripNumbers.add(line.getTripNumber());
lineIterator.remove();
} else {
line.setRemain2Delete(remain);
}
}
}
}
for (String tn : deleteTripNumbers) {
trackView.getTrackLineMap().remove(tn);
}
}
}

View File

@ -1,15 +1,16 @@
package club.joylink.rtss.simulation.cbtc.CTC.data;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
@ -244,18 +245,14 @@ public class TrackView {
public boolean isArrive() {
if (receivingRoute != null) {
if (StringUtils.hasText(receivingRoute.getItem().getActualTime())) {
return true;
}
return receivingRoute.getItem().isFinish();
}
return false;
}
public boolean isDeparture() {
if (departureRoute != null) {
if (StringUtils.hasText(departureRoute.getItem().getActualTime())) {
return true;
}
return departureRoute.getItem().isFinish();
}
return false;
}