From 6c6ae7ddfe0a9a72f0bc48033b903800bf140572 Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Thu, 8 Sep 2022 21:11:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=AD=A6=E6=A0=A1=E7=BB=8F?= =?UTF-8?q?=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() } }