Commit 38abc006 authored by xianyang's avatar xianyang

代码业务汇总导出

parent 64511855
......@@ -171,8 +171,13 @@ class MonthDataDerive(object):
return StreamingResponse(file, media_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
def derive_data(self, date, key_type):
def derive_data(self, date, key_type, name):
assets_list = []
if name:
assets_list.append(f" create_time <= {time_str_to_timestamp(start_time + ' 00:00:00')} ")
if key_type:
assets_list.append(f" create_time <= {time_str_to_timestamp(end_time + ' 23:59:59')} ")
if assets_list:
sql = f"SELECT reference_type, type, SUM(cast(amount as decimal(20,6)))/1000 as money FROM {date} where reference_type='{key_type}' GROUP BY reference_type, type ORDER BY reference_type"
else:
sql = f"SELECT reference_type, type, SUM(cast(amount as decimal(20,6)))/1000 as money FROM {date} GROUP BY reference_type, type ORDER BY reference_type"
......
......@@ -96,6 +96,7 @@ def month_to_export(param: schemas.MonthStatistics, request: Request, token=Depe
headers = request.get("headers")
if not param.date:
return HttpResultResponse(code=500, msg='查询月份不能为空')
result = crud.MonthDataDerive().derive_data('assets_log_' + param.date, param.type)
result, num = crud.CalculationMonthlyBill().month_statistics_task('assets_log_' + param.date, param.type, param.name,
param.page, 999999)
field_head = ['业务名称', '财务编码类型', '出账金额', '入账金额', '是否异常', '异常金额']
return statement_crud.data_to_file(db, result, "业务类型汇总", headers, field_head)
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