老月度均价表
This commit is contained in:
+5
-5
@@ -29,7 +29,7 @@ public class MonthlyDistrictStatCalcBatch extends BaseBatch {
|
||||
@Override
|
||||
void process(Object args) {
|
||||
List<String> cities = [];
|
||||
def allCity = ["广州","深圳","临沂"]//CommonUtils.findAllCity()
|
||||
def allCity = CommonUtils.findAllCity()
|
||||
|
||||
def keys = new BasicDBObject("city", 1).append("name", 1).append("region", 1).append("estate_type2", 1)
|
||||
cities.addAll(allCity)
|
||||
@@ -38,7 +38,7 @@ public class MonthlyDistrictStatCalcBatch extends BaseBatch {
|
||||
districts.addAll DbUtils.seaweed.find(new BasicDBObject("city", city).append("cat", "district").append("visible", 0), keys).batchSize(2000).toList()
|
||||
println(city)
|
||||
}
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(1)
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(30)
|
||||
districts.each {BasicDBObject district->
|
||||
executorService.submit(new Calculator(district))
|
||||
}
|
||||
@@ -92,14 +92,14 @@ class Calculator extends Thread{
|
||||
def monDate = getMomDate(date)
|
||||
def yoyDate = getYoyDate(date)
|
||||
BasicDBObject monDbo = statMap.get(monDate)
|
||||
if(monDbo != null && monDbo.avg_price_2b != 0) {
|
||||
trend.mom = DataUtil.roundDouble(((trend.avg_price_2b - monDbo.avg_price_2b)/(double)monDbo.avg_price_2b),4)
|
||||
if(monDbo != null && monDbo.avg_price != 0) {
|
||||
trend.mom = DataUtil.roundDouble(((trend.avg_price - monDbo.avg_price)/(double)monDbo.avg_price),4)
|
||||
}else{
|
||||
trend.mom = 0d
|
||||
}
|
||||
BasicDBObject yoyDbo = statMap.get(yoyDate)
|
||||
if(yoyDbo != null && yoyDbo.avg_price != 0){
|
||||
trend.yoy = DataUtil.roundDouble(((trend.avg_price_2b - yoyDbo.avg_price_2b)/(double)yoyDbo.avg_price_2b),4)
|
||||
trend.yoy = DataUtil.roundDouble(((trend.avg_price - yoyDbo.avg_price)/(double)yoyDbo.avg_price),4)
|
||||
}else{
|
||||
trend.yoy = 0d
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user