From 4993beffc1b6bf0536848db92107687b60190c7d Mon Sep 17 00:00:00 2001 From: lulz1 Date: Sat, 9 Mar 2024 13:13:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=98=E6=9B=B4=E8=A1=8C?= =?UTF-8?q?=E7=A8=8Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/chint/domain/aggregates/order/Leg.java | 4 +--- .../chint/domain/aggregates/order/OrderDetail.java | 8 ++++---- .../chint/domain/aggregates/order/RouteOrder.java | 13 ++++++------- 3 files changed, 11 insertions(+), 14 deletions(-) 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的状态