From da6476465147eac5e24fffa6af2de02f8d86c78d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 22 Jul 2021 11:41:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BD=E5=AE=B6=E6=A0=87=E5=87=86=E5=B1=85?= =?UTF-8?q?=E5=A7=94=E4=BC=9A=E7=BB=8F=E7=BA=AC=E5=BA=A6=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../temp/shenjian/poi/CommitteeLatLng.groovy | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy new file mode 100644 index 000000000..cadb279a7 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy @@ -0,0 +1,50 @@ +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 + +/** + * 国家标准居委会经纬度获取 + * + * @author shenjian + * @since 2021/7/22 + */ +class CommitteeLatLng { + + static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017) + static ExecutorService executorService = Executors.newFixedThreadPool(30) + + static void main(String[] args) { + dealPoi(new BasicDBObject("status_location", new BasicDBObject('$ne', 0))) + executorService.shutdown() + } + + static dealPoi(DBObject query) { + villagesConn.find(query).batchSize(5000).each {objTemp -> + final def obj = objTemp + executorService.submit(new Runnable() { + @Override + void run() { + def city = obj.city_name + def address = obj.province_name + city + obj.area_name + obj.street_name + obj.name; + def location = GaoDeUtils.parserByGaode(city, address); + if (location && location.lng) { + def lng = location.lng + def lat = location.lat + villagesConn.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status_location", 0) + .append("lng", lng).append("lat", lat).append("flag_location", "已获取经纬度"))) + } else { + villagesConn.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status_location", 2).append("flag_location", "经纬度为空"))) + } + println("已处理小区:" + obj) + } + }) + } + } +}