diff --git a/apps/ticket/urls.py b/apps/ticket/urls.py index ea94a083..846bee10 100644 --- a/apps/ticket/urls.py +++ b/apps/ticket/urls.py @@ -1,7 +1,7 @@ from django.urls import path from apps.ticket.views import TicketListView, TicketView, TicketTransition, TicketFlowlog, TicketFlowStep, TicketState, \ TicketsStates, TicketAccept, TicketDeliver, TicketAddNode, \ - TicketAddNodeEnd, TicketField, TicketScriptRetry, TicketComment, TicketHookCallBack + TicketAddNodeEnd, TicketField, TicketScriptRetry, TicketComment, TicketHookCallBack, TicketParticipantInfo urlpatterns = [ path('', TicketListView.as_view()), @@ -18,5 +18,6 @@ path('//retry_script', TicketScriptRetry.as_view()), path('//comments', TicketComment.as_view()), path('//hook_call_back', TicketHookCallBack.as_view()), + path('//participant_info', TicketParticipantInfo.as_view()), path('/states', TicketsStates.as_view()), # 批量获取工单状态 ] diff --git a/apps/ticket/views.py b/apps/ticket/views.py index 42bf5b5f..9ea9b618 100644 --- a/apps/ticket/views.py +++ b/apps/ticket/views.py @@ -519,3 +519,25 @@ def post(self, request, *args, **kwargs): else: code, msg, data = -1, msg, '' return api_response(code, msg, data) + + +class TicketParticipantInfo(View): + def get(self, request, *args, **kwargs): + """ + 工单当前处理人详情,调用方后端可用获取处理人信息后提供催办等功能 + :param request: + :param args: + :param kwargs: + :return: + """ + ticket_id = kwargs.get('ticket_id') + flag, msg = TicketBaseService.get_ticket_participant_info(ticket_id) + if flag: + code, msg, data = 0, '', msg + else: + code, msg, data = -1, msg, {} + return api_response(code, msg, data) + + + + diff --git a/service/ticket/ticket_base_service.py b/service/ticket/ticket_base_service.py index 6bd16c4a..eaa8c17b 100644 --- a/service/ticket/ticket_base_service.py +++ b/service/ticket/ticket_base_service.py @@ -1901,3 +1901,31 @@ def hook_call_back(cls, ticket_id, app_name, request_data_dict): if not flag: return False, msg return True, '' + + @classmethod + @auto_log + def get_ticket_participant_info(cls, ticket_id): + """ + 获取工单当前详细参与人信息 + :param ticket_id: + :return: + """ + ticket_obj = TicketRecord.objects.filter(id=ticket_id, is_deleted=0).first() + from apps.account.models import LoonUser + participant_username_list, participant_info_list = [], [] + + if ticket_obj.participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_PERSONAL: + participant_username_list = [ticket_obj.participant] + elif ticket_obj.participant_type_id in ( + CONSTANT_SERVICE.PARTICIPANT_TYPE_MULTI, CONSTANT_SERVICE.PARTICIPANT_TYPE_MULTI_ALL): + participant_username_list = ticket_obj.participant.split(',') + elif ticket_obj.participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_ROLE: + participant_username_list, msg = AccountBaseService.get_role_username_list(ticket_obj.participant) + elif ticket_obj.participant_type_id == CONSTANT_SERVICE.PARTICIPANT_TYPE_DEPT: + participant_username_list, msg = AccountBaseService.get_dept_username_list(ticket_obj.participant) + if participant_username_list: + participant_queryset = LoonUser.objects.filter(username__in=participant_username_list, is_deleted=0) + for participant_0 in participant_queryset: + participant_info_list.append(dict(username=participant_0.username, alias=participant_0.alias, + phone=participant_0.phone, email=participant_0.email)) + return True, dict(participant_username_list=participant_username_list, participant_info_list=participant_info_list)