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
9ada3a7c
Commit
9ada3a7c
authored
Apr 27, 2020
by
lvshibao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
group中的table添加市,县
parent
15bda856
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
9 deletions
+54
-9
dataapi.py
src/inspect_report/api/dataapi.py
+10
-6
tasksapi.py
src/inspect_report/api/tasksapi.py
+5
-2
dbhelper.py
src/inspect_report/dbhelper.py
+29
-1
group.html
src/inspect_report/templates/inspect/group.html
+10
-0
No files found.
src/inspect_report/api/dataapi.py
View file @
9ada3a7c
...
@@ -4,7 +4,8 @@ from rest_framework.decorators import action
...
@@ -4,7 +4,8 @@ from rest_framework.decorators import action
from
rest_framework.request
import
Request
from
rest_framework.request
import
Request
from
before_request
import
before_request
from
before_request
import
before_request
from
inspect_report.dbhelper
import
db_static_score
,
db_seat_rule
,
db_seat_check
,
db_seat_area
,
db_static_rule
from
inspect_report.dbhelper
import
db_static_score
,
db_seat_rule
,
db_seat_check
,
db_seat_area
,
db_static_rule
,
\
set_city_country_by_team_name
from
datetime
import
datetime
from
datetime
import
datetime
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
import
logging
import
logging
...
@@ -30,7 +31,10 @@ class DataApi(viewsets.ViewSet):
...
@@ -30,7 +31,10 @@ class DataApi(viewsets.ViewSet):
:return:
:return:
"""
"""
rules
=
db_static_score
(
req
)
scores
=
db_static_score
(
req
)
scores
=
set_city_country_by_team_name
(
scores
,
'area'
)
response
=
HttpResponse
(
content_type
=
'text/csv'
)
response
=
HttpResponse
(
content_type
=
'text/csv'
)
file_name
=
'组长概览_'
+
datetime
.
now
()
.
strftime
(
'
%
Y
%
m
%
d
%
H
%
M
%
S'
)
+
'.csv'
file_name
=
'组长概览_'
+
datetime
.
now
()
.
strftime
(
'
%
Y
%
m
%
d
%
H
%
M
%
S'
)
+
'.csv'
response
[
'Content-Type'
]
=
'application/octet-stream'
response
[
'Content-Type'
]
=
'application/octet-stream'
...
@@ -39,11 +43,11 @@ class DataApi(viewsets.ViewSet):
...
@@ -39,11 +43,11 @@ class DataApi(viewsets.ViewSet):
response
.
write
(
codecs
.
BOM_UTF8
)
response
.
write
(
codecs
.
BOM_UTF8
)
writer
=
csv
.
writer
(
response
)
writer
=
csv
.
writer
(
response
)
# 设置表头
# 设置表头
header
=
[
'地市'
,
'全部会话数'
,
'触发违规项次数'
,
'服务类平均分'
,
'业务类平均分'
,
'总平均分(包含0分项)'
,
'触发0分项次数'
]
header
=
[
'地市'
,
'
县'
,
'团队'
,
'
全部会话数'
,
'触发违规项次数'
,
'服务类平均分'
,
'业务类平均分'
,
'总平均分(包含0分项)'
,
'触发0分项次数'
]
writer
.
writerow
(
header
)
writer
.
writerow
(
header
)
# 设置表数据
# 设置表数据
for
r
in
rul
es
:
for
r
in
scor
es
:
row
=
[
r
[
'area'
],
r
[
'total_session'
],
r
[
'validate_num'
],
r
[
'avg_score_svc'
],
r
[
'avg_score_bus'
],
row
=
[
r
[
'
city'
],
r
[
'country'
],
r
[
'
area'
],
r
[
'total_session'
],
r
[
'validate_num'
],
r
[
'avg_score_svc'
],
r
[
'avg_score_bus'
],
r
[
'avg_score'
],
r
[
'validate_zero'
]]
r
[
'avg_score'
],
r
[
'validate_zero'
]]
writer
.
writerow
(
row
)
writer
.
writerow
(
row
)
return
response
return
response
...
@@ -120,7 +124,7 @@ class DataApi(viewsets.ViewSet):
...
@@ -120,7 +124,7 @@ class DataApi(viewsets.ViewSet):
response
.
write
(
codecs
.
BOM_UTF8
)
response
.
write
(
codecs
.
BOM_UTF8
)
writer
=
csv
.
writer
(
response
)
writer
=
csv
.
writer
(
response
)
# 设置表头
# 设置表头
header
=
[
'
地市
'
,
'坐席工号'
,
'坐席名称'
,
'全部会话数'
,
'触发违规项次数'
,
'服务类平均分'
,
'业务类平均分'
,
'平均分'
,
'触发0分项次数'
]
header
=
[
'
团队
'
,
'坐席工号'
,
'坐席名称'
,
'全部会话数'
,
'触发违规项次数'
,
'服务类平均分'
,
'业务类平均分'
,
'平均分'
,
'触发0分项次数'
]
writer
.
writerow
(
header
)
writer
.
writerow
(
header
)
# 设置表数据
# 设置表数据
for
r
in
scores
:
for
r
in
scores
:
...
...
src/inspect_report/api/tasksapi.py
View file @
9ada3a7c
...
@@ -8,7 +8,8 @@ from rest_framework.response import Response
...
@@ -8,7 +8,8 @@ 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.agency
import
get_team_names
from
inspect_report.dbhelper
import
db_static_score
,
db_seat_rule
,
db_seat_check
,
db_seat_area
,
db_static_rule
from
inspect_report.dbhelper
import
db_static_score
,
db_seat_rule
,
db_seat_check
,
db_seat_area
,
db_static_rule
,
\
set_city_country_by_team_name
from
inspect_report.models
import
RulesStat
,
SeatStat
,
ScoreStat
,
Round
,
Seat
from
inspect_report.models
import
RulesStat
,
SeatStat
,
ScoreStat
,
Round
,
Seat
import
json
import
json
from
django.views.decorators.clickjacking
import
xframe_options_exempt
from
django.views.decorators.clickjacking
import
xframe_options_exempt
...
@@ -350,8 +351,10 @@ class TasksApi(viewsets.ViewSet):
...
@@ -350,8 +351,10 @@ class TasksApi(viewsets.ViewSet):
total_count
,
scores
=
page_with_seat_name
(
all_scores
,
page
,
page_size
)
total_count
,
scores
=
page_with_seat_name
(
all_scores
,
page
,
page_size
)
scores
=
set_city_country_by_team_name
(
scores
.
object_list
,
'area'
)
return
Response
(
return
Response
(
{
'code'
:
0
,
'msg'
:
'success'
,
'count'
:
total_count
,
'data'
:
scores
.
object_list
})
{
'code'
:
0
,
'msg'
:
'success'
,
'count'
:
total_count
,
'data'
:
scores
})
@
action
([
'post'
],
detail
=
False
)
@
action
([
'post'
],
detail
=
False
)
@
before_request
@
before_request
...
...
src/inspect_report/dbhelper.py
View file @
9ada3a7c
...
@@ -6,10 +6,38 @@ from pypinyin import pinyin, Style
...
@@ -6,10 +6,38 @@ from pypinyin import pinyin, Style
from
config.config
import
TABLE_PRE
from
config.config
import
TABLE_PRE
from
inspect_report.agency
import
get_team_names
,
get_agent_name
from
inspect_report.agency
import
get_team_names
,
get_agent_name
from
inspect_report.cron
import
get_remain
from
inspect_report.cron
import
get_remain
from
inspect_report.models
import
ScoreStat
,
Round
,
SeatStat
,
Seat
,
Country
,
Tasks
,
CheckSession
,
RulesStat
from
inspect_report.models
import
ScoreStat
,
Round
,
SeatStat
,
Seat
,
Country
,
Tasks
,
CheckSession
,
RulesStat
,
Team
from
inspect_report.pagehelper
import
page_with_seat_name
from
inspect_report.pagehelper
import
page_with_seat_name
def
set_city_country_by_team_name
(
objects
,
key
):
team_country_dict
=
get_city_country_team
()
for
object_dict
in
objects
:
object_dict
[
'city'
]
=
team_country_dict
[
object_dict
[
key
]][
'city'
]
object_dict
[
'country'
]
=
team_country_dict
[
object_dict
[
key
]][
'country'
]
return
objects
def
get_city_country_team
():
teams
=
Team
.
objects
.
values
(
'name'
,
'country_id'
)
countries
=
Country
.
objects
.
values
(
'id'
,
'name'
,
'parent'
)
countries_dict
=
dict
()
for
country
in
countries
:
countries_dict
[
country
[
'id'
]]
=
{
'name'
:
country
[
'name'
],
'parent'
:
country
[
'parent'
]}
teams_dict
=
dict
()
for
team
in
teams
:
teams_dict
[
team
[
'name'
]]
=
dict
()
country_dict
=
countries_dict
[
team
[
'country_id'
]]
if
country_dict
[
'parent'
]
is
not
None
and
int
(
country_dict
[
'parent'
])
!=
153
:
teams_dict
[
team
[
'name'
]][
'country'
]
=
country_dict
[
'name'
]
teams_dict
[
team
[
'name'
]][
'city'
]
=
countries_dict
[
country_dict
[
'parent'
]][
'name'
]
else
:
teams_dict
[
team
[
'name'
]][
'country'
]
=
''
teams_dict
[
team
[
'name'
]][
'city'
]
=
country_dict
[
'name'
]
return
teams_dict
def
db_static_score
(
req
):
def
db_static_score
(
req
):
city_id
=
req
.
data
.
get
(
'city'
,
None
)
city_id
=
req
.
data
.
get
(
'city'
,
None
)
country_id
=
req
.
data
.
get
(
'country'
,
None
)
country_id
=
req
.
data
.
get
(
'country'
,
None
)
...
...
src/inspect_report/templates/inspect/group.html
View file @
9ada3a7c
...
@@ -199,6 +199,16 @@
...
@@ -199,6 +199,16 @@
border
border
@
sort-change=
'sortChange'
@
sort-change=
'sortChange'
style=
"width: 100%;margin-bottom:20px;"
>
style=
"width: 100%;margin-bottom:20px;"
>
<el-table-column
prop=
"city"
label=
"市"
>
</el-table-column>
<el-table-column
prop=
"country"
label=
"县"
>
</el-table-column>
<el-table-column
<el-table-column
prop=
"area"
prop=
"area"
label=
"团队"
label=
"团队"
...
...
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