diff --git a/yudao-module-mqtt/yudao-module-mqtt-api/src/main/java/cn/iocoder/yudao/module/mqtt/api/path/dto/PositionMapLineDTO.java b/yudao-module-mqtt/yudao-module-mqtt-api/src/main/java/cn/iocoder/yudao/module/mqtt/api/path/dto/PositionMapLineDTO.java index 56ffffc7b..c1df7f708 100644 --- a/yudao-module-mqtt/yudao-module-mqtt-api/src/main/java/cn/iocoder/yudao/module/mqtt/api/path/dto/PositionMapLineDTO.java +++ b/yudao-module-mqtt/yudao-module-mqtt-api/src/main/java/cn/iocoder/yudao/module/mqtt/api/path/dto/PositionMapLineDTO.java @@ -6,6 +6,9 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Arrays; +import java.util.List; + @Data @Builder @NoArgsConstructor @@ -109,67 +112,46 @@ public class PositionMapLineDTO { private Integer ppToward; + private static final List ANTI_LIST = Arrays.asList(1, 3, 6); + private static final List WHATEVER_LIST = Arrays.asList(4, 7, 8); + /** * 双向车道 反向行走变更车头朝向 - * + *

* 车头朝向(0:正正 1:正反 2:反正 3:反反 4正随 5随正 6随反 7反随 8随随 * * @param toward * @return */ public Integer changeToward(Integer toward) { - if (toward == 0) { - return 0; - } else if (toward == 1) { - return 1; - } else if (toward == 2) { - return 0; - } else if (toward == 3) { - return 1; - } else if (toward == 4) { - return 2; - } else if (toward == 5) { - return 0; - } else if (toward == 6) { - return 1; - } else if (toward == 7) { - return 2; - } else if (toward == 8) { - return 2; - } else { - return 0; + int ppToward = 0; + if (ANTI_LIST.contains(toward)) { + ppToward = 1; + } else if (WHATEVER_LIST.contains(toward)) { + ppToward = 2; } + return ppToward; } + + private static final List FIRST_ANTI_LIST = Arrays.asList(2, 3, 7); + private static final List FIRST_WHATEVER_LIST = Arrays.asList(5, 6, 8); + /** * 双向车道 反向行走变更车头朝向 - * + *

* 车头朝向(0:正正 1:正反 2:反正 3:反反 4正随 5随正 6随反 7反随 8随随 * * @param toward * @return */ public Integer changeTowardFirst(Integer toward) { - if (toward == 0) { - return 0; - } else if (toward == 1) { - return 0; - } else if (toward == 2) { - return 1; - } else if (toward == 3) { - return 1; - } else if (toward == 4) { - return 0; - } else if (toward == 5) { - return 2; - } else if (toward == 6) { - return 2; - } else if (toward == 7) { - return 1; - } else if (toward == 8) { - return 2; - } else { - return 0; + int ppToward = 0; + if (FIRST_ANTI_LIST.contains(toward)) { + ppToward = 1; + } else if (FIRST_WHATEVER_LIST.contains(toward)) { + ppToward = 2; } + return ppToward; } }