From d8e8bb6885d74da4513a89aefb54c2172946ce64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 16 Dec 2021 15:55:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=87=8D=E6=96=B0=E8=B7=91=E5=B0=8F?= =?UTF-8?q?=E5=8C=BA=E9=AB=98=E5=BE=B7=E6=9C=80=E6=96=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/temp/shenjian/poi/GetPoi.groovy | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoi.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoi.groovy index 2a2591844..ef54bf028 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoi.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoi.groovy @@ -30,19 +30,22 @@ import java.util.concurrent.atomic.AtomicLong class GetPoi { static final def URL = "http://192.168.0.216:38080/FangJiaDataService/saveAmapPoi" - static final ExecutorService executorService = Executors.newFixedThreadPool(10) + static final ExecutorService executorService = Executors.newFixedThreadPool(20) static void main(String[] args) { AtomicLong atomicLong = new AtomicLong(0) - List> seaweeds = ExcelUtils.read("D:\\数据\\建行\\房产估值\\小区\\500000_重庆小区数据匹配.xlsx") - for (List infoTemp : seaweeds) { - final List info = infoTemp + DBObject filter = new BasicDBObject() + filter.append("_id", 1).append("name", 1).append("city", 1).append("region", 1) + DBObject query = new BasicDBObject() + query.append("cat", "district").append("visible", 0).append("city", "重庆") + DbUtils.seaweed.find(query, filter).batchSize(10000).forEach( {seaweedTemp -> + final DBObject seaweed = seaweedTemp; executorService.submit(new Runnable() { @Override void run() { - String city = "重庆"//info.get(2) - String region = info.get(3) - String seaweedName = info.get(4) + String city = seaweed.get("city") + String region = seaweed.get("region") + String seaweedName = seaweed.get("name") List pois = GaoDeUtils.searchPoi(city, seaweedName, region, "120300|120301|120302"); if (CollectionUtils.isNotEmpty(pois)) { String jsonStr = JSONObject.toJSONString(pois) @@ -56,7 +59,7 @@ class GetPoi { } } }) - } + }) executorService.shutdown() } From d5da3bf5d1b8649bd32abb579119573c604051fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Thu, 16 Dec 2021 17:04:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=8E=B7=E5=8F=96excel=E5=B0=8F=E5=8C=BA?= =?UTF-8?q?=E6=9C=80=E6=96=B0poi=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../temp/shenjian/poi/GetPoiFromExcel.groovy | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoiFromExcel.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoiFromExcel.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoiFromExcel.groovy new file mode 100644 index 000000000..d2644582e --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/GetPoiFromExcel.groovy @@ -0,0 +1,51 @@ +package com.fangjia.script.temp.shenjian.poi + +import com.alibaba.fastjson.JSONObject +import com.fangjia.script.statistics.poi.AmapPoi +import com.fangjia.script.temp.shenjian.util.ExcelUtils +import com.fangjia.script.temp.shenjian.util.GaoDeUtils +import com.fangjia.script.temp.shenjian.util.HttpUtils +import org.apache.commons.collections.CollectionUtils +import org.apache.commons.io.FileUtils + +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + +class GetPoiFromExcel { + + static final def URL = "http://192.168.0.216:38080/FangJiaDataService/saveAmapPoi" + static final ExecutorService executorService = Executors.newFixedThreadPool(10) + + static void main(String[] args) { + AtomicLong atomicLong = new AtomicLong(0) + List fileList = FileUtils.listFiles(new File("D:\\Users\\Domi\\Desktop\\房价网\\项目\\建行\\模型级联\\POI"), null, false); + for (File file : fileList) { + List> seaweeds = ExcelUtils.read(file.getPath()) + final cityTemp = file.getName().substring(0, file.getName().indexOf("高德")) + for (List infoTemp : seaweeds) { + final List info = infoTemp + executorService.submit(new Runnable() { + @Override + void run() { + String city = cityTemp + String region = info.get(2) + String seaweedName = info.get(3) + List pois = GaoDeUtils.searchPoi(city, seaweedName, region, "120300|120301|120302"); + if (CollectionUtils.isNotEmpty(pois)) { + String jsonStr = JSONObject.toJSONString(pois) + HttpUtils.postForJson(URL, jsonStr) + atomicLong.incrementAndGet() + } + synchronized (this) { + if (atomicLong.intValue() % 500 == 0) { + println(atomicLong.intValue()) + } + } + } + }) + } + } + executorService.shutdown() + } +}