|
@@ -168,6 +168,58 @@ public class AddressQueryEngine {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public Object sj_szxSearchByName_to_server(String address) {
|
|
|
+// 鉴权
|
|
|
+ Map<String, String> headerMap = new HashMap<>();
|
|
|
+ String timestamp = System.currentTimeMillis() + "";
|
|
|
+ String appCode = "7unv4vbwqxnq4a7m9h";
|
|
|
+ String UUid = UUID.randomUUID().toString();
|
|
|
+ String appSecret = "w6tawvf4k3ck4ikij9";
|
|
|
+ headerMap.put("x-timestamp", timestamp);
|
|
|
+ headerMap.put("x-appcode", appCode);
|
|
|
+ headerMap.put("x-uuid", UUid);
|
|
|
+// 签名
|
|
|
+ headerMap.put("x-sign", getSigns(timestamp, appCode, UUid, appSecret));
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ JSONArray requestJson = new JSONArray();
|
|
|
+ JSONObject paramObject = new JSONObject();
|
|
|
+ paramObject.put("name", "query");
|
|
|
+ paramObject.put("position", "QUERY");
|
|
|
+ paramObject.put("value", address);
|
|
|
+ requestJson.add(paramObject);
|
|
|
+// 判断是否是关键字版搜索服务
|
|
|
+ if (Constant.SJ_SZX_SEARCH_BY_NAME.contains("1742459783686")) {
|
|
|
+ JSONObject paramObject2 = new JSONObject();
|
|
|
+ paramObject2.put("name", "region");
|
|
|
+ paramObject2.put("position", "QUERY");
|
|
|
+ paramObject2.put("value", Constant.getAMAP_CITY_CODE());
|
|
|
+ requestJson.add(paramObject2);
|
|
|
+ JSONObject paramObject3 = new JSONObject();
|
|
|
+ paramObject3.put("name", "page_size");
|
|
|
+ paramObject3.put("position", "QUERY");
|
|
|
+ paramObject3.put("value", "10");
|
|
|
+ requestJson.add(paramObject3);
|
|
|
+ }
|
|
|
+ params.put("requestJson", requestJson);
|
|
|
+// 发起请求
|
|
|
+ ResponseEntity response = AddressNetTools.getInstance().requestGetOrPost(HttpMethod.POST, Constant.SJ_SZX_SEARCH_BY_NAME, params, headerMap, 1);
|
|
|
+ if (response != null && response.hasBody()) {
|
|
|
+ String body = response.getBody() + "";
|
|
|
+ if (!StringUtils.hasText(body))
|
|
|
+ return AddressTools.getInstance().faildQuery(AddressResultEnum.RESULT_NULL, "搜索无结果");
|
|
|
+ try {
|
|
|
+ return JSONObject.parseObject(body);
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("请求地址:" + address + ";返回结果:" + body + ";处理异常:" + e);
|
|
|
+ return AddressTools.getInstance().faildQuery(AddressResultEnum.DATA_FROMAT_FAILD, "格式化失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ System.out.println("地址[" + address + "]未查询到数据!");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/***
|
|
|
* 高德普通地名搜索
|
|
|
* @param address
|