From 40a338302d50e4bd4ceca3951c7e8152e40f2748 Mon Sep 17 00:00:00 2001 From: gaojuan1 Date: Tue, 22 Oct 2024 15:17:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=A5=E5=85=85=E5=9F=8E?= =?UTF-8?q?=E5=B8=82=EF=BC=8C=E5=8C=BA=E5=9F=9F=EF=BC=8C=E5=B0=8F=E5=8C=BA?= =?UTF-8?q?=E5=9D=87=E4=BB=B7=E5=92=8C=E7=A7=9F=E9=87=91=E7=9A=84=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gj/data_handle/AddCityRegionPrice.groovy | 115 +++++++++++++++++- 1 file changed, 112 insertions(+), 3 deletions(-) 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 cc42938d7..954e0402b 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 @@ -6,21 +6,33 @@ import com.fangjia.script.averager.InsertMonitorSquareRentCalcCommandBatch import com.fangjia.script.commData.CommonDatautils import com.fangjia.script.util.CommonUtils import com.fangjia.script.util.DateUtils +import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.mongodb.MongoClient +import com.rabbitmq.client.AMQP class AddCityRegionPrice { public final static DBCollection COMMAND_COLL = new MongoClient("log.mongo.db.fangjia.com", 52002).getDB('fangjia_log').getCollection('calc_command') + + public static final def mongoDbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; + public static final DBCollection SQMETRE_RENT_COLL = MongoUtils.getCollectionByName2("fangjia", "sqmetre_rent", mongoDbUrl) + public static final DBCollection DEAL_PRICE_COLL = MongoUtils.getCollectionByName2("fangjia", "deal_price", mongoDbUrl) + static main(args) { def task = new AddCityRegionPrice() // task.addRegionPrice() -// task.addCityprice() + task.addCityprice() // task.addDistrictprice() // task.addCityRentPrice() - task.addDistrictRentprice() +// task.addRegionRentPrice() +// task.addDistrictRentprice() +// task.updateRegionRentData() +// task.updateDealPriceAreaType() +// task.checkCityImport() } def addRegionPrice(){ @@ -54,7 +66,7 @@ class AddCityRegionPrice { def addCityprice(){ InsertMonitorCalcCommandBatch insertBatch = new InsertMonitorCalcCommandBatch() - def citys = CommonDatautils.findAllCity().reverse() + def citys = ["乐东"]// CommonDatautils.findAllCity().reverse() def add = 0 for(def c : citys){ def startObj = CommonDatautils.queryCityOrRegionPrice(c, null, 1) @@ -125,6 +137,35 @@ class AddCityRegionPrice { } } + def addRegionRentPrice(){ + InsertMonitorSquareRentCalcCommandBatch inserBatch = new InsertMonitorSquareRentCalcCommandBatch(); + def citys = CommonDatautils.findAllCity() + for(def c : citys){ + + def regions = CommonDatautils.getCityRegions(c) + for(def r : regions){ +// if(r!="南川"){ +// continue +// } + def startObj = CommonDatautils.queryFirstOrLastRentPrice(c, r, null, 1) + def endObj = CommonDatautils.queryFirstOrLastRentPrice(c, r, null, -1) + if(startObj && endObj){ + def months = DateUtils.getBetweenMonth(DateUtil.formatByPattern(startObj.weekend, "yyyyMM"),"202409") + months.each {m-> +// println m + def lastDay = DateUtils.truncateDay(DateUtils.getLastDayOfMonth(DateUtil.parseDate(m+"01", "yyyyMMdd"))) + def obj = CommonDatautils.findSqmetreRent(c, r, null, lastDay) + if(!obj){ + inserBatch.saveCityCalcCommand(c, r, null, lastDay, "fangjia-priceanalysis-0") + println "[add] "+c+" "+r+" "+DateUtil.formatByPattern(lastDay, "yyyy-MM-dd") + } + } + } + } + + } + } + def addDistrictRentprice(){ InsertMonitorSquareRentCalcCommandBatch inserBatch = new InsertMonitorSquareRentCalcCommandBatch(); def citys = CommonDatautils.findAllCity() @@ -158,4 +199,72 @@ class AddCityRegionPrice { } } + + def updateRegionRentData(){ + def q = new BasicDBObject("cat", "region") + def keys = new BasicDBObject() + keys.put("markup", 1) + def dbcursor = SQMETRE_RENT_COLL.find(q, keys).batchSize(5000) + def index = 1 + for(def d : dbcursor){ + if(!(d.markup instanceof Double)){ + def udata = new BasicDBObject() + double markup = 1.0 + markup = d.markup * markup + udata.put("markup", markup) + SQMETRE_RENT_COLL.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + println index + index++ + } + } + } + + + def updateDealPriceAreaType(){ + def index = 1 + def citys = ["凉山州","福州","南京","佛山","沈阳","苏州"] + citys.each {c-> + def q = new BasicDBObject() + q.put("city", c) +// q.put("price_flag", "国信达成交-推导") + def dbcursor = DEAL_PRICE_COLL.find(q) + for(def d : dbcursor){ +// if(!(d.area instanceof Double)){ +// def udata = new BasicDBObject() +// double area = 1.0 +// area = d.area * area +// udata.put("area", area) +// DEAL_PRICE_COLL.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) +// println c+" "+index +// index++ +// } + if(!(d.total_price instanceof Integer)){ + def udata = new BasicDBObject() + udata.put("total_price", d.total_price.toString().toDouble().toInteger()) + DEAL_PRICE_COLL.update(new BasicDBObject("_id", d._id), new BasicDBObject('$set', udata)) + println c+" "+index + index++ + } + } + } + } + + def checkCityImport(){ + def citys = ["海口","三亚","三沙","五指山","琼海","儋州","文昌","万宁","东方","定安","屯昌","澄迈","临高","白沙","昌江","乐东","陵水","保亭","琼中"] + for(def c : citys){ + def startObj = CommonDatautils.findStatIndexBySort("城市", c, null, 1) + def endObj = CommonDatautils.findStatIndexBySort("城市", c,null, -1) + if(startObj && endObj){ + def months = DateUtils.getBetweenMonth(startObj.yearmonth.toString(),"202409") + months.each {m-> + def obj = CommonDatautils.findStatIndexByMonth("城市", c,null, m.toInteger()) + if(!obj){ + println "[add] "+c+" "+m + } + } + }else{ + println c +" 一个也没有" + } + } + } }