feat: 自动提交 - 周二 2025/09/23 15:32:55.51
This commit is contained in:
@@ -287,14 +287,47 @@ class QueryOptimizer:
|
||||
status_counts = Counter([wo.status for wo in workorders])
|
||||
category_counts = Counter([wo.category for wo in workorders])
|
||||
priority_counts = Counter([wo.priority for wo in workorders])
|
||||
resolved_count = status_counts.get('resolved', 0)
|
||||
|
||||
# 调试信息
|
||||
logger.info(f"工单状态统计: {dict(status_counts)}")
|
||||
logger.info(f"工单总数: {total}")
|
||||
|
||||
# 处理状态映射(支持中英文状态)
|
||||
status_mapping = {
|
||||
'open': ['open', '待处理', '新建', 'new'],
|
||||
'in_progress': ['in_progress', '处理中', '进行中', 'progress', 'processing'],
|
||||
'resolved': ['resolved', '已解决', '已完成'],
|
||||
'closed': ['closed', '已关闭', '关闭']
|
||||
}
|
||||
|
||||
# 统计各状态的数量
|
||||
mapped_counts = {'open': 0, 'in_progress': 0, 'resolved': 0, 'closed': 0}
|
||||
|
||||
for status, count in status_counts.items():
|
||||
if status is None:
|
||||
continue
|
||||
status_lower = str(status).lower()
|
||||
mapped = False
|
||||
for mapped_status, possible_values in status_mapping.items():
|
||||
if status_lower in [v.lower() for v in possible_values]:
|
||||
mapped_counts[mapped_status] += count
|
||||
mapped = True
|
||||
break
|
||||
|
||||
if not mapped:
|
||||
logger.warning(f"未映射的状态: '{status}' (数量: {count})")
|
||||
|
||||
# 调试信息
|
||||
logger.info(f"映射后的状态统计: {mapped_counts}")
|
||||
|
||||
resolved_count = mapped_counts['resolved']
|
||||
|
||||
workorders_stats = {
|
||||
'total': total,
|
||||
'open': status_counts.get('open', 0),
|
||||
'in_progress': status_counts.get('in_progress', 0),
|
||||
'resolved': resolved_count,
|
||||
'closed': status_counts.get('closed', 0),
|
||||
'open': mapped_counts['open'],
|
||||
'in_progress': mapped_counts['in_progress'],
|
||||
'resolved': mapped_counts['resolved'],
|
||||
'closed': mapped_counts['closed'],
|
||||
'by_category': dict(category_counts),
|
||||
'by_priority': dict(priority_counts)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user