fix:优化行程规划分页查询的逻辑
This commit is contained in:
parent
391ec93f27
commit
c0a5b62b0c
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue