|
|
@@ -0,0 +1,47 @@
|
|
|
+package top.haijunit.train.service;
|
|
|
+
|
|
|
+import lombok.Getter;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import top.haijunit.train.constant.DirectionEnum;
|
|
|
+import top.haijunit.train.domain.entity.SignEntity;
|
|
|
+import top.haijunit.train.utils.CalculateUtil;
|
|
|
+
|
|
|
+import java.time.Duration;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.LinkedList;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author zhanghaijun
|
|
|
+ * @date 2023/11/13 17:19
|
|
|
+ * @description 列车运行
|
|
|
+ */
|
|
|
+@Getter
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class TrainRun {
|
|
|
+
|
|
|
+ private final String trainCode;
|
|
|
+ private final LocalDateTime data;
|
|
|
+ private final double mileage;
|
|
|
+ private final double speed = 0.00;
|
|
|
+ private final double speedFull = 0.00;
|
|
|
+ // 方向
|
|
|
+ private DirectionEnum direction;
|
|
|
+ // 进路区间
|
|
|
+ private LinkedList<SignEntity> distanceList;
|
|
|
+
|
|
|
+ public void run() {
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ Duration duration = Duration.between(this.getData(), now);
|
|
|
+ long seconds = duration.getSeconds();
|
|
|
+ double m = CalculateUtil.calculateDistance(this.getMileage(), this.getSpeed(), this.getSpeedFull(), seconds);
|
|
|
+ // TODO
|
|
|
+ for (SignEntity sign : distanceList) {
|
|
|
+ if (direction.getCompare().applyAsDouble(sign.getKilometer(), m) > 0) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|