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