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
204f82d3
Commit
204f82d3
authored
Jul 27, 2020
by
zhengjinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
客户画像命中3次以上,才打上标签
parent
cc0572f8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
77 deletions
+102
-77
openapi.py
src/inspect_report/api/openapi.py
+1
-1
profileapi.py
src/inspect_report/api/profileapi.py
+5
-3
profile.html
src/inspect_report/templates/inspect/profile.html
+1
-0
report_utils.py
src/inspect_report/utils/report_utils.py
+30
-26
profile.js
static/inspect/js/profile.js
+65
-47
No files found.
src/inspect_report/api/openapi.py
View file @
204f82d3
...
@@ -24,7 +24,7 @@ class OpenApi(viewsets.ViewSet):
...
@@ -24,7 +24,7 @@ class OpenApi(viewsets.ViewSet):
logger
.
error
(
'[phone_label]---invalid params'
)
logger
.
error
(
'[phone_label]---invalid params'
)
return
Response
({
'code'
:
-
1
,
'msg'
:
'请传入手机号'
})
return
Response
({
'code'
:
-
1
,
'msg'
:
'请传入手机号'
})
labels
=
[]
labels
=
[]
profile
=
CustomProfile
.
objects
.
filter
(
phone_number
=
phone_num
)
.
first
()
profile
=
CustomProfile
.
objects
.
filter
(
phone_number
=
phone_num
,
custom_labels__isnull
=
False
)
.
first
()
if
not
profile
:
if
not
profile
:
return
Response
({
'code'
:
0
,
'msg'
:
'查询成功'
,
'data'
:
json
.
dumps
(
labels
)})
return
Response
({
'code'
:
0
,
'msg'
:
'查询成功'
,
'data'
:
json
.
dumps
(
labels
)})
if
profile
.
custom_labels
:
if
profile
.
custom_labels
:
...
...
src/inspect_report/api/profileapi.py
View file @
204f82d3
...
@@ -27,11 +27,13 @@ class ProfileApi(viewsets.ViewSet):
...
@@ -27,11 +27,13 @@ class ProfileApi(viewsets.ViewSet):
if
username
in
name_list
:
if
username
in
name_list
:
logger
.
info
(
'[profile_labels]获取的username是:
%
s'
,
username
)
logger
.
info
(
'[profile_labels]获取的username是:
%
s'
,
username
)
region
=
username
region
=
username
condition
=
{}
condition
=
{
'custom_labels__isnull'
:
False
}
if
region
and
region
!=
'安徽picc'
:
if
region
and
region
!=
'安徽picc'
:
condition
[
'region'
]
=
region
condition
[
'region'
]
=
region
profiles
=
CustomProfile
.
objects
.
filter
(
**
condition
)
.
values
(
'phone_number'
,
'region'
,
'call_recent'
,
profiles
=
CustomProfile
.
objects
.
filter
(
**
condition
)
.
order_by
(
'-call_recent'
)
.
values
(
'phone_number'
,
'region'
,
'call_count'
,
'custom_labels'
)
'call_recent'
,
'call_count'
,
'custom_labels'
)
paginator
=
Paginator
(
profiles
,
page_size
)
paginator
=
Paginator
(
profiles
,
page_size
)
total_count
=
paginator
.
count
total_count
=
paginator
.
count
try
:
try
:
...
...
src/inspect_report/templates/inspect/profile.html
View file @
204f82d3
...
@@ -46,6 +46,7 @@
...
@@ -46,6 +46,7 @@
prop=
"call_recent"
prop=
"call_recent"
label=
"最近通话日期"
label=
"最近通话日期"
width=
"200"
width=
"200"
:formatter=
"datetimeFormat"
>
>
</el-table-column>
</el-table-column>
<el-table-column
<el-table-column
...
...
src/inspect_report/utils/report_utils.py
View file @
204f82d3
...
@@ -203,8 +203,7 @@ def delete_stat_by_task(task):
...
@@ -203,8 +203,7 @@ def delete_stat_by_task(task):
ScoreStat
.
objects
.
filter
(
taskId
=
task
.
id
)
.
delete
()
ScoreStat
.
objects
.
filter
(
taskId
=
task
.
id
)
.
delete
()
def
save_custom_profile
(
task
,
check
,
name
):
def
save_custom_profile
(
task
,
check
,
name
,
profile_count
):
label
=
name
.
replace
(
'[客户画像]'
,
''
)
custom
=
check
[
'customName'
]
.
split
(
'&'
)
if
check
[
'customName'
]
else
[]
custom
=
check
[
'customName'
]
.
split
(
'&'
)
if
check
[
'customName'
]
else
[]
region
=
task
[
'name'
]
.
split
(
'_'
)[
0
]
region
=
task
[
'name'
]
.
split
(
'_'
)[
0
]
if
custom
:
if
custom
:
...
@@ -213,29 +212,32 @@ def save_custom_profile(task, check, name):
...
@@ -213,29 +212,32 @@ def save_custom_profile(task, check, name):
if
custom_phone
and
len
(
custom_phone
)
>
11
and
custom_phone
.
startswith
(
'0'
):
if
custom_phone
and
len
(
custom_phone
)
>
11
and
custom_phone
.
startswith
(
'0'
):
custom_phone
=
custom_phone
[
1
:]
custom_phone
=
custom_phone
[
1
:]
profile
=
CustomProfile
.
objects
.
filter
(
phone_number
=
custom_phone
)
.
first
()
profile
=
CustomProfile
.
objects
.
filter
(
phone_number
=
custom_phone
)
.
first
()
team
=
'未找到团队'
#
team = '未找到团队'
#
team = team_seat().get(check['agentName'], '未找到团队')
team
=
team_seat
()
.
get
(
check
[
'agentName'
],
'未找到团队'
)
call_time
=
datetime
.
strptime
(
check
[
'startTime'
]
.
replace
(
'.0'
,
''
),
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
if
check
[
'startTime'
]
\
call_time
=
datetime
.
strptime
(
check
[
'startTime'
]
.
replace
(
'.0'
,
''
),
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
if
check
[
'startTime'
]
\
else
None
else
None
if
profile
:
if
profile
:
profile
.
call_count
+=
profile_count
if
call_time
:
if
call_time
:
profile
.
call_recent
=
call_time
profile
.
call_recent
=
call_time
profile
.
call_count
+=
1
if
not
profile
.
custom_labels
:
profile
.
custom_labels
=
label
if
label
not
in
profile
.
custom_labels
.
split
(
'、'
):
profile
.
custom_labels
+=
f
'、{label}'
profile
.
save
()
else
:
else
:
profile
=
CustomProfile
.
objects
.
create
(
name
=
custom_name
,
phone_number
=
custom_phone
,
profile
=
CustomProfile
.
objects
.
create
(
name
=
custom_name
,
phone_number
=
custom_phone
,
call_recent
=
call_time
,
call_recent
=
call_time
,
call_count
=
1
,
custom_labels
=
label
,
region
=
region
,
call_count
=
1
,
region
=
region
,
create_at
=
datetime
.
now
(),
update_at
=
datetime
.
now
())
create_at
=
datetime
.
now
(),
update_at
=
datetime
.
now
())
CustomLabel
.
objects
.
create
(
profile_id
=
profile
.
id
,
call_time
=
call_time
,
if
name
and
'[客户画像]'
in
name
:
label
=
label
,
team
=
team
,
agent_name
=
check
[
'agentName'
],
task_id
=
check
[
'taskId'
],
label
=
name
.
replace
(
'[客户画像]'
,
''
)
session_id
=
check
[
'sessionId'
],
session_table_id
=
check
[
'id'
],
CustomLabel
.
objects
.
create
(
profile_id
=
profile
.
id
,
call_time
=
call_time
,
session_collection_id
=
task
[
'sessionCollectionId'
],
create_at
=
datetime
.
now
(),
label
=
label
,
team
=
team
,
agent_name
=
check
[
'agentName'
],
task_id
=
check
[
'taskId'
],
update_at
=
datetime
.
now
())
session_id
=
check
[
'sessionId'
],
session_table_id
=
check
[
'id'
],
session_collection_id
=
task
[
'sessionCollectionId'
],
create_at
=
datetime
.
now
(),
update_at
=
datetime
.
now
())
if
CustomLabel
.
objects
.
filter
(
profile_id
=
profile
.
id
,
label
=
label
)
.
count
()
>=
3
:
if
not
profile
.
custom_labels
:
profile
.
custom_labels
=
label
if
label
not
in
profile
.
custom_labels
.
split
(
'、'
):
profile
.
custom_labels
+=
f
'、{label}'
profile
.
save
()
def
single_data_stat
(
t
,
create_date
,
stat_count
=
0
):
def
single_data_stat
(
t
,
create_date
,
stat_count
=
0
):
...
@@ -271,20 +273,22 @@ def single_data_stat(t, create_date, stat_count=0):
...
@@ -271,20 +273,22 @@ def single_data_stat(t, create_date, stat_count=0):
if
result
:
if
result
:
rules_list
=
[]
rules_list
=
[]
data
=
json
.
loads
(
result
)
data
=
json
.
loads
(
result
)
profile_count
=
1
for
d
in
data
:
for
d
in
data
:
if
'isViolation'
in
d
.
keys
()
and
d
[
'isViolation'
]
and
'rule'
in
d
.
keys
()
and
'name'
in
d
[
'rule'
]
.
keys
():
if
'isViolation'
in
d
.
keys
()
and
d
[
'isViolation'
]
and
'rule'
in
d
.
keys
()
and
'name'
in
d
[
'rule'
]
.
keys
():
name
=
d
[
'rule'
][
'name'
]
name
=
d
[
'rule'
][
'name'
]
name
=
name
.
replace
(
'【'
,
'['
)
.
replace
(
'】'
,
']'
)
name
=
name
.
replace
(
'【'
,
'['
)
.
replace
(
'】'
,
']'
)
if
name
and
'[客户画像]'
in
name
:
if
rule_stat_flag
:
if
rule_stat_flag
:
save_custom_profile
(
t
,
check
,
name
)
save_custom_profile
(
t
,
check
,
name
,
profile_count
)
else
:
profile_count
=
0
if
name
and
'[客户画像]'
not
in
name
:
validate_rule_count
+=
1
validate_rule_count
+=
1
if
rule_stat_flag
:
if
rule_stat_flag
:
rule_obj
=
{
'create_date'
:
create_date
,
'sessionCollectionId'
:
t
[
'sessionCollectionId'
],
rule_obj
=
{
'create_date'
:
create_date
,
'sessionCollectionId'
:
t
[
'sessionCollectionId'
],
'rule'
:
name
,
'rule_num'
:
1
,
'rule'
:
name
,
'rule_num'
:
1
,
'task'
:
'未找到团队'
,
#
'task': '未找到团队',
#
'task': team_seat().get(check['agentName'], '未找到团队'),
'task'
:
team_seat
()
.
get
(
check
[
'agentName'
],
'未找到团队'
),
'agentName'
:
check
[
'agentName'
],
'customName'
:
check
[
'customName'
],
'agentName'
:
check
[
'agentName'
],
'customName'
:
check
[
'customName'
],
'score'
:
check
[
'score'
],
'remainTime'
:
remain
,
'score'
:
check
[
'score'
],
'remainTime'
:
remain
,
'taskId'
:
check
[
'taskId'
],
'sessionId'
:
check
[
'sessionId'
],
'taskId'
:
check
[
'taskId'
],
'sessionId'
:
check
[
'sessionId'
],
...
@@ -303,8 +307,8 @@ def single_data_stat(t, create_date, stat_count=0):
...
@@ -303,8 +307,8 @@ def single_data_stat(t, create_date, stat_count=0):
else
:
else
:
seat_dict
[
check
[
'agentName'
]]
=
{
'create_date'
:
create_date
,
'agentName'
:
check
[
'agentName'
],
seat_dict
[
check
[
'agentName'
]]
=
{
'create_date'
:
create_date
,
'agentName'
:
check
[
'agentName'
],
'taskId'
:
check
[
'taskId'
],
'taskId'
:
check
[
'taskId'
],
'task'
:
'未找到团队'
,
#
'task': '未找到团队',
#
'task': team_seat().get(check['agentName'], '未找到团队'),
'task'
:
team_seat
()
.
get
(
check
[
'agentName'
],
'未找到团队'
),
'sessionCollectionId'
:
t
[
'sessionCollectionId'
],
'sessionCollectionId'
:
t
[
'sessionCollectionId'
],
'total_session'
:
1
}
'total_session'
:
1
}
seat_dict
[
check
[
'agentName'
]][
'validate_session'
]
=
1
if
validate_rule_count
>
0
else
0
seat_dict
[
check
[
'agentName'
]][
'validate_session'
]
=
1
if
validate_rule_count
>
0
else
0
...
@@ -339,8 +343,8 @@ def single_data_stat(t, create_date, stat_count=0):
...
@@ -339,8 +343,8 @@ def single_data_stat(t, create_date, stat_count=0):
else
:
else
:
score_dict
[
check
[
'agentName'
]]
=
{
'create_date'
:
create_date
,
'agentName'
:
check
[
'agentName'
],
score_dict
[
check
[
'agentName'
]]
=
{
'create_date'
:
create_date
,
'agentName'
:
check
[
'agentName'
],
'taskId'
:
check
[
'taskId'
],
'taskId'
:
check
[
'taskId'
],
'task'
:
'未找到团队'
,
#
'task': '未找到团队',
#
'task': team_seat().get(check['agentName'], '未找到团队'),
'task'
:
team_seat
()
.
get
(
check
[
'agentName'
],
'未找到团队'
),
'sessionCollectionId'
:
t
[
'sessionCollectionId'
],
'total_session'
:
1
,
'sessionCollectionId'
:
t
[
'sessionCollectionId'
],
'total_session'
:
1
,
'score'
:
score
,
'service_score'
:
service_score
,
'score'
:
score
,
'service_score'
:
service_score
,
'business_score'
:
business_score
,
'validate_zero'
:
validate_zero
}
'business_score'
:
business_score
,
'validate_zero'
:
validate_zero
}
...
...
static/inspect/js/profile.js
View file @
204f82d3
new
Vue
({
new
Vue
({
el
:
'
#childApp
'
,
el
:
'
#childApp
'
,
data
:
function
()
{
data
:
function
()
{
return
{
return
{
ss
:
'
sas
'
,
ss
:
'
sas
'
,
dateTime
:
''
,
dateTime
:
''
,
cityList
:
[],
cityList
:
[],
countryList
:[],
countryList
:
[],
teamList
:[],
teamList
:
[],
cityvalue
:
''
,
cityvalue
:
''
,
countryvalue
:
''
,
countryvalue
:
''
,
teamvalue
:
''
,
teamvalue
:
''
,
country_show
:
false
,
country_show
:
false
,
team_show
:
true
,
team_show
:
true
,
start_date
:
''
,
start_date
:
''
,
isscrollTop
:
false
,
isscrollTop
:
false
,
currentPage
:
1
,
currentPage
:
1
,
pagesize
:
10
,
pagesize
:
10
,
total
:
10
,
total
:
10
,
poppage
:
1
,
poppage
:
1
,
poppagesize
:
10
,
poppagesize
:
10
,
poptotal
:
10
,
poptotal
:
10
,
poprule
:
''
,
poprule
:
''
,
poptables
:
''
,
poptables
:
''
,
popcurrentPage
:
1
,
popcurrentPage
:
1
,
isHidePage
:
true
,
isHidePage
:
true
,
scrollTop
:
0
,
scrollTop
:
0
,
end_date
:
''
,
end_date
:
''
,
poploading
:
false
,
poploading
:
false
,
BASEURL
:
window_url
,
BASEURL
:
window_url
,
dialogTableVisible
:
false
,
dialogTableVisible
:
false
,
takeList
:
[],
takeList
:
[],
dateRange
:
[
new
Date
(),
new
Date
()],
dateRange
:
[
new
Date
(),
new
Date
()],
loading
:
true
,
loading
:
true
,
poptableData
:
[],
poptableData
:
[],
tableData
:
[]
tableData
:
[]
}
}
},
},
methods
:
{
methods
:
{
changeCity
(
msg
)
{
changeCity
(
msg
)
{
console
.
log
(
msg
);
console
.
log
(
msg
);
...
@@ -43,29 +43,29 @@ new Vue({
...
@@ -43,29 +43,29 @@ new Vue({
this
.
cityvalue
=
msg
;
this
.
cityvalue
=
msg
;
this
.
getProfile
();
// 获取统计数据
this
.
getProfile
();
// 获取统计数据
},
},
getCity
(){
getCity
()
{
let
that
=
this
;
let
that
=
this
;
var
request
=
new
XMLHttpRequest
();
var
request
=
new
XMLHttpRequest
();
let
uri
=
window_url
+
'
api/v1/agency/city/
'
;
let
uri
=
window_url
+
'
api/v1/agency/city/
'
;
request
.
open
(
'
GET
'
,
uri
,
false
);
request
.
open
(
'
GET
'
,
uri
,
false
);
request
.
send
(
null
);
request
.
send
(
null
);
if
(
request
.
status
===
200
)
{
if
(
request
.
status
===
200
)
{
data
=
JSON
.
parse
(
request
.
response
);
data
=
JSON
.
parse
(
request
.
response
);
console
.
log
(
data
.
code
);
console
.
log
(
data
.
code
);
if
(
data
.
code
!=
0
)
{
if
(
data
.
code
!=
0
)
{
that
.
$message
(
'
服务器错误
'
);
that
.
$message
(
'
服务器错误
'
);
}
else
{
}
else
{
that
.
cityList
=
data
.
data
.
city_list
;
that
.
cityList
=
data
.
data
.
city_list
;
that
.
cityvalue
=
''
;
that
.
cityvalue
=
''
;
console
.
log
(
that
.
cityvalue
);
console
.
log
(
that
.
cityvalue
);
that
.
init_simple
=
true
;
that
.
init_simple
=
true
;
}
}
}
else
{
}
else
{
that
.
$message
(
'
服务器错误
'
);
that
.
$message
(
'
服务器错误
'
);
}
}
},
},
getProfile
()
{
getProfile
()
{
let
that
=
this
;
let
that
=
this
;
let
page
=
this
.
currentPage
;
let
page
=
this
.
currentPage
;
...
@@ -104,6 +104,24 @@ new Vue({
...
@@ -104,6 +104,24 @@ new Vue({
dateFormat
(
date
)
{
dateFormat
(
date
)
{
return
date
.
getFullYear
()
+
"
-
"
+
(
date
.
getMonth
()
+
1
)
+
"
-
"
+
date
.
getDate
();
return
date
.
getFullYear
()
+
"
-
"
+
(
date
.
getMonth
()
+
1
)
+
"
-
"
+
date
.
getDate
();
},
},
datetimeFormat
(
row
,
column
)
{
let
data
=
row
[
column
.
property
];
if
(
data
==
null
)
{
return
null
}
let
dt
=
new
Date
(
data
);
let
month
=
dt
.
getMonth
()
+
1
;
month
=
month
.
toString
().
length
===
1
?
(
'
0
'
+
month
.
toString
())
:
month
.
toString
();
let
day
=
dt
.
getDate
();
day
=
day
.
toString
().
length
===
1
?
(
'
0
'
+
day
.
toString
())
:
day
.
toString
();
let
hh
=
dt
.
getHours
();
hh
=
hh
.
toString
().
length
===
1
?
(
'
0
'
+
hh
.
toString
())
:
hh
.
toString
();
let
mm
=
dt
.
getMinutes
();
mm
=
mm
.
toString
().
length
===
1
?
(
'
0
'
+
mm
.
toString
())
:
mm
.
toString
();
let
ss
=
dt
.
getSeconds
();
ss
=
ss
.
toString
().
length
===
1
?
(
'
0
'
+
ss
.
toString
())
:
ss
.
toString
();
return
dt
.
getFullYear
()
+
'
-
'
+
month
+
'
-
'
+
day
+
'
'
+
hh
+
'
:
'
+
mm
+
'
:
'
+
ss
},
init
()
{
init
()
{
this
.
getCity
();
// 获取任务
this
.
getCity
();
// 获取任务
this
.
getProfile
();
// 获取统计数据
this
.
getProfile
();
// 获取统计数据
...
...
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