Commit 4091744b authored by xianyang's avatar xianyang

优化账户数据源

parent f88d0280
...@@ -187,7 +187,7 @@ def get_finance_group_by(date, condition): ...@@ -187,7 +187,7 @@ def get_finance_group_by(date, condition):
return result return result
def get_finance_info(unique_tag, page, size, start_time, end_time, is_list=None): def get_finance_info(unique_tag, id, page, size, start_time, end_time, is_list=None):
"""账户财务信息""" """账户财务信息"""
finance_condition = [] finance_condition = []
month, last_month, before_last_month = get_last_month() month, last_month, before_last_month = get_last_month()
...@@ -233,21 +233,8 @@ def get_finance_info(unique_tag, page, size, start_time, end_time, is_list=None) ...@@ -233,21 +233,8 @@ def get_finance_info(unique_tag, page, size, start_time, end_time, is_list=None)
count = future1.result() count = future1.result()
res = future2.result() res = future2.result()
else: else:
total_list = [] sys_sql = f"select initial_money as balance,income,outcome,create_time from v2_system_account_statistics_copy where fi_account_id={id} ORDER BY create_time DESC"
fi_sql = f"select uuid from fi_account where unique_tag='{unique_tag}'" result = LinkMysql(env.DB_3YV2).query_mysql(sys_sql)
fi_res = LinkMysql(env.DB_3YV2).query_mysql(fi_sql)
finance_condition.append(f" uuid='{fi_res[0]['uuid']}'")
with ThreadPoolExecutor(max_workers=3) as pool:
future1 = pool.submit(get_finance_group_by, 'assets_log_' + month, finance_condition)
future2 = pool.submit(get_finance_group_by, 'assets_log_' + last_month, finance_condition)
future3 = pool.submit(get_finance_group_by, 'assets_log_' + before_last_month, finance_condition)
month_data = future1.result()
last_data = future2.result()
before_last_data = future3.result()
total_list = total_list + month_data if month_data else total_list
total_list = total_list + last_data if last_data else total_list
ultimately_data = total_list + before_last_data if before_last_data else total_list
result = out_income_combine(ultimately_data)
res = result[int(page - 1) * size: page * size] res = result[int(page - 1) * size: page * size]
count = result count = result
# 判断是列表还是导出接口 # 判断是列表还是导出接口
......
...@@ -53,12 +53,13 @@ def read_account(data: schemas.AccountUpdate, token=Depends(login_required)): ...@@ -53,12 +53,13 @@ def read_account(data: schemas.AccountUpdate, token=Depends(login_required)):
def finance_information(unique_tag: str, def finance_information(unique_tag: str,
page: int, page: int,
size: int, size: int,
id: Optional[int] = None,
start_time: Optional[str] = "", start_time: Optional[str] = "",
end_time: Optional[str] = "", end_time: Optional[str] = "",
token=Depends(login_required)): token=Depends(login_required)):
# unique_tag:Optional[str] = Query(None, min_length=3, max_length=50, regex="^xiao\d+$") 参数验证 # unique_tag:Optional[str] = Query(None, min_length=3, max_length=50, regex="^xiao\d+$") 参数验证
"""账户财务详情列表""" """账户财务详情列表"""
res, total = crud.get_finance_info(unique_tag, page, size, start_time, end_time, 1) res, total = crud.get_finance_info(unique_tag, id, page, size, start_time, end_time, 1)
return HttpResultResponse(total=total, data=res) return HttpResultResponse(total=total, data=res)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment