修复求和数据页面显示的问题
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
import sys
|
||||
sys.path.insert(0, '.')
|
||||
from lib.db import execute_query
|
||||
|
||||
print('=== 检查最近的340路历史记录 ===')
|
||||
history = execute_query('SELECT id, report_date, start_time, end_time, total_orders, sum_results, status FROM t_daily_report_history WHERE config_id = %s ORDER BY report_date DESC LIMIT 5', (1784534746013,))
|
||||
for h in history:
|
||||
print(f"ID: {h['id']}")
|
||||
print(f" 报表日期: {h['report_date']}")
|
||||
print(f" 开始时间: {h['start_time']}")
|
||||
print(f" 结束时间: {h['end_time']}")
|
||||
print(f" 订单数: {h['total_orders']}")
|
||||
print(f" 状态: {h['status']}")
|
||||
print(f" 求和结果: {h['sum_results'][:100]}...")
|
||||
print()
|
||||
|
||||
print('=== 检查7月23日是否有报表生成 ===')
|
||||
history_23 = execute_query('SELECT id, report_date, start_time, end_time, total_orders, status FROM t_daily_report_history WHERE config_id = %s AND report_date = %s', (1784534746013, '2026-07-23'))
|
||||
for h in history_23:
|
||||
print(f"ID: {h['id']}, 报表日期: {h['report_date']}, 状态: {h['status']}, 订单数: {h['total_orders']}")
|
||||
print(f" 开始时间: {h['start_time']}, 结束时间: {h['end_time']}")
|
||||
|
||||
print('\n=== 检查7月14日是否有自动采集的数据 ===')
|
||||
auto_14 = execute_query('SELECT * FROM t_daily_report_sum_data WHERE report_date = %s AND split_value = %s AND data_source = %s', ('2026-07-14', '163425', 'auto'))
|
||||
print(f"7月14日自动采集数据: {len(auto_14)}条")
|
||||
|
||||
print('\n=== 检查7月15日是否有自动采集的数据 ===')
|
||||
auto_15 = execute_query('SELECT * FROM t_daily_report_sum_data WHERE report_date = %s AND split_value = %s AND data_source = %s', ('2026-07-15', '163425', 'auto'))
|
||||
print(f"7月15日自动采集数据: {len(auto_15)}条")
|
||||
|
||||
print('\n=== 查询7月23日的求和数据 ===')
|
||||
sum_23 = execute_query('SELECT * FROM t_daily_report_sum_data WHERE report_date = %s AND split_value = %s', ('2026-07-23', '163425'))
|
||||
print(f"7月23日求和数据: {len(sum_23)}条")
|
||||
for s in sum_23:
|
||||
print(f" ID: {s['id']}, 字段: {s['sum_field_key']}, 值: {s['sum_value']}, 来源: {s['data_source']}")
|
||||
@@ -40,7 +40,8 @@ def collect_sum_data():
|
||||
def list_sum_data():
|
||||
"""查询求和数据列表"""
|
||||
try:
|
||||
page = int(request.args.get('page', 1))
|
||||
page_param = request.args.get('page')
|
||||
page = int(page_param) if page_param else None
|
||||
page_size = int(request.args.get('page_size', 20))
|
||||
start_date = request.args.get('start_date')
|
||||
end_date = request.args.get('end_date')
|
||||
@@ -48,7 +49,7 @@ def list_sum_data():
|
||||
config_name = request.args.get('config_name')
|
||||
sum_field_key = request.args.get('sum_field_key')
|
||||
data_source = request.args.get('data_source')
|
||||
log_info(f'[求和数据API] 查询求和数据列表,第{page}页', 'api')
|
||||
log_info(f'[求和数据API] 查询求和数据列表,page={page}, page_size={page_size}', 'api')
|
||||
|
||||
result = get_sum_data_list(
|
||||
page=page,
|
||||
|
||||
@@ -234,13 +234,13 @@ def _calculate_charge_degree(history):
|
||||
return None
|
||||
|
||||
|
||||
def get_sum_data_list(page=1, page_size=20, start_date=None, end_date=None, config_id=None,
|
||||
def get_sum_data_list(page=None, page_size=20, start_date=None, end_date=None, config_id=None,
|
||||
config_name=None, sum_field_key=None, data_source=None):
|
||||
"""
|
||||
查询求和数据列表
|
||||
|
||||
Args:
|
||||
page: 页码
|
||||
page: 页码(None表示不分页,返回所有数据)
|
||||
page_size: 每页大小
|
||||
start_date: 开始日期(可选)
|
||||
end_date: 结束日期(可选)
|
||||
@@ -253,8 +253,6 @@ def get_sum_data_list(page=1, page_size=20, start_date=None, end_date=None, conf
|
||||
dict: 查询结果
|
||||
"""
|
||||
try:
|
||||
offset = (page - 1) * page_size
|
||||
|
||||
where_clauses = ['1=1']
|
||||
params = []
|
||||
|
||||
@@ -292,13 +290,23 @@ def get_sum_data_list(page=1, page_size=20, start_date=None, end_date=None, conf
|
||||
total = total_result[0]['total']
|
||||
|
||||
# 查询数据
|
||||
list_result = execute_query(
|
||||
f'''SELECT * FROM t_daily_report_sum_data
|
||||
WHERE {where_sql}
|
||||
ORDER BY report_date DESC, sort_order ASC, config_id ASC, id DESC
|
||||
LIMIT %s OFFSET %s''',
|
||||
tuple(params) + (page_size, offset)
|
||||
)
|
||||
if page is not None:
|
||||
offset = (page - 1) * page_size
|
||||
list_result = execute_query(
|
||||
f'''SELECT * FROM t_daily_report_sum_data
|
||||
WHERE {where_sql}
|
||||
ORDER BY report_date DESC, sort_order ASC, config_id ASC, id DESC
|
||||
LIMIT %s OFFSET %s''',
|
||||
tuple(params) + (page_size, offset)
|
||||
)
|
||||
else:
|
||||
list_result = execute_query(
|
||||
f'''SELECT * FROM t_daily_report_sum_data
|
||||
WHERE {where_sql}
|
||||
ORDER BY report_date DESC, sort_order ASC, config_id ASC, id DESC'''
|
||||
,
|
||||
tuple(params)
|
||||
)
|
||||
|
||||
return {
|
||||
'success': True,
|
||||
|
||||
@@ -189,8 +189,7 @@ async function loadSumData(page = 1) {
|
||||
}
|
||||
|
||||
const params = new URLSearchParams();
|
||||
params.append('page', page);
|
||||
params.append('page_size', '50');
|
||||
params.append('page_size', '1000');
|
||||
if (startDate) params.append('start_date', startDate);
|
||||
if (endDate) params.append('end_date', endDate);
|
||||
if (configName) params.append('config_name', configName);
|
||||
|
||||
Reference in New Issue
Block a user