添加楼盘评级算法
This commit is contained in:
@@ -23,10 +23,13 @@ def sync_district_office(type):
|
||||
for city in cities:
|
||||
actions = list()
|
||||
id_list = list()
|
||||
for doc in seaweed_conn.find({'city': city, 'cat': type, 'status': 0}, {'city': 1, 'region': 1, 'block': 1, 'cat': 1, 'name': 1, 'address': 1,
|
||||
'estate_type2': 1, 'township': 1, 'alias': 1, 'addr_alias': 1, 'lng': 1, 'lat': 1, 'status': 1})\
|
||||
for doc in seaweed_conn.find({'city': city, 'cat': type, 'status': 0},
|
||||
{'city': 1, 'region': 1, 'block': 1, 'cat': 1, 'name': 1, 'address': 1,
|
||||
'estate_type2': 1, 'township': 1, 'alias': 1, 'addr_alias': 1, 'lng': 1, 'lat': 1,
|
||||
'status': 1}) \
|
||||
.batch_size(10000):
|
||||
updateDict = {'city': doc['city'], 'region': doc['region'], 'category': doc['cat'], 'name': doc['name'], 'status': doc['status']}
|
||||
updateDict = {'city': doc['city'], 'region': doc['region'], 'category': doc['cat'], 'name': doc['name'],
|
||||
'status': doc['status']}
|
||||
if 'estate_type2' in doc:
|
||||
updateDict['estate_type'] = doc['estate_type2']
|
||||
|
||||
@@ -42,7 +45,7 @@ def sync_district_office(type):
|
||||
if 'addr_alias' in doc:
|
||||
updateDict['addr_alias'] = doc['addr_alias']
|
||||
if 'lng' in doc and doc['lng'] is not None and str(doc['lng']) != 'nan':
|
||||
updateDict['location'] = {'lon': doc['lng'] / 10**10, 'lat': doc['lat'] / 10**10}
|
||||
updateDict['location'] = {'lon': doc['lng'] / 10 ** 10, 'lat': doc['lat'] / 10 ** 10}
|
||||
updateDict['update_date'] = update_date
|
||||
action = UpdateOne({'_id': doc['_id']}, {'$set': updateDict}, upsert=True)
|
||||
|
||||
@@ -51,14 +54,16 @@ def sync_district_office(type):
|
||||
seaweed_didata_conn.bulk_write(actions)
|
||||
actions.clear()
|
||||
|
||||
didata_id_df = pd.DataFrame(list(seaweed_didata_conn.find({'city': city, 'category': type}, {'_id': 1}).batch_size(10000)))
|
||||
didata_id_df = pd.DataFrame(
|
||||
list(seaweed_didata_conn.find({'city': city, 'category': type}, {'_id': 1}).batch_size(10000)))
|
||||
if len(didata_id_df) > 0:
|
||||
didata_id_df = didata_id_df[['_id']]
|
||||
id_df = pd.DataFrame(id_list)
|
||||
deleted_seaweed_df = pd.concat([didata_id_df, id_df, id_df]).drop_duplicates(keep=False)
|
||||
|
||||
for deleted_seaweed_index, deleted_seaweed_item in deleted_seaweed_df.iterrows():
|
||||
action = UpdateOne({'_id': ObjectId(deleted_seaweed_item['_id'])}, {'$set': {'status': 1, 'update_date': update_date}}, upsert=False)
|
||||
action = UpdateOne({'_id': ObjectId(deleted_seaweed_item['_id'])},
|
||||
{'$set': {'status': 1, 'update_date': update_date}}, upsert=False)
|
||||
actions.append(action)
|
||||
if len(actions) == 10000:
|
||||
seaweed_didata_conn.bulk_write(actions)
|
||||
@@ -69,8 +74,9 @@ def sync_district_office(type):
|
||||
actions.clear()
|
||||
log.info(city + "-" + type + "-同步完成")
|
||||
|
||||
|
||||
if type == 'all':
|
||||
sync_district_office("district")
|
||||
sync_district_office("office")
|
||||
else:
|
||||
sync_district_office(type)
|
||||
sync_district_office(type)
|
||||
|
||||
Reference in New Issue
Block a user