From d78e6a664a840cc0fa34536d01f6640243fd58d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Fri, 3 Sep 2021 14:04:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=9C=88=E7=BB=8F=E7=BA=AC=E5=BA=A6?= =?UTF-8?q?=E6=96=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../temp/shenjian/poi/BusinessLatLng.groovy | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/BusinessLatLng.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/BusinessLatLng.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/BusinessLatLng.groovy new file mode 100644 index 000000000..519e5de21 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/BusinessLatLng.groovy @@ -0,0 +1,46 @@ +package com.fangjia.script.temp.shenjian.poi + +import com.fangjia.script.temp.shenjian.util.GaoDeUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection +import com.mongodb.DBObject + +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors + +/** + * 商圈经纬度 + */ +class BusinessLatLng { + static DBCollection collection = MongoUtils.getCollectionByName("fangjia_crawl", "business", "192.168.0.235", 27018) + static ExecutorService executorService = Executors.newFixedThreadPool(1) + + static void main(String[] args) { + dealPoi(new BasicDBObject("city", "上海").append("region", "浦东新区")) + executorService.shutdown() + } + + static dealPoi(DBObject query) { + collection.find(query).batchSize(5000).each {objTemp -> + final def obj = objTemp + executorService.submit(new Runnable() { + @Override + void run() { + def city = obj.city + def address = city + obj.region + obj.address; + def location = GaoDeUtils.parserByGaode(city, address); + if (location && location.lng) { + def lng = Double.valueOf(location.lng) + def lat = Double.valueOf(location.lat) + collection.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status_location", 0) + .append("location", new BasicDBObject("lat", lat).append("lon", lng)).append("flag_location", "已获取经纬度"))) + } else { + collection.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status_location", 2).append("flag_location", "经纬度为空"))) + } + println("已处理小区:" + obj) + } + }) + } + } +}