diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/ImportIndexStats.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/ImportIndexStats.groovy index 9e4af1c91..aa6426963 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/ImportIndexStats.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/trade/ImportIndexStats.groovy @@ -28,10 +28,11 @@ import java.util.concurrent.atomic.AtomicLong @BatchOwner(Watcher.GaoJuan) class ImportIndexStats extends BaseBatch{ + public static final def mongoDbUrl = "mongodb://developer:G00IDCDEV12385@mongo.db.fangjia.com:28017"; //public final static DBCollection under_line = new Mongo("192.168.0.136", 27017).getDB('fangjia').getCollection('stats_index'); public static final DBCollection on_line = MongoUtils.getCollectionByName("fangjia", "stats_index", "mongo.db.fangjia.com") public static final DBCollection STATS_INDEX_COLL = MongoUtils.getCollectionByName("fangjia_stat", "stats_index", "mongo.db.fangjia.com") - public static final DBCollection REGION_STAT_COLL = MongoUtils.getCollectionByName("fangjia", "region_stat", "mongo.db.fangjia.com") + public static final DBCollection REGION_STAT_COLL = MongoUtils.getCollectionByName2("fangjia", "region_stat", mongoDbUrl) final DBCollection indices_price_house_sellColl = MongoUtils.getCollectionByName("crawl", "indices_price_house_sell", "192.168.0.206", 27020) final DBCollection indices_price_house_sell_typeColl = MongoUtils.getCollectionByName("crawl", "indices_price_house_sell_type", "192.168.0.206", 27020) @@ -39,7 +40,7 @@ class ImportIndexStats extends BaseBatch{ final DBCollection indices_price_house_newColl = MongoUtils.getCollectionByName("crawl", "indices_price_house_new", "192.168.0.206", 27020) final DBCollection indices_price_house_new_typeColl = MongoUtils.getCollectionByName("crawl", "indices_price_house_new_type", "192.168.0.206", 27020) - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(10) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(50) //DSCollection seawater = new DataStore("192.168.0.65", 27777).getCollection("fangjia.seawater") private static def cityList=["北京", "天津", "石家庄", "太原", "呼和浩特", "沈阳", "大连", "长春", "哈尔滨", "上海", "南京", "杭州", "宁波", "合肥", "福州", "厦门", @@ -106,7 +107,7 @@ class ImportIndexStats extends BaseBatch{ //计算统计局没有发布的城市的价格指数 def calculatePriceIndex(def year, def month, def date){ - def citys =CommonDatautils.findAllCity(); + def citys = ["三沙"]//CommonDatautils.findAllCity(); // def date = createDateString(year, month, 0, ""); def haveIndexCitys = findPriceIndexCitys(date.toInteger()); @@ -144,26 +145,28 @@ class ImportIndexStats extends BaseBatch{ } }); } - latch.await(5, TimeUnit.MINUTES); + latch.await(2, TimeUnit.MINUTES); } def calculating(city, year, month, date){ def result = [:]; calculateAvgPriceIndex(city, year, month, result); - calculateAreaPriceInfex(result, city, year, month, 90);//0-90 - calculateAreaPriceInfex(result, city, year, month, 144);//90-144 - calculateAreaPriceInfex(result, city, year, month, 1000);//144-1000 - - checkPriceIndex(result);//涨跌幅控制 if(result){ - result.city = city; - result.yearmonth = date.toInteger(); - result.source = 2; - result.remark = "均价计算"; - result.cat = "district"; - result.type = "城市" - savePriceIndex(result); + calculateAreaPriceInfex(result, city, year, month, 90);//0-90 + calculateAreaPriceInfex(result, city, year, month, 144);//90-144 + calculateAreaPriceInfex(result, city, year, month, 1000);//144-1000 + + checkPriceIndex(result);//涨跌幅控制 + if(result){ + result.city = city; + result.yearmonth = date.toInteger(); + result.source = 2; + result.remark = "均价计算"; + result.cat = "district"; + result.type = "城市" + savePriceIndex(result); + } } return result } @@ -526,8 +529,7 @@ class ImportIndexStats extends BaseBatch{ def findCityByDates(def city, def startDate, def endDate){ DBObject q = new BasicDBObject() q.put("city", city); - q.put("region", null); - q.put("block", null); + q.put("cat", "城市") if(startDate && endDate){ q.put('weekend', new BasicDBObject('$gte', DateUtils.parseFromTightYYYYMMDD(startDate)).append('$lte', DateUtils.parseFromTightYYYYMMDD(endDate))); }