接车宝排查问题及续约待办派发数据源加载
This commit is contained in:
@@ -25,6 +25,7 @@ class CommonModule:
|
||||
# 创建一个存储日期的集合,用于去重
|
||||
self.date_set = set()
|
||||
self.conn = Config.CONN_INFO
|
||||
self.renewal_conn = Config.CONN_INFO_RENEWAL
|
||||
|
||||
def time_to_UTC(self, time_input):
|
||||
"""
|
||||
@@ -123,7 +124,7 @@ class CommonModule:
|
||||
return data_NGV
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error occurred: {e}")
|
||||
error_task_logger.error(f"获取NGV明细失败: {e}")
|
||||
return None
|
||||
|
||||
def get_yichang_details(self, days_back=1):
|
||||
@@ -170,11 +171,49 @@ class CommonModule:
|
||||
return data_yichang
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error occurred: {e}")
|
||||
error_task_logger.error(f"获取异常明细时出错: {e}")
|
||||
return None
|
||||
|
||||
def get_renewal_details(self, ):
|
||||
"""
|
||||
从固定的数据库中获取续约待办数据
|
||||
"""
|
||||
try:
|
||||
# 获得连接
|
||||
conn = psycopg2.connect(**self.renewal_conn)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取指定天数前的日期
|
||||
now_time = datetime.now()
|
||||
yes_time = now_time + timedelta(days=-2)
|
||||
yes_time_nyr = int(yes_time.strftime('%Y%m%d')) # 获取前两天日期
|
||||
|
||||
# 获取指定天数前的日期
|
||||
today = date.today()
|
||||
days_to_add = 120
|
||||
future_date = str(today + timedelta(days=days_to_add))
|
||||
|
||||
print("距离今天还有{}天的日期是:{}".format(days_to_add, future_date))
|
||||
|
||||
sql = f"""SELECT * FROM "public"."holo_ads_report_saas_profile_ngv_detail_d" WHERE "date_id" = '{yes_time_nyr}' and "expiry_time" like '%{future_date}%';"""
|
||||
# 执行语句并获取结果集
|
||||
cursor.execute(sql)
|
||||
rows = cursor.fetchall()
|
||||
all_fields = cursor.description # 获取所有字段名
|
||||
|
||||
# 执行结果转化为dataframe
|
||||
col = [i[0] for i in all_fields]
|
||||
data_NGV = pd.DataFrame(list(rows), columns=col)
|
||||
|
||||
# 关闭数据库连接
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
return data_NGV
|
||||
except Exception as e:
|
||||
error_task_logger.error(f"获取续约待办数据时出错: {e}")
|
||||
return None
|
||||
|
||||
def get_saas_data(self):
|
||||
pass
|
||||
|
||||
def get_jcb_details(self, ):
|
||||
"""
|
||||
@@ -260,7 +299,7 @@ class CommonModule:
|
||||
return data_NGV
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error occurred: {e}")
|
||||
error_task_logger.error(f"获取借车宝NGV明细时出错: {e}")
|
||||
return None
|
||||
|
||||
def get_syxcx_details(self, ):
|
||||
@@ -313,7 +352,7 @@ class CommonModule:
|
||||
return data_SY
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error occurred: {e}")
|
||||
error_task_logger.error(f"获取私域小程序数据时出错: {e}")
|
||||
return None
|
||||
|
||||
def get_commission_details(self, ):
|
||||
@@ -363,12 +402,12 @@ class CommonModule:
|
||||
return data_commission
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error occurred: {e}")
|
||||
error_task_logger.error(f"获取小六提成数据时出错: {e}")
|
||||
return None
|
||||
|
||||
def get_differentindustries_details(self, ):
|
||||
"""
|
||||
从f6operation_data_relay数据库中获取小六提成数据。
|
||||
从f6operation_data_relay数据库中获取异业合作数据。
|
||||
返回pandas DataFrame。
|
||||
"""
|
||||
|
||||
@@ -413,7 +452,7 @@ class CommonModule:
|
||||
return data_commission
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error occurred: {e}")
|
||||
error_task_logger.error(f"获取异业合作数据时出错: {e}")
|
||||
return None
|
||||
|
||||
def get_perforamnce_details(self, ):
|
||||
@@ -467,62 +506,13 @@ class CommonModule:
|
||||
return data_commission
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error occurred: {e}")
|
||||
error_task_logger.error(f"获取履约表数据时出错: {e}")
|
||||
return None
|
||||
|
||||
def get_commission_details(self, ):
|
||||
"""
|
||||
从f6operation_data_relay数据库中获取小六提成数据。
|
||||
返回pandas DataFrame。
|
||||
"""
|
||||
|
||||
try:
|
||||
# 获得连接并创建游标
|
||||
conn = pymysql.connect(
|
||||
host=Config.BI_CONN_host,
|
||||
database=Config.BI_CONN_INFO_database,
|
||||
user=Config.BI_CONN_INFO_user,
|
||||
password=Config.BI_CONN_INFO_password,
|
||||
# charset='utf8mb4', # 设置字符集以避免编码问题
|
||||
# cursorclass=pymysql.cursors.DictCursor # 返回字典形式的结果
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取指定天数前的日期
|
||||
# now_time = datetime.now()
|
||||
# target_time = now_time + timedelta(days=-days_back)
|
||||
|
||||
# SQL 查询语句
|
||||
sql = f"""
|
||||
SELECT * FROM JianDaoYun_DailyVisit_Commission;
|
||||
"""
|
||||
|
||||
# 执行查询并获取结果
|
||||
cursor.execute(sql)
|
||||
rows = cursor.fetchall() # pymysql 的 DictCursor 会返回字典列表
|
||||
|
||||
# 将结果转换为 DataFrame
|
||||
if rows: # 如果有数据
|
||||
data_commission = pd.DataFrame(rows)
|
||||
else: # 如果没有数据,返回空 DataFrame
|
||||
data_commission = pd.DataFrame()
|
||||
# 关闭游标
|
||||
cursor.close()
|
||||
headers = [
|
||||
"门店id", "提成类型_二级分类", "提成基数(本月)", "提成基数(上月)", "公司id", "门店编码", "门店名称"
|
||||
]
|
||||
|
||||
data_commission.columns = headers
|
||||
|
||||
return data_commission
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error occurred: {e}")
|
||||
return None
|
||||
|
||||
def get_GroupNotification_details(self, ):
|
||||
"""
|
||||
从f6operation_data_relay数据库中获取小六提成数据。
|
||||
从f6operation_data_relay数据库中获取短信数据支撑数据。
|
||||
返回pandas DataFrame。
|
||||
"""
|
||||
|
||||
@@ -568,7 +558,7 @@ class CommonModule:
|
||||
return data_commission
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error occurred: {e}")
|
||||
error_task_logger.error(f"获取短信数据支撑数据时出错: {e}")
|
||||
return None
|
||||
|
||||
from datetime import datetime, timedelta, UTC, timezone
|
||||
|
||||
Reference in New Issue
Block a user