From 13b1838cfd7df8c49450e2529943a0f87fbd0354 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期四, 19 六月 2025 18:01:55 +0800
Subject: [PATCH] 推单距离优化

---
 UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapElectricFenceUtil.java |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapElectricFenceUtil.java b/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapElectricFenceUtil.java
index f49fcfe..40580fc 100644
--- a/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapElectricFenceUtil.java
+++ b/UserZYTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/GDMapElectricFenceUtil.java
@@ -17,6 +17,7 @@
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.RestTemplate;
 
+import java.io.IOException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -120,7 +121,20 @@
         }
         return resoult;
     }
-
+    public Double getDrivingRoute(double startLat, double startLon, double endLat, double endLon) {
+        String url = "https://restapi.amap.com/v3/direction/driving?" +
+                "origin=" + startLon + "," + startLat +
+                "&destination=" + endLon + "," + endLat +
+                "&key=" + key;
+        String forObject = restTemplate.getForObject(url, String.class);
+        // 转化为json对象
+        JSONObject jsonObject = JSONObject.parseObject(forObject);
+        JSONObject route = jsonObject.getJSONObject("route");
+        JSONArray paths = route.getJSONArray("paths");
+        JSONObject o = (JSONObject)paths.get(0);
+        Double distance = o.getDouble("distance");
+        return distance;
+    }
 
 
 

--
Gitblit v1.7.1