还原
This commit is contained in:
@@ -23,18 +23,7 @@ seaweed_df = MAIN_MONGO_CLIENT.get_collection('fangjia', 'seaweed')
|
||||
office_sell_stat_conn = MAIN_MONGO_CLIENT.get_collection('fangjia_stat', 'office_sell_stat')
|
||||
|
||||
# 计算有样本写字楼的基准价 1. 取近一年,最近100个样本的中位值
|
||||
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', '')
|
||||
|
||||
|
||||
def calc(city, year_month):
|
||||
sql = "select * from latest_seawater where cat='office_sell' "
|
||||
if pd.notna(city):
|
||||
sql += "and city='" + city + "' "
|
||||
@@ -365,6 +354,15 @@ def calc(**kwargs):
|
||||
print("已计算" + str(count) + "条数据")
|
||||
actions.clear()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 测试脚本:直接运行时模拟 Airflow 的上下文
|
||||
calc(dag_run=type('DagRun', (), {'conf': {'city': '上海', 'district': '静安', 'name': '凯迪克大厦'}}))
|
||||
if __name__ == '__main__':
|
||||
yearmonth = sys.argv[1] if len(sys.argv) > 1 else ''
|
||||
|
||||
if yearmonth == '':
|
||||
date = dateutils.add_months(datetime.today(), months=-1)
|
||||
yearmonth = int(dateutils.format_date(date, '%Y%m'))
|
||||
try:
|
||||
if type(yearmonth) is str:
|
||||
yearmonth = int(yearmonth)
|
||||
calc(None, yearmonth)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
@@ -13,7 +13,6 @@ es_client = ElasticSearchClient(host='192.168.0.206')
|
||||
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 calc(city, year_month):
|
||||
print(f"开始处理{city}, {year_month}")
|
||||
query = {'date': year_month, 'cat': 'office'}
|
||||
|
||||
Reference in New Issue
Block a user