xuhy
1 天以前 13b1838cfd7df8c49450e2529943a0f87fbd0354
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.*;
@@ -93,7 +94,7 @@
            JSONObject data = jsonObject.getJSONObject("data");
            String status = data.getString("status");
            gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "创建电子围栏");
//            gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "创建电子围栏");
//            if(status.equals("0")){//创建成功
//                GDFence gdFence = new GDFence();
@@ -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;
    }
@@ -153,7 +167,7 @@
        JSONObject jsonObject = JSON.parseObject(forObject);
        JSONObject data = jsonObject.getJSONObject("data");
        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "查询电子围栏");
//        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "查询电子围栏");
        if(ToolUtil.isNotEmpty(center)){//圆形电子围栏
            JSONArray rs_list = data.getJSONArray("rs_list");
@@ -192,7 +206,7 @@
        JSONArray rs_list = data.getJSONArray("rs_list");
        jsonArray.addAll(rs_list);
        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "查询电子围栏");
//        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "查询电子围栏");
        //判断是否有分页
        int total_record = data.getIntValue("total_record");
@@ -285,7 +299,7 @@
        String s = restTemplate.patchForObject(url, formEntity, String.class);
        System.out.println(s);
        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "更新电子围栏");
//        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "更新电子围栏");
    }
@@ -323,7 +337,7 @@
        }
        System.out.println("检测:" + forObject);
        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/status", "电子围栏监控");
//        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/status", "电子围栏监控");
        return ids;
    }
@@ -337,7 +351,7 @@
        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", "删除电子围栏");
//        gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/meta", "删除电子围栏");
        return true;
    }
@@ -358,7 +372,7 @@
        JSONObject jsonObject = JSON.parseObject(forObject);
        String status = jsonObject.getString("status");
        gdInterfaceService.saveData("https://restapi.amap.com/v3/distance", "查询两点间的距离");
//        gdInterfaceService.saveData("https://restapi.amap.com/v3/distance", "查询两点间的距离");
        if(status.equals("1")){
            JSONArray results = jsonObject.getJSONArray("results");
@@ -388,7 +402,7 @@
        JSONObject jsonObject = JSON.parseObject(forObject);
        String status = jsonObject.getString("status");
        gdInterfaceService.saveData("https://restapi.amap.com/v3/direction/driving", "获取路径规划");
//        gdInterfaceService.saveData("https://restapi.amap.com/v3/direction/driving", "获取路径规划");
        if(status.equals("1")){
            JSONObject route = jsonObject.getJSONObject("route");