liujie
2026-02-14 8b5ac6aa170ba050387c14931b95b9d9ce5ee4e2
Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/Robotaxi
1个文件已添加
2个文件已修改
448 ■■■■■ 已修改文件
xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/utils/TaxiPricingDemoService.java 320 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/utils/TrajectoryGenerator.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
@@ -77,6 +77,7 @@
import com.xiaopeng.order.service.IXpOrderReassignService;
import com.xiaopeng.order.service.IXpOrderService;
import com.xiaopeng.order.utils.TaxiPricingDemoService;
import com.xiaopeng.order.utils.TrajectoryGenerator;
import com.xiaopeng.order.utils.holiday.HolidayUtil;
import com.xiaopeng.order.vo.OrderDetailVo;
import io.swagger.annotations.ApiModelProperty;
@@ -949,8 +950,8 @@
            cancelTaxiPassengerVo.setVin(vehicle.getVehicleVin());
            cancelTaxiPassengerVo.setUid(uid);
            cancelTaxiPassengerVo.setOrderNo(order.getOrderNumber());
//            cancelTaxiPassengerVo.setAppId();
            // TODO 加配置文件取
            cancelTaxiPassengerVo.setAppId("");
            userVehicleClient.cancelTaxiPassenger(cancelTaxiPassengerVo);
        }
        // 根据订单所属开通城市id 查询定价
@@ -960,25 +961,37 @@
            throw new ServiceException("当前城市未配置定价规则", I18nKeyConstant.ORDER_PRICING_NOT_EXISTS);
        }
        // 费用
        // 查询订单轨迹
        List<OrderTrajectory> trajectories = mongoTemplate.find(
                new Query(Criteria.where("orderId").is(orderId))
                        .with(Sort.by(Sort.Direction.ASC, "locatetime")),
                OrderTrajectory.class
        );
        List<TaxiPricingDemoService.GpsPoint> gpsPoints = new ArrayList<>();
        for (OrderTrajectory trajectory : trajectories) {
            TaxiPricingDemoService.GpsPoint point = new TaxiPricingDemoService.GpsPoint(trajectory.getDistance(), trajectory.getLocatetime());
            gpsPoints.add(point);
        }
//        // 查询订单轨迹
//        List<OrderTrajectory> trajectories = mongoTemplate.find(
//                new Query(Criteria.where("orderId").is(orderId))
//                        .with(Sort.by(Sort.Direction.ASC, "locatetime")),
//                OrderTrajectory.class
//        );
//        List<TaxiPricingDemoService.GpsPoint> gpsPoints = new ArrayList<>();
//        for (OrderTrajectory trajectory : trajectories) {
//            TaxiPricingDemoService.GpsPoint point = new TaxiPricingDemoService.GpsPoint(trajectory.getDistance(), trajectory.getLocatetime());
//            gpsPoints.add(point);
//        }
    // 补充临时轨迹数据
        List<TaxiPricingDemoService.GpsPoint> gpsPoints = TaxiPricingDemoService.createMockGpsPoints(DateUtils.toDate(order.getCreateTime()));
        TaxiPricingDemoService.PricingConfig config = new TaxiPricingDemoService.PricingConfig();
        JSONArray startingFareJsonArray = JSONArray.parseArray(pricing.getStartingFareJson());
        JSONObject basicPricingJson = JSONObject.parseObject(pricing.getBasicPricingJson());
        config.peaks.add(new TaxiPricingDemoService.PricingRule("高峰期", basicPricingJson.getString("num21").split("-")[0], basicPricingJson.getString("num21").split("-")[1], Double.parseDouble(basicPricingJson.getString("num24")), Double.parseDouble(basicPricingJson.getString("num25")), Double.parseDouble(basicPricingJson.getString("num26")), Double.parseDouble(basicPricingJson.getString("num27")), Double.parseDouble(basicPricingJson.getString("num28"))));
        config.peaks.add(new TaxiPricingDemoService.PricingRule("高峰期", basicPricingJson.getString("num22").split("-")[0], basicPricingJson.getString("num22").split("-")[1], Double.parseDouble(basicPricingJson.getString("num24")), Double.parseDouble(basicPricingJson.getString("num25")), Double.parseDouble(basicPricingJson.getString("num26")), Double.parseDouble(basicPricingJson.getString("num27")), Double.parseDouble(basicPricingJson.getString("num28"))));
        config.night = new TaxiPricingDemoService.PricingRule("夜间行驶", basicPricingJson.getString("num14").split("-")[0], basicPricingJson.getString("num14").split("-")[1], Double.parseDouble(basicPricingJson.getString("num16")), Double.parseDouble(basicPricingJson.getString("num17")), Double.parseDouble(basicPricingJson.getString("num18")), Double.parseDouble(basicPricingJson.getString("num19")), Double.parseDouble(basicPricingJson.getString("num20")));
        config.holiday = new TaxiPricingDemoService.PricingRule("节假日", "00:00", "23:59", Double.parseDouble(basicPricingJson.getString("num30")), Double.parseDouble(basicPricingJson.getString("num31")), Double.parseDouble(basicPricingJson.getString("num32")), Double.parseDouble(basicPricingJson.getString("num33")), Double.parseDouble(basicPricingJson.getString("num234")));
        if(pricing.getPricingType()==1){
            JSONObject basicPricingJson = JSONObject.parseObject(pricing.getBasicPricingJson());
            config.peaks.add(new TaxiPricingDemoService.PricingRule("高峰期", basicPricingJson.getString("num21").split("-")[0], basicPricingJson.getString("num21").split("-")[1], Double.parseDouble(basicPricingJson.getString("num24")), Double.parseDouble(basicPricingJson.getString("num25")), Double.parseDouble(basicPricingJson.getString("num26")), Double.parseDouble(basicPricingJson.getString("num27")), Double.parseDouble(basicPricingJson.getString("num28"))));
            config.peaks.add(new TaxiPricingDemoService.PricingRule("高峰期", basicPricingJson.getString("num22").split("-")[0], basicPricingJson.getString("num22").split("-")[1], Double.parseDouble(basicPricingJson.getString("num24")), Double.parseDouble(basicPricingJson.getString("num25")), Double.parseDouble(basicPricingJson.getString("num26")), Double.parseDouble(basicPricingJson.getString("num27")), Double.parseDouble(basicPricingJson.getString("num28"))));
            config.night = new TaxiPricingDemoService.PricingRule("夜间行驶", basicPricingJson.getString("num14").split("-")[0], basicPricingJson.getString("num14").split("-")[1], Double.parseDouble(basicPricingJson.getString("num16")), Double.parseDouble(basicPricingJson.getString("num17")), Double.parseDouble(basicPricingJson.getString("num18")), Double.parseDouble(basicPricingJson.getString("num19")), Double.parseDouble(basicPricingJson.getString("num20")));
            config.holiday = new TaxiPricingDemoService.PricingRule("节假日", "00:00", "23:59", Double.parseDouble(basicPricingJson.getString("num30")), Double.parseDouble(basicPricingJson.getString("num31")), Double.parseDouble(basicPricingJson.getString("num32")), Double.parseDouble(basicPricingJson.getString("num33")), Double.parseDouble(basicPricingJson.getString("num234")));
            // --- 远途加价区间配置 (关键修改) ---
            // 1. 超过 num1(12) 不足 num2(20), 加收 num3(1.2)
            config.longSteps.add(new TaxiPricingDemoService.LongRangeStep(Double.parseDouble(basicPricingJson.getString("num6")), Double.parseDouble(basicPricingJson.getString("num7")), Double.parseDouble(basicPricingJson.getString("num8"))));
            // 2. 超过 num4(20) 不足 num5(35), 加收 num6(2.0)
            config.longSteps.add(new TaxiPricingDemoService.LongRangeStep(Double.parseDouble(basicPricingJson.getString("num9")), Double.parseDouble(basicPricingJson.getString("num10")), Double.parseDouble(basicPricingJson.getString("num11"))));
            // 3. 超过 num7(35) 以后, 加收 num8(3.5) -> numEnd 传个极大值
            config.longSteps.add(new TaxiPricingDemoService.LongRangeStep(Double.parseDouble(basicPricingJson.getString("num12")), 999999, Double.parseDouble(basicPricingJson.getString("num13"))));
        }
        for (Object o : startingFareJsonArray) {
            // 转化为jsonObject
            JSONObject jsonObject = (JSONObject) o;
@@ -991,13 +1004,7 @@
            String num7 = jsonObject.getString("num7");
            config.normals.add(new TaxiPricingDemoService.PricingRule("普通时段", num1, num2, Double.parseDouble(num3), Double.parseDouble(num4), Double.parseDouble(num5), Double.parseDouble(num6), Double.parseDouble(num7)));
        }
        // --- 远途加价区间配置 (关键修改) ---
        // 1. 超过 num1(12) 不足 num2(20), 加收 num3(1.2)
        config.longSteps.add(new TaxiPricingDemoService.LongRangeStep(Double.parseDouble(basicPricingJson.getString("num6")), Double.parseDouble(basicPricingJson.getString("num7")), Double.parseDouble(basicPricingJson.getString("num8"))));
        // 2. 超过 num4(20) 不足 num5(35), 加收 num6(2.0)
        config.longSteps.add(new TaxiPricingDemoService.LongRangeStep(Double.parseDouble(basicPricingJson.getString("num9")), Double.parseDouble(basicPricingJson.getString("num10")), Double.parseDouble(basicPricingJson.getString("num11"))));
        // 3. 超过 num7(35) 以后, 加收 num8(3.5) -> numEnd 传个极大值
        config.longSteps.add(new TaxiPricingDemoService.LongRangeStep(Double.parseDouble(basicPricingJson.getString("num12")), 999999, Double.parseDouble(basicPricingJson.getString("num13"))));
        TaxiPricingDemoService.TaxiPricingService service = new TaxiPricingDemoService.TaxiPricingService();
        Map<String, BigDecimal> bill = service.calculateOrderPrice(DateUtils.toDate(order.getCreateTime()), order.getMileageKilometers(), gpsPoints, config);
@@ -1547,11 +1554,15 @@
            }
        }
        List<OrderTrajectory> trajectories = mongoTemplate.find(
                new Query(Criteria.where("orderId").is(orderId))
                        .with(Sort.by(Sort.Direction.ASC, "locatetime")),
                OrderTrajectory.class
        );
//        List<OrderTrajectory> trajectories = mongoTemplate.find(
//                new Query(Criteria.where("orderId").is(orderId))
//                        .with(Sort.by(Sort.Direction.ASC, "locatetime")),
//                OrderTrajectory.class
//        );
        List<TaxiPricingDemoService.GpsPoint> mockGpsPoints = TaxiPricingDemoService.createMockGpsPoints(DateUtils.toDate(order.getCreateTime()));
        // 生成轨迹记录
        List<OrderTrajectory> trajectories = TrajectoryGenerator.generateTrajectory(mockGpsPoints);
        orderDetailVo.setTrajectories(trajectories);
        if (order.getTripBegin() != null && order.getTripEnd() != null) {
            // 计算两个时间相差多少分钟
xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/utils/TaxiPricingDemoService.java
@@ -270,7 +270,7 @@
        return config;
    }
    private static List<GpsPoint> createMockGpsPoints(Date startTime) {
    public static List<GpsPoint> createMockGpsPoints(Date startTime) {
        List<GpsPoint> list = new ArrayList<>();
        long startTs = startTime.getTime();
        list.add(new GpsPoint(0, startTs));
@@ -318,6 +318,324 @@
        list.add(new GpsPoint(182, startTs + 2 * 410 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 420 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 430 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 440 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 450 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 460 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 470 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 490 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 500 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 510 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 520 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 530 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 540 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 550 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 560 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 570 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 590 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 600 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 1980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 2980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3180 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3280 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3380 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3480 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3580 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3680 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3780 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3880 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 3980 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 4080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 4080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 4080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 4080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 4080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 4080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 4080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 4080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 4080 * 1000));
        list.add(new GpsPoint(182, startTs + 2 * 4180 * 1000));
        return list;
    }
}
xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/utils/TrajectoryGenerator.java
New file
@@ -0,0 +1,55 @@
package com.xiaopeng.order.utils;
import com.xiaopeng.order.mangodb.model.OrderTrajectory;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class TrajectoryGenerator {
    // 成都市中心经纬度(示例)
    private static final double BASE_LAT = 30.5728; // 纬度
    private static final double BASE_LON = 104.0668; // 经度
    /**
     * 根据 GpsPoint 数据生成 OrderTrajectory 轨迹记录
     *
     * @param gpsPoints 模拟的 GpsPoint 数据
     * @return 轨迹记录列表
     */
    public static List<OrderTrajectory> generateTrajectory(List<TaxiPricingDemoService.GpsPoint> gpsPoints) {
        List<OrderTrajectory> trajectories = new ArrayList<>();
        // 初始位置
        double currentLat = BASE_LAT;
        double currentLon = BASE_LON;
        for (int i = 0; i < gpsPoints.size(); i++) {
            TaxiPricingDemoService.GpsPoint point = gpsPoints.get(i);
            // 生成随机偏移量(确保相邻点距离不超过100米)
            double deltaLat = (Math.random() - 0.5) * 0.001; // 纬度偏移
            double deltaLon = (Math.random() - 0.5) * 0.001; // 经度偏移
            // 更新当前位置
            currentLat += deltaLat;
            currentLon += deltaLon;
            // 创建 OrderTrajectory 对象
            OrderTrajectory trajectory = new OrderTrajectory();
            trajectory.setOrderId(1L); // 假设订单 ID 为 1
            trajectory.setLocation(String.format("%.6f,%.6f", currentLon, currentLat)); // 经纬度格式化
            trajectory.setDirection((int) (Math.random() * 360)); // 随机方向角
            trajectory.setSpeed(Math.random() * 50); // 随机速度(0~50 km/h)
            trajectory.setLocatetime(point.getLocatetime()); // 时间戳
            trajectory.setDistance(point.getDistance()); // 距离
            trajectories.add(trajectory);
        }
        return trajectories;
    }
}