diff --git a/src/main/java/com/chint/domain/aggregates/order/Leg.java b/src/main/java/com/chint/domain/aggregates/order/Leg.java index e6d906f0..61681499 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Leg.java +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -101,9 +101,7 @@ public class Leg { } public LegEvent getLastLegEvent() { - return this.eventList.stream() - .max(Comparator.comparing(LegEvent::getHappenTime)) - .orElse(null); + return this.eventList.get(this.eventList.size() - 1); } public OrderDetail getLastOrderDetail() { diff --git a/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java b/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java index 07711f8b..8139a41c 100644 --- a/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java +++ b/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java @@ -111,10 +111,10 @@ public class OrderDetail { } public OrderEvent getLastEvent() { - return this.orderEventList - .stream() - .max(Comparator.comparingLong(OrderEvent::getOrderEventId)) - .orElseThrow(() -> new NotFoundException(NOT_FOUND)); + return this.orderEventList.get(this.orderEventList.size() - 1); +// .stream() +// .max(Comparator.comparingLong(OrderEvent::getOrderEventId)) +// .orElseThrow(() -> new NotFoundException(NOT_FOUND)); } public OrderDetail price(String price) { diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java index 926ec078..15dbfdb8 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -27,7 +27,6 @@ import org.springframework.data.relational.core.mapping.Table; import java.time.Duration; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -185,12 +184,9 @@ public class RouteOrder extends BaseEntity { } if (this.approveEvents != null && !this.approveEvents.isEmpty()) { - ApprovalEvent approvalEvent = this.approveEvents.stream() - .max(Comparator.comparingLong(ApprovalEvent::getApprovalEventId)) - .get() - .reloadStatus(); - this.approvalStatus = approvalEvent.getEventName(); - this.approvalStatusCode = approvalEvent.getEventType(); + ApprovalEvent lastApprovalEvent = getLastApprovalEvent(); + this.approvalStatus = lastApprovalEvent.getEventName(); + this.approvalStatusCode = lastApprovalEvent.getEventType(); } this.getOrderDetails().forEach(OrderDetail::reloadStatus); @@ -198,6 +194,9 @@ public class RouteOrder extends BaseEntity { return this; } + private ApprovalEvent getLastApprovalEvent() { + return this.approveEvents.get(this.approveEvents.size() - 1); + } public RouteOrder reloadStatus(OrderSaveData orderSaveData) { // 重新加载所有Leg的状态