Commit 863a5fd1 authored by zhengjinlei's avatar zhengjinlei

获取坐席列表

parent 2b6cdac5
# coding: utf-8
from django.shortcuts import render
from django.db.models import Count
from rest_framework import viewsets
from rest_framework.decorators import action
from rest_framework.request import Request
......@@ -11,6 +12,8 @@ from config.config import TABLE_PRE
from django.views.decorators.clickjacking import xframe_options_exempt
from inspect_report import permissions
import logging
from functools import reduce
logger = logging.getLogger(__name__)
......@@ -40,18 +43,24 @@ class TasksApi(viewsets.ViewSet):
"""
task_id = req.GET.get('task', '')
task_condition = {}
session_condition = {}
if task_id:
task_condition['pk'] = task_id
tasks = Tasks.objects.filter(**task_condition)
session_condition['taskId'] = task_id
tasks = Tasks.objects.filter(**task_condition).values('sessionCollectionId').annotate(Count=Count('sessionCollectionId'))
return_data = []
for t in tasks:
session_collection = t.sessionCollectionId
session_collection = t['sessionCollectionId']
table_name = TABLE_PRE + session_collection
tn = CheckSession.set_table(table_name)
agents = tn.objects.filter(taskId=t.id).values('agentName')
for agent in agents:
if agent not in return_data:
return_data.append(agent)
agents = tn.objects.filter(**session_condition).values('agentName').annotate(Count=Count('agentName')).values('agentName')
return_data.append(agents)
# for agent in agents:
# if agent not in return_data:
# return_data.append(agent)
data_reduce = lambda x, y: x if y in x else x + [y]
return_data = reduce(data_reduce, [[], ] + return_data)
return Response({'code': 0, 'msg': 'success', 'data': return_data})
@action(['post'], detail=False)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment