| | |
| | | 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.*; |
| | |
| | | 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(); |
| | |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | 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"); |
| | |
| | | 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"); |
| | |
| | | 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", "更新电子围栏"); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | System.out.println("检测:" + forObject); |
| | | |
| | | gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/status", "电子围栏监控"); |
| | | // gdInterfaceService.saveData("https://restapi.amap.com/v4/geofence/status", "电子围栏监控"); |
| | | return ids; |
| | | } |
| | | |
| | |
| | | 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; |
| | | } |
| | |
| | | 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"); |
| | |
| | | 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"); |