fix(accounting): billing.dspy — convert DictObject to list when sor.sqlExe returns non-list
This commit is contained in:
parent
0e750b6d31
commit
31c348878a
@ -27,7 +27,9 @@ where a.orgid = ${orgid}$
|
|||||||
and d.acc_date >= ${start_date}$
|
and d.acc_date >= ${start_date}$
|
||||||
and d.acc_date <= ${end_date}$"""
|
and d.acc_date <= ${end_date}$"""
|
||||||
rows = await sor.sqlExe(sql, ns)
|
rows = await sor.sqlExe(sql, ns)
|
||||||
debug(f'billing rows type={type(rows).__name__}, is_list={isinstance(rows, list)}, len={len(rows) if isinstance(rows, list) else "N/A"}')
|
if not isinstance(rows, list):
|
||||||
|
rows = list(rows) if rows else []
|
||||||
|
debug(f'billing rows type={type(rows).__name__}, len={len(rows)}')
|
||||||
|
|
||||||
# 统计数据 — 独立 ns 避免被 sqlor 修改
|
# 统计数据 — 独立 ns 避免被 sqlor 修改
|
||||||
stats_ns = {
|
stats_ns = {
|
||||||
@ -52,8 +54,8 @@ where a.orgid = ${orgid}$
|
|||||||
'credit_sum': float(stats_recs[0].credit_sum) if stats_recs else 0
|
'credit_sum': float(stats_recs[0].credit_sum) if stats_recs else 0
|
||||||
}
|
}
|
||||||
result = {
|
result = {
|
||||||
'total': len(rows) if isinstance(rows, list) else 0,
|
'total': len(rows),
|
||||||
'rows': rows if isinstance(rows, list) else [],
|
'rows': rows,
|
||||||
'stats': stats
|
'stats': stats
|
||||||
}
|
}
|
||||||
return json.dumps(result, ensure_ascii=False, default=str)
|
return json.dumps(result, ensure_ascii=False, default=str)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user