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