新增售租比
This commit is contained in:
+18
-11
@@ -30,18 +30,18 @@ def get_old_or_new(finish_building_date):
|
||||
|
||||
def deal(actions, x):
|
||||
global count
|
||||
estate_charge_ranking = ''
|
||||
estate_charge_ranking = None
|
||||
if pd.notna(x['estate_charge']):
|
||||
estate_charge = float(x['estate_charge'])
|
||||
if estate_charge >= 1:
|
||||
estate_charge_ranking = "一级"
|
||||
if estate_charge >= 0.75:
|
||||
elif estate_charge >= 0.75:
|
||||
estate_charge_ranking = "二级"
|
||||
if estate_charge >= 0.50:
|
||||
elif estate_charge >= 0.50:
|
||||
estate_charge_ranking = "三级"
|
||||
if estate_charge >= 0.35:
|
||||
elif estate_charge >= 0.35:
|
||||
estate_charge_ranking = "四级"
|
||||
if estate_charge < 0.35:
|
||||
elif estate_charge < 0.35:
|
||||
estate_charge_ranking = "五级"
|
||||
else:
|
||||
old_or_new = get_old_or_new(x['finish_building_date'])
|
||||
@@ -53,24 +53,31 @@ def deal(actions, x):
|
||||
elif old_or_new == '旧':
|
||||
estate_charge_ranking = '五级'
|
||||
|
||||
doc_info = dict()
|
||||
if pd.notna(estate_charge_ranking):
|
||||
doc_info['estate_charge_ranking'] = estate_charge_ranking
|
||||
if pd.notna(x['avg_price']) and pd.notna(x['rent_price']):
|
||||
doc_info['sell_to_rent'] = int(x['avg_price'] / x['rent_price'])
|
||||
|
||||
action_doc = {
|
||||
"_op_type": "update",
|
||||
"_index": index_name,
|
||||
"_id": x['_id'],
|
||||
"doc": {'estate_charge_ranking': estate_charge_ranking}
|
||||
"doc": doc_info
|
||||
}
|
||||
actions.append(action_doc)
|
||||
if len(doc_info) > 0:
|
||||
actions.append(action_doc)
|
||||
if len(actions) == 5000:
|
||||
helpers.bulk(es206_client.elastic_client, actions)
|
||||
count += len(actions)
|
||||
log.info(f"物业费等级已更新{count}")
|
||||
log.info(f"物业费等级、售租比已更新{count}")
|
||||
actions.clear()
|
||||
|
||||
|
||||
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 from community_summary "
|
||||
sql = "select city, region, name, estate_charge, finish_building_date, build_type, avg_price, rent_price from community_summary"
|
||||
if pd.notna(city):
|
||||
sql += " where city='" + city + "'"
|
||||
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
||||
@@ -82,7 +89,7 @@ def sync(city=None):
|
||||
helpers.bulk(es206_client.elastic_client, actions)
|
||||
actions.clear()
|
||||
|
||||
log.info(f"完成同步物业费等级至206 {index_name}")
|
||||
log.info(f"完成同步物业费等级、售租比至206 {index_name}")
|
||||
|
||||
|
||||
sync()
|
||||
@@ -75,7 +75,7 @@ with DAG(
|
||||
# bash_command='python /opt/airflow/dags/repo/dags/business/business/community/extra.py {{dag_run.conf["type"] if "type" in dag_run.conf}}',
|
||||
# )
|
||||
t16 = BashOperator(
|
||||
task_id='estate_charge_ranking_dag',
|
||||
bash_command='python /opt/airflow/dags/repo/dags/business/business/community/estate_charge_ranking.py {{dag_run.conf["type"] if "type" in dag_run.conf}}',
|
||||
task_id='other_dag',
|
||||
bash_command='python /opt/airflow/dags/repo/dags/business/business/community/other.py {{dag_run.conf["type"] if "type" in dag_run.conf}}',
|
||||
)
|
||||
# t1 >> t2 >> t3 >> t4 >> t5 >> t6 >> t6_1 >> t7 >> t8 >> t9 >> t10 >> t11 >> t12 >> t13 >> t14 >> t15 >> t16
|
||||
|
||||
Reference in New Issue
Block a user