新增根据ID获取详情
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
package com.fangjia.script.temp.shenjian.poi
|
||||
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.fangjia.script.coredata.util.CollectionUtils
|
||||
import com.fangjia.script.statistics.poi.AmapPoi
|
||||
import com.fangjia.script.temp.shenjian.util.ExcelUtils
|
||||
import com.fangjia.script.temp.shenjian.util.GaoDeUtils
|
||||
import com.fangjia.script.temp.shenjian.util.HttpUtils
|
||||
|
||||
/**
|
||||
* 反查高德小区信息
|
||||
*/
|
||||
class CounterCheckGaoDe {
|
||||
|
||||
static final def URL = "http://192.168.0.216:38080/FangJiaDataService/saveAmapPoi"
|
||||
|
||||
static void main(String[] args) {
|
||||
List<List<String>> infos = ExcelUtils.read("D:\\Users\\Domi\\Desktop\\房价网\\项目\\建行\\模型级联\\地图反查信息_高德结果.xlsx")
|
||||
for (List<String> info : infos) {
|
||||
if (info.size() < 6) {
|
||||
String id = info.get(4)
|
||||
List<AmapPoi> amapPois = GaoDeUtils.getAmapById(id)
|
||||
if (CollectionUtils.isNotEmpty(amapPois)) {
|
||||
String jsonStr = JSONObject.toJSONString(amapPois)
|
||||
HttpUtils.postForJson(URL, jsonStr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -29,7 +29,7 @@ class ExcelUtils {
|
||||
|
||||
static List<List<String>> read(String filePath) {
|
||||
SimpleExcelListener listener = new SimpleExcelListener(filePath);
|
||||
ExcelReader excelReader = EasyExcelFactory.read(filePath, null, listener).headRowNumber(0).build();
|
||||
ExcelReader excelReader = EasyExcelFactory.read(filePath, null, listener).headRowNumber(1).build();
|
||||
excelReader.readAll()
|
||||
List<List<String>> dataList = listener.getDataList();
|
||||
excelReader.finish()
|
||||
|
||||
+29
@@ -203,6 +203,35 @@ class GaoDeUtils {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详情
|
||||
*/
|
||||
static List<AmapPoi> getAmapById(id){
|
||||
def params = [:]
|
||||
params.key = GAO_DE_AK[keyUsed.intValue()]
|
||||
params.id = id
|
||||
params.output = 'json'
|
||||
JSONObject json = HttpRequestUtil.getJsonContent("https://restapi.amap.com/v3/place/detail", params);
|
||||
if (json == null) {
|
||||
json = HttpRequestUtil.getJsonContent("https://restapi.amap.com/v3/place/detail", params);
|
||||
}
|
||||
if (json && json.info && json.info == "OK") {
|
||||
try {
|
||||
List<AmapPoi> ret = JSONObject.parseArray(json.pois.toString(), AmapPoi.class)
|
||||
return ret
|
||||
} catch(Exception ex) {
|
||||
ex.printStackTrace()
|
||||
}
|
||||
} else if (json && json.infocode && json.infocode == "10004") {
|
||||
// 开发者的单位时间内(1分钟)访问量超限,被系统自动封停,下一分钟自动解封。
|
||||
Thread.sleep(60000)
|
||||
} else if (json && json.infocode && json.infocode == "10017") {
|
||||
// 所请求的资源不可用
|
||||
System.exit(1)
|
||||
}
|
||||
return Collections.emptyList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找关键字经纬度
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user