diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/UpdateHouseRegion.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/UpdateHouseRegion.groovy index c71f088de..a47028b79 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/UpdateHouseRegion.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/UpdateHouseRegion.groovy @@ -37,13 +37,13 @@ class UpdateHouseRegion { static main(args) { def task = new UpdateHouseRegion() -// task.updateSeawaterRegion() + task.updateSeawaterRegion() // task.updateDealRegion() - task.updateThirdPartyRegion() +// task.updateThirdPartyRegion() } def updateThirdPartyRegion(){ - def city = "杭州" + def city = "东莞" def rets = findThirdPartyPrice(city) batchThirdPartyUpdate(city, rets); @@ -60,40 +60,70 @@ class UpdateHouseRegion { return rets; } - def updateDealRegion(){ - def city = "杭州" + def findDealData(def city){ def q = new BasicDBObject() q.put("city", city) q.put('trade_date', new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD("2021-01-01"))); - def cursor = DEAL_PRICE_COLL.find(q) + def cursor = DEAL_PRICE_COLL.find(q).batchSize(2000) + def datas = [] def index = 0 - def updateIndex = 0 for(def obj : cursor){ index++ - def region = obj.region - def name = obj.district_name - def rets = CommonDatautils.findDistrictsByName(city, name, "district") - if (!rets) { - rets = CommonDatautils.findDistrictByAlias(city, null, name, "district") - } - - if (rets.size() == 1) { - def dist = rets[0] - if (region != dist.region) { - updateIndex++ - def udata = new BasicDBObject() - udata.put("region", dist.region) - DEAL_PRICE_COLL.update(new BasicDBObject('_id', obj.get("_id")), new BasicDBObject('$set', udata)) - println updateIndex+" "+index+" "+region+" "+dist.region - } - } + datas << obj + println index } - - + return datas } + + def updateDealRegion(){ + def city = "东莞" + def datas = findDealData(city) + batchDealRegion(city, datas) + } + + def batchDealRegion(def city, def datas){ + def updateCount = new AtomicLong() + def curCount = new AtomicLong() + def totalCount = datas.size(); + final CountDownLatch latch = new CountDownLatch(totalCount) + println city +" 成交总量:"+totalCount + for(def i=0;i