Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
inspect_report
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengjinlei
inspect_report
Commits
9e9c8fe7
Commit
9e9c8fe7
authored
Apr 23, 2020
by
lvshibao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
group页面修改
parent
2147ea60
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
20 deletions
+28
-20
agency.py
src/inspect_report/agency.py
+18
-0
tasksapi.py
src/inspect_report/api/tasksapi.py
+10
-20
No files found.
src/inspect_report/agency.py
0 → 100644
View file @
9e9c8fe7
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
src/inspect_report/api/tasksapi.py
View file @
9e9c8fe7
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment