From 30736280a925d28fbf8cb252febe6d6afdec6a49 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 7 Jan 2025 11:02:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/dealPrice/SynchDealPriceToEs.groovy | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy index 13ea5e3de..355968064 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -2,6 +2,7 @@ package com.fangjia.script.dealPrice import com.fangjia.core.util.MongoUtils import com.fangjia.script.gj.xiamen.ElasticUtils89 +import com.fangjia.script.util.DateUtils import com.fangjia.script.util.ElasticUtils import com.mongodb.AggregationOutput import com.mongodb.BasicDBObject @@ -26,12 +27,17 @@ class SynchDealPriceToEs { def batchsize = 2000 def citys = getCityCount() citys.each{city,count-> - def dbcursor = dealPriceConn.find(new BasicDBObject("city", city)).batchSize(batchsize) - def ret = [] - for(def o : dbcursor){ - ret << o - } - save(ret) + for(def year = 1999;year<=2025;year++){ + def q = new BasicDBObject("city", city) + q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) + def dbcursor = dealPriceConn.find(q).batchSize(batchsize) + println city +" "+ dbcursor.count() + def ret = [] + for(def o : dbcursor){ + ret << o + } + save(ret) + } // def index = 0 // for(def d : dbcursor){ // ret << d From 82ef32206fd7e654fb668e244534bf97f6eab25a Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 7 Jan 2025 11:12:54 +0800 Subject: [PATCH 2/2] update --- .../dealPrice/SynchDealPriceToEs.groovy | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy index 355968064..f9f518cb8 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/dealPrice/SynchDealPriceToEs.groovy @@ -26,18 +26,21 @@ class SynchDealPriceToEs { def run(){ def batchsize = 2000 def citys = getCityCount() - citys.each{city,count-> - for(def year = 1999;year<=2025;year++){ - def q = new BasicDBObject("city", city) - q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) - def dbcursor = dealPriceConn.find(q).batchSize(batchsize) - println city +" "+ dbcursor.count() - def ret = [] - for(def o : dbcursor){ - ret << o - } - save(ret) - } + citys.each{city,count-> + if(city instanceof String){ + for(def year = 1999;year<=2025;year++){ + def q = new BasicDBObject("city", city) + q.put("trade_date", new BasicDBObject('$gte', DateUtils.parseFromTightByPattern(year+"-01-01", "yyyy-MM-dd")).append('$lte', DateUtils.parseFromTightByPattern(year+1+"-01-01", "yyyy-MM-dd"))) + def dbcursor = dealPriceConn.find(q).batchSize(batchsize) + println city +" "+ dbcursor.count() + def ret = [] + for(def o : dbcursor){ + ret << o + } + save(ret) + } + } + // def index = 0 // for(def d : dbcursor){ // ret << d