补充区域价格
This commit is contained in:
+34
@@ -2351,6 +2351,22 @@ class CommonDatautils {
|
|||||||
}
|
}
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static def findCityOrRegionPrice(city, region, weekend){
|
||||||
|
DBObject q = new BasicDBObject()
|
||||||
|
q.put("city", city);
|
||||||
|
if(region){
|
||||||
|
q.put("region", region);
|
||||||
|
}
|
||||||
|
q.put('weekend', weekend);
|
||||||
|
def dbCursor = REGION_STAT_COLL.find(q).sort(new BasicDBObject().append("weekend", -1)).limit(1);
|
||||||
|
def price = null;
|
||||||
|
for(def obj : dbCursor){
|
||||||
|
price = obj.get("avg_price");
|
||||||
|
}
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
public static def findDistrictPrice(def city, def region, def name){
|
public static def findDistrictPrice(def city, def region, def name){
|
||||||
DBObject queryCondition = new BasicDBObject()
|
DBObject queryCondition = new BasicDBObject()
|
||||||
@@ -3414,6 +3430,24 @@ class CommonDatautils {
|
|||||||
|
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static def queryCityOrRegionPrice(city, region, sort){
|
||||||
|
DBObject queryCondition = new BasicDBObject()
|
||||||
|
queryCondition.put("city", city);
|
||||||
|
if(region){
|
||||||
|
queryCondition.put("region", region);
|
||||||
|
queryCondition.put("cat", "区域")
|
||||||
|
}else{
|
||||||
|
queryCondition.put("cat", "城市")
|
||||||
|
}
|
||||||
|
DBCursor cur = REGION_STAT_COLL.find(queryCondition).sort(new BasicDBObject().append("weekend", sort)).limit(1)
|
||||||
|
cur.setOptions(Bytes.QUERYOPTION_NOTIMEOUT)
|
||||||
|
def obj = 0;
|
||||||
|
while(cur.hasNext()) {
|
||||||
|
obj = cur.next()
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
static def queryCityRegionPrice(city, region, startDate, endDate){
|
static def queryCityRegionPrice(city, region, startDate, endDate){
|
||||||
DBObject queryCondition = new BasicDBObject()
|
DBObject queryCondition = new BasicDBObject()
|
||||||
|
|||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
package com.fangjia.script.gj.data_handle
|
||||||
|
|
||||||
|
import com.fangjia.core.util.DateUtil
|
||||||
|
import com.fangjia.script.averager.InsertMonitorCalcCommandBatch
|
||||||
|
import com.fangjia.script.commData.CommonDatautils
|
||||||
|
import com.fangjia.script.util.CommonUtils
|
||||||
|
|
||||||
|
class AddCityRegionPrice {
|
||||||
|
static main(args) {
|
||||||
|
def task = new AddCityRegionPrice()
|
||||||
|
task.run()
|
||||||
|
}
|
||||||
|
|
||||||
|
def run(){
|
||||||
|
InsertMonitorCalcCommandBatch insertBatch = new InsertMonitorCalcCommandBatch()
|
||||||
|
def citys = CommonDatautils.findAllCity()
|
||||||
|
def add = 0
|
||||||
|
for(def c : citys){
|
||||||
|
def regions = CommonDatautils.getCityRegions(c)
|
||||||
|
for(def r : regions){
|
||||||
|
def startObj = CommonDatautils.queryCityOrRegionPrice(c, r, 1)
|
||||||
|
def endObj = CommonDatautils.queryCityOrRegionPrice(c, r, -1)
|
||||||
|
def betweenDates = DateUtil.getWeekendBetweenDates(startObj.weekend, endObj.weekend);
|
||||||
|
for(def weekend : betweenDates ){
|
||||||
|
def price = CommonDatautils.findCityOrRegionPrice(c, r, weekend)
|
||||||
|
if(!price){
|
||||||
|
add++
|
||||||
|
insertBatch.saveCityCalcCommand(c,r,null, weekend, "fangjia-priceanalysis-0")
|
||||||
|
println "[add] ${add} "+c+" "+r+" "+DateUtil.formatByPattern(weekend, "yyyy-MM-dd")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user