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
8519e533
Commit
8519e533
authored
Dec 11, 2019
by
zhengjinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
列表展示
parent
57f36d03
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
135 additions
and
18 deletions
+135
-18
tasksapi.py
src/inspect_report/api/tasksapi.py
+79
-8
rule.html
src/inspect_report/templates/inspect/rule.html
+14
-5
all.js
static/inspect/js/all.js
+42
-5
No files found.
src/inspect_report/api/tasksapi.py
View file @
8519e533
...
...
@@ -75,6 +75,70 @@ class TasksApi(viewsets.ViewSet):
@
action
([
'post'
],
detail
=
False
)
def
rule
(
self
,
req
:
Request
):
"""
获取违规项分析
:param req:
:return:
"""
task_id
=
req
.
data
.
get
(
'task'
,
''
)
agent_name
=
req
.
data
.
get
(
'agentName'
,
''
)
start_date
=
req
.
data
.
get
(
'start_date'
,
(
datetime
.
now
()
+
timedelta
(
days
=-
1
))
.
strftime
(
'
%
Y-
%
m-
%
d'
))
end_date
=
req
.
data
.
get
(
'end_date'
,
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
))
data_sort
=
[]
return_data
=
{}
if
agent_name
:
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'
],
]
for
k
,
v
in
task_dict
.
items
():
table_name
=
TABLE_PRE
+
k
tn
=
CheckSession
.
set_table
(
table_name
)
session_condition
=
{
'taskId__in'
:
v
,
'agentName'
:
agent_name
}
checks
=
tn
.
objects
.
filter
(
**
session_condition
)
.
values
(
'id'
,
'checkResult'
)
for
check
in
checks
:
result
=
check
[
'checkResult'
]
if
result
:
data
=
json
.
loads
(
result
)
for
d
in
data
:
if
'isViolation'
in
d
.
keys
()
and
d
[
'isViolation'
]
and
'rule'
in
d
.
keys
()
and
'name'
in
d
[
'rule'
]
.
keys
():
name
=
d
[
'rule'
][
'name'
]
if
name
in
return_data
.
keys
():
return_data
[
name
][
'count'
]
+=
1
else
:
return_data
[
name
]
=
{
'count'
:
1
,
'tables'
:
[]}
if
k
not
in
return_data
[
name
][
'tables'
]:
return_data
[
name
][
'tables'
]
.
append
(
k
)
else
:
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
[
'area'
]
=
task_id
tasks
=
RulesStat
.
objects
.
filter
(
**
task_condition
)
.
values
(
'rule_name'
,
'from_table'
,
'rule_num'
)
for
t
in
tasks
:
name
=
t
[
'rule_name'
]
if
name
in
return_data
.
keys
():
return_data
[
name
][
'count'
]
+=
int
(
t
[
'rule_num'
])
else
:
return_data
[
name
]
=
{
'count'
:
int
(
t
[
'rule_num'
]),
'tables'
:
[]}
if
t
[
'from_table'
]
not
in
return_data
[
name
][
'tables'
]:
return_data
[
name
][
'tables'
]
.
append
(
t
[
'from_table'
])
for
k
,
v
in
return_data
.
items
():
v
[
'rule'
]
=
k
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
})
@
action
([
'post'
],
detail
=
False
)
def
rule_bak
(
self
,
req
:
Request
):
"""
获取违规项分析
:param req:
...
...
@@ -524,14 +588,14 @@ class TasksApi(viewsets.ViewSet):
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
[
'
rule_name
'
]
=
task_id
task_condition
[
'
area
'
]
=
task_id
tasks
=
RulesStat
.
objects
.
filter
(
**
task_condition
)
.
values
(
'rule_name'
,
'from_table'
,
'rule_num'
)
for
t
in
tasks
:
name
=
t
[
'rule_name'
]
if
name
in
return_data
.
keys
():
return_data
[
name
][
'count'
]
+=
int
(
t
[
'rule_num'
])
else
:
return_data
[
name
]
=
{
'count'
:
1
,
'tables'
:
[]}
return_data
[
name
]
=
{
'count'
:
int
(
t
[
'rule_num'
])
,
'tables'
:
[]}
if
t
[
'from_table'
]
not
in
return_data
[
name
][
'tables'
]:
return_data
[
name
][
'tables'
]
.
append
(
t
[
'from_table'
])
data_sort
=
[]
...
...
@@ -622,8 +686,8 @@ class TasksApi(viewsets.ViewSet):
tn
=
CheckSession
.
set_table
(
table_name
)
session_condition
=
{
'checkResult__contains'
:
rule_name
,
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
+
' 23:59:59'
}
checks
=
tn
.
objects
.
filter
(
**
session_condition
)
.
values
(
'id'
,
'agentName'
,
'customName'
,
'createdAt__lt'
:
end_date
+
' 23:59:59'
,
'violationRuleCount__gt'
:
0
}
checks
=
tn
.
objects
.
filter
(
**
session_condition
)
.
values
(
'id'
,
'agentName'
,
'customName'
,
'checkResult'
,
'remainTime'
,
'score'
,
'sessionId'
,
'taskId'
)
paginator
=
Paginator
(
checks
,
page_size
)
total_count
+=
paginator
.
count
...
...
@@ -635,10 +699,17 @@ class TasksApi(viewsets.ViewSet):
seats
=
paginator
.
page
(
paginator
.
num_pages
)
for
check
in
seats
:
detail
=
{
'agentName'
:
check
[
'agentName'
],
'customName'
:
check
[
'customName'
],
'remainTime'
:
check
[
'remainTime'
],
'score'
:
check
[
'score'
],
'sessionId'
:
check
[
'sessionId'
],
'sessionCollectionId'
:
k
,
'taskId'
:
check
[
'taskId'
]}
return_data
.
append
(
detail
)
result
=
check
[
'checkResult'
]
if
result
:
data
=
json
.
loads
(
result
)
for
d
in
data
:
if
'isViolation'
in
d
.
keys
()
and
d
[
'isViolation'
]
and
'rule'
in
d
.
keys
()
\
and
'name'
in
d
[
'rule'
]
.
keys
()
and
d
[
'rule'
][
'name'
]
==
rule_name
:
detail
=
{
'agentName'
:
check
[
'agentName'
],
'customName'
:
check
[
'customName'
],
'remainTime'
:
check
[
'remainTime'
],
'score'
:
check
[
'score'
],
'sessionId'
:
check
[
'sessionId'
],
'sessionCollectionId'
:
k
,
'taskId'
:
check
[
'taskId'
]}
return_data
.
append
(
detail
)
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'count'
:
total_count
,
'data'
:
return_data
})
...
...
src/inspect_report/templates/inspect/rule.html
View file @
8519e533
...
...
@@ -50,14 +50,14 @@
</el-select>
</div>
<div
id=
'main'
style=
'width:80%;height:600px'
v-loading=
'true'
></div>
<el-dialog
title=
"详情"
:visible.sync=
"dialogTableVisible"
>
<el-dialog
title=
"详情"
v-loading=
'poploading'
width=
'700px'
:visible.sync=
"dialogTableVisible"
>
<el-table
style=
'margin-top:-20px'
:data=
"tableData"
max-height=
'5
00'
>
<el-table-column
prop=
"agentName"
label=
"坐席id"
></el-table-column>
<el-table-column
prop=
"customName"
label=
"客户"
></el-table-column>
<el-table
style=
'margin-top:-20px'
:data=
"tableData"
height=
'4
00'
>
<el-table-column
prop=
"agentName"
label=
"坐席id"
width=
'190'
></el-table-column>
<el-table-column
prop=
"customName"
label=
"客户"
width=
'190'
></el-table-column>
<el-table-column
prop=
"remainTime"
label=
"通话时间(秒)"
>
{#
<template
slot-scope=
'scope'
>
#}
{#
<span>
{{
scope.row.remainTime}}秒
</span>
#}
{#
<span>
{{
formatSeconds(scope.row.remainTime)}}
</span>
#}
{#
</template>
#}
</el-table-column>
<el-table-column
prop=
"score"
label=
"分数"
></el-table-column>
...
...
@@ -67,6 +67,15 @@
</template>
</el-table-column>
</el-table>
<el-pagination
@
current-change=
'popCurrentChange'
style=
'margin: 0 auto;text-align:center;margin-bottom:20px;'
layout=
"prev, pager, next"
:current-page.sync=
'popcurrentPage'
background
:page-size=
"poppagesize"
:total=
"poptotal"
>
</el-pagination>
</el-dialog>
</div>
<script
type=
"text/javascript"
>
...
...
static/inspect/js/all.js
100755 → 100644
View file @
8519e533
...
...
@@ -13,6 +13,13 @@ new Vue({
takevalue
:
''
,
loading
:
true
,
tableData
:
[],
poppage
:
1
,
poppagesize
:
10
,
poptotal
:
10
,
poprule
:
''
,
poptables
:
''
,
poploading
:
false
,
popcurrentPage
:
1
,
}
},
methods
:
{
...
...
@@ -80,10 +87,10 @@ new Vue({
let
msgArr
=
[];
let
that
=
this
;
for
(
let
key
in
msg
){
msgArr
.
unshift
([
msg
[
key
].
rule
,
msg
[
key
].
count
,
msg
[
key
].
detail
s
])
msgArr
.
unshift
([
msg
[
key
].
rule
,
msg
[
key
].
count
,
msg
[
key
].
table
s
])
}
let
sourceArr
=
[
[
'
product
'
,
'
amount
'
,
'
detail
'
],
[
'
product
'
,
'
amount
'
,
'
tables
'
],
].
concat
(
msgArr
);
var
option
=
{
dataZoom
:
[
...
...
@@ -162,7 +169,12 @@ new Vue({
var
myChart
=
echarts
.
init
(
document
.
getElementById
(
'
main
'
));
myChart
.
setOption
(
option
);
myChart
.
on
(
'
click
'
,
function
(
msg
){
that
.
tableData
=
msg
.
data
[
2
];
that
.
poptables
=
msg
.
data
[
2
];
that
.
poprule
=
msg
.
data
[
0
];
that
.
popcurrentPage
=
1
;
that
.
poppage
=
1
;
that
.
getDetail
(
that
.
taskvalue
,
that
.
start_date
,
that
.
end_date
,
that
.
poptables
,
that
.
poprule
,
that
.
poppage
,
that
.
poppagesize
);
//that.tableData = msg.data[2];
that
.
dialogTableVisible
=
true
;
})
if
(
msg
.
length
==
0
){
...
...
@@ -179,9 +191,34 @@ new Vue({
window
.
onresize
=
function
(){
myChart
.
resize
();
}
},
popCurrentChange
(
page
){
this
.
poppage
=
page
;
this
.
getDetail
(
this
.
taskvalue
,
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
){
//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
=>
{
console
.
log
(
data
.
data
);
if
(
data
.
code
!=
0
){
that
.
$message
(
data
.
msg
);
if
(
data
.
msg
){
that
.
$message
(
data
.
msg
);
}
else
{
that
.
$message
(
'
服务器错误
'
)
}
}
//that.titleInfo = data.data;
that
.
poptotal
=
data
.
count
;
that
.
poptableData
=
data
.
data
;
//this.$loading().close();
that
.
tableData
=
data
.
data
;
this
.
poploading
=
false
;
})
},
getRule
(
task
,
start_date
,
end_date
,
agentName
){
let
that
=
this
;
let
arr
=
[];
...
...
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