From 383395581e01aa10e5b4ce323f47bed66e6ffee8 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Tue, 15 Nov 2022 15:21:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E6=83=85=E5=B0=8F=E5=8C=BA=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E5=A1=AB=E8=A1=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ronghe/BigdataCitypriceBatch.groovy | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCitypriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCitypriceBatch.groovy index 80e99bd54..ad1d1b2b3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCitypriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/BigdataCitypriceBatch.groovy @@ -25,7 +25,7 @@ class BigdataCitypriceBatch extends BaseBatch{ public static final String[] TAGS = ["独栋", "联排", "叠加", "双拼", "花园面积", "泳池", "别墅", "带花园", "洋房", "叠拼", "独院", "联体", "微墅", "大平墅"]; - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(80) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(1) static main(args) { runBatch(new BigdataCitypriceBatch(), args) @@ -33,7 +33,6 @@ class BigdataCitypriceBatch extends BaseBatch{ @Override void process(Object args) { - // def citys = ["杭州","宁波","温州","嘉兴","湖州","绍兴","金华","台州"]//CcbCommonUtils.getRunningCitys(args) def startDate = DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date(),-1), "yyyyMMdd").toInteger(); def endDate = DateUtils.formatDateByPattern(DateUtils.getLastDayOfMonth(new Date(),-1), "yyyyMMdd").toInteger(); @@ -114,12 +113,21 @@ class BigdataCitypriceBatch extends BaseBatch{ def districtRun(citys, startDate, endDate, cityCodeDataMap){ def rets = [] def allDistricts = [] + def allPriceMap = [:] + def allRentMap = [:] for(def city : citys) { def districts = CcbCommonUtils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lng","estate_type2","name_cat","address", "alias"]); allDistricts.addAll(districts) + + def priceMap = CommonDatautils.queryDistrictStatByDate(city, startDate, endDate) + allPriceMap = allPriceMap + priceMap + + def rentMap = CommonDatautils.findSqmetreRentByCityAndDate(city, endDate) + allRentMap = allRentMap + rentMap + } - def cityLists = districtRunningByCity(allDistricts, startDate, endDate, cityCodeDataMap) + def cityLists = districtRunningByCity(allDistricts, startDate, endDate, cityCodeDataMap, allPriceMap, allRentMap) if(cityLists){ rets.addAll(cityLists) } @@ -133,7 +141,7 @@ class BigdataCitypriceBatch extends BaseBatch{ println "BIGDATA_COMMPRICE 数据文件输出完成......" } - def districtRunningByCity(districts, startDate, endDate, cityCodeDataMap){ + def districtRunningByCity(districts, startDate, endDate, cityCodeDataMap, allPriceMap, allRentMap){ def totalCount = new AtomicLong() def distCount = districts.size() final CountDownLatch latch = new CountDownLatch(distCount) @@ -145,7 +153,7 @@ class BigdataCitypriceBatch extends BaseBatch{ void run() { try { totalCount.addAndGet(1) - def row = createDistDate(dist, startDate, endDate, cityCodeDataMap) + def row = createDistDate(dist, startDate, endDate, cityCodeDataMap, allPriceMap, allRentMap) if(row){ rets << row println totalCount.get() +"/"+distCount + dist.city+" "+dist.region+" "+dist.name+" "+row[4]+" "+row[6] @@ -163,7 +171,7 @@ class BigdataCitypriceBatch extends BaseBatch{ } - def createDistDate(dist, startDate, endDate, cityCodeDataMap){ + def createDistDate(dist, startDate, endDate, cityCodeDataMap, allPriceMap, allRentMap){ def sellDataType = 1 def rentDataType = 1 def sellMap = findHouses(dist.city, dist.region, "sell", startDate, endDate, dist.name, dist.alias, dist.estate_type2) @@ -221,6 +229,12 @@ class BigdataCitypriceBatch extends BaseBatch{ rentDataType = null } } + if(!sell_avg_price){ + sell_avg_price = allPriceMap.get(dist.city +"##"+ dist.region +"##"+ dist.name) + } + if(!rent_avg_price){ + rent_avg_price = allRentMap.get(dist.city +"##"+ dist.region +"##"+ dist.name) + } if (sell_avg_price || rent_avg_price) { def row = [] row << cityCodeDataMap.get(dist.city)