From ec47bf5cd885a4971269c8dc84f0dec927941819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 15 Nov 2021 12:58:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AEID=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shenjian/poi/CounterCheckGaoDe.groovy | 30 +++++++++++++++++++ .../temp/shenjian/util/ExcelUtils.groovy | 2 +- .../temp/shenjian/util/GaoDeUtils.groovy | 29 ++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CounterCheckGaoDe.groovy 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() + } + /** * 查找关键字经纬度 */