|
|
@@ -66,13 +66,13 @@ public class TrainComputerService {
|
|
|
// 停车标数据
|
|
|
HashMap<Long, SignStopEntity> stopSignalMap = selectionService.getStopSignalMap(list.stream().map(SectionItem::getSectionId).collect(Collectors.toList()));
|
|
|
SectionItem currentSection = sectionOptional.get();
|
|
|
- BigDecimal currentAllOffset = NumberUtil.add(train.getOffset(), NumberUtil.mul(train.getDirection().getFactor(), distance.abs()));
|
|
|
+ BigDecimal currentOffset = NumberUtil.add(train.getOffset(), NumberUtil.mul(train.getDirection().getFactor(), distance.abs())).abs();
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SectionItem sectionItem = list.get(i);
|
|
|
SignStopEntity stopSign = stopSignalMap.get(sectionItem.getSectionId());
|
|
|
- if (null != stopSign) {
|
|
|
+ if (null != stopSign && train.getBlockId().equals(sectionItem.getSectionId())) {
|
|
|
// 存在停车标
|
|
|
- if (NumberUtil.isGreater(stopSign.getSelectionOff(), train.getOffset()) && NumberUtil.isLessOrEqual(stopSign.getSelectionOff(), currentAllOffset)) {
|
|
|
+ if (NumberUtil.isGreater(stopSign.getSelectionOff(), train.getOffset()) && NumberUtil.isLessOrEqual(stopSign.getSelectionOff(), currentOffset)) {
|
|
|
train.setSpeed(BigDecimal.ZERO);
|
|
|
train.setAcceleration(BigDecimal.ZERO);
|
|
|
train.setBlockId(sectionItem.getSectionId());
|
|
|
@@ -84,12 +84,12 @@ public class TrainComputerService {
|
|
|
}
|
|
|
}
|
|
|
if (i != list.size() - 1) {
|
|
|
- currentAllOffset = NumberUtil.sub(currentAllOffset, sectionItem.getSectionLength());
|
|
|
+ currentOffset = NumberUtil.sub(currentOffset, sectionItem.getSectionLength()).abs();
|
|
|
}
|
|
|
currentSection = sectionItem;
|
|
|
}
|
|
|
train.setSpeed(CalculatorUtil.velocity(train.getSpeed(), train.getAcceleration(), train.getUpdateTimeMillis(), nowMillis).abs());
|
|
|
- train.setOffset(currentAllOffset.abs());
|
|
|
+ train.setOffset(currentOffset);
|
|
|
train.setBlockId(currentSection.getSectionId());
|
|
|
train.setBlockNo(currentSection.getSectionName());
|
|
|
train.setDirection(currentSection.getDirection());
|