|
@@ -20,6 +20,7 @@ import org.apache.commons.codec.binary.Base64;
|
|
|
import javax.crypto.Mac;
|
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ThreadLocalRandom;
|
|
|
|
|
|
public class AddressQueryEngine {
|
|
|
|
|
@@ -306,7 +307,7 @@ public class AddressQueryEngine {
|
|
|
* @return
|
|
|
*/
|
|
|
public AddressResult gdSearchByName(String address) {
|
|
|
- String geoUrl = Constant.AMAP_GEO_URL + "?key=" + Constant.AMAP_KEY + "&address=" + address + "&city=" + Constant.getAMAP_CITY_CODE() + "&output=JSON";
|
|
|
+ String geoUrl = Constant.AMAP_GEO_URL + "?key=" + Constant.AMAP_KEY[ThreadLocalRandom.current().nextInt(0, 4)] + "&address=" + address + "&city=" + Constant.getAMAP_CITY_CODE() + "&output=JSON";
|
|
|
ResponseEntity response = AddressNetTools.getInstance().requestGetOrPost(HttpMethod.GET, geoUrl, null, null, 0);
|
|
|
if (response != null && response.getBody() != null) {
|
|
|
String body = response.getBody() + "";
|
|
@@ -335,7 +336,7 @@ public class AddressQueryEngine {
|
|
|
}
|
|
|
JSONArray pois = new JSONArray();
|
|
|
String geoUrl =
|
|
|
- Constant.AMAP_SEARCH_NAME_V3 + "?key=" + Constant.AMAP_KEY + "&types=" + Constant.AMAP_SEARCH_TYPES +
|
|
|
+ Constant.AMAP_SEARCH_NAME_V3 + "?key=" + Constant.AMAP_KEY[ThreadLocalRandom.current().nextInt(0, 4)] + "&types=" + Constant.AMAP_SEARCH_TYPES +
|
|
|
"&keywords=" + address + "&city=" + Constant.getAMAP_CITY_CODE() + "&offset=20";
|
|
|
ResponseEntity responseEntity = AddressNetTools.getInstance().requestGetOrPost(HttpMethod.GET, geoUrl, null, null, 0);
|
|
|
if (responseEntity.hasBody()) {
|