| 12345678910111213141516171819202122 |
- package com.ruoyi.app.flashdelivery.route;
- import java.math.BigDecimal;
- import java.util.List;
- @FunctionalInterface
- /** 外部路线距离提供器,失败时由上层服务负责本地降级。 */
- public interface RouteDistanceProvider {
- /** 按起终点和订单车型计算路线距离与时长;失败直接抛异常,由上层负责降级。 */
- RouteDistance route(BigDecimal originLatitude, BigDecimal originLongitude,
- BigDecimal destinationLatitude, BigDecimal destinationLongitude,
- Integer vehicleType);
- /** 完整有序路线;多点不允许悄悄省略中间站。 */
- default RouteDistance route(List<GeoPoint> points, Integer vehicleType) {
- FlashDeliveryRouteService.validatePoints(points);
- if (points.size() != 2) throw new UnsupportedOperationException("multi-stop route unavailable");
- GeoPoint origin = points.get(0);
- GeoPoint destination = points.get(1);
- return route(origin.latitude(), origin.longitude(), destination.latitude(), destination.longitude(), vehicleType);
- }
- }
|