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() } }