From c859830a101ff263d5f0c0503ed8525c5d65a713 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 22 Oct 2024 15:21:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E5=9D=87=E4=BB=B7?= =?UTF-8?q?=E8=A1=A8=E4=BF=AE=E6=94=B9=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/RegionUpdateBatch.groovy | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy new file mode 100644 index 000000000..6fce88fa6 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/RegionUpdateBatch.groovy @@ -0,0 +1,65 @@ +package com.fangjia.script.gj.data_handle + +import com.fangjia.script.commData.CommonDatautils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + +//更新第三方均价表中小区区域 +class RegionUpdateBatch { + + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(50) + + static final DBCollection AVERAGE_STATISTICS = MongoUtils.getCollectionByName("fangjia", "average_statistics", "192.168.0.43") + + static main(args) { + def task = new RegionUpdateBatch() + task.run() + + } + def run(){ + def citys = CommonDatautils.findAllCity() + for(def city : citys){ + def districtMap = CommonDatautils.findAllDistricMaptByCity(city, "district", ["city","region", "name"]) + def keys = new BasicDBObject() + keys.put("city", 1) + keys.put("region", 1) + keys.put("name", 1) + keys.put("seaweed_id", 1) + def statistics = AVERAGE_STATISTICS.find(new BasicDBObject("city", city), keys) + def total = statistics.size() + final CountDownLatch latch = new CountDownLatch(total) + def totalCount = new AtomicLong() + for(def i=0;i