diff --git a/assets/image_20260710150426596.png b/assets/image_20260710150426596.png new file mode 100644 index 0000000..f8abf38 Binary files /dev/null and b/assets/image_20260710150426596.png differ diff --git a/lib/report_generator.py b/lib/report_generator.py index 6d61e29..16003f1 100644 --- a/lib/report_generator.py +++ b/lib/report_generator.py @@ -205,8 +205,16 @@ def generate_daily_report(config_id, start_time=None, end_time=None): print(f" 时间范围: {start_time_str} 至 {end_time_str}") print(f" 选择字段: {len(selected_fields)} 个") - # 构建查询SQL - fields_str = ', '.join(selected_fields) + # 构建查询SQL - 过滤掉虚拟字段(时段电量等) + # 虚拟字段不是数据库表中的实际字段,需要动态计算 + TIME_PERIOD_FIELDS = {'sharp_electricity', 'peak_electricity', 'flat_electricity', 'valley_electricity'} + db_fields = [f for f in selected_fields if f not in TIME_PERIOD_FIELDS] + + # 确保至少有 order_no 字段用于关联分时数据 + if 'order_no' not in db_fields: + db_fields.append('order_no') + + fields_str = ', '.join(db_fields) # 检查是否为多选值(逗号分隔) split_values = [v.strip() for v in config['split_value'].split(',') if v.strip()]