From 6c6ae7ddfe0a9a72f0bc48033b903800bf140572 Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Thu, 8 Sep 2022 21:11:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=AD=A6=E6=A0=A1?= =?UTF-8?q?=E7=BB=8F=E7=BA=AC=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../temp/shenjian/poi/FillLngLat.groovy | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy index d114be591..9d8b1d3a9 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy @@ -5,6 +5,9 @@ import com.fangjia.script.temp.shenjian.util.EsUtils import com.fangjia.script.temp.shenjian.util.GaoDeUtils import com.fangjia.script.util.ElasticUtils +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors + /** * 补充学校经纬度 * @author shenjian @@ -12,16 +15,25 @@ import com.fangjia.script.util.ElasticUtils */ class FillLngLat { + static ExecutorService executorService = Executors.newFixedThreadPool(4) static void main(String[] args) { - ElasticUtils.executeSqlQuery("select * from dws_poi where location is null", { data -> - println(data) - def lngLat = GaoDeUtils.parserByGaode(data.city, data.region + data.name + data.address) - if (lngLat != null && lngLat.size() == 2 ) { - JSONObject jsonObject = new JSONObject() - jsonObject.put("lon", Double.valueOf(lngLat['lng'])) - jsonObject.put("lat", Double.valueOf(lngLat['lat'])) - EsUtils.bulkUpdateFieldByIds("dws_poi", "location", jsonObject, Arrays.asList(data.source_id)) - } + ElasticUtils.executeSqlQuery("select * from dws_poi where location is null", { dataT -> + final def data = dataT + executorService.submit(new Runnable() { + @Override + void run() { + println(data) + def lngLat = GaoDeUtils.parserByGaode(data.city, data.region + data.name + data.address) + if (lngLat != null && lngLat.size() == 2 ) { + JSONObject jsonObject = new JSONObject() + jsonObject.put("lon", Double.valueOf(lngLat['lng'])) + jsonObject.put("lat", Double.valueOf(lngLat['lat'])) + EsUtils.bulkUpdateFieldByIds("dws_poi", "location", jsonObject, Arrays.asList(data.source_id)) + } + } + }) + }) + executorService.shutdown() } } From ef319f7e83e9adec011ad6feb5f4dfe9ee472b1a Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Mon, 19 Sep 2022 18:11:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9Epoi=20excel=E5=AE=9A?= =?UTF-8?q?=E7=82=B9=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../temp/shenjian/poi/FillLngLat.groovy | 2 +- .../temp/shenjian/poi/SeaweedAroundPoi.groovy | 6 +- .../poi/SeaweedAroundPoiFromExcel.groovy | 84 +++++++++++++++++++ .../temp/shenjian/util/GaoDeUtils.groovy | 6 +- 4 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoiFromExcel.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy index 9d8b1d3a9..a0c3ec24f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy @@ -17,7 +17,7 @@ class FillLngLat { static ExecutorService executorService = Executors.newFixedThreadPool(4) static void main(String[] args) { - ElasticUtils.executeSqlQuery("select * from dws_poi where location is null", { dataT -> + ElasticUtils.executeSqlQuery("select * from dws_poi where location is not null", { dataT -> final def data = dataT executorService.submit(new Runnable() { @Override diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoi.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoi.groovy index 147d08336..ca74c0184 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoi.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoi.groovy @@ -178,11 +178,11 @@ class SeaweedAroundPoi extends BaseBatch { // put("写字楼", "120201"); // put("学校", "141200|141201|141202|141203|141204"); // put("银行", "1601|1603"); -// put("大型超市", "0604"); + put("大型超市", "0604"); // put("商场", "0601"); - put("餐饮", "0501|0502|0503|0504"); +// put("餐饮", "0501|0502|0503|0504"); // put("旅游景点", "110000"); -// put("公园广场", "110100|110101|110102|110103|110104|110105") + put("公园广场", "110100|110101|110102|110103|110104|110105") // put("图书馆", "140500"); // put("政府机关", "130100|130101|130102|130103|130104|130105|130106|130107"); // put("丧葬设施", "071900|071901|071902|071903") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoiFromExcel.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoiFromExcel.groovy new file mode 100644 index 000000000..66abaacf9 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoiFromExcel.groovy @@ -0,0 +1,84 @@ +package com.fangjia.script.temp.shenjian.poi + +import com.alibaba.fastjson.JSONObject +import com.fangjia.script.BaseBatch +import com.fangjia.script.BatchOwner +import com.fangjia.script.Watcher +import com.fangjia.script.statistics.poi.AmapPoi +import com.fangjia.script.temp.shenjian.util.GaoDeUtils +import com.fangjia.script.temp.shenjian.util.HttpUtils +import com.fangjia.script.temp.shenjian.util.SeaweedUtils +import com.fangjia.script.util.DbUtils +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBList +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import com.mongodb.DBObject +import org.apache.commons.collections.CollectionUtils + +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors + +/** + * 小区周边POI数据获取 + * + * @author shenjian + * @since 2021/5/24 + */ +class SeaweedAroundPoiFromExcel { + + static void main(String[] args) { + def types = listAllType() + dealPoi(new BasicDBObject(), types) + } + + static dealPoi(DBObject query, def types) { + com.fangjia.script.util.ExcelUtils.multiThreadingModify("D:\\Users\\Domi\\Documents\\知识库\\建行\\审核小区\\东莞银行房价数据测试20220916-v3.xlsx", { List item -> + def city = item['H'] + def lng = item['AQ'] + def lat = item['AR'] + if (lng) { + List pois = GaoDeUtils.searchNearDtoByPoi(city, types, lng, lat, 1000, "") + if (CollectionUtils.isNotEmpty(pois)) { + String jsonStr = JSONObject.toJSONString(pois) + HttpUtils.postForJson("http://192.168.0.100:38080/FangJiaDataService/saveAmapPoi", jsonStr) + } + Thread.sleep(1000) + print(lng + " " + lat) + } + }); + }; + + + + public static def listAllType() { + StringBuilder ret = new StringBuilder() + for (def val : KEYWORDS_MAP.values()) { + ret.append(val).append("|") + } + String result = ret.toString() + return result.substring(0, result.length() - 1) + }; + + public static final Map KEYWORDS_MAP = new HashMap() { + { +// put("餐饮", "05"); +// put("地铁", "150500"); +// put("公交", "1507"); +// put("医院", "090100|090101|090200|090202|090203|090204|090205|090206|090207|090208|090209|090210|090211"); +// put("写字楼", "120201"); +// put("学校", "141200|141201|141202|141203|141204"); +// put("银行", "1601|1603"); + put("大型超市", "0604"); +// put("商场", "0601"); +// put("餐饮", "0501|0502|0503|0504"); +// put("旅游景点", "110000"); + put("公园广场", "110100|110101|110102|110103|110104|110105") +// put("图书馆", "140500"); +// put("政府机关", "130100|130101|130102|130103|130104|130105|130106|130107"); +// put("丧葬设施", "071900|071901|071902|071903") + + } + } +} 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 0aa5d9ce5..50ac505aa 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 @@ -146,11 +146,13 @@ class GaoDeUtils { while (result.size() < count) { params.page = "${page}".toString() page++ - params.key = this.getGaodeKey("v3/place/around") + //params.key = this.getGaodeKey("v3/place/around") + params.key = "25b2d459fd133e22f8abcebeac972692" params.offset = "100" JSONObject json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v3/place/around", params); if (json == null) { - params.key = this.getGaodeKey("v3/place/around") + //params.key = this.getGaodeKey("v3/place/around") + params.key = "25b2d459fd133e22f8abcebeac972692" params.offset = "100" json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v3/place/around", params); }