| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.api.dto.account.GetUserCouponDto; |
| | | import com.xiaopeng.api.dto.map.RouteAndFareDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.feignClient.account.XpAppUserClient; |
| | | import com.xiaopeng.api.feignClient.account.XpAppUserCouponClient; |
| | | import com.xiaopeng.api.feignClient.map.XpMapClient; |
| | |
| | | xpOrder.setTimeSlot(currentTimeSlot); |
| | | xpOrder.setCreateTime(LocalDateTime.now()); |
| | | |
| | | |
| | | // 计算距离 和 时间 |
| | | RouteAndFareDto routeAndFareDto = new RouteAndFareDto(); |
| | | LonLatDto lonLatDto = new LonLatDto(); |
| | | lonLatDto.setLongitude(xpPoint.getPointLon()); |
| | | lonLatDto.setLatitude(xpPoint.getPointLat()); |
| | | routeAndFareDto.setOrigin(lonLatDto); |
| | | |
| | | LonLatDto lonLatDto1 = new LonLatDto(); |
| | | lonLatDto1.setLongitude(endXpPoint.getPointLon()); |
| | | lonLatDto1.setLatitude(endXpPoint.getPointLat()); |
| | | routeAndFareDto.setDestination(lonLatDto1); |
| | | |
| | | |
| | | XpOpenCity xpOpenCity = xpOpenCityMapper.selectById(dto.getOpenCityId()); |
| | | XpRoutePlan xpRoutePlan = xpRoutePlanMapper.selectOne(new LambdaQueryWrapper<XpRoutePlan>().eq(XpRoutePlan::getAuditStatus, 2).eq(XpRoutePlan::getCityCode, xpOpenCity.getCityCode())); |
| | | if (xpRoutePlan != null) { |
| | | routeAndFareDto.setRoutePlanRule(xpRoutePlan.getRoutePlanRule()); |
| | | } |
| | | R<RouteVo> distanceAndDuration = xpMapClient.getDistanceAndDuration(routeAndFareDto); |
| | | Integer distance = 0; |
| | | Integer duration = 0; |
| | | if(distanceAndDuration.getCode()!=200){ |
| | | //静默处理 |
| | | return 0l; |
| | | } |
| | | distance=distanceAndDuration.getData().getDistance(); |
| | | duration=distanceAndDuration.getData().getDuration(); |
| | | |
| | | |
| | | // 产生订单 |
| | | R<Long> addOrderR = xpOrderClient.addOrder(xpOrder); |
| | | if(addOrderR.getCode()!=R.SUCCESS){ |
| | |
| | | double v = FastDistanceCalculator.distanceFast(Double.parseDouble(lonLat.split(",")[1]), Double.parseDouble(lonLat.split(",")[0]), xpPoint.getPointLat(), xpPoint.getPointLon()); |
| | | if(v<maxPushDistance){ |
| | | if(isPriorityDispatch){ |
| | | // 头部 value 订单_经纬度_状态_用户id_订单编号 |
| | | redisService.addToTail(s,orderId+"_"+xpPoint.getPointLon()+","+xpPoint.getPointLat()+"_0"+"_"+uid+"_"+xpOrder.getOrderNumber()); |
| | | // 头部 value 订单_经纬度_状态_用户id_订单编号_距离_时间 |
| | | redisService.addToTail(s,orderId+"_"+xpPoint.getPointLon()+","+xpPoint.getPointLat()+"_0"+"_"+uid+"_"+xpOrder.getOrderNumber()+"_"+distance+"_"+duration+"_"+routeAndFareDto.getRoutePlanRule()); |
| | | }else { |
| | | // 尾部 |
| | | redisService.addToTail(s,orderId+"_"+xpPoint.getPointLon()+","+xpPoint.getPointLat()+"_0"+"_"+uid+"_"+xpOrder.getOrderNumber()); |
| | | redisService.addToTail(s,orderId+"_"+xpPoint.getPointLon()+","+xpPoint.getPointLat()+"_0"+"_"+uid+"_"+xpOrder.getOrderNumber()+"_"+distance+"_"+duration+"_"+routeAndFareDto.getRoutePlanRule()); |
| | | } |
| | | return orderId; |
| | | } |
| | | } |
| | | |
| | | String key = CacheConstants.QUEUE_POINT_ID+"-"+ xpPoint.getId()+"-"+xpPoint.getPointLon()+","+xpPoint.getPointLat(); |
| | | redisService.setCacheList(key,Arrays.asList(orderId+"_"+xpPoint.getPointLon()+","+xpPoint.getPointLat()+"_0"+"_"+uid+"_"+xpOrder.getOrderNumber())); |
| | | redisService.setCacheList(key,Arrays.asList(orderId+"_"+xpPoint.getPointLon()+","+xpPoint.getPointLat()+"_0"+"_"+uid+"_"+xpOrder.getOrderNumber()+"_"+distance+"_"+duration+"_"+routeAndFareDto.getRoutePlanRule())); |
| | | return orderId; |
| | | |
| | | // |