diff --git a/dags/jh/price/price_exception.py b/dags/jh/price/price_exception.py index 2ad5aec..3910a7a 100644 --- a/dags/jh/price/price_exception.py +++ b/dags/jh/price/price_exception.py @@ -6,6 +6,7 @@ import pandas as pd import logging import os import sys +import requests os.environ["ORACLE_HOME"] = "/home/airflow/instantclient_21_7" @@ -41,6 +42,19 @@ def simple_calc(result_df): result_df = pd.merge(result_df, simple_df, on=['commid'], how='left') return result_df +def send_msg(): + infos = "【自动检测异常价格】异常价格数据已生成完毕,请点击 https://nextcloud.fangjia.com/s/KwxGsosMcnYxdoa 查看详情" + data = { + "msgtype": "text", + "text": { + "content": infos + } + } + # 发送消息至群 + requests.post( + url='https://oapi.dingtalk.com/robot/send?access_token=1b6d0d782d3c316f2d3b6b18ea5144816170dd392befbf2042a24a01fb84b736', + json=data) + def up_to_nextcloud(): """ 上传统计信息至nextcloud @@ -74,9 +88,9 @@ five_map = dict() for index, item in df.iterrows(): year_month = item['year_month'] key = item['cityname'] + "," + item['distname'] + "," + item['commid'] + "," + item['commname'] - if year_month == month_last: + if year_month == int(month_last): five_map[key] = str(item['avg_price']) + "|" + str(item['calc_type']) + '|' + str(item['confidence']) - elif year_month == month_now: + elif year_month == int(month_now): six_map[key] = str(item['avg_price']) + "|" + str(item['calc_type']) + '|' + str(item['confidence']) actions = list() @@ -109,7 +123,7 @@ aim_file_name = path + '/' + file_name excel_writer = pd.ExcelWriter(aim_file_name) -if type == 'simple': +if type == 'sample': result_df = simple_calc(result_df) result_df = result_df.drop_duplicates(subset=['commid'], keep='first') @@ -128,3 +142,5 @@ excel_writer.save() excel_writer.close() up_to_nextcloud() + +send_msg() \ No newline at end of file diff --git a/dags/jh/price_exception_dag.py b/dags/jh/price_exception_dag.py index e07159e..a130a98 100644 --- a/dags/jh/price_exception_dag.py +++ b/dags/jh/price_exception_dag.py @@ -8,7 +8,7 @@ with DAG( schedule_interval="0 10 23 * *", start_date=pendulum.datetime(2022, 8, 23, tz="Asia/Shanghai"), catchup=True, - description="建行每月价格异常检测脚本,默认检测本月与上月差异, 若输出样本存在与否,设置type=simple" + description="建行每月价格异常检测脚本,默认检测本月与上月差异, 若输出样本存在与否,设置type=sample" ) as dag: t1 = BashOperator( task_id='price_exception',