feat: base wf增加ticket_count接口添加分类

This commit is contained in:
caoqianming 2025-12-12 10:24:34 +08:00
parent 8c18bbf6ae
commit 7f34d45160
1 changed files with 3 additions and 2 deletions

View File

@ -186,8 +186,9 @@ class WorkflowViewSet(CustomModelViewSet):
工作流下的工单数量统计 工作流下的工单数量统计
""" """
queryset = self.filter_queryset(self.get_queryset()) queryset = self.filter_queryset(self.get_queryset())
result = Ticket.objects.filter(workflow__in=queryset).annotate(workflow_name=F('workflow__name')).values( result = Ticket.objects.filter(workflow__in=queryset).annotate(
'workflow', 'workflow_name').annotate( workflow_name=F('workflow__name'), workflow_cate=F('workflow__cate')).values(
'workflow', 'workflow_name', 'workflow_cate').annotate(
count_done=Count(Case(When(state__type=2, then=1), output_field=IntegerField())), count_done=Count(Case(When(state__type=2, then=1), output_field=IntegerField())),
count_processing=Count(Case(When(state__type=1, then=1), output_field=IntegerField())), count_processing=Count(Case(When(state__type=1, then=1), output_field=IntegerField())),
) )