From 0b7caf6a9fd27f03aa482198f00ee50edb1fad9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E8=89=B3?= Date: Mon, 19 Oct 2026 09:30:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(office):=20=E5=B0=86=20fill=5Fbase=5Fprice?= =?UTF-8?q?=20=E6=95=B0=E6=8D=AE=E5=BA=93=E8=BF=9E=E6=8E=A5=E7=A7=BB?= =?UTF-8?q?=E8=87=B3=E5=87=BD=E6=95=B0=E5=86=85=E9=83=A8=E4=BB=A5=E9=81=BF?= =?UTF-8?q?=E5=85=8D=20DagBag=20=E5=AF=BC=E5=85=A5=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dags/office/sell/fill_base_price.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dags/office/sell/fill_base_price.py b/dags/office/sell/fill_base_price.py index 5c18d39..36214aa 100644 --- a/dags/office/sell/fill_base_price.py +++ b/dags/office/sell/fill_base_price.py @@ -1,20 +1,20 @@ -from goojia_utils import DIDATA_DEV_ELASTIC_CLIENT, dateutils, MAIN_MONGO_CLIENT, threads, areautils import pandas as pd from datetime import datetime from pymongo import UpdateOne import logging -import sys log = logging.getLogger(__name__) -office_sell_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'office_sell_stat') -office_rent_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'office_rent_stat') - def fill_base_price(**kwargs): """ 写字楼基准价 """ + from goojia_utils import dateutils, MAIN_MONGO_CLIENT + + office_sell_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'office_sell_stat') + office_rent_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'office_rent_stat') + # 从 Airflow 的 dag_run.conf 获取参数 conf = kwargs.get('dag_run').conf if kwargs.get('dag_run') else {} city = conf.get('city', '') @@ -38,12 +38,16 @@ def fill_base_price(**kwargs): if len(office_rent) <= 0: return if year_month != '': - calc_by_yearmonth(office_sell, office_rent, year_month) + calc_by_yearmonth(office_sell, office_rent, year_month, office_sell_stat_conn) else: # 对于单个重算的不进行补充,已经自己补充过了 pass -def calc_by_yearmonth(office_sell, office_rent, year_month): +def calc_by_yearmonth(office_sell, office_rent, year_month, office_sell_stat_conn=None): + from goojia_utils import MAIN_MONGO_CLIENT, threads + + if office_sell_stat_conn is None: + office_sell_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'office_sell_stat') office_sell_df = office_sell[['city', 'district', 'name', 'avg_price']] office_sell_df = office_sell_df.rename(columns={'avg_price': 'sell_price'}) office_rent_df = office_rent[['city', 'district', 'name', 'avg_price', 'estate_type2', 'bed_kind', 'location']]