From 1532c5dc78b8db385fe53412dfd8ece2d4ad0e94 Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Tue, 16 Aug 2022 15:04:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B7=E6=9C=AC=E5=8F=82=E6=95=B0=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dags/stat/district_sell_deal_dag.py | 2 +- dags/stat/evaluate/district_sell_property.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dags/stat/district_sell_deal_dag.py b/dags/stat/district_sell_deal_dag.py index 570b5f3..423242c 100644 --- a/dags/stat/district_sell_deal_dag.py +++ b/dags/stat/district_sell_deal_dag.py @@ -15,6 +15,6 @@ with DAG( ) t2 = BashOperator( task_id='district_sell_property', - bash_command='python /opt/airflow/dags/repo/dags/stat/evaluate/district_sell_property.py', + bash_command='python /opt/airflow/dags/repo/dags/stat/evaluate/district_sell_property.py {{dag_run.conf["sell_num"] if "sell_num" in dag_run.conf}}', ) t1 >> t2 diff --git a/dags/stat/evaluate/district_sell_property.py b/dags/stat/evaluate/district_sell_property.py index 492408c..6e679a1 100644 --- a/dags/stat/evaluate/district_sell_property.py +++ b/dags/stat/evaluate/district_sell_property.py @@ -5,8 +5,11 @@ import logging from goojia_utils import MAIN_MONGO_CLIENT, ElasticSearchClient, dateutils import pandas as pd import datetime +import sys log = logging.getLogger(__name__) +sell_num = sys.argv[1] if len(sys.argv) > 1 else 2 +log.info("输出参数" + sell_num) year_month_day = dateutils.format_date(datetime.datetime.now()) aim_file_name = '/home/airflow/data/evaluate/估值数据统计结果' + year_month_day + '.xlsx' @@ -42,7 +45,7 @@ def sell_stat(): '_id'].transform('size') sell_seaweed_merge_df = sell_seaweed_merge_df[['city', 'region', '_id', 'count']] sell_seaweed_merge_df = sell_seaweed_merge_df.drop_duplicates(subset=['city', 'region', '_id']) - sell_seaweed_ok_df = sell_seaweed_merge_df[sell_seaweed_merge_df['count'] >= 3] + sell_seaweed_ok_df = sell_seaweed_merge_df[sell_seaweed_merge_df['count'] > sell_num] sell_seaweed_ok_df['city_seaweed_count'] = sell_seaweed_ok_df.groupby('city')['city'].transform('size') city_seaweed_count_df = sell_seaweed_ok_df[['city', 'city_seaweed_count']].drop_duplicates( subset=['city', 'city_seaweed_count']) @@ -77,7 +80,7 @@ def sell_stat(): try: sql = "select count(*) from latest_seawater where city='" + city + "' and region='" + region + "' and cat='sell' and district_name in(" + names_str + ") and p_date > " + one_year_time num = es206_client.search_by_sql(sql)['hits']['total']['value'] - if num >= 3: + if num > sell_num: count += 1 total_num += num all_num += num