fix:优化行程规划分页查询的逻辑

This commit is contained in:
lulz1 2024-07-09 10:56:32 +08:00
parent 391ec93f27
commit c0a5b62b0c
7 changed files with 30 additions and 14 deletions

View File

@ -541,6 +541,15 @@ public class OrderQuery {
if (routeOrder.getApprovalStatusCode() != APPROVAL_EVENT_PREPARE) { if (routeOrder.getApprovalStatusCode() != APPROVAL_EVENT_PREPARE) {
legItems.forEach(leg -> legDomainService.legCheckOrder(leg)); legItems.forEach(leg -> legDomainService.legCheckOrder(leg));
} }
List<LegEvent> 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)) { if (legDomainService.checkLocation(legItems)) {
routeRepository.reloadRouteOrderInCache(routeOrder); routeRepository.reloadRouteOrderInCache(routeOrder);
} }

View File

@ -55,4 +55,6 @@ public interface RouteRepository {
RouteOrder findTempRouteOrderBySysCodeAndBillCode(String sysCode, String billCode); RouteOrder findTempRouteOrderBySysCodeAndBillCode(String sysCode, String billCode);
RouteOrder saveTempRouteOrder(RouteOrder routeOrder, Long hours); RouteOrder saveTempRouteOrder(RouteOrder routeOrder, Long hours);
RouteOrder cacheEvictTempRouteOrder(RouteOrder routeOrder);
} }

View File

@ -61,19 +61,12 @@ public class LegDomainService {
if (leg.getLegStatus().equals(LEG_STATUS_APPROVAL)) { if (leg.getLegStatus().equals(LEG_STATUS_APPROVAL)) {
return leg; return leg;
} }
if (isRefundEvent(lastOrderStatus, leg)) { isRefundEvent(lastOrderStatus, leg);
return legRepository.save(leg); isCancelEvent(lastOrderStatus, leg);
} isOrderedOrPayedEvent(orderDetailList, leg);
if (isCancelEvent(lastOrderStatus, leg)) {
return legRepository.save(leg);
}
if (isOrderedOrPayedEvent(orderDetailList, leg)) {
return legRepository.save(leg);
}
if (leg.getLegStatus().equals(LEG_STATUS_CHANGE)) { if (leg.getLegStatus().equals(LEG_STATUS_CHANGE)) {
LegEvent legEvent = legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL); LegEvent legEvent = legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL);
leg.addEvent(legEvent); leg.addEvent(legEvent);
return legRepository.save(leg);
} }
return leg; return leg;
} }

View File

@ -166,7 +166,8 @@ public class LegEventHandler implements LegEventService {
//保存routeOrder的状态 //保存routeOrder的状态
RouteOrder save = routeRepository.save(routeOrder); RouteOrder save = routeRepository.save(routeOrder);
command.order(save); command.order(save);
//删除临时创建行程规划单
routeRepository.cacheEvictTempRouteOrder(save);
//异步执行自动同步功能 //异步执行自动同步功能
Command.of(RouteAutoSyncCommand.class).route(save).async().sendToQueue(); Command.of(RouteAutoSyncCommand.class).route(save).async().sendToQueue();
} }

View File

@ -36,8 +36,10 @@ public class RouteCacheService {
public List<RouteOrder> preloadUserRoutes(String employeeNo) { public List<RouteOrder> preloadUserRoutes(String employeeNo) {
List<Long> routeIdsByEmployeeNo = routeCacheManage List<Long> routeIdsByEmployeeNo = Optional.ofNullable(routeCacheManage
.getRouteIdsByEmployeeNo(employeeNo, null, null).stream().filter(Objects::nonNull).toList(); .getRouteIdsByEmployeeNo(employeeNo, null, null))
.orElse(List.of())
.stream().filter(Objects::nonNull).toList();
if (!routeIdsByEmployeeNo.isEmpty()) { if (!routeIdsByEmployeeNo.isEmpty()) {
return routeCacheManage.getRouteListByIds(routeIdsByEmployeeNo); return routeCacheManage.getRouteListByIds(routeIdsByEmployeeNo);
} }

View File

@ -233,4 +233,13 @@ public class RouteRepositoryImpl implements RouteRepository {
redisTemplate.opsForValue().set(redisKey, routeOrder, 15L, TimeUnit.DAYS); redisTemplate.opsForValue().set(redisKey, routeOrder, 15L, TimeUnit.DAYS);
return routeOrder; return routeOrder;
} }
@Override
public RouteOrder cacheEvictTempRouteOrder(RouteOrder routeOrder) {
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
String redisKey = "TemporaryRouteOrder:" + approveOrderNo.getSysCode() + "-" + approveOrderNo.getFakeOrderNo();
redisTemplate.delete(redisKey);
return routeOrder;
}
} }

View File

@ -250,7 +250,7 @@ public class CTripTest {
@Test @Test
void search() { void search() {
BaseContext.setCurrentUser(user); BaseContext.setCurrentUser(user);
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("33303376379"); SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("33513622716");
System.out.println(response); System.out.println(response);
} }