提交代码修改

dev-discount
袁野 2 years ago
parent 7ed5736e25
commit 6d4259111b
  1. 9
      hai-cweb/src/main/java/com/cweb/controller/CommonController.java
  2. 26
      hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java

@ -287,8 +287,17 @@ public class CommonController {
) { ) {
try { try {
JSONObject jsonObjectR = commonService.findByLatAndLng(lng , lat);
if (!jsonObjectR.getString("status").equals("0")) {
log.error("findByLatAndLng error!", "定位错误,请重新定位" );
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "定位错误,请重新定位");
}
JSONObject object = commonService.findByLatAndLng(lng , lat).getJSONObject("result").getJSONObject("addressComponent"); JSONObject object = commonService.findByLatAndLng(lng , lat).getJSONObject("result").getJSONObject("addressComponent");
ApiCity apiCity = commonService.findCityByName(object.getString("city")); ApiCity apiCity = commonService.findCityByName(object.getString("city"));
if (apiCity == null) { if (apiCity == null) {

@ -534,18 +534,20 @@ public class CommonServiceImpl implements CommonService {
@Override @Override
public JSONObject findByLatAndLng(String lng, String lat) throws Exception { public JSONObject findByLatAndLng(String lng, String lat) throws Exception {
Map<String,Object> map = new HashMap<>();//参数 //参数
map.put("ak", "SfrwGH7INvjPq7BwCrYrioBQZm9XXxrR");//申请百度开放平台KEY(ak) Map<String,Object> map = new HashMap<>();
map.put("output", "json");// 输出Json数据 //申请百度开放平台KEY(ak)
map.put("extensions_town", "true");// 行政区划返回乡镇级数据(town),仅国内召回乡镇数据 map.put("ak", "SfrwGH7INvjPq7BwCrYrioBQZm9XXxrR");
map.put("coordtype", "wgs84ll"); // GPS 经纬度类型 // 输出Json数据
map.put("location", lat+","+lng+"");//百度经纬度 map.put("output", "json");
// 行政区划返回乡镇级数据(town),仅国内召回乡镇数据
String url = "http://api.map.baidu.com/reverse_geocoding/v3/"; map.put("extensions_town", "true");
// GPS 经纬度类型
System.out.println("请求经纬度========" + map); map.put("coordtype", "wgs84ll");
//百度经纬度
return HttpsUtils.doGet(url , map); map.put("location", lat+","+lng+"");
return HttpsUtils.doGet("http://api.map.baidu.com/reverse_geocoding/v3/" , map);
} }

Loading…
Cancel
Save