增加求和采集和细节修改

This commit is contained in:
2026-07-14 14:24:21 +08:00
parent 42c319877c
commit ccc041604a
12 changed files with 1438 additions and 108 deletions

View File

@@ -450,6 +450,12 @@ def generate_daily_report(config_id, start_time=None, end_time=None):
total = sum(float(order.get(field, 0) or 0) for order in orders)
sum_results[field] = round(total, 3)
# 强制采集充电电量(charge_degree),即使不在求和字段配置中也要采集
if 'charge_degree' not in sum_results and orders and 'charge_degree' in orders[0]:
total_charge_degree = sum(float(order.get('charge_degree', 0) or 0) for order in orders)
sum_results['charge_degree'] = round(total_charge_degree, 3)
print(f"[日报生成] 强制采集充电电量: {sum_results['charge_degree']} kWh")
# 构建ID到名称的映射
id_name_maps = build_id_to_name_map(orders, selected_fields)
@@ -492,6 +498,18 @@ def generate_daily_report(config_id, start_time=None, end_time=None):
)
print(f"[日报生成] 历史记录已保存,ID={history_id}")
# 自动采集求和数据到求和数据表
try:
if sum_results:
from lib.sum_data_collector import collect_sum_data_from_history
collect_result = collect_sum_data_from_history(history_id)
if collect_result['success']:
print(f"[日报生成] 求和数据采集成功")
else:
print(f"[日报生成] 求和数据采集失败: {collect_result['message']}")
except Exception as collect_error:
print(f"[日报生成] 求和数据采集异常: {str(collect_error)}")
print(f"[日报生成] ✓ 生成成功")
print(f" 订单数量: {len(orders)}")
print(f" 总金额: {total_amount}")