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); }