完成价格异常迁移

This commit is contained in:
Jian Shen
2022-08-24 11:12:53 +08:00
parent 659b139b18
commit 0b43cf414b
2 changed files with 20 additions and 4 deletions
+19 -3
View File
@@ -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()
+1 -1
View File
@@ -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',