From e37e494a1f24dedfcf1e58ae91e60ef8216f392d Mon Sep 17 00:00:00 2001 From: haoslm <6083297@qq.com> Date: Thu, 23 Jul 2026 15:17:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B1=82=E5=92=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check_data.py | 35 ----------------------------------- lib/api/sum_data_api.py | 5 +++-- lib/sum_data_collector.py | 30 +++++++++++++++++++----------- public/static/js/sum_data.js | 3 +-- 4 files changed, 23 insertions(+), 50 deletions(-) delete mode 100644 check_data.py diff --git a/check_data.py b/check_data.py deleted file mode 100644 index 4a395aa..0000000 --- a/check_data.py +++ /dev/null @@ -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']}") diff --git a/lib/api/sum_data_api.py b/lib/api/sum_data_api.py index 8509cb3..7d00cad 100644 --- a/lib/api/sum_data_api.py +++ b/lib/api/sum_data_api.py @@ -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, diff --git a/lib/sum_data_collector.py b/lib/sum_data_collector.py index 93754bd..5d6c8b4 100644 --- a/lib/sum_data_collector.py +++ b/lib/sum_data_collector.py @@ -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, diff --git a/public/static/js/sum_data.js b/public/static/js/sum_data.js index bad563f..ebde454 100644 --- a/public/static/js/sum_data.js +++ b/public/static/js/sum_data.js @@ -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);