| | |
| | | } |
| | | |
| | | // 10. 检查等待时间 |
| | | Integer waitTime = getWaitTime(routeAndFareDto.getOrigin().getLongitude(), routeAndFareDto.getOrigin().getLatitude()); |
| | | if (waitTime > 3) { |
| | | throw new ServiceException("当前区域正在等待中,请耐心等待", I18nKeyConstant.WAITING_TIME); |
| | | } |
| | | fareVo.setWaitingTime(waitTime); |
| | | // Integer waitTime = getWaitTime(routeAndFareDto.getOrigin().getLongitude(), routeAndFareDto.getOrigin().getLatitude()); |
| | | // if (waitTime > 3) { |
| | | // throw new ServiceException("当前区域正在等待中,请耐心等待", I18nKeyConstant.WAITING_TIME); |
| | | // } |
| | | // fareVo.setWaitingTime(waitTime); |
| | | |
| | | |
| | | // 11. 生成订单ID并缓存 |
| | |
| | | //每次查找车辆推单后的等待秒数 |
| | | int sleepTime = 3; |
| | | Integer onePushTime = xpTradingStrategy.getOnePushTime(); |
| | | Double onePushDistance = xpTradingStrategy.getOnePushDistance(); |
| | | int count = onePushTime / sleepTime; |
| | | // 第一轮推单 |
| | | log.info("开始第一轮推单 {}", orderNo); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, distance, duration, planRule); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, onePushDistance, distance, duration, planRule); |
| | | |
| | | // 第二轮推单 |
| | | Integer twoPushTime = xpTradingStrategy.getTwoPushTime(); |
| | | Double twoPushDistance = xpTradingStrategy.getTwoPushDistance(); |
| | | count = twoPushTime / sleepTime; |
| | | log.info("开始第二轮推单 {}", orderNo); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, distance, duration, planRule); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, twoPushDistance, distance, duration, planRule); |
| | | |
| | | // 第三轮推单 |
| | | Integer threePushTime = xpTradingStrategy.getThreePushTime(); |
| | | Double threePushDistance = xpTradingStrategy.getThreePushDistance(); |
| | | count = threePushTime / sleepTime; |
| | | log.info("开始第三轮推单 {}", orderNo); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, distance, duration, planRule); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, threePushDistance, distance, duration, planRule); |
| | | |
| | | // 第四轮推单 |
| | | Integer fourPushTime = xpTradingStrategy.getFourPushTime(); |
| | | Double fourPushDistance = xpTradingStrategy.getFourPushDistance(); |
| | | count = fourPushTime / sleepTime; |
| | | log.info("开始第四轮推单 {}", orderNo); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, distance, duration, planRule); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, fourPushDistance, distance, duration, planRule); |
| | | |
| | | // 第五轮推单 |
| | | Integer fivePushTime = xpTradingStrategy.getFivePushTime(); |
| | | Double fivePushDistance = xpTradingStrategy.getFivePushDistance(); |
| | | count = fivePushTime / sleepTime; |
| | | log.info("开始第五轮推单 {}", orderNo); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, distance, duration, planRule); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, fivePushDistance, distance, duration, planRule); |
| | | |
| | | // 取消订单 |
| | | R<XpOrder> xpOrderR = xpOrderClient.queryOrderById(Long.valueOf(orderId)); |
| | |
| | | * @param xpTradingStrategy 规则 |
| | | */ |
| | | @SneakyThrows |
| | | private void processPushOrder(String quoteName, int count, int sleepTime, String uid, String[] split, String orderNo, XpTradingStrategy xpTradingStrategy, String distance, String duration, String planRule) { |
| | | private void processPushOrder(String quoteName, int count, int sleepTime, String uid, String[] split, String orderNo, XpTradingStrategy xpTradingStrategy, Double pushDistance, String distance, String duration, String planRule) { |
| | | log.info("进入推单环节 单号 {}", orderNo); |
| | | if (count == 0) { |
| | | count = 1; |
| | |
| | | for (int i = 0; i < count; i++) { |
| | | //等到sleepTime秒钟 |
| | | Thread.sleep(sleepTime * 1000); |
| | | log.info("进入找车环节 单号 {}", orderNo); |
| | | log.info("进入找车环节 单号 {} 第{}轮", orderNo, count++); |
| | | // 根据距离找车 |
| | | // 车多则根据配置找具体车数量 根据距离最近 |
| | | // 更改 暂不限制数量 |
| | | |
| | | List<VehiclePosition> positionList = vehiclePositionService.findAvailableVehiclesNearby(Double.parseDouble(split[0]), Double.parseDouble(split[1]), xpTradingStrategy.getOnePushDistance(), xpTradingStrategy.getSimultaneouslyOrderCount()); |
| | | log.info("根据距离找车 {} 距离 {}KM 经度 {} 维度 {} 查找结果 {} 单号 {}", orderNo, xpTradingStrategy.getOnePushDistance(), split[0], split[1], positionList, orderNo); |
| | | List<VehiclePosition> positionList = vehiclePositionService.findAvailableVehiclesNearby(Double.parseDouble(split[0]), Double.parseDouble(split[1]), pushDistance, xpTradingStrategy.getSimultaneouslyOrderCount()); |
| | | log.info("根据距离找车 {} 距离 {}KM 经度 {} 维度 {} 查找结果 {} 单号 {}", orderNo, pushDistance, split[0], split[1], positionList, orderNo); |
| | | // 获取车辆的区域信息 |
| | | if (positionList.isEmpty()) { |
| | | continue; |