From 3c442d504fed80c87f15cb81de773ac2b94b4b7c Mon Sep 17 00:00:00 2001 From: gaojuan Date: Fri, 8 Sep 2023 16:09:23 +0800 Subject: [PATCH] upate --- .../fuzhou/DistrictSellStatBatch.groovy | 20 +++---- .../com/fangjia/script/gj/MeituanTest.groovy | 53 +++++++++++++++++++ 2 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/MeituanTest.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictSellStatBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictSellStatBatch.groovy index 6f339f416..4e3d5668e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictSellStatBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/fuzhou/DistrictSellStatBatch.groovy @@ -88,6 +88,7 @@ class DistrictSellStatBatch extends BaseBatch { } }else{ def q = new BasicDBObject("city", city).append("cat", "district").append("status", 0) +// q.put("name", "翠园楼") if(day == 2){ districts = DbUtils.seaweed.find(q, keys).batchSize(2000) }else{ @@ -135,8 +136,8 @@ class DistrictSellStatBatch extends BaseBatch { def rets = new CopyOnWriteArrayList() districts.each{dist-> -// fixedThreadPool.execute(new Runnable() { -// void run() { + fixedThreadPool.execute(new Runnable() { + void run() { try { totalCount.addAndGet(1) def key = dist.region +"##" + dist.name @@ -152,12 +153,7 @@ class DistrictSellStatBatch extends BaseBatch { mom = DataUtil.roundDouble(((weekendPriceObj.avg_price - lastMonthPriceObj.avg_price)/(double)lastMonthPriceObj.avg_price),4) } - def curPrice = null; - if(curPriceObj){ - curPrice = curPriceObj.avg_price - }else{ - curPrice = weekendPriceObj.avg_price - } + def curPrice = weekendPriceObj.avg_price if(weekendPriceObj.value_type!=1){ if(dist.city == "福州"){ @@ -198,7 +194,7 @@ class DistrictSellStatBatch extends BaseBatch { data.put("commid", dist._id.toString()) data.put("mom", mom) data.put("yoy", yoy) - data.put("avg_price", weekendPriceObj.avg_price) + data.put("avg_price",curPrice) data.put("value_type", weekendPriceObj.value_type) data.put("credit", weekendPriceObj.credit) DISTRICT_SELL_STAT.update(new BasicDBObject("_id", curPriceObj._id) , new BasicDBObject('$set', data),true,false) @@ -228,10 +224,10 @@ class DistrictSellStatBatch extends BaseBatch { } finally { latch.countDown() } -// }; -// }) + }; + }) } -// latch.await() + latch.await() } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/MeituanTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/MeituanTest.groovy new file mode 100644 index 000000000..33d88dd25 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/MeituanTest.groovy @@ -0,0 +1,53 @@ +package com.fangjia.script.gj + +import com.fangjia.script.util.ExcelUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject +import com.mongodb.DBCollection + +import java.util.concurrent.CountDownLatch +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicLong + +DBCollection DISTRICT_SELL_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_sell_stat", "mongo.db.fangjia.com") + +ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) +File file = new File("d:\\数据\\美团\\FJW_COMM_20230815.csv"); +def rows = []; + +file.eachLine{ + def d = it.split("@",-1) + if(d[1] && d[1]!='福州' && d[7] && d[7].isNumber()){ + rows << d + } +} +println rows.size() +def totalCount = new AtomicLong() +final CountDownLatch latch = new CountDownLatch(rows.size()) + +for(def i=0;i