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
988beb22
Commit
988beb22
authored
Apr 23, 2020
by
lvshibao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rules页面修改
parent
56cee779
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
119 deletions
+111
-119
agency.py
src/inspect_report/agency.py
+8
-0
dataapi.py
src/inspect_report/api/dataapi.py
+15
-26
tasksapi.py
src/inspect_report/api/tasksapi.py
+18
-32
group.html
src/inspect_report/templates/inspect/group.html
+2
-2
rule.html
src/inspect_report/templates/inspect/rule.html
+12
-4
rule.js
static/inspect/js/rule.js
+56
-55
No files found.
src/inspect_report/agency.py
View file @
988beb22
...
...
@@ -16,3 +16,11 @@ def get_team_names(city_id, country_id):
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
def
get_country_names
(
city_id
):
city
=
Country
.
objects
.
filter
(
id
=
city_id
)
.
first
()
if
city
.
parent
is
None
:
return
None
else
:
return
city
.
name
src/inspect_report/api/dataapi.py
View file @
988beb22
...
...
@@ -67,42 +67,31 @@ class DataApi(viewsets.ViewSet):
return
response
@
action
([
'get'
],
detail
=
False
)
@
before_request
def
static_rule_export
(
self
,
req
:
Request
):
"""
违规项统计-导出
:param req:
:return:
"""
task_id
=
req
.
GET
.
get
(
'task'
,
''
)
start_date
=
req
.
GET
.
get
(
'start_date'
,
(
datetime
.
now
()
+
timedelta
(
days
=-
1
))
.
strftime
(
'
%
Y-
%
m-
%
d'
))
end_date
=
req
.
GET
.
get
(
'end_date'
,
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
))
task_condition
=
{
'hasCheck'
:
1
,
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
+
' 23:59:59'
}
if
task_id
:
task_condition
[
'name__startswith'
]
=
task_id
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'sessionCollectionId'
)
task_dict
=
{}
for
t
in
tasks
:
if
t
[
'sessionCollectionId'
]
in
task_dict
.
keys
():
task_dict
[
t
[
'sessionCollectionId'
]]
.
append
(
t
[
'id'
])
else
:
task_dict
[
t
[
'sessionCollectionId'
]]
=
[
t
[
'id'
],
]
return_data
=
{}
call_count
=
0
for
k
,
v
in
task_dict
.
items
():
table_name
=
TABLE_PRE
+
k
tn
=
CheckSession
.
set_table
(
table_name
)
session_condition
=
{
'taskId__in'
:
v
,
'violationRuleCount__gt'
:
0
}
validate_all
=
tn
.
objects
.
filter
(
**
session_condition
)
.
aggregate
(
Count
(
"id"
))
call_count
+=
validate_all
[
'id__count'
]
city_id
=
req
.
data
.
get
(
'city'
,
None
)
country_id
=
req
.
data
.
get
(
'country'
,
None
)
task_condition
=
req
.
data
.
get
(
'date_condition'
,
{})
q_start_date
=
datetime
.
strptime
(
start_date
,
'
%
Y-
%
m-
%
d'
)
.
date
()
q_end_date
=
(
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d'
)
+
+
timedelta
(
days
=
1
))
.
date
()
task_condition
=
{
'create_date__gte'
:
q_start_date
,
'create_date__lt'
:
q_end_date
}
if
task_id
:
task_condition
[
'task'
]
=
task_id
team_names
=
get_team_names
(
city_id
,
country_id
)
task_condition
[
'task__in'
]
=
team_names
call_count
=
SeatStat
.
objects
.
filter
(
**
task_condition
)
.
aggregate
(
Sum
(
"validate_session"
))
task_condition
=
req
.
data
.
get
(
'date_condition'
,
{})
task_condition
[
'task__in'
]
=
team_names
# tasks = RulesStat.objects.filter(**task_condition).values('rule', 'sessionCollectionId', 'rule_num')
tasks
=
RulesStat
.
objects
.
all
()
.
filter
(
**
task_condition
)
\
.
extra
(
select
=
{
'rule'
:
"rule"
,
'sessionCollectionId'
:
'sessionCollectionId'
})
\
.
values
(
'rule'
,
'sessionCollectionId'
)
.
annotate
(
rule_num
=
Count
(
'id'
))
.
order_by
(
'-rule_num'
)
return_data
=
{}
for
t
in
tasks
:
name
=
t
[
'rule'
]
if
name
in
return_data
.
keys
():
...
...
src/inspect_report/api/tasksapi.py
View file @
988beb22
...
...
@@ -7,7 +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.agency
import
get_team_names
,
get_country_names
from
inspect_report.models
import
Tasks
,
CheckSession
,
RulesStat
,
SeatStat
,
ScoreStat
,
Round
,
Team
,
Country
import
json
from
datetime
import
datetime
,
timedelta
...
...
@@ -447,39 +447,25 @@ class TasksApi(viewsets.ViewSet):
:param req:
:return:
"""
username
=
req
.
data
.
get
(
'username'
,
''
)
task_id
=
req
.
data
.
get
(
'task'
,
''
)
task_condition
=
req
.
data
.
get
(
'at_condition'
,
{})
task_condition
[
'hasCheck'
]
=
1
if
task_id
:
task_condition
[
'name__startswith'
]
=
task_id
if
username
in
name_list
:
task_condition
[
'name__startswith'
]
=
username
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'sessionCollectionId'
)
task_dict
=
{}
for
t
in
tasks
:
if
t
[
'sessionCollectionId'
]
in
task_dict
.
keys
():
task_dict
[
t
[
'sessionCollectionId'
]]
.
append
(
t
[
'id'
])
else
:
task_dict
[
t
[
'sessionCollectionId'
]]
=
[
t
[
'id'
],
]
return_data
=
{}
call_count
=
0
for
k
,
v
in
task_dict
.
items
():
table_name
=
TABLE_PRE
+
k
tn
=
CheckSession
.
set_table
(
table_name
)
session_condition
=
{
'taskId__in'
:
v
,
'violationRuleCount__gt'
:
0
}
validate_all
=
tn
.
objects
.
filter
(
**
session_condition
)
.
aggregate
(
Count
(
"id"
))
call_count
+=
validate_all
[
'id__count'
]
city_id
=
req
.
data
.
get
(
'city'
,
None
)
country_id
=
req
.
data
.
get
(
'country'
,
None
)
task_condition
=
req
.
data
.
get
(
'date_condition'
,
{})
if
task_id
:
task_condition
[
'task'
]
=
task_id
elif
username
:
task_condition
[
'task'
]
=
username
team_names
=
get_team_names
(
city_id
,
country_id
)
task_condition
[
'task__in'
]
=
team_names
call_count
=
SeatStat
.
objects
.
filter
(
**
task_condition
)
.
aggregate
(
Sum
(
"validate_session"
))
task_condition
=
req
.
data
.
get
(
'date_condition'
,
{})
task_condition
[
'task__in'
]
=
team_names
# tasks = RulesStat.objects.filter(**task_condition).values('rule', 'sessionCollectionId', 'rule_num')
tasks
=
RulesStat
.
objects
.
all
()
.
filter
(
**
task_condition
)
\
.
extra
(
select
=
{
'rule'
:
"rule"
,
'sessionCollectionId'
:
'sessionCollectionId'
})
\
.
values
(
'rule'
,
'sessionCollectionId'
)
.
annotate
(
rule_num
=
Count
(
'id'
))
.
order_by
(
'-rule_num'
)
return_data
=
{}
for
t
in
tasks
:
name
=
t
[
'rule'
]
if
name
in
return_data
.
keys
():
...
...
@@ -496,7 +482,7 @@ class TasksApi(viewsets.ViewSet):
v
[
'call_count'
]
=
call_count
data_sort
.
append
(
v
)
# data_sort = sorted(data_sort, key=lambda x: x['count'], reverse=True)
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'data'
:
data_sort
,
'username'
:
username
})
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'data'
:
data_sort
})
@
action
([
'post'
],
detail
=
False
)
@
before_request
...
...
@@ -506,7 +492,8 @@ class TasksApi(viewsets.ViewSet):
:param req:
:return:
"""
username
=
req
.
data
.
get
(
'username'
,
''
)
city_id
=
req
.
data
.
get
(
'city'
,
None
)
country_id
=
req
.
data
.
get
(
'country'
,
None
)
tables
=
req
.
data
.
get
(
'tables'
,
''
)
rule_name
=
req
.
data
.
get
(
'rule'
,
''
)
page
=
req
.
data
.
get
(
'page'
,
'1'
)
...
...
@@ -518,8 +505,7 @@ class TasksApi(viewsets.ViewSet):
session_condition
=
req
.
data
.
get
(
'date_condition'
,
{})
session_condition
[
'rule'
]
=
rule_name
session_condition
[
'sessionCollectionId__in'
]
=
table_list
if
username
in
name_list
:
session_condition
[
'agentName__contains'
]
=
name_code_dict
[
username
]
session_condition
[
'task__in'
]
=
get_team_names
(
city_id
,
country_id
)
checks
=
RulesStat
.
objects
.
filter
(
**
session_condition
)
.
values
(
'agentName'
,
'customName'
,
'remainTime'
,
'score'
,
'sessionCollectionId'
,
'sessionId'
,
'taskId'
)
paginator
=
Paginator
(
checks
,
page_size
)
...
...
src/inspect_report/templates/inspect/group.html
View file @
988beb22
...
...
@@ -87,7 +87,7 @@
end-placeholder=
"结束日期"
:default-time=
"['00:00:00', '23:59:59']"
>
</el-date-picker>
<el-select
v-model=
"cityvalue"
filterable
placeholder=
"请选择"
@
change=
"changeCity"
>
<el-select
v-model=
"cityvalue"
filterable
placeholder=
"请选择
市
"
@
change=
"changeCity"
>
<el-option
v-for=
"item in cityList"
:key=
"item.id"
...
...
@@ -95,7 +95,7 @@
:value=
"item.id"
>
</el-option>
</el-select>
<el-select
v-model=
"countryvalue"
filterable
placeholder=
"请选择"
@
change=
"changeCountry"
>
<el-select
v-model=
"countryvalue"
filterable
placeholder=
"请选择
县
"
@
change=
"changeCountry"
>
<el-option
v-for=
"item in countryList"
:key=
"item.id"
...
...
src/inspect_report/templates/inspect/rule.html
View file @
988beb22
...
...
@@ -87,9 +87,17 @@
end-placeholder=
"结束日期"
:default-time=
"['00:00:00', '23:59:59']"
>
</el-date-picker>
<el-select
v-
if=
"sel_is_show == true"
v-model=
"taskvalue"
filterable
placeholder=
"请选择"
@
change=
"changeTask
"
>
<el-select
v-
model=
"cityvalue"
filterable
placeholder=
"请选择市"
@
change=
"changeCity
"
>
<el-option
v-for=
"item in taskList"
v-for=
"item in cityList"
:key=
"item.id"
:label=
"item.name"
:value=
"item.id"
>
</el-option>
</el-select>
<el-select
v-model=
"countryvalue"
filterable
placeholder=
"请选择县"
@
change=
"changeCountry"
>
<el-option
v-for=
"item in countryList"
:key=
"item.id"
:label=
"item.name"
:value=
"item.id"
>
...
...
@@ -101,7 +109,8 @@
<form
ref=
"loadModal"
:action=
"`${BASEURL}api/v1/data/static_rule_export/`"
method=
"get"
>
<input
type=
"hidden"
name=
"start_date"
:value=
"start_date"
>
<input
type=
"hidden"
name=
"end_date"
:value=
"end_date"
>
<input
type=
"hidden"
name=
"task"
:value=
"taskvalue"
>
<input
type=
"hidden"
name=
"city"
:value=
"cityvalue"
>
<input
type=
"hidden"
name=
"country"
:value=
"countryvalue"
>
</form>
</div>
<div
id=
'main'
style=
'width:100%;padding-bottom:20px'
>
...
...
@@ -193,7 +202,6 @@
<script
src=
"{% static "
inspect
/
js
/
vue
.
min
.
js
"
%}"
></script>
<script
src=
"{% static "
inspect
/
js
/
element
.
js
"
%}"
></script>
<script
src=
"{% static "
inspect
/
js
/
http
.
js
"
%}"
></script>
<script
type=
"text/javascript"
src=
"{% static "
inspect
/
js
/
config
.
js
"
%}"
></script>
<script
type=
"text/javascript"
src=
"{% static "
inspect
/
js
/
rule
.
js
"
%}"
></script>
</body>
</html>
static/inspect/js/rule.js
View file @
988beb22
...
...
@@ -4,8 +4,10 @@ new Vue({
return
{
ss
:
'
sas
'
,
dateTime
:
''
,
taskList
:[],
taskvalue
:
''
,
cityList
:[],
countryList
:[],
cityvalue
:
null
,
countryvalue
:
null
,
start_date
:
''
,
isscrollTop
:
false
,
currentPage
:
1
,
...
...
@@ -25,13 +27,11 @@ new Vue({
dialogTableVisible
:
false
,
takeList
:[],
dateRange
:[
new
Date
(),
new
Date
()],
takevalue
:
''
,
titleInfo
:
{
"
total_session
"
:
0
,
"
validate_session
"
:
0
,
"
ratio
"
:
0
,
},
sel_is_show
:
true
,
loading
:
true
,
poptableData
:
[],
tableData
:
[]
...
...
@@ -51,42 +51,55 @@ new Vue({
changeRange
(
dateRange
){
this
.
start_date
=
dateRange
[
0
];
this
.
end_date
=
dateRange
[
1
];
this
.
getRule
(
this
.
task
value
,
this
.
start_date
,
this
.
end_date
,
this
.
takevalue
);
// 获取统计数据
this
.
getRule
(
this
.
cityvalue
,
this
.
country
value
,
this
.
start_date
,
this
.
end_date
,
this
.
takevalue
);
// 获取统计数据
},
change
Task
(
msg
){
change
City
(
msg
){
console
.
log
(
msg
);
this
.
taskvalue
=
msg
;
this
.
getTake
()
this
.
getRule
(
this
.
taskvalue
,
this
.
start_date
,
this
.
end_date
,
this
.
takevalue
);
// 获取统计数据
this
.
cityvalue
=
msg
;
this
.
countryvalue
=
null
;
this
.
getCountry
(
this
.
cityvalue
);
this
.
getRule
(
this
.
cityvalue
,
this
.
countryvalue
,
this
.
start_date
,
this
.
end_date
,
this
.
takevalue
);
// 获取统计数据
},
changeTake
(
msg
){
this
.
takevalue
=
msg
;
this
.
getRule
(
this
.
taskvalue
,
this
.
start_date
,
this
.
end_date
,
this
.
takevalue
);
// 获取统计数据
changeCountry
(
msg
){
console
.
log
(
msg
);
this
.
countryvalue
=
msg
;
this
.
getRule
(
this
.
cityvalue
,
this
.
countryvalue
,
this
.
start_date
,
this
.
end_date
,
this
.
takevalue
);
// 获取统计数据
},
getTask
()
{
getCountry
()
{
let
that
=
this
;
that
.
taskList
=
[
{
id
:
''
,
name
:
'
全省
'
},
{
id
:
'
合肥
'
,
name
:
'
合肥
'
},
{
id
:
'
芜湖
'
,
name
:
'
芜湖
'
},
{
id
:
'
蚌埠
'
,
name
:
'
蚌埠
'
},
{
id
:
'
淮南
'
,
name
:
'
淮南
'
},
{
id
:
'
马鞍山
'
,
name
:
'
马鞍山
'
},
{
id
:
'
淮北
'
,
name
:
'
淮北
'
},
{
id
:
'
铜陵
'
,
name
:
'
铜陵
'
},
{
id
:
'
安庆
'
,
name
:
'
安庆
'
},
{
id
:
'
黄山
'
,
name
:
'
黄山
'
},
{
id
:
'
滁州
'
,
name
:
'
滁州
'
},
{
id
:
'
阜阳
'
,
name
:
'
阜阳
'
},
{
id
:
'
毫州
'
,
name
:
'
毫州
'
},
{
id
:
'
宿州
'
,
name
:
'
宿州
'
},
{
id
:
'
六安
'
,
name
:
'
六安
'
},
{
id
:
'
宣城
'
,
name
:
'
宣城
'
},
{
id
:
'
巢湖
'
,
name
:
'
巢湖
'
},
{
id
:
'
池州
'
,
name
:
'
池州
'
},
{
id
:
'
安徽省营业部
'
,
name
:
'
安徽省营业部
'
},
];
RquestsGet
(
'
api/v1/agency/country/?city_id=
'
+
this
.
cityvalue
).
then
(
data
=>
{
//console.log(data);
if
(
data
.
code
!=
0
)
{
that
.
$message
(
'
服务器错误
'
)
}
else
{
that
.
countryList
=
data
.
data
.
country_list
;
}
})
},
getCity
(){
let
that
=
this
;
var
request
=
new
XMLHttpRequest
();
let
uri
=
window_url
+
'
api/v1/agency/city/
'
;
request
.
open
(
'
GET
'
,
uri
,
false
);
request
.
send
(
null
);
if
(
request
.
status
===
200
)
{
data
=
JSON
.
parse
(
request
.
response
);
console
.
log
(
data
.
code
);
if
(
data
.
code
!=
0
){
that
.
$message
(
'
服务器错误
'
);
}
else
{
that
.
cityList
=
data
.
data
.
city_list
;
that
.
countryList
=
data
.
data
.
country_list
;
that
.
cityvalue
=
data
.
data
.
city_id
;
console
.
log
(
that
.
cityvalue
);
that
.
init_simple
=
true
;
}
}
else
{
that
.
$message
(
'
服务器错误
'
);
}
//RquestsGet('api/v1/tasks/obtain/').then(data => {
// //console.log(data);
// if(data.code != 0){
...
...
@@ -97,32 +110,20 @@ new Vue({
// }
//})
},
getTake
(){
let
that
=
this
;
RquestsGet
(
'
api/v1/tasks/seat/?task=
'
+
that
.
taskvalue
).
then
(
data
=>
{
//console.log(data);
if
(
data
.
code
!=
0
){
//that.takeList = [{agentName:'全部坐席'}]
}
else
{
that
.
takeList
=
data
.
data
;
}
})
},
CurrentChange
(
page
){
this
.
currentPage
=
page
;
},
popCurrentChange
(
page
){
this
.
poppage
=
page
;
this
.
getDetail
(
this
.
taskvalue
,
this
.
start_dat
e
,
this
.
end_date
,
this
.
poptables
,
this
.
poprule
,
this
.
poppage
,
this
.
poppagesize
);
this
.
getDetail
(
this
.
cityvalue
,
this
.
countryvalu
e
,
this
.
end_date
,
this
.
poptables
,
this
.
poprule
,
this
.
poppage
,
this
.
poppagesize
);
},
getRule
(
task
,
start_date
,
end_date
,
agentName
){
getRule
(
city
,
country
,
start_date
,
end_date
,
agentName
){
let
that
=
this
;
console
.
log
(
start_date
,
end_date
);
let
arr
=
[];
this
.
$loading
({
text
:
'
数据加载中...
'
});
RquestsPost
(
'
api/v1/tasks/static_rule/
'
,{
task
,
end_date
,
start_date
,
agentName
}).
then
(
data
=>
{
RquestsPost
(
'
api/v1/tasks/static_rule/
'
,{
city
,
country
,
end_date
,
start_date
,
agentName
}).
then
(
data
=>
{
console
.
log
(
data
.
data
);
if
(
data
.
code
!=
0
){
that
.
$message
(
data
.
msg
);
...
...
@@ -145,7 +146,7 @@ new Vue({
this
.
isHidePage
=
!
(
data
.
data
.
length
>
0
);
this
.
$loading
().
close
();
})
RquestsPost
(
'
api/v1/tasks/static/
'
,{
task
,
end_date
,
start_date
,
agentName
}).
then
(
data
=>
{
RquestsPost
(
'
api/v1/tasks/static/
'
,{
city
,
country
,
end_date
,
start_date
,
agentName
}).
then
(
data
=>
{
console
.
log
(
data
.
data
);
if
(
data
.
code
!=
0
){
that
.
$message
(
data
.
msg
);
...
...
@@ -183,15 +184,15 @@ new Vue({
this
.
popcurrentPage
=
1
;
this
.
poppage
=
1
;
//this.taskvalue = tableData.area;
this
.
getDetail
(
this
.
task
value
,
this
.
start_date
,
this
.
end_date
,
this
.
poptables
,
this
.
poprule
,
this
.
poppage
,
this
.
poppagesize
);
this
.
getDetail
(
this
.
cityvalue
,
this
.
country
value
,
this
.
start_date
,
this
.
end_date
,
this
.
poptables
,
this
.
poprule
,
this
.
poppage
,
this
.
poppagesize
);
},
getDetail
(
task
,
start_date
,
end_date
,
tables
,
rule
,
page
,
page_size
){
getDetail
(
city
,
country
,
start_date
,
end_date
,
tables
,
rule
,
page
,
page_size
){
//this.getRule(this.taskvalue,this.start_date,this.end_date,this.takevalue); // 获取统计数据
let
that
=
this
;
this
.
$loading
({
text
:
'
数据加载中...
'
});
this
.
poploading
=
true
;
RquestsPost
(
'
api/v1/tasks/rule_detail/
'
,{
task
,
end_date
,
start_date
,
tables
,
rule
,
page
,
page_size
}).
then
(
data
=>
{
RquestsPost
(
'
api/v1/tasks/rule_detail/
'
,{
city
,
country
,
end_date
,
start_date
,
tables
,
rule
,
page
,
page_size
}).
then
(
data
=>
{
console
.
log
(
data
.
data
);
this
.
$loading
().
close
();
this
.
dialogTableVisible
=
true
;
...
...
@@ -244,10 +245,10 @@ new Vue({
this
.
dateRange
=
[
new
Date
(
new
Date
()
-
24
*
60
*
60
*
1000
),
new
Date
()];
this
.
start_date
=
this
.
dateFormat
(
new
Date
(
new
Date
()
-
24
*
60
*
60
*
1000
));
this
.
end_date
=
this
.
dateFormat
(
new
Date
());
this
.
get
Task
();
// 获取任务
this
.
get
City
();
// 获取任务
//this.getTake(); // 获取坐席
this
.
getRule
(
this
.
task
value
,
this
.
start_date
,
this
.
end_date
,
this
.
takevalue
);
// 获取统计数据
this
.
getRule
(
this
.
cityvalue
,
this
.
country
value
,
this
.
start_date
,
this
.
end_date
,
this
.
takevalue
);
// 获取统计数据
}
},
...
...
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