|
@@ -82,14 +82,14 @@ public class AddressQueryEngine {
|
|
// 创建请求
|
|
// 创建请求
|
|
addressResult = szxSearchByName(addr);
|
|
addressResult = szxSearchByName(addr);
|
|
// TODO 高德接口无法使用,市中心的接口请求成为了最后一道防线 && ifRuleData(addressResult.getData().get(0).getScore())
|
|
// TODO 高德接口无法使用,市中心的接口请求成为了最后一道防线 && ifRuleData(addressResult.getData().get(0).getScore())
|
|
- if (addressResult != null && addressResult.getData() != null && addressResult.getData().size() > 0) {
|
|
|
|
|
|
+ if (addressResult != null && addressResult.getData() != null && addressResult.getData().size() > 0 && ifRuleData(addressResult.getData().get(0).getScore())) {
|
|
addressResult.setCode(AddressResultEnum.SZX_SUCCESS);
|
|
addressResult.setCode(AddressResultEnum.SZX_SUCCESS);
|
|
addressResult.setMessage("成功");
|
|
addressResult.setMessage("成功");
|
|
return getCjWgWgwByLoc(addressResult);
|
|
return getCjWgWgwByLoc(addressResult);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// TODO 如果多次尝试请求市中心地址后,还是请求失败就使用高德地名地址搜索,现在是到了上限,暂时不用
|
|
// TODO 如果多次尝试请求市中心地址后,还是请求失败就使用高德地名地址搜索,现在是到了上限,暂时不用
|
|
- /*for (String addr : addrs) {
|
|
|
|
|
|
+ for (String addr : addrs) {
|
|
// 创建请求(要返回对应的搜索地址,返回地址,总分,市:cityname,街道:adname,村居:community)
|
|
// 创建请求(要返回对应的搜索地址,返回地址,总分,市:cityname,街道:adname,村居:community)
|
|
addressResult = gdV3SearchByName(addr);
|
|
addressResult = gdV3SearchByName(addr);
|
|
if (addressResult != null && addressResult.getData() != null && addressResult.getData().size() > 0) {
|
|
if (addressResult != null && addressResult.getData() != null && addressResult.getData().size() > 0) {
|
|
@@ -97,7 +97,7 @@ public class AddressQueryEngine {
|
|
addressResult.setMessage("成功");
|
|
addressResult.setMessage("成功");
|
|
return getCjWgWgwByLoc(addressResult);
|
|
return getCjWgWgwByLoc(addressResult);
|
|
}
|
|
}
|
|
- }*/
|
|
|
|
|
|
+ }
|
|
// addressResult.setCode(AddressResultEnum.RESULT_NULL);
|
|
// addressResult.setCode(AddressResultEnum.RESULT_NULL);
|
|
if(addressResult != null){
|
|
if(addressResult != null){
|
|
addressResult.setMessage("失败");
|
|
addressResult.setMessage("失败");
|
|
@@ -311,7 +311,7 @@ public class AddressQueryEngine {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public AddressResult gdSearchByName(String address) {
|
|
public AddressResult gdSearchByName(String address) {
|
|
- String geoUrl = Constant.AMAP_GEO_URL + "?key=" + Constant.AMAP_KEY[ThreadLocalRandom.current().nextInt(0, 4)] + "&address=" + address + "&city=" + Constant.getAMAP_CITY_CODE() + "&output=JSON";
|
|
|
|
|
|
+ String geoUrl = Constant.AMAP_GEO_URL + "?key=" + Constant.AMAP_KEY[ThreadLocalRandom.current().nextInt(0, Constant.AMAP_KEY.length)] + "&address=" + address + "&city=" + Constant.getAMAP_CITY_CODE() + "&output=JSON";
|
|
ResponseEntity response = AddressNetTools.getInstance().requestGetOrPost(HttpMethod.GET, geoUrl, null, null, 0);
|
|
ResponseEntity response = AddressNetTools.getInstance().requestGetOrPost(HttpMethod.GET, geoUrl, null, null, 0);
|
|
if (response != null && response.getBody() != null) {
|
|
if (response != null && response.getBody() != null) {
|
|
String body = response.getBody() + "";
|
|
String body = response.getBody() + "";
|
|
@@ -341,7 +341,7 @@ public class AddressQueryEngine {
|
|
JSONArray pois = new JSONArray();
|
|
JSONArray pois = new JSONArray();
|
|
ScheduledTasks.gdRequestSize++;
|
|
ScheduledTasks.gdRequestSize++;
|
|
String geoUrl =
|
|
String geoUrl =
|
|
- Constant.AMAP_SEARCH_NAME_V3 + "?key=" + Constant.AMAP_KEY[ThreadLocalRandom.current().nextInt(0, 4)] + "&types=" + Constant.AMAP_SEARCH_TYPES +
|
|
|
|
|
|
+ Constant.AMAP_SEARCH_NAME_V3 + "?key=" + Constant.AMAP_KEY[ThreadLocalRandom.current().nextInt(0, Constant.AMAP_KEY.length)] + "&types=" + Constant.AMAP_SEARCH_TYPES +
|
|
"&keywords=" + address + "&city=" + Constant.getAMAP_CITY_CODE() + "&offset=20";
|
|
"&keywords=" + address + "&city=" + Constant.getAMAP_CITY_CODE() + "&offset=20";
|
|
ResponseEntity responseEntity = AddressNetTools.getInstance().requestGetOrPost(HttpMethod.GET, geoUrl, null, null, 0);
|
|
ResponseEntity responseEntity = AddressNetTools.getInstance().requestGetOrPost(HttpMethod.GET, geoUrl, null, null, 0);
|
|
if (responseEntity.hasBody()) {
|
|
if (responseEntity.hasBody()) {
|