diff --git a/dags/office/rent/base_price.py b/dags/office/rent/base_price.py index 1f84650..089a222 100644 --- a/dags/office/rent/base_price.py +++ b/dags/office/rent/base_price.py @@ -30,12 +30,13 @@ def calc(**kwargs): """ # 从 Airflow 的 dag_run.conf 获取参数 conf = kwargs.get('dag_run').conf if kwargs.get('dag_run') else {} - city = conf.get('city', '') - year_month = conf.get('year_month', '') - district = conf.get('district', '') - office_name = conf.get('name', '') - - if office_name == '': + city = conf.get('city', None) + year_month = conf.get('year_month', None) + district = conf.get('district', None) + office_name = conf.get('name', None) + if year_month is None: + year_month = dateutils.format_date(dateutils.add_months(datetime.today().year, months=-1), "%Y%m") + if pd.isna(office_name): calcByCity(city, year_month) else: # 直接重算出最近一年的数据,保证一年有数据 diff --git a/dags/office/sell/base_price.py b/dags/office/sell/base_price.py index f565c2a..5996f79 100644 --- a/dags/office/sell/base_price.py +++ b/dags/office/sell/base_price.py @@ -30,16 +30,13 @@ def calc(**kwargs): """ # 从 Airflow 的 dag_run.conf 获取参数 conf = kwargs.get('dag_run').conf if kwargs.get('dag_run') else {} - city = conf.get('city', '') - year_month = conf.get('year_month', '') - district = conf.get('district', '') - office_name = conf.get('name', '') - if city == "": - city = None - if district == "": - district = None - if office_name == "": - office_name = None + city = conf.get('city', None) + year_month = conf.get('year_month', None) + district = conf.get('district', None) + office_name = conf.get('name', None) + if year_month is None: + year_month = dateutils.format_date(dateutils.add_months(datetime.today().year, months=-1), "%Y%m") + if pd.isna(office_name): calcByCity(city, year_month) else: diff --git a/dags/office/sell/fill_base_price.py b/dags/office/sell/fill_base_price.py index 7cfc1e1..9387102 100644 --- a/dags/office/sell/fill_base_price.py +++ b/dags/office/sell/fill_base_price.py @@ -21,6 +21,8 @@ def fill_base_price(**kwargs): year_month = conf.get('year_month', '') district = conf.get('district', '') office_name = conf.get('name', '') + if year_month == "": + year_month = dateutils.format_date(dateutils.add_months(datetime.today().year, months=-1), "%Y%m") query = {'cat': 'office'} if year_month != '':