Pu Zhibing
21 小时以前 1da73e129402bb3923e92f3d561ac49acc87fee5
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;
    }
@@ -283,7 +297,6 @@
        String url = "https://restapi.amap.com/v4/geofence/meta?key=" + key + "&gid=" + gid;
        String s = restTemplate.patchForObject(url, formEntity, String.class);
        System.out.println(s);
//        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "更新电子围栏");
    }
@@ -321,7 +334,6 @@
                }
            }
        }
        System.out.println("检测:" + forObject);
//        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/status", "电子围栏监控");
        return ids;
@@ -335,7 +347,6 @@
     */
    public boolean deleteElectricFenc(String gid){
        restTemplate.delete("https://restapi.amap.com/v4/geofence/meta?key={1}&gid={2}", key, gid);
        System.out.println("删除:" );
//        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "删除电子围栏");
@@ -353,7 +364,6 @@
    public Map<String, String> getDistance(String origins, String destination, Integer type){
        String url = "https://restapi.amap.com/v3/distance?key=" + key + "&origins=" + origins + "&destination=" + destination +
                "&type=" + type;
        System.out.println(url);
        String forObject = restTemplate.getForObject(url, String.class);
        JSONObject jsonObject = JSON.parseObject(forObject);
        String status = jsonObject.getString("status");