From d4ec5b4db43cf4a9bf6f70ddf04fe3badb6cf6c0 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期日, 15 三月 2026 23:27:07 +0800
Subject: [PATCH] 计费修改

---
 xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/utils/AliPushUtil.java             |    2 
 xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/utils/TaxiPricingDemoService.java               |  117 +++++++++++++++++++++-----------------
 xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpTaskServiceImpl.java |   12 ++--
 3 files changed, 72 insertions(+), 59 deletions(-)

diff --git a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpTaskServiceImpl.java b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpTaskServiceImpl.java
index 6017864..81d9d30 100644
--- a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpTaskServiceImpl.java
+++ b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpTaskServiceImpl.java
@@ -176,11 +176,11 @@
         PageInfo<TaskPageListVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
         List<TaskPageListVO> list = this.baseMapper.pageList(pageInfo, query);
         XpTaskRule xpTaskRule = xpTaskRuleMapper.selectOne(new LambdaQueryWrapper<XpTaskRule>().last("limit 1"));
-//        if (Objects.nonNull(xpTaskRule)) {
-//            list.stream().filter(item -> item.getTaskCategory().equals(2)).forEach(item -> {
-//                item.setCanArriveRange(xpTaskRule.getCanArriveRange());
-//            });
-//        }
+        if (Objects.nonNull(xpTaskRule)) {
+            list.stream().filter(item -> item.getTaskCategory().equals(2)).forEach(item -> {
+                item.setCanArriveRange(xpTaskRule.getCanArriveRange());
+            });
+        }
         pageInfo.setRecords(list);
         return pageInfo;
     }
@@ -815,10 +815,10 @@
         res.setTaskCategory(task.getTaskCategory());
         res.setTaskTypeId(task.getTaskTypeId());
         res.setStatus(task.getStatus());
-        res.setHandleTime(task.getHandleTime());
         XpVehicleClean vehicleDetection = vehicleCleanMapper.selectOne(new LambdaQueryWrapper<XpVehicleClean>()
                 .eq(XpVehicleClean::getTaskId, id).last("limit 1"));
         if (vehicleDetection != null) {
+            res.setHandleTime(vehicleDetection.getCreateTime());
             res.setTaskImage(vehicleDetection.getTaskImage());
             res.setOperationUserId(vehicleDetection.getOperationsUserId());
             if (vehicleDetection.getOperationsUserId() != null) {
diff --git a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/utils/TaxiPricingDemoService.java b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/utils/TaxiPricingDemoService.java
index d9881ff..8c17108 100644
--- a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/utils/TaxiPricingDemoService.java
+++ b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/utils/TaxiPricingDemoService.java
@@ -20,9 +20,9 @@
         Date orderTime = new Date();
 //
         // 模拟总里程 25.0 km,以触发多级远途加价
-        double totalMillige = 1.24;
+        double totalMillige = 8.946;
         Calendar cal = Calendar.getInstance();
-        cal.set(2026, Calendar.APRIL, 11, 15, 48, 50);
+        cal.set(2026, Calendar.APRIL, 15, 22, 4, 50);
         orderTime = cal.getTime();
         // 模拟 GPS 轨迹点
         List<GpsPoint> points = createMockGpsPoints(orderTime);
@@ -142,9 +142,9 @@
                 }
             }
             // 2. 远途加价计算 (基于区间判定)
-            BigDecimal longExtra = calculateLongDistExtra(BigDecimal.valueOf(totalMileageKm), config.longSteps);
+            BigDecimal longExtra = calculateLongDistExtra(BigDecimal.valueOf(totalMileageKm).subtract(remainBaseM.divide(new BigDecimal(1000))), config.longSteps);
             // 计算远途里程
-            BigDecimal longExtraValue = calculateLongDistExtra(BigDecimal.valueOf(totalMileageKm), config.longSteps);
+            BigDecimal longExtraValue = calculateLongDistExtra(BigDecimal.valueOf(totalMileageKm).subtract(remainBaseM.divide(new BigDecimal(1000))), config.longSteps);
             result.put("远途费&"+longExtraValue, longExtra);
             return formatMap(result);
         }
@@ -158,16 +158,29 @@
             // 当前点所在的公里数
             BigDecimal extraStart = BigDecimal.ZERO;
             BigDecimal extraRate = BigDecimal.ZERO;
+            BigDecimal totalExtra = BigDecimal.ZERO;
+            BigDecimal remainingDistance = billM;
 
             // 匹配区间规则
+            // 分段累进计费
             for (LongRangeStep step : steps) {
-                if (step.isMatch(billM)) {
-                    extraRate = step.addPrice;
-                    extraStart = step.numStart;
-                    break;
-                }
+               if (remainingDistance.compareTo(BigDecimal.ZERO) <= 0) {
+                   break;
+               }
+
+               // 计算当前区间的宽度
+               BigDecimal rangeWidth = step.numEnd.subtract(step.numStart);
+
+               // 计算在当前区间应计费的距离
+               BigDecimal distanceInThisRange = remainingDistance.min(rangeWidth);
+
+               // 如果还有剩余距离需要计入当前区间
+               if (distanceInThisRange.compareTo(BigDecimal.ZERO) > 0) {
+                   totalExtra = totalExtra.add(distanceInThisRange.multiply(step.addPrice));
+                   remainingDistance = remainingDistance.subtract(distanceInThisRange);
+               }
             }
-            return billM.subtract(extraStart).multiply(extraRate);
+            return totalExtra;
         }
         /**
          * 计算远途费的里程
@@ -293,48 +306,48 @@
         list.add(new GpsPoint(188, startTs + 2 * 50 * 1000));
         list.add(new GpsPoint(150, startTs + 2 * 60 * 1000));
         list.add(new GpsPoint(126, startTs + 2 * 70 * 1000));
-//        list.add(new GpsPoint(138, startTs + 2 * 80 * 1000));
-//        list.add(new GpsPoint(119, startTs + 2 * 90 * 1000));
-//        list.add(new GpsPoint(147, startTs + 2 * 100 * 1000));
-//        list.add(new GpsPoint(155, startTs + 2 * 110 * 1000));
-//        list.add(new GpsPoint(182, startTs + 2 * 120 * 1000));
-//        list.add(new GpsPoint(172, startTs + 2 * 130 * 1000));
-//        list.add(new GpsPoint(202, startTs + 2 * 140 * 1000));
-//        list.add(new GpsPoint(162, startTs + 2 * 150 * 1000));
-//        list.add(new GpsPoint(182, startTs + 2 * 160 * 1000));
-//        list.add(new GpsPoint(132, startTs + 2 * 170 * 1000));
-//        list.add(new GpsPoint(122, startTs + 2 * 180 * 1000));
-//        list.add(new GpsPoint(262, startTs + 2 * 190 * 1000));
-//        list.add(new GpsPoint(242, startTs + 2 * 200 * 1000));
-//        list.add(new GpsPoint(282, startTs + 2 * 210 * 1000));
-//        list.add(new GpsPoint(222, startTs + 2 * 220 * 1000));
-//        list.add(new GpsPoint(212, startTs + 2 * 230 * 1000));
-//        list.add(new GpsPoint(142, startTs + 2 * 240 * 1000));
-//        list.add(new GpsPoint(262, startTs + 2 * 250 * 1000));
-//        list.add(new GpsPoint(169, startTs + 2 * 260 * 1000));
-//        list.add(new GpsPoint(170, startTs + 2 * 270 * 1000));
-//        list.add(new GpsPoint(180, startTs + 2 * 280 * 1000));
-//        list.add(new GpsPoint(165, startTs + 2 * 290 * 1000));
-//        list.add(new GpsPoint(180, startTs + 2 * 300 * 1000));
-//        list.add(new GpsPoint(198, startTs + 2 * 310 * 1000));
-//        list.add(new GpsPoint(182, startTs + 2 * 320 * 1000));
-//        list.add(new GpsPoint(182, startTs + 2 * 330 * 1000));
-//        list.add(new GpsPoint(182, startTs + 2 * 340 * 1000));
-//        list.add(new GpsPoint(182, startTs + 2 * 350 * 1000));
-//        list.add(new GpsPoint(182, startTs + 2 * 360 * 1000));
-//        list.add(new GpsPoint(182, startTs + 2 * 370 * 1000));
-//        list.add(new GpsPoint(182, startTs + 2 * 380 * 1000));
-//        list.add(new GpsPoint(182, startTs + 2 * 390 * 1000));
-//        list.add(new GpsPoint(182, startTs + 2 * 400 * 1000));
-//        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(138, startTs + 2 * 80 * 1000));
+        list.add(new GpsPoint(119, startTs + 2 * 90 * 1000));
+        list.add(new GpsPoint(147, startTs + 2 * 100 * 1000));
+        list.add(new GpsPoint(155, startTs + 2 * 110 * 1000));
+        list.add(new GpsPoint(182, startTs + 2 * 120 * 1000));
+        list.add(new GpsPoint(172, startTs + 2 * 130 * 1000));
+        list.add(new GpsPoint(202, startTs + 2 * 140 * 1000));
+        list.add(new GpsPoint(162, startTs + 2 * 150 * 1000));
+        list.add(new GpsPoint(182, startTs + 2 * 160 * 1000));
+        list.add(new GpsPoint(132, startTs + 2 * 170 * 1000));
+        list.add(new GpsPoint(122, startTs + 2 * 180 * 1000));
+        list.add(new GpsPoint(262, startTs + 2 * 190 * 1000));
+        list.add(new GpsPoint(242, startTs + 2 * 200 * 1000));
+        list.add(new GpsPoint(282, startTs + 2 * 210 * 1000));
+        list.add(new GpsPoint(222, startTs + 2 * 220 * 1000));
+        list.add(new GpsPoint(212, startTs + 2 * 230 * 1000));
+        list.add(new GpsPoint(142, startTs + 2 * 240 * 1000));
+        list.add(new GpsPoint(262, startTs + 2 * 250 * 1000));
+        list.add(new GpsPoint(169, startTs + 2 * 260 * 1000));
+        list.add(new GpsPoint(170, startTs + 2 * 270 * 1000));
+        list.add(new GpsPoint(180, startTs + 2 * 280 * 1000));
+        list.add(new GpsPoint(165, startTs + 2 * 290 * 1000));
+        list.add(new GpsPoint(180, startTs + 2 * 300 * 1000));
+        list.add(new GpsPoint(198, startTs + 2 * 310 * 1000));
+        list.add(new GpsPoint(182, startTs + 2 * 320 * 1000));
+        list.add(new GpsPoint(182, startTs + 2 * 330 * 1000));
+        list.add(new GpsPoint(182, startTs + 2 * 340 * 1000));
+        list.add(new GpsPoint(182, startTs + 2 * 350 * 1000));
+        list.add(new GpsPoint(182, startTs + 2 * 360 * 1000));
+        list.add(new GpsPoint(182, startTs + 2 * 370 * 1000));
+        list.add(new GpsPoint(182, startTs + 2 * 380 * 1000));
+        list.add(new GpsPoint(182, startTs + 2 * 390 * 1000));
+        list.add(new GpsPoint(182, startTs + 2 * 400 * 1000));
+        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));
diff --git a/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/utils/AliPushUtil.java b/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/utils/AliPushUtil.java
index 15a3784..ae51b98 100644
--- a/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/utils/AliPushUtil.java
+++ b/xp-robotaxi-push-message-boot/src/main/java/com/xiaopeng/pushMessage/utils/AliPushUtil.java
@@ -104,7 +104,7 @@
                         .targetValue(account)
                         .title(title)
                         .body(content)
-//                        .androidExtParameters(body)
+                        .androidExtParameters(body)
                         .androidNotificationChannel(channelIds)
                         .build();
                 if(deviceType == 2){

--
Gitblit v1.7.1