From 49478aa83b992aabef67e480eca9cf88fec4348b Mon Sep 17 00:00:00 2001 From: lulz1 Date: Sat, 9 Mar 2024 12:34:14 +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 --- .../services/OrderApplicationService.java | 14 ++++++-------- .../com/chint/domain/aggregates/order/Leg.java | 4 +--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/chint/application/services/OrderApplicationService.java b/src/main/java/com/chint/application/services/OrderApplicationService.java index 2ed566e0..f7cfc534 100644 --- a/src/main/java/com/chint/application/services/OrderApplicationService.java +++ b/src/main/java/com/chint/application/services/OrderApplicationService.java @@ -86,13 +86,11 @@ public class OrderApplicationService { RouteOrder order = Optional.ofNullable(routeRepository.queryById(addLegData.getRouteId())) .orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND)); order.reloadStatus(); - checkLegDataTime(addLegData, order); - LegData legData = addLegData.getLegData(); List legs = processLegData(legData, order); orderDomainService.queryLocation(legs); - RouteOrder routeOrder = orderDomainService.saveOrder(order); + legs.forEach(leg -> { leg.reloadStatus(); legDomainService.addPreEvent(leg); @@ -108,14 +106,14 @@ public class OrderApplicationService { leg = legDomainService.addApproveEvent(leg); } - legRepository.save(leg); + order.addLeg(leg); if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) { - Command.of(BPMLegChangeCommand.class).routeOrder(order).newleg(leg.reloadStatus()).routeId(routeOrder.getRouteId()).changeType(0).sendToQueue(); + Command.of(BPMLegChangeCommand.class).routeOrder(order).newleg(leg.reloadStatus()).routeId(order.getRouteId()).changeType(0).sendToQueue(); } + + }); - - //异步操作-如果是当前的状态已经进行过匹配,那么就要订单同步到供应商一次 // if (order.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) { // CompletableFuture.runAsync(() -> { @@ -125,7 +123,7 @@ public class OrderApplicationService { // .sendToQueue(); // }); // } - return routeOrder; // 仅在所有操作完成后保存一次 + return orderDomainService.saveOrder(order); // 仅在所有操作完成后保存一次 } @Transactional 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 3daa304e..e6d906f0 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Leg.java +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -118,9 +118,7 @@ public class Leg { this.legStatus = LegConstant.LEG_STATUS_PREPARE; } else { // Find the latest event based on the maximum id - LegEvent latestEvent = this.eventList.stream() - .max(Comparator.comparingLong(LegEvent::getLegEventId)) - .orElse(null); + LegEvent latestEvent = this.getLastLegEvent(); // Set the legStatus based on the type of the latest event this.legStatus = latestEvent.getEventType();