From c0a5b62b0c6f612002926d7dd6e8a81bc41db5f4 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Tue, 9 Jul 2024 10:56:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E8=A1=8C=E7=A8=8B?= =?UTF-8?q?=E8=A7=84=E5=88=92=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/chint/application/queryies/OrderQuery.java | 9 +++++++++ .../chint/domain/repository/RouteRepository.java | 2 ++ .../com/chint/domain/service/LegDomainService.java | 13 +++---------- .../domain/service/leg_event/LegEventHandler.java | 3 ++- .../infrastructure/cache/RouteCacheService.java | 6 ++++-- .../repository/RouteRepositoryImpl.java | 9 +++++++++ src/test/java/com/chint/CTripTest.java | 2 +- 7 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index f6a2943f..f9570683 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -541,6 +541,15 @@ public class OrderQuery { if (routeOrder.getApprovalStatusCode() != APPROVAL_EVENT_PREPARE) { legItems.forEach(leg -> legDomainService.legCheckOrder(leg)); } + + List eventList = routeOrder.getLegItems().stream().flatMap(it -> it.getEventList().stream()) + .filter(it -> it.getLegId() == null) + .toList(); + if (!eventList.isEmpty()) { + routeRepository.save(routeOrder); + } + + if (legDomainService.checkLocation(legItems)) { routeRepository.reloadRouteOrderInCache(routeOrder); } diff --git a/src/main/java/com/chint/domain/repository/RouteRepository.java b/src/main/java/com/chint/domain/repository/RouteRepository.java index 4fb3f417..d36bf34f 100644 --- a/src/main/java/com/chint/domain/repository/RouteRepository.java +++ b/src/main/java/com/chint/domain/repository/RouteRepository.java @@ -55,4 +55,6 @@ public interface RouteRepository { RouteOrder findTempRouteOrderBySysCodeAndBillCode(String sysCode, String billCode); RouteOrder saveTempRouteOrder(RouteOrder routeOrder, Long hours); + + RouteOrder cacheEvictTempRouteOrder(RouteOrder routeOrder); } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/service/LegDomainService.java b/src/main/java/com/chint/domain/service/LegDomainService.java index d3e88569..7b64c270 100644 --- a/src/main/java/com/chint/domain/service/LegDomainService.java +++ b/src/main/java/com/chint/domain/service/LegDomainService.java @@ -61,19 +61,12 @@ public class LegDomainService { if (leg.getLegStatus().equals(LEG_STATUS_APPROVAL)) { return leg; } - if (isRefundEvent(lastOrderStatus, leg)) { - return legRepository.save(leg); - } - if (isCancelEvent(lastOrderStatus, leg)) { - return legRepository.save(leg); - } - if (isOrderedOrPayedEvent(orderDetailList, leg)) { - return legRepository.save(leg); - } + isRefundEvent(lastOrderStatus, leg); + isCancelEvent(lastOrderStatus, leg); + isOrderedOrPayedEvent(orderDetailList, leg); if (leg.getLegStatus().equals(LEG_STATUS_CHANGE)) { LegEvent legEvent = legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL); leg.addEvent(legEvent); - return legRepository.save(leg); } return leg; } diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java index 580f2628..158b1e87 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java @@ -166,7 +166,8 @@ public class LegEventHandler implements LegEventService { //保存routeOrder的状态 RouteOrder save = routeRepository.save(routeOrder); command.order(save); - + //删除临时创建行程规划单 + routeRepository.cacheEvictTempRouteOrder(save); //异步执行自动同步功能 Command.of(RouteAutoSyncCommand.class).route(save).async().sendToQueue(); } diff --git a/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java b/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java index 1b1899a4..94e4f5b2 100644 --- a/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java +++ b/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java @@ -36,8 +36,10 @@ public class RouteCacheService { public List preloadUserRoutes(String employeeNo) { - List routeIdsByEmployeeNo = routeCacheManage - .getRouteIdsByEmployeeNo(employeeNo, null, null).stream().filter(Objects::nonNull).toList(); + List routeIdsByEmployeeNo = Optional.ofNullable(routeCacheManage + .getRouteIdsByEmployeeNo(employeeNo, null, null)) + .orElse(List.of()) + .stream().filter(Objects::nonNull).toList(); if (!routeIdsByEmployeeNo.isEmpty()) { return routeCacheManage.getRouteListByIds(routeIdsByEmployeeNo); } diff --git a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java index a1c1f869..de2a796d 100644 --- a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java @@ -233,4 +233,13 @@ public class RouteRepositoryImpl implements RouteRepository { redisTemplate.opsForValue().set(redisKey, routeOrder, 15L, TimeUnit.DAYS); return routeOrder; } + + + @Override + public RouteOrder cacheEvictTempRouteOrder(RouteOrder routeOrder) { + ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + String redisKey = "TemporaryRouteOrder:" + approveOrderNo.getSysCode() + "-" + approveOrderNo.getFakeOrderNo(); + redisTemplate.delete(redisKey); + return routeOrder; + } } diff --git a/src/test/java/com/chint/CTripTest.java b/src/test/java/com/chint/CTripTest.java index 5ec40f20..d7e7d364 100644 --- a/src/test/java/com/chint/CTripTest.java +++ b/src/test/java/com/chint/CTripTest.java @@ -250,7 +250,7 @@ public class CTripTest { @Test void search() { BaseContext.setCurrentUser(user); - SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("33303376379"); + SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("33513622716"); System.out.println(response); }