修复缓存缺失导致查询数据库的问题

This commit is contained in:
lulz1 2024-03-19 10:30:14 +08:00
parent 1a3d3aece4
commit a8d3ff4fb3
8 changed files with 32 additions and 28 deletions

View File

@ -67,7 +67,7 @@ public class OrderOutController {
return Result.Success(SUCCESS, orderQuery.pageQuery(queryData));
}
// @Cacheable(value = "EstimateTrainPrice" , key = "#priceQueryData")
@ApiOperation("查询火车估算价格")
@PostMapping("/estimate/train")
public Result<TrainPriceData> estimateTrainPrice(@RequestBody PriceQueryData priceQueryData) {
@ -75,14 +75,14 @@ public class OrderOutController {
}
// @Cacheable(value = "FlightPriceData" , key = "#priceQueryData")
@ApiOperation("查询飞机估算价格")
@PostMapping("/estimate/flight")
public Result<FlightPriceData> estimateFlightPrice(@RequestBody PriceQueryData priceQueryData) {
return Result.Success(SUCCESS, orderQuery.queryFlightPrice(priceQueryData));
}
// @Cacheable(value = "HotelPriceData" , key = "#priceQueryData")
@ApiOperation("查询酒店估算价格")
@PostMapping("/estimate/hotel")
public Result<HotelPriceData> estimateHotelPrice(@RequestBody PriceQueryData priceQueryData) {

View File

@ -4,13 +4,11 @@ import cn.hutool.core.bean.BeanUtil;
import com.chint.application.dtos.response.*;
import com.chint.application.dtos.trip.*;
import com.chint.application.queryies.estimate.EstimatePrice;
import com.chint.domain.aggregates.location.CityEntity;
import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity;
import com.chint.domain.aggregates.location.basedata.DistrictPOIInfoEntity;
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.*;
import com.chint.domain.service.LegDomainService;
import com.chint.domain.service.OrderDomainService;
@ -36,7 +34,6 @@ import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
import static com.chint.infrastructure.constant.FSSCConstant.*;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER;
@ -106,7 +103,7 @@ public class OrderQuery {
User currentUser = BaseContext.getCurrentUser();
//从缓存的地方获取数据该用户所有的行程规划单
List<RouteOrder> routeOrders = routeRepository.findByActualOrderNoNotNull(currentUser.getEmployeeNo());
List<RouteOrder> routeOrders = routeRepository.findAllByEmployeeNo(currentUser.getEmployeeNo());
if (routeOrders == null || routeOrders.isEmpty()) {

View File

@ -32,5 +32,8 @@ public class BaseOrderExtension {
private String standardItems;
// 超标原因
private String overStandardReason;
// 项目订单号
private String projectOrderNo;
// 成本中心
private String costCenter;
}

View File

@ -67,25 +67,28 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if(approveOrderNo != null){
baseOrderExtension.setAccountCompanyId(approveOrderNo.getAccountCompanyCode());
baseOrderExtension.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
baseOrderExtension.setCostCenter(approveOrderNo.getCostCenter());
baseOrderExtension.setProjectOrderNo(approveOrderNo.getProjectName());
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
if (sysCode != null) {
if (sysCode.equals(BELONG_SYS_CODE_FSSC)) {
baseOrderExtension.setBelongSysType(BELONG_SYS_TYPE_FSSC);
}
if (sysCode.equals(BELONG_SYS_CODE_H3BPM)) {
baseOrderExtension.setBelongSysType(BELONG_SYS_TYPE_H3BPM);
}
if (sysCode.equals(BELONG_SYS_CODE_XNFSSC)) {
baseOrderExtension.setBelongSysType(BELONG_SYS_TYPE_XNFSSC);
}
if (sysCode.equals(BELONG_SYS_CODE_ANFSSC)) {
baseOrderExtension.setBelongSysType(BELONG_SYS_TYPE_ANFSSC);
}
}
}
// if (sysCode != null) {
// if (sysCode.equals(BELONG_SYS_CODE_FSSC)) {
// trainOrderDetail.setBelongSysType(BELONG_SYS_TYPE_FSSC);
// }
// if (sysCode.equals(BELONG_SYS_CODE_H3BPM)) {
// trainOrderDetail.setBelongSysType(BELONG_SYS_TYPE_H3BPM);
//
// }
// if (sysCode.equals(BELONG_SYS_CODE_XNFSSC)) {
// trainOrderDetail.setBelongSysType(BELONG_SYS_TYPE_XNFSSC);
// }
// if (sysCode.equals(BELONG_SYS_CODE_ANFSSC)) {
// trainOrderDetail.setBelongSysType(BELONG_SYS_TYPE_ANFSSC);
// }
// }
//配置唯一标识
return baseOrderExtension;
}
}

View File

@ -32,7 +32,7 @@ public interface RouteRepository {
List<RouteOrder> findByActualOrderNoNotNull(OrderQueryData orderQueryData);
List<RouteOrder> findByActualOrderNoNotNull(String employeeNo);
List<RouteOrder> findAllByEmployeeNo(String employeeNo);
Page<RouteOrder> findByTime(OrderQueryData queryData);

View File

@ -29,6 +29,7 @@ public class RouteCacheService {
routeCacheManage.cacheFakeOrderNoAndSysCodeMapRouteId(approveOrderNo.getFakeOrderNo(), approveOrderNo.getSysCode(), routeOrder);
routeCacheManage.cacheActualOrderNoAndSysCodeMapRouteId(approveOrderNo.getActualOrderNo(), approveOrderNo.getSysCode(), routeOrder);
}
invalidateUserRoutesCache(employeeNo);
//获取当前用户所有的订单 缓存用户的routeIds列表
routeCacheManage.getRouteIdsByEmployeeNo(employeeNo, routeOrders, null);
return routeOrders;
@ -43,7 +44,6 @@ public class RouteCacheService {
.getRouteListByIds(routeIdsByEmployeeNo)
.stream()
.filter(Objects::nonNull)
.filter(it -> it.getApproveOrderNo() != null && it.getApproveOrderNo().getActualOrderNo() != null)
.toList();
//如果这里数量对不上名单那么对该用户的信息重新进行缓存
if (routeListByIds.size() != routeIdsByEmployeeNo.size()) {

View File

@ -131,7 +131,7 @@ public class RouteRepositoryImpl implements RouteRepository {
}
@Override
public List<RouteOrder> findByActualOrderNoNotNull(String employeeNo) {
public List<RouteOrder> findAllByEmployeeNo(String employeeNo) {
return routeCacheService.getUserRoutes(employeeNo);
// return jdbcRouteRepository.findByUserIdAndApproveOrderNo_ActualOrderNoNotNullOrApproveOrderNo_CreatorAndApproveOrderNo_ActualOrderNoNotNull(employeeNo, employeeNo);
}

View File

@ -19,6 +19,7 @@ public class UserRepositoryImpl implements UserRepository {
}
@Cacheable(value = "RindByUserEmployeeNo",key = "#employeeNo")
@Override
public User findByUserEmployeeNo(String employeeNo) {
return jdbcUserRepository.findByEmployeeNo(employeeNo);