diff --git a/apps/wf/services.py b/apps/wf/services.py index ba19d221..4907639b 100755 --- a/apps/wf/services.py +++ b/apps/wf/services.py @@ -8,6 +8,7 @@ from datetime import timedelta import random from apps.utils.queryset import get_parent_queryset from apps.wf.tasks import run_task +from rest_framework.exceptions import ParseError class WfService(object): @@ -161,45 +162,45 @@ class WfService(object): in new_ticket_data else Ticket.ticket_data.get(destination_participant, 0) elif destination_participant_type == State.PARTICIPANT_TYPE_FORMCODE: # 代码获取 - # if '.' in destination_participant: module, func = destination_participant.rsplit(".", 1) m = importlib.import_module(module) f = getattr(m, func) destination_participant = f(state=state, ticket=ticket, new_ticket_data=new_ticket_data, handler=handler) - # else: - # destination_participant = getattr(GetParticipants, destination_participant)( - # state=state, ticket=ticket, new_ticket_data=new_ticket_data, hander=handler) elif destination_participant_type == State.PARTICIPANT_TYPE_DEPT: # 部门 destination_participant = list(User.objects.filter( - dept__in=destination_participant).values_list('id', flat=True)) + depts__in=destination_participant).values_list('id', flat=True)) elif destination_participant_type == State.PARTICIPANT_TYPE_POST: # 岗位 user_queryset = User.objects.filter(posts__in=destination_participant) # 如果选择了岗位, 需要走过滤策略 if state.filter_policy == 1: depts = get_parent_queryset(ticket.belong_dept) - user_queryset = user_queryset.filter(dept__in=depts) + user_queryset = user_queryset.filter(depts__in=depts) elif state.filter_policy == 2: depts = get_parent_queryset(ticket.create_by.belong_dept) - user_queryset = user_queryset.filter(dept__in=depts) + user_queryset = user_queryset.filter(depts__in=depts) elif state.filter_policy == 3: depts = get_parent_queryset(handler.belong_dept) - user_queryset = user_queryset.filter(dept__in=depts) + user_queryset = user_queryset.filter(depts__in=depts) destination_participant = list(user_queryset.values_list('id', flat=True)) elif destination_participant_type == State.PARTICIPANT_TYPE_ROLE: # 角色 user_queryset = User.objects.filter(roles__in=destination_participant) # 如果选择了角色, 需要走过滤策略 if state.filter_policy == 1: depts = get_parent_queryset(ticket.belong_dept) - user_queryset = user_queryset.filter(dept__in=depts) + user_queryset = user_queryset.filter(depts__in=depts) elif state.filter_policy == 2: depts = get_parent_queryset(ticket.create_by.belong_dept) - user_queryset = user_queryset.filter(dept__in=depts) + user_queryset = user_queryset.filter(depts__in=depts) elif state.filter_policy == 3: depts = get_parent_queryset(handler.belong_dept) - user_queryset = user_queryset.filter(dept__in=depts) + user_queryset = user_queryset.filter(depts__in=depts) destination_participant = list(user_queryset.values_list('id', flat=True)) + if destination_participant: + pass + else: + raise ParseError('未找到处理人,工单无法继续') if type(destination_participant) == list: destination_participant_type = State.PARTICIPANT_TYPE_MULTI destination_participant = list(set(destination_participant))