Commit 9e9c8fe7 authored by lvshibao's avatar lvshibao

group页面修改

parent 2147ea60
from django.db.models import Q
from inspect_report.models import Team, Country
def get_team_names(city_id, country_id):
# # 获取坐席团队关系
team_names = list()
if city_id and country_id:
team_names = Team.objects.filter(country_id=country_id).values_list('name')
elif city_id and country_id == '':
city = Country.objects.filter(id=city_id).first()
if city.parent is None:
team_names = Team.objects.filter().values_list('name')
else:
country_id_list = Country.objects.filter(Q(parent=city_id) | Q(id=city_id)).values_list('id')
team_names = Team.objects.filter(country_id__in=country_id_list).values_list('name')
return team_names
......@@ -7,6 +7,7 @@ from rest_framework.request import Request
from rest_framework.response import Response
from before_request import before_request
from inspect_report.agency import get_team_names
from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, ScoreStat, Round, Team, Country
import json
from datetime import datetime, timedelta
......@@ -243,14 +244,13 @@ class TasksApi(viewsets.ViewSet):
:param req:
:return:
"""
username = req.data.get('username', '')
# logger.info('username获取: ' + username)
task_id = req.data.get('task', '')
city_id = req.data.get('city', None)
country_id = req.data.get('country', None)
session_condition = req.data.get('date_condition', {})
if task_id:
session_condition['task'] = task_id
if username in name_list:
session_condition['task'] = username
team_names = get_team_names(city_id, country_id)
session_condition['task_in'] = team_names
seat_data = SeatStat.objects.filter(**session_condition).aggregate(
validate_session_sum=Sum('validate_session'), total_session_sum=Sum('total_session'))
avg_score = ScoreStat.objects.filter(**session_condition).aggregate(score_avg=Round(Avg('score'), 2))
......@@ -540,24 +540,14 @@ class TasksApi(viewsets.ViewSet):
:param req:
:return:
"""
city_id = req.data.get('city', '')
country_id = req.data.get('country', '')
city_id = req.data.get('city', None)
country_id = req.data.get('country', None)
page = req.data.get('page', '1')
page_size = req.data.get('page_size', '10')
sort = req.data.get('sort', '-avg_score')
task_condition = req.data.get('date_condition', {})
# # 获取坐席团队关系
team_names = list()
if city_id and country_id:
team_names = Team.objects.filter(country_id=country_id).values_list('name')
elif city_id and country_id == '':
city = Country.objects.filter(id=city_id).first()
if city.parent is None:
team_names = Team.objects.filter().values_list('name')
else:
country_id_list = Country.objects.filter(Q(parent=city_id) | Q(id=city_id)).values_list('id')
team_names = Team.objects.filter(country_id__in=country_id_list).values_list('name')
team_names = get_team_names(city_id, country_id)
task_condition['task__in'] = team_names
......
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