From b679ffa1a43015a37259d91edbaa388a31177b99 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Sun, 29 Sep 2024 17:48:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8D=E5=BD=95=E9=9B=86=E8=B7=915=E7=BA=A7?= =?UTF-8?q?=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/commData/CommonDatautils.groovy | 27 +++++++++ .../gj/data_handle/AddCityRegionPrice.groovy | 60 ++++++++++++++++++- .../script/gj/data_handle/MinglujiData.groovy | 4 +- 3 files changed, 87 insertions(+), 4 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index f6dc6e3b1..f710a70fe 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy @@ -1892,6 +1892,33 @@ class CommonDatautils { } + public static def queryFirstOrLastDistrictPrice(city, region, name, sort){ + DBObject queryCondition = new BasicDBObject() + queryCondition.put("city", city); + queryCondition.put("region", region); + queryCondition.put("district_name", name); + + DBCursor cur = DIST_STAT_COLL.find(queryCondition).sort(new BasicDBObject("weekend", sort)).limit(1) + cur.setOptions(Bytes.QUERYOPTION_NOTIMEOUT) + def dbo = null; + while(cur.hasNext()) { + dbo = cur.next() + } + return dbo; + } + + + public static def queryDistrictPriceByWeekend(city, region, name, weekend){ + DBObject queryCondition = new BasicDBObject() + queryCondition.put("city", city); + queryCondition.put("region", region); + queryCondition.put("district_name", name); + queryCondition.put("weekend", weekend); + + return DIST_STAT_COLL.findOne(queryCondition) + } + + public static def queryDistrictPrice(city, region, name, weekend, cat){ DBObject queryCondition = new BasicDBObject() queryCondition.put("city", city); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddCityRegionPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddCityRegionPrice.groovy index 816bf86c9..667f06d6d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddCityRegionPrice.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/AddCityRegionPrice.groovy @@ -8,10 +8,12 @@ import com.fangjia.script.util.CommonUtils class AddCityRegionPrice { static main(args) { def task = new AddCityRegionPrice() - task.run() +// task.addRegionPrice() +// task.addCityprice() + task.addDistrictprice() } - def run(){ + def addRegionPrice(){ InsertMonitorCalcCommandBatch insertBatch = new InsertMonitorCalcCommandBatch() def citys = CommonDatautils.findAllCity() def add = 0 @@ -38,4 +40,58 @@ class AddCityRegionPrice { } } + + + def addCityprice(){ + InsertMonitorCalcCommandBatch insertBatch = new InsertMonitorCalcCommandBatch() + def citys = CommonDatautils.findAllCity().reverse() + def add = 0 + for(def c : citys){ + def startObj = CommonDatautils.queryCityOrRegionPrice(c, null, 1) + def endObj = CommonDatautils.queryCityOrRegionPrice(c, null, -1) + if(startObj && endObj){ + def betweenDates = DateUtil.getWeekendBetweenDates(startObj.weekend, endObj.weekend); + for(def weekend : betweenDates ){ + def price = CommonDatautils.findCityOrRegionPrice(c, null, weekend) + if(!price){ + add++ + insertBatch.saveCityCalcCommand(c,null,null, weekend, "fangjia-priceanalysis-0") + println "[add] ${add} "+c+" "+DateUtil.formatByPattern(weekend, "yyyy-MM-dd") + } + } + println c +" 校验完成" + }else{ + println c+" 有空值" + } + } + } + + + def addDistrictprice(){ + InsertMonitorCalcCommandBatch insertBatch = new InsertMonitorCalcCommandBatch() + def citys = CommonDatautils.findAllCity().reverse() + def add = 0 + for(def c : citys){ + def districts = CommonDatautils.findAllDistricts(c, "district", ["city", "region", "name", "estate_type2"]) + for(def d : districts){ + def startObj = CommonDatautils.queryFirstOrLastDistrictPrice(c, d.region, d.name, 1) + def endObj = CommonDatautils.queryFirstOrLastDistrictPrice(c, d.region, d.name, -1) + if(startObj && endObj){ + def betweenDates = DateUtil.getWeekendBetweenDates(startObj.weekend, endObj.weekend); + for(def weekend : betweenDates ){ + def price = CommonDatautils.queryDistrictPriceByWeekend(c, d.region, d.name, weekend) + if(!price){ + add++ + insertBatch.saveDistrictCalcCommand(c, d.region, d.name, d.estate_type2, weekend, "fangjia-priceanalysis-0") + println "[add] ${add} "+c+" "+d.region+" "+d.name+" "+DateUtil.formatByPattern(weekend, "yyyy-MM-dd") + } + } + println c +" 校验完成" + }else{ + println c+ " "+d.region+" "+d.name+" 无价格" + } + } + } + + } } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy index 5fefd22f6..1c94475bc 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/MinglujiData.groovy @@ -36,8 +36,8 @@ class MinglujiData { // exportDatas(city) // matchDev(prov, city) // matchCommunity(city) -// fiveLevelSplit(city) - nineLevelSplit(city) + fiveLevelSplit(city) +// nineLevelSplit(city) // tempMatchDev(prov) // checkDev()