From 5f96250f53ce57116cfc43139326c92952ee4f0b Mon Sep 17 00:00:00 2001 From: lulz1 Date: Sat, 9 Mar 2024 12:57:23 +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 --- pom.xml | 5 +++++ .../application/out/LocationController.java | 1 - .../services/OrderApplicationService.java | 17 +++-------------- .../java/com/chint/RouteApplicationTests.java | 13 ++----------- 4 files changed, 10 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index f69df198..285c7937 100644 --- a/pom.xml +++ b/pom.xml @@ -88,6 +88,11 @@ 1.0 + + org.springframework.boot + spring-boot-starter-cache + + diff --git a/src/main/java/com/chint/application/out/LocationController.java b/src/main/java/com/chint/application/out/LocationController.java index 0e77f31d..b9405863 100644 --- a/src/main/java/com/chint/application/out/LocationController.java +++ b/src/main/java/com/chint/application/out/LocationController.java @@ -89,6 +89,5 @@ public class LocationController { dto.setInternationalCitys(internationalLocationRes); return Result.Success(SUCCESS, dto); - } } \ No newline at end of file diff --git a/src/main/java/com/chint/application/services/OrderApplicationService.java b/src/main/java/com/chint/application/services/OrderApplicationService.java index f7cfc534..a28fb6f1 100644 --- a/src/main/java/com/chint/application/services/OrderApplicationService.java +++ b/src/main/java/com/chint/application/services/OrderApplicationService.java @@ -90,7 +90,7 @@ public class OrderApplicationService { 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); @@ -106,24 +106,13 @@ public class OrderApplicationService { leg = legDomainService.addApproveEvent(leg); } - order.addLeg(leg); + legRepository.save(leg); if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) { Command.of(BPMLegChangeCommand.class).routeOrder(order).newleg(leg.reloadStatus()).routeId(order.getRouteId()).changeType(0).sendToQueue(); } - - }); - //异步操作-如果是当前的状态已经进行过匹配,那么就要订单同步到供应商一次 -// if (order.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) { -// CompletableFuture.runAsync(() -> { -// Command -// .of(LegSyncCommand.class) -// .data(SyncLegData.of(routeOrder.getRouteId(), routeOrder.getSupplierName())) -// .sendToQueue(); -// }); -// } - return orderDomainService.saveOrder(order); // 仅在所有操作完成后保存一次 + return routeOrder; // 仅在所有操作完成后保存一次 } @Transactional diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index f582a908..4bf43e07 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -234,18 +234,9 @@ class RouteApplicationTests { locationRepository.saveAll(all); } - // @Test +// @Test void deleteRouteOrder() { - routeRepository.deleteById(15L); - routeRepository.deleteById(17L); - routeRepository.deleteById(18L); - routeRepository.deleteById(19L); - routeRepository.deleteById(19L); - routeRepository.deleteById(19L); - routeRepository.deleteById(19L); - routeRepository.deleteById(19L); - routeRepository.deleteById(19L); - routeRepository.deleteById(19L); + routeRepository.deleteById(785L); } // @Test