diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CounterCheckGaoDe.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CounterCheckGaoDe.groovy new file mode 100644 index 000000000..8f22e231e --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CounterCheckGaoDe.groovy @@ -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> infos = ExcelUtils.read("D:\\Users\\Domi\\Desktop\\房价网\\项目\\建行\\模型级联\\地图反查信息_高德结果.xlsx") + for (List info : infos) { + if (info.size() < 6) { + String id = info.get(4) + List amapPois = GaoDeUtils.getAmapById(id) + if (CollectionUtils.isNotEmpty(amapPois)) { + String jsonStr = JSONObject.toJSONString(amapPois) + HttpUtils.postForJson(URL, jsonStr) + } + } + } + } +} diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/ExcelUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/ExcelUtils.groovy index 0b0380f42..6f01207ca 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/ExcelUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/ExcelUtils.groovy @@ -29,7 +29,7 @@ class ExcelUtils { static List> 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> dataList = listener.getDataList(); excelReader.finish() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/GaoDeUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/GaoDeUtils.groovy index f257a6dd6..00bf34570 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/GaoDeUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/GaoDeUtils.groovy @@ -203,6 +203,35 @@ class GaoDeUtils { return Collections.emptyList(); } + /** + * 获取详情 + */ + static List 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 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() + } + /** * 查找关键字经纬度 */