xp-robotaxi-api/src/main/java/com/xiaopeng/api/factory/operation/XpPointClientFallbackFactory.java
@@ -109,6 +109,12 @@ log.error("获取点位信息失败:{}", cause.getMessage()); return null; } @Override public R<Boolean> nowInTimePoint(Long pointId) { log.error("判断点位是在有效期内失败:{}", cause.getMessage()); return R.fail("判断点位是在有效期内失败"); } }; } } xp-robotaxi-api/src/main/java/com/xiaopeng/api/feignClient/operation/XpPointClient.java
@@ -78,5 +78,11 @@ @PostMapping("/base/v1/mini-program/inner/point/getPointsInfo") R<List<XpPoint>> getPointsInfo(@RequestBody Set<Long> points); /** * 判断点位是在有效期内 * @param pointId * @return */ @GetMapping("/base/v1/mini-program/inner/point/nowInTimePoint") R<Boolean> nowInTimePoint(@RequestParam Long pointId); } xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/service/KafkaConsumerService.java
@@ -28,19 +28,7 @@ import com.xiaopeng.api.vo.OrderType; import com.xiaopeng.api.vo.SystemEventType; import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; import com.xiaopeng.api.vo.automaticPilot.protobuf.*; import com.xiaopeng.api.vo.automaticPilot.protobuf.AbnormalReason; import com.xiaopeng.api.vo.automaticPilot.protobuf.GearLevel; import com.xiaopeng.api.vo.automaticPilot.protobuf.OrderPhase; import com.xiaopeng.api.vo.automaticPilot.protobuf.OrderStatusInfo; import com.xiaopeng.api.vo.automaticPilot.protobuf.RealtimePose; import com.xiaopeng.api.vo.automaticPilot.protobuf.ResponseMessage; import com.xiaopeng.api.vo.automaticPilot.protobuf.RtTripInfo; import com.xiaopeng.api.vo.automaticPilot.protobuf.StatusCode; import com.xiaopeng.api.vo.automaticPilot.protobuf.VehicleDynamicStatus; import com.xiaopeng.api.vo.automaticPilot.protobuf.VehicleStaticInfo; import com.xiaopeng.api.vo.automaticPilot.protobuf.VehicleStatus; import com.xiaopeng.api.vo.automaticPilot.protobuf.Wgs; import com.xiaopeng.api.vo.automaticPilot.protobuf.RTCmdType; import com.xiaopeng.api.vo.operation.RouteVo; import com.xiaopeng.api.vo.vehicleConvoy.CancelTaxiPassengerVo; import com.xiaopeng.automaticPilot.util.XPUUtil; xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java
@@ -14,6 +14,7 @@ import com.xiaopeng.api.feignClient.account.XpAppUserClient; import com.xiaopeng.api.feignClient.account.XpAppUserCouponClient; import com.xiaopeng.api.feignClient.map.XpMapClient; import com.xiaopeng.api.feignClient.operation.XpPointClient; import com.xiaopeng.api.feignClient.order.XpOrderClient; import com.xiaopeng.api.feignClient.pushMessage.XpPushMessageClient; import com.xiaopeng.api.model.account.XpAppUser; @@ -120,6 +121,9 @@ @Resource private GDMapGeocodingUtil gdMapGeocodingUtil; @Resource private XpPointClient xpPointClient; // 自定义线程池用于并行执行任务 private final ExecutorService executorService; @@ -195,10 +199,11 @@ throw new ServiceException("获取城市信息失败", I18nKeyConstant.CITY_NOT_FOUND); } String cityCode = geocode.get("cityCode"); XpOpenCity xpOpenCity = xpOpenCityMapper.selectOne(new LambdaQueryWrapper<XpOpenCity>().eq(XpOpenCity::getCityCode, cityCode)); if (xpOpenCity == null) { List<XpOpenCity> openCities = xpOpenCityMapper.selectList(new LambdaQueryWrapper<XpOpenCity>().eq(XpOpenCity::getCityCode, cityCode)); if (openCities == null || openCities.isEmpty()) { throw new ServiceException("获取城市信息失败", I18nKeyConstant.CITY_NOT_FOUND); } XpOpenCity xpOpenCity = openCities.get(0); routeAndFareDto.setOpenCityId(xpOpenCity.getId()); XpRoutePlan xpRoutePlan = xpRoutePlanMapper.selectOne(new LambdaQueryWrapper<XpRoutePlan>().eq(XpRoutePlan::getAuditStatus, 2).eq(XpRoutePlan::getCityCode, cityCode)); if (xpRoutePlan != null) { @@ -221,7 +226,6 @@ RouteVo routeVo = distanceAndDuration.getData(); // 2. 计算价格(需要在并行任务前完成,因为优惠券查询需要价格) XpPricingCardVo xpPricingCardVo; if (xpPricing.getPricingType() == 1) { xpPricingCardVo = xpPricingUtil.calculationPrice(userId, @@ -448,12 +452,11 @@ XpPoint endXpPoint = xpPointService.getById(dto.getEndPointId()); // 判断点位是否在运营区域内 LocalTime now = LocalTime.now(); boolean inTime = xpPointService.getInTime(now, xpPoint.getEffectivePeriod(), xpPoint.getEffectiveTimePeriod()); boolean inTime = xpPointClient.nowInTimePoint(dto.getStartPointId()).getData(); if (!inTime) { throw new ServiceException("当前点位未开通服务", I18nKeyConstant.NO_CURRENT_REGION); } inTime = xpPointService.getInTime(now, endXpPoint.getEffectivePeriod(), endXpPoint.getEffectiveTimePeriod()); inTime = xpPointClient.nowInTimePoint(dto.getEndPointId()).getData(); if (!inTime) { throw new ServiceException("当前点位未开通服务", I18nKeyConstant.NO_CURRENT_REGION); } xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/controller/XpPointController.java
@@ -98,7 +98,15 @@ } /** * 判断点位是在有效期内 * @param pointId * @return */ @GetMapping("/inner/point/nowInTimePoint") public R<Boolean> nowInTimePoint(@RequestParam Long pointId){ return R.ok(xpPointService.nowInTimePoint(pointId)); } } xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/XpPointService.java
@@ -84,4 +84,12 @@ PageInfo<XpPoint> pageList(PointPageListListQuery query); /** * 判断点位是否在当前时间范围内有效 * @param pointId * @return */ Boolean nowInTimePoint(Long pointId); } xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPointServiceImpl.java
@@ -89,6 +89,11 @@ .apply("ST_Distance_Sphere(point({0}, {1}), point(point_lon, point_lat)) <= {2}", dto.getLongitude(), dto.getLatitude(), orderDistance)); NearestVo nearestVo = new NearestVo(); if(list.isEmpty()){ nearestVo.setPoints(new ArrayList<>()); nearestVo.setTotal(0); return nearestVo; } List<NearestNextVo> nearestNextVos = new ArrayList<>(); LocalTime now = LocalTime.now(); List<Long> areaIds = list.stream().map(XpPoint::getElectronicAreaId).collect(Collectors.toList()); @@ -117,9 +122,8 @@ //永不失效,但是还未到开始时间 if(1 == failureType && LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime())){ continue; } //定时失效,但是当前时间不在时间范围内 if(LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime()) || LocalDateTime.now().isAfter(xpElectronicFence.getFailureTime())){ }else if(2 == failureType && (LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime()) || LocalDateTime.now().isAfter(xpElectronicFence.getFailureTime()))){ //定时失效,但是当前时间不在时间范围内 continue; } }else{ @@ -293,12 +297,9 @@ Integer failureType = xpElectronicFence.getFailureType(); //永不失效,但是还未到开始时间 if(1 == failureType && LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime())){ // 不在运营段 xpPointsListVo.setState(0); } //定时失效,但是当前时间不在时间范围内 if(LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime()) || LocalDateTime.now().isAfter(xpElectronicFence.getFailureTime())){ // 不在运营段 }else if(2 == failureType && (LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime()) || LocalDateTime.now().isAfter(xpElectronicFence.getFailureTime()))){ //定时失效,但是当前时间不在时间范围内 xpPointsListVo.setState(0); } }else{ @@ -348,4 +349,41 @@ return pageInfo; } @Override public Boolean nowInTimePoint(Long pointId) { XpPoint xpPoint = this.getById(pointId); if(null == xpPoint){ return false; } Integer operationType = xpPoint.getOperationType(); if(1 == operationType){ //与运营区同步 XpElectronicFenceArea xpElectronicFenceArea = xpElectronicFenceAreaService.getById(xpPoint.getElectronicAreaId()); if(null == xpElectronicFenceArea){ return false; } XpElectronicFence xpElectronicFence = xpElectronicFenceService.getById(xpElectronicFenceArea.getElectronicId()); if(null == xpElectronicFence){ return false; } //失效类型 1=永不失效 2=定时失效 Integer failureType = xpElectronicFence.getFailureType(); //永不失效,但是还未到开始时间 if(1 == failureType && LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime())){ return false; }else if(2 == failureType && (LocalDateTime.now().isBefore(xpElectronicFence.getEffectTime()) || LocalDateTime.now().isAfter(xpElectronicFence.getFailureTime()))){ //定时失效,但是当前时间不在时间范围内 return false; } }else{ //自定义时间段 // 判断是否在时间段内 boolean intime = getInTime(LocalTime.now(), xpPoint.getEffectivePeriod(), xpPoint.getEffectiveTimePeriod()); if (!intime) { return false; } } return true; } }