diff --git a/dags/office/dag_base_price.py b/dags/office/dag_base_price.py new file mode 100644 index 0000000..28460a3 --- /dev/null +++ b/dags/office/dag_base_price.py @@ -0,0 +1,22 @@ +""" +写字楼基准价计算 +""" +from airflow.operators.bash import BashOperator + +import pendulum + +from airflow import DAG + +with DAG( + dag_id="base_price_dag", + schedule_interval="0 1 27 * *", + start_date=pendulum.datetime(2025, 2, 28, tz="Asia/Shanghai"), + catchup=True, + description="写字楼基准价计算" +) as dag: + t1 = BashOperator( + task_id='base_price', + bash_command='python /opt/airflow/dags/repo/dags/office/rent/base_price.py', + ) + t1 + diff --git a/dags/office/rent/base_price.py b/dags/office/rent/base_price.py index 4bea019..555e0e1 100644 --- a/dags/office/rent/base_price.py +++ b/dags/office/rent/base_price.py @@ -251,7 +251,10 @@ def calc(city, year_month): actions.clear() # 第五步 - db_df = pd.DataFrame(list(office_rent_stat_conn.find({'cat': 'office', 'date': year_month, 'calc_type': {'$in': [1, 2, 3]}}))) + query = {'cat': 'office', 'date': year_month, 'calc_type': {'$in': [1, 2, 3]}} + if pd.notna(city): + query['city'] = city + db_df = pd.DataFrame(list(office_rent_stat_conn.find(query))) office_info = office[['city', 'region', 'name', 'lng', 'lat', 'estate_type2', 'bed_kind']].drop_duplicates( keep='first') # 计算价格的写字楼 @@ -301,7 +304,7 @@ def calc(city, year_month): actions.clear() office_rent_stat_conn.bulk_write(actions) -# for year_month in range(202406, 202501): -# print(year_month) -# calc('上海', year_month) -calc('上海', 202412) \ No newline at end of file +for year_month in range(202406, 202501): + print(year_month) + calc(None, year_month) +#calc('上海', 202412) \ No newline at end of file