【列车运行方向判断逻辑增加车次号判断】
This commit is contained in:
parent
535d4dce08
commit
e209801521
@ -15,6 +15,7 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/** 线网的列车数据,一些公共方法 */
|
/** 线网的列车数据,一些公共方法 */
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -67,32 +68,41 @@ public abstract class LineNetTrainComMethod {
|
|||||||
* 根据目的码确定方向,并确定公里标
|
* 根据目的码确定方向,并确定公里标
|
||||||
*
|
*
|
||||||
* @param obj 要设置的对象
|
* @param obj 要设置的对象
|
||||||
|
* @param globalId 车次号
|
||||||
* @param destinationCode 目的码
|
* @param destinationCode 目的码
|
||||||
* @param type 设备类型
|
* @param type 设备类型
|
||||||
* @param name 设备名称
|
* @param name 设备名称
|
||||||
*/
|
*/
|
||||||
public static void setTrainDirectionAndKilometerCode(
|
public static void setTrainDirectionAndKilometerCode(
|
||||||
WsMessageProto.WsLineNetTrainOffsetMessage.Builder obj,
|
WsMessageProto.WsLineNetTrainOffsetMessage.Builder obj,
|
||||||
|
String globalId,
|
||||||
String destinationCode,
|
String destinationCode,
|
||||||
DeviceType type,
|
DeviceType type,
|
||||||
String name) {
|
String name) {
|
||||||
|
TrainRunDirection direction = null;
|
||||||
DeviceKilometer.Builder deviceKm = getDeviceKM(obj.getLineId(), type, name);
|
DeviceKilometer.Builder deviceKm = getDeviceKM(obj.getLineId(), type, name);
|
||||||
if (deviceKm == null) {
|
if (deviceKm != null && StringUtils.isNoneEmpty(destinationCode)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
DeviceKilometer.Builder destinationKm = getDirectionCodeKM(obj.getLineId(), destinationCode);
|
DeviceKilometer.Builder destinationKm = getDirectionCodeKM(obj.getLineId(), destinationCode);
|
||||||
if (destinationKm == null) {
|
// 目的地最大公里标大于设备最大公里标,上行
|
||||||
return;
|
if (destinationKm != null) {
|
||||||
|
direction =
|
||||||
|
destinationKm.getMaxKilometer() > deviceKm.getMaxKilometer()
|
||||||
|
? TrainRunDirection.UP
|
||||||
|
: TrainRunDirection.DOWN;
|
||||||
}
|
}
|
||||||
// 确定方向
|
}
|
||||||
if (destinationKm.getMaxKilometer() > deviceKm.getMaxKilometer()) { // 目的地最大公里标大于设备最大公里标,上行
|
// 如果目的码都没有确定方向,则使用车次确定方向
|
||||||
obj.setDir(TrainRunDirection.UP.getDir());
|
if (direction == null && StringUtils.isNoneEmpty(globalId)) {
|
||||||
} else {
|
direction = TrainRunDirection.match(Integer.parseInt(globalId.substring(0, 1)));
|
||||||
obj.setDir(TrainRunDirection.DOWN.getDir());
|
}
|
||||||
|
if (direction != null) {
|
||||||
|
obj.setDir(direction.getDir());
|
||||||
}
|
}
|
||||||
// 赋值公里标
|
// 赋值公里标
|
||||||
|
if (deviceKm != null) {
|
||||||
obj.setKilometerCode(selectDeviceKilometerCode(obj.getDir(), deviceKm));
|
obj.setKilometerCode(selectDeviceKilometerCode(obj.getDir(), deviceKm));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设备的公里标
|
* 获取设备的公里标
|
||||||
@ -165,5 +175,14 @@ public abstract class LineNetTrainComMethod {
|
|||||||
public boolean isMatch(int dir) {
|
public boolean isMatch(int dir) {
|
||||||
return this.dir == dir;
|
return this.dir == dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TrainRunDirection match(int dir) {
|
||||||
|
for (TrainRunDirection t : TrainRunDirection.values()) {
|
||||||
|
if (dir == t.getDir()) {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
|
|||||||
import club.joylink.xiannccda.ats.message.MessageData;
|
import club.joylink.xiannccda.ats.message.MessageData;
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
import club.joylink.xiannccda.ats.message.MessageId;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationInitResponse;
|
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationInitResponse;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationInitResponse.TrainCell;
|
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationInitResponse.TrainCell;
|
||||||
@ -36,7 +35,11 @@ public class LineNetTrainInitConvertor extends DeviceStatusConvertor {
|
|||||||
offset.setTrainIndex(trainCell.getTrainIndex()); // 列车标示号,全线唯一
|
offset.setTrainIndex(trainCell.getTrainIndex()); // 列车标示号,全线唯一
|
||||||
offset.setGroupId(trainCell.getGroupId()); // 车组号
|
offset.setGroupId(trainCell.getGroupId()); // 车组号
|
||||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(
|
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(
|
||||||
offset, trainCell.getDestinationId(), trainCell.getDevType(), trainCell.getDevName());
|
offset,
|
||||||
|
trainCell.getGlobalId(),
|
||||||
|
trainCell.getDestinationId(),
|
||||||
|
trainCell.getDevType(),
|
||||||
|
trainCell.getDevName());
|
||||||
offset.setShow(offset.getKilometerCode() != 0);
|
offset.setShow(offset.getKilometerCode() != 0);
|
||||||
buildList.add(offset);
|
buildList.add(offset);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package club.joylink.xiannccda.ats.message.collect.convertor;
|
|||||||
import club.joylink.xiannccda.ats.message.MessageData;
|
import club.joylink.xiannccda.ats.message.MessageData;
|
||||||
import club.joylink.xiannccda.ats.message.MessageId;
|
import club.joylink.xiannccda.ats.message.MessageId;
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusConvertor;
|
||||||
|
|
||||||
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
import club.joylink.xiannccda.ats.message.collect.DeviceStatusDataOperate;
|
||||||
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationUpdateResponse;
|
import club.joylink.xiannccda.ats.message.line3.rep.TrainIndicationUpdateResponse;
|
||||||
import club.joylink.xiannccda.dto.protos.WsMessageProto;
|
import club.joylink.xiannccda.dto.protos.WsMessageProto;
|
||||||
@ -36,7 +35,11 @@ public class LineNetTrainUpdateConvertor extends DeviceStatusConvertor {
|
|||||||
offset.setGroupId(response.getGroupId()); // 车组号
|
offset.setGroupId(response.getGroupId()); // 车组号
|
||||||
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
LineNetTrainComMethod.getDeviceStatusById(offset); // 合并老旧数据
|
||||||
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(
|
LineNetTrainComMethod.setTrainDirectionAndKilometerCode(
|
||||||
offset, response.getDestinationId(), response.getDevType(), response.getDevName());
|
offset,
|
||||||
|
response.getGlobalId(),
|
||||||
|
response.getDestinationId(),
|
||||||
|
response.getDevType(),
|
||||||
|
response.getDevName());
|
||||||
offset.setShow(offset.getKilometerCode() != 0);
|
offset.setShow(offset.getKilometerCode() != 0);
|
||||||
buildList.add(offset);
|
buildList.add(offset);
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit b3b9885e2784cdad86901303e0bb9abf28c35e10
|
Subproject commit c9a07e75f06e8247d33f9e08c52d5045f1db2bc2
|
Loading…
Reference in New Issue
Block a user