update
This commit is contained in:
+26
@@ -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){
|
// public static def findAllDistrictByCity(def city, def cat, def fields){
|
||||||
//
|
//
|
||||||
// DBObject q = new BasicDBObject();
|
// DBObject q = new BasicDBObject();
|
||||||
|
|||||||
+10
-5
@@ -42,10 +42,11 @@ class AddAvgpriceBatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def checkToBprice(){
|
def checkToBprice(){
|
||||||
def citys = CommonDatautils.findAllCity()
|
def citys = CommonDatautils.findAllCity().reverse()
|
||||||
for(def i=0;i<citys.size();i++){ //76
|
for(def i=0;i<citys.size();i++){ //76
|
||||||
def c = citys[i]
|
def c = citys[i]
|
||||||
def rets = findNoPrices(c, DateUtils.parseFromTightYYYYMMDD("2022-01-01"))
|
def keyDistMap = CommonDatautils.findAllDistrictsKey(c, "district", ["city","region","name"])
|
||||||
|
def rets = findNoPrices(c, DateUtils.parseFromTightYYYYMMDD("2022-01-01"), keyDistMap)
|
||||||
println c + " "+rets.size()
|
println c + " "+rets.size()
|
||||||
addCommand(rets)
|
addCommand(rets)
|
||||||
|
|
||||||
@@ -79,7 +80,7 @@ class AddAvgpriceBatch {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def findNoPrices(c, weekend){
|
def findNoPrices(c, weekend, keyDistMap){
|
||||||
def q = new BasicDBObject("city", c).append("weekend", new BasicDBObject('$gte', weekend)).append("avg_price_2b", null)
|
def q = new BasicDBObject("city", c).append("weekend", new BasicDBObject('$gte', weekend)).append("avg_price_2b", null)
|
||||||
|
|
||||||
def keys = new BasicDBObject()
|
def keys = new BasicDBObject()
|
||||||
@@ -92,9 +93,13 @@ class AddAvgpriceBatch {
|
|||||||
def dbcursor = DIST_STAT_COLL.find(q, keys).batchSize(5000)
|
def dbcursor = DIST_STAT_COLL.find(q, keys).batchSize(5000)
|
||||||
def rets = []
|
def rets = []
|
||||||
for(def d : dbcursor){
|
for(def d : dbcursor){
|
||||||
if(!d.avg_price_2b) {
|
def distObj = keyDistMap.get(d.region+"##"+d.district_name)
|
||||||
rets << ["city": d.city, "district": d.region, "name": d.district_name,"estate_type":d.estate_type, "weekend": d.weekend]
|
if(distObj){
|
||||||
|
if(!d.avg_price_2b) {
|
||||||
|
rets << ["city": d.city, "district": d.region, "name": d.district_name,"estate_type":d.estate_type, "weekend": d.weekend]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return rets
|
return rets
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -2,6 +2,7 @@ package com.fangjia.script.linxsh.util
|
|||||||
|
|
||||||
import com.fangjia.core.RegionData
|
import com.fangjia.core.RegionData
|
||||||
import com.fangjia.script.util.DataUtil
|
import com.fangjia.script.util.DataUtil
|
||||||
|
import com.fangjia.script.util.MongoUtils
|
||||||
import com.mongodb.BasicDBObject
|
import com.mongodb.BasicDBObject
|
||||||
import com.mongodb.DBCollection
|
import com.mongodb.DBCollection
|
||||||
import com.mongodb.DBCursor
|
import com.mongodb.DBCursor
|
||||||
@@ -47,6 +48,8 @@ class AddressUtil {
|
|||||||
|
|
||||||
private static final cityMap = new HashMap<String, String>()
|
private static final cityMap = new HashMap<String, String>()
|
||||||
|
|
||||||
|
public static final DBCollection SERVER_AREA_COLL = MongoUtils.getCollectionByName("fangjia", "server_area", "mongo.db.fangjia.com")
|
||||||
|
|
||||||
static {
|
static {
|
||||||
initCityMap()
|
initCityMap()
|
||||||
}
|
}
|
||||||
@@ -55,9 +58,7 @@ class AddressUtil {
|
|||||||
* 初始化城市数据
|
* 初始化城市数据
|
||||||
*/
|
*/
|
||||||
static def initCityMap() {
|
static def initCityMap() {
|
||||||
Mongo mongo = new Mongo("mongo.db.fangjia.com", 28017);
|
DBCursor cursor = SERVER_AREA_COLL.find(new BasicDBObject(), new BasicDBObject("display", 1).append("city_grade", 1));
|
||||||
DBCollection SERVER_AREA = mongo.getDB("fangjia").getCollection("server_area");
|
|
||||||
DBCursor cursor = SERVER_AREA.find(new BasicDBObject(), new BasicDBObject("display", 1).append("city_grade", 1));
|
|
||||||
for(DBObject dbObject : cursor) {
|
for(DBObject dbObject : cursor) {
|
||||||
if(!"全国".equals(dbObject.display)) {
|
if(!"全国".equals(dbObject.display)) {
|
||||||
cityMap.put(dbObject.display, dbObject.display)
|
cityMap.put(dbObject.display, dbObject.display)
|
||||||
|
|||||||
@@ -1548,6 +1548,34 @@ public class OpenApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static JSONObject houseAction(String city, String address) {
|
||||||
|
try {
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user