xp-robotaxi-api/src/main/java/com/xiaopeng/api/vo/order/XpPointsListVo.java
@@ -28,4 +28,13 @@ @ApiModelProperty("电子围栏区域id") private Long electronicAreaId; private Integer effectivePeriod; private String effectiveTimePeriod; private Integer state=1; } xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/constant/I18nKeyConstant.java
@@ -11,6 +11,9 @@ String NO_CURRENT_REGION = "no.current.region"; String NO_CURRENT_POINT = "no.current.point"; String SYSTEM_EXCEPTION = "system.exception"; String TO_WORK = "to.work"; xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/XpPointService.java
@@ -18,6 +18,7 @@ import com.xiaopeng.api.dto.operation.PointMapQuery; import com.xiaopeng.operation.vo.OrderDistanceVo; import java.time.LocalTime; import java.util.List; /** @@ -35,6 +36,14 @@ * 获取附近上车站点 */ NearestVo nearest(@Valid NearestDto dto); /** * 判断点位是否时间段内 * @param now * @return */ boolean getInTime(LocalTime now, Integer effectivePeriod, String effectiveTimePeriod); List<XpPoint> pointMap(PointMapQuery query); List<XpPoint> listAll(PointPageListQuery query); xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPointServiceImpl.java
@@ -76,7 +76,7 @@ for (XpPoint xpPoint : list) { // 判断是否在时间段内 boolean intime = getInTime(now, xpPoint); boolean intime = getInTime(now, xpPoint.getEffectivePeriod(), xpPoint.getEffectiveTimePeriod()); if (!intime) { continue; } @@ -108,36 +108,35 @@ private boolean getInTime(LocalTime now,XpPoint xpPoint){ public boolean getInTime(LocalTime now, Integer effectivePeriod, String effectiveTimePeriod){ // 2非工作日 0工作日 1节假日 3调休日 Integer holidayToday = holidayUtil.isHolidayToday(); Integer operationType = xpPoint.getEffectivePeriod(); if(operationType==1){ boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now, xpPoint.getEffectiveTimePeriod()); if(effectivePeriod==1){ boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now,effectiveTimePeriod); if (!inTime) { return false; } }else if(operationType==2){ }else if(effectivePeriod==2){ if(holidayToday!=0){ return false; } boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now, xpPoint.getEffectiveTimePeriod()); boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now,effectiveTimePeriod); if (!inTime) { return false; } }else if(operationType==3){ }else if(effectivePeriod==3){ if(holidayToday!=2){ return false; } boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now, xpPoint.getEffectiveTimePeriod()); boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now,effectiveTimePeriod); if (!inTime) { return false; } }else if(operationType==4){ }else if(effectivePeriod==4){ if(holidayToday!=1){ return false; } boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now, xpPoint.getEffectiveTimePeriod()); boolean inTime = TimeRangeChecker.isCurrentTimeInRanges(now,effectiveTimePeriod); if (!inTime) { return false; } @@ -204,9 +203,18 @@ return searchVo; } LocalTime now = LocalTime.now(); for (XpPointsListVo xpPointsListVo : list) { boolean inTime = getInTime(now, xpPointsListVo.getEffectivePeriod(), xpPointsListVo.getEffectiveTimePeriod()); if (!inTime) { // 不在运营段 xpPointsListVo.setState(0); } // 组装数据 并排序 List<XpPointsListVo> resultList = list.stream().peek(vo -> vo.setDistance(FastDistanceCalculator.distanceFast(query.getLat(), query.getLon(), vo.getLatitude(), vo.getLongitude()))).collect(Collectors.toList()); } // 组装数据 并排序 剔除不在运营段的 数据 List<XpPointsListVo> resultList = list.stream().peek(vo -> vo.setDistance(FastDistanceCalculator.distanceFast(query.getLat(), query.getLon(), vo.getLatitude(), vo.getLongitude()))).filter(vo -> vo.getState() == 1).collect(Collectors.toList()); // 可用点位 List<XpPointsListVo> availablePoints = resultList.stream().filter(e -> query.getElectronicAreaId() != null && e.getElectronicAreaId().equals(query.getElectronicAreaId())).sorted(Comparator.comparing(XpPointsListVo::getDistance)).collect(Collectors.toList());// xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPricingServiceImpl.java
@@ -36,6 +36,7 @@ import com.xiaopeng.operation.mapper.*; import com.xiaopeng.operation.query.PricingPageListQuery; import com.xiaopeng.operation.service.IXpGeoQueryEntityService; import com.xiaopeng.operation.service.XpPointService; import com.xiaopeng.operation.service.XpPricingService; import com.xiaopeng.operation.utils.XpPricingUtil; import com.xiaopeng.operation.utils.holiday.HolidayUtil; @@ -48,6 +49,7 @@ import javax.annotation.PreDestroy; import javax.annotation.Resource; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; @@ -97,9 +99,6 @@ @Resource private XpPointMapper xpPointMapper; @Resource private XpWhitelistMapper xpWhitelistMapper; @Resource @@ -113,6 +112,9 @@ @Autowired private XpElectronicFenceMapper xpElectronicFenceMapper; @Autowired private XpPointService xpPointService; // 自定义线程池用于并行执行任务 @@ -396,6 +398,9 @@ @Override public Long saveOrder(XpOrderDto dto, String uid) { // 是否在运营区域时间内 XpElectronicFenceArea xpElectronicFenceArea = xpElectronicFenceAreaMapper.selectById(dto.getXpElectronicFenceAreaId()); XpElectronicFence xpElectronicFence = xpElectronicFenceMapper.selectById(xpElectronicFenceArea.getElectronicId()); @@ -414,10 +419,21 @@ } // 获取起点经纬度 XpPoint xpPoint = xpPointMapper.selectById(dto.getStartPointId()); XpPoint xpPoint = xpPointService.getById(dto.getStartPointId()); // 终点 XpPoint endXpPoint = xpPointMapper.selectById(dto.getStartPointId()); XpPoint endXpPoint = xpPointService.getById(dto.getStartPointId()); // 判断点位是否在运营区域内 LocalTime now = LocalTime.now(); boolean inTime = xpPointService.getInTime(now, xpPoint.getEffectivePeriod(), xpPoint.getEffectiveTimePeriod()); if(!inTime){ throw new ServiceException("当前点位未开通服务", I18nKeyConstant.NO_CURRENT_REGION); } inTime = xpPointService.getInTime(now, endXpPoint.getEffectivePeriod(), endXpPoint.getEffectiveTimePeriod()); if(!inTime){ throw new ServiceException("当前点位未开通服务", I18nKeyConstant.NO_CURRENT_REGION); } // 判断当天取消的次数 后台配置 redis 查询 Object cancelOrder = redisService.getCacheObject("CANCEL_ORDER_" + uid); xp-robotaxi-operation-boot/src/main/resources/i18n/messages.properties
@@ -17,3 +17,4 @@ pricing.not.exist=定价不存在 pricing.json.invalid=价格配置JSON格式不正确 pricing.rule.empty=价格规则不能为空 no.current.point=????????? xp-robotaxi-operation-boot/src/main/resources/i18n/messages_en_US.properties
@@ -17,3 +17,4 @@ pricing.not.exist=Pricing does not exist pricing.json.invalid=Invalid JSON format for pricing configuration pricing.rule.empty=Price rule cannot be empty no.current.point=The current location is not open for service xp-robotaxi-operation-boot/src/main/resources/i18n/messages_zh_CN.properties
@@ -17,3 +17,4 @@ pricing.not.exist=定价不存在 pricing.json.invalid=价格配置JSON格式不正确 pricing.rule.empty=价格规则不能为空 no.current.point=????????? xp-robotaxi-operation-boot/src/main/resources/mapper/operation/XpPointMapper.xml
@@ -91,7 +91,7 @@ <select id="queryPointByName" resultType="com.xiaopeng.api.vo.order.XpPointsListVo"> select p.id,p.electronic_area_id as electronicAreaId,p.point_name as name,p.point_address as address,p.point_lon as longitude,p.point_lat as latitude select p.id,p.electronic_area_id as electronicAreaId,p.point_name as name,p.point_address as address,p.point_lon as longitude,p.point_lat as latitude,p.effective_period,p.effective_time_period from xp_electronic_fence_area xefa left join xp_point p on p.electronic_area_id = xefa.id where p.is_deleted = 0 and p.operation_status =2 and xefa.is_deleted = 0