添加补充城市,区域,小区均价和租金的命令

This commit is contained in:
2024-10-22 15:17:50 +08:00
parent 2701a125d8
commit 40a338302d
@@ -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 +" 一个也没有"
}
}
}
}