新增居住人口
This commit is contained in:
@@ -58,6 +58,8 @@ def deal(actions, x):
|
|||||||
doc_info['estate_charge_ranking'] = estate_charge_ranking
|
doc_info['estate_charge_ranking'] = estate_charge_ranking
|
||||||
if pd.notna(x['avg_price']) and pd.notna(x['rent_price']):
|
if pd.notna(x['avg_price']) and pd.notna(x['rent_price']):
|
||||||
doc_info['sell_to_rent'] = int(x['avg_price'] / x['rent_price'])
|
doc_info['sell_to_rent'] = int(x['avg_price'] / x['rent_price'])
|
||||||
|
if pd.notna(x['household_count']):
|
||||||
|
doc_info['person_num'] = int(x['household_count'] * 2.3)
|
||||||
|
|
||||||
action_doc = {
|
action_doc = {
|
||||||
"_op_type": "update",
|
"_op_type": "update",
|
||||||
@@ -70,14 +72,14 @@ def deal(actions, x):
|
|||||||
if len(actions) == 5000:
|
if len(actions) == 5000:
|
||||||
helpers.bulk(es206_client.elastic_client, actions)
|
helpers.bulk(es206_client.elastic_client, actions)
|
||||||
count += len(actions)
|
count += len(actions)
|
||||||
log.info(f"物业费等级、售租比已更新{count}")
|
log.info(f"物业费等级、售租比、人口数已更新{count}")
|
||||||
actions.clear()
|
actions.clear()
|
||||||
|
|
||||||
|
|
||||||
def sync(city=None):
|
def sync(city=None):
|
||||||
log.info(f"开始同步物业费等级、售租比至206 {index_name}")
|
log.info(f"开始同步物业费等级、售租比、人口数至206 {index_name}")
|
||||||
|
|
||||||
sql = "select city, region, name, estate_charge, finish_building_date, build_type, avg_price, rent_price from community_summary"
|
sql = "select city, region, name, estate_charge, finish_building_date, build_type, avg_price, rent_price, household_count from community_summary"
|
||||||
if pd.notna(city):
|
if pd.notna(city):
|
||||||
sql += " where city='" + city + "'"
|
sql += " where city='" + city + "'"
|
||||||
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
||||||
@@ -89,7 +91,7 @@ def sync(city=None):
|
|||||||
helpers.bulk(es206_client.elastic_client, actions)
|
helpers.bulk(es206_client.elastic_client, actions)
|
||||||
actions.clear()
|
actions.clear()
|
||||||
|
|
||||||
log.info(f"完成同步物业费等级、售租比至206 {index_name}")
|
log.info(f"完成同步物业费等级、售租比、人口数至206 {index_name}")
|
||||||
|
|
||||||
|
|
||||||
sync()
|
sync()
|
||||||
Reference in New Issue
Block a user