| | |
| | | return "fail"; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String fenceToLocation(String gaodeKey, String serviceId, String locationLonglat, String fenceId) { |
| | | String url = "https://tsapi.amap.com/v1/track/geofence/status/location"; |
| | | HttpPost httpPost = new HttpPost(url); |
| | | Map<String,String> map = new HashMap<>(); |
| | | //高德Key |
| | | //用户在高德地图官网申请Web服务API类型Key |
| | | map.put("key",gaodeKey); |
| | | //服务唯一编号 |
| | | //sid为猎鹰service唯一编号 |
| | | map.put("sid",serviceId); |
| | | //指定坐标 |
| | | //格式:x,y |
| | | map.put("location",locationLonglat); |
| | | //围栏的唯一标识 |
| | | //支持一次传入多个,以","分割; |
| | | //单次最多支持100个,如超出将只截取前100个作为输入。 |
| | | map.put("gfids",fenceId); |
| | | log.info("查询指定坐标与围栏关系"+JSON.toJSONString(map)); |
| | | String result = null; |
| | | try { |
| | | result = HttpCurlUtil.sendGetHttp(url, map); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | log.info("查询指定坐标与围栏关系"+result); |
| | | cn.hutool.json.JSONObject maps = JSONUtil.parseObj(result); |
| | | String errCode = maps.get("errcode").toString(); |
| | | if("10000".equals(errCode)){ |
| | | String dataStr = maps.get("data").toString(); |
| | | cn.hutool.json.JSONObject dataResults = JSONUtil.parseObj(dataStr); |
| | | String resultsStr = dataResults.get("results").toString(); |
| | | cn.hutool.json.JSONObject resultsStrJson = JSONUtil.parseObj(resultsStr); |
| | | String in = resultsStrJson.get("in").toString(); |
| | | return in; |
| | | }else{ |
| | | return "fail"; |
| | | } |
| | | } |
| | | } |