fix:修复分页查询,因缓存确实导致无法查到行程规划单的问题
This commit is contained in:
parent
64ea271e4b
commit
b7e1734ec7
|
@ -41,7 +41,7 @@ public class RouteCacheService {
|
|||
.orElse(List.of())
|
||||
.stream().filter(Objects::nonNull).toList();
|
||||
if (!routeIdsByEmployeeNo.isEmpty()) {
|
||||
return routeCacheManage.getRouteListByIds(routeIdsByEmployeeNo);
|
||||
return queryByIdIn(routeIdsByEmployeeNo);
|
||||
}
|
||||
log.info("开始缓存用户行程规划单");
|
||||
List<RouteOrder> routeOrders = jdbcRouteRepository.findByUserIdOrApproveOrderNo_Creator(employeeNo, employeeNo);
|
||||
|
@ -215,9 +215,22 @@ public class RouteCacheService {
|
|||
|
||||
public List<RouteOrder> queryByIdIn(List<Long> routeIds) {
|
||||
if (routeIds != null && !routeIds.isEmpty()) {
|
||||
return routeCacheManage.getRouteListByIds(routeIds);
|
||||
List<RouteOrder> inCacheRouteOrder = routeCacheManage.getRouteListByIds(routeIds);
|
||||
List<Long> inCacheRouteIds = inCacheRouteOrder.stream().filter(Objects::nonNull)
|
||||
.map(RouteOrder::getRouteId).toList();
|
||||
List<Long> notInCacheRouteIds = routeIds.stream().filter(it -> !inCacheRouteIds.contains(it))
|
||||
.toList();
|
||||
List<RouteOrder> byRouteIdIn = jdbcRouteRepository.findByRouteIdIn(notInCacheRouteIds);
|
||||
CompletableFuture.runAsync(() -> byRouteIdIn.forEach(this::updateRouteCache));
|
||||
inCacheRouteOrder.addAll(byRouteIdIn);
|
||||
return inCacheRouteOrder;
|
||||
} else {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRouteCache(RouteOrder routeOrder) {
|
||||
routeCacheManage.invalidateRouteCache(routeOrder.getRouteId());
|
||||
routeCacheManage.cacheRouteOrder(routeOrder);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue