diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index a595aa2fe..cdd711513 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy @@ -855,6 +855,32 @@ class CommonDatautils { } + public static def findAllDistrictsKey(def city, def cat, def fields){ + + DBObject q = new BasicDBObject(); + q.put("status",0) +// q.put("status",new BasicDBObject('$ne', 0)) + q.put("cat", cat); + q.put("city", city) +// q.put("loop_line_info",new BasicDBObject('$exists',false)) +// q.put("name","经纬天地园二期") + + DBObject keys = new BasicDBObject(); + if(fields){ + for(def field : fields){ + keys.put(field, 1); + } + } + def dbsour = SEAWEED_COLL.find(q, keys).batchSize(5000) + def keyMap = [:] + for(def d : dbsour){ + keyMap.put(d.region+"##"+d.name, d) + } + return keyMap; + } + + + // public static def findAllDistrictByCity(def city, def cat, def fields){ // // DBObject q = new BasicDBObject(); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/AddAvgpriceBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/AddAvgpriceBatch.groovy index cbeb06541..f8017e35e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/AddAvgpriceBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/AddAvgpriceBatch.groovy @@ -42,10 +42,11 @@ class AddAvgpriceBatch { } def checkToBprice(){ - def citys = CommonDatautils.findAllCity() + def citys = CommonDatautils.findAllCity().reverse() for(def i=0;i() + public static final DBCollection SERVER_AREA_COLL = MongoUtils.getCollectionByName("fangjia", "server_area", "mongo.db.fangjia.com") + static { initCityMap() } @@ -55,9 +58,7 @@ class AddressUtil { * 初始化城市数据 */ static def initCityMap() { - Mongo mongo = new Mongo("mongo.db.fangjia.com", 28017); - DBCollection SERVER_AREA = mongo.getDB("fangjia").getCollection("server_area"); - DBCursor cursor = SERVER_AREA.find(new BasicDBObject(), new BasicDBObject("display", 1).append("city_grade", 1)); + DBCursor cursor = SERVER_AREA_COLL.find(new BasicDBObject(), new BasicDBObject("display", 1).append("city_grade", 1)); for(DBObject dbObject : cursor) { if(!"全国".equals(dbObject.display)) { cityMap.put(dbObject.display, dbObject.display) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/OpenApiClient.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/OpenApiClient.groovy index 4ff48400d..9d7fad788 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/OpenApiClient.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/OpenApiClient.groovy @@ -1548,6 +1548,34 @@ public class OpenApiClient { } + public static JSONObject houseAction(String city, String address) { + try { + Map params = new HashMap(); + params.put("city", city); + params.put("address", address); + params.put("token", TOKEN); + params.put("__refresh_cache","1") + + String content = new HttpRequest().get("https://open.fangjia.com/house/around", params, "utf-8") + JSONObject result = JSONObject.fromObject(content); + while (result == null) { + result = HttpRequestUtil.getJsonContent("https://open.fangjia.com/house/around", params, "utf-8") + println("${city} ${address} 程序调用异常") + Thread.sleep(6000) + } + if (result.getInt("code") == 0) { + return result.getJSONObject("result"); + } else if (result.getInt("code") !=0) { + println("${city} ${address}") + } + } catch (Exception e) { + println("${city} ${address} ${e.getMessage()}") + e.printStackTrace(); + } + return null + } + + }