From 0d8c221dd324bbc44fe13506cbd389e2ca303e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=81=A5?= Date: Mon, 9 Jun 2025 14:49:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dags/jh/sample/samples_notice.py | 35 ++++++++++++++------------------ 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/dags/jh/sample/samples_notice.py b/dags/jh/sample/samples_notice.py index 04824b3..736a477 100644 --- a/dags/jh/sample/samples_notice.py +++ b/dags/jh/sample/samples_notice.py @@ -13,8 +13,6 @@ last = dateutils.add_months(first_day, 0, -2, 0, 0) last_day = last.strftime('%Y%m%d') log.info(f"系统当前时间 : {now}") -token = '1b6d0d782d3c316f2d3b6b18ea5144816170dd392befbf2042a24a01fb84b736' -dingutils.send_text('【房源样本数量自动检测】数据已生成完毕,请点击 https://nextcloud.fangjia.com/s/KwxGsosMcnYxdoa 查看详情', token) def proc(): # 区域维度,统计2个月内样本数据量 @@ -101,10 +99,6 @@ def proc(): air_file_name = path + '/' + file_name return text, air_file_name, df_region_res, df_root_city_res, df_root_res, file_name, count_old, count_new - -text, air_file_name, df_region_res, df_root_city_res, df_root_res, file_name, count_old, count_new = proc() - - def up_to_nextcloud(): """ 上传统计信息至nextcloud @@ -117,17 +111,18 @@ def up_to_nextcloud(): nxc = NextCloud(endpoint=NEXTCLOUD_URL, user=NEXTCLOUD_USERNAME, password=NEXTCLOUD_PASSWORD) nxc.upload_file(air_file_name, nextcloud_file_name) - -if text != '': - with pd.ExcelWriter(air_file_name) as writer: - if not df_region_res.empty: - df_region_res.to_excel(writer, sheet_name="房源样本数量检测-区域维度", columns=["city", "region", 'count'], index=False) - if not df_root_city_res.empty: - df_root_city_res.to_excel(writer, sheet_name="房源样本数量检测-房源网站维度(样本数)", columns=['root', 'city', 'count'], - index=False) - if not df_root_res.empty: - df_root_res.to_excel(writer, sheet_name="房源样本数量检测-房源网站维度(样本减少百分比)", columns=['root', count_old, count_new], - index=False) - up_to_nextcloud() - token = '1b6d0d782d3c316f2d3b6b18ea5144816170dd392befbf2042a24a01fb84b736' - dingutils.send_text(text, token) +if __name__ == '__main__': + text, air_file_name, df_region_res, df_root_city_res, df_root_res, file_name, count_old, count_new = proc() + if text != '': + with pd.ExcelWriter(air_file_name) as writer: + if not df_region_res.empty: + df_region_res.to_excel(writer, sheet_name="房源样本数量检测-区域维度", columns=["city", "region", 'count'], index=False) + if not df_root_city_res.empty: + df_root_city_res.to_excel(writer, sheet_name="房源样本数量检测-房源网站维度(样本数)", columns=['root', 'city', 'count'], + index=False) + if not df_root_res.empty: + df_root_res.to_excel(writer, sheet_name="房源样本数量检测-房源网站维度(样本减少百分比)", columns=['root', count_old, count_new], + index=False) + up_to_nextcloud() + token = '1b6d0d782d3c316f2d3b6b18ea5144816170dd392befbf2042a24a01fb84b736' + dingutils.send_text(text, token)