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
f917478d
Commit
f917478d
authored
Dec 19, 2019
by
zhengjinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建定时任务
parent
e5041c7c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
11 deletions
+36
-11
settings.py
src/config/settings.py
+1
-0
tasksapi.py
src/inspect_report/api/tasksapi.py
+2
-2
cron.py
src/inspect_report/cron.py
+33
-9
No files found.
src/config/settings.py
View file @
f917478d
...
@@ -14,6 +14,7 @@ import datetime
...
@@ -14,6 +14,7 @@ import datetime
import
os
import
os
import
pymysql
import
pymysql
import
raven
import
raven
from
.loggings
import
LOGGING
from
.
import
config
from
.
import
config
...
...
src/inspect_report/api/tasksapi.py
View file @
f917478d
...
@@ -42,8 +42,8 @@ class TasksApi(viewsets.ViewSet):
...
@@ -42,8 +42,8 @@ class TasksApi(viewsets.ViewSet):
:return:
:return:
"""
"""
task_id
=
req
.
GET
.
get
(
'task'
,
''
)
task_id
=
req
.
GET
.
get
(
'task'
,
''
)
start_date
=
req
.
data
.
get
(
'start_date'
,
(
datetime
.
now
()
+
timedelta
(
days
=-
1
))
.
strftime
(
'
%
Y-
%
m-
%
d'
))
start_date
=
req
.
GET
.
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'
))
end_date
=
req
.
GET
.
get
(
'end_date'
,
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
))
q_start_date
=
datetime
.
strptime
(
start_date
,
'
%
Y-
%
m-
%
d'
)
.
date
()
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
()
q_end_date
=
(
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d'
)
+
+
timedelta
(
days
=
1
))
.
date
()
session_condition
=
{
'create_date__gte'
:
q_start_date
,
'create_date__lt'
:
q_end_date
}
session_condition
=
{
'create_date__gte'
:
q_start_date
,
'create_date__lt'
:
q_end_date
}
...
...
src/inspect_report/cron.py
View file @
f917478d
...
@@ -3,11 +3,13 @@ from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, Scor
...
@@ -3,11 +3,13 @@ from inspect_report.models import Tasks, CheckSession, RulesStat, SeatStat, Scor
from
config.config
import
TABLE_PRE
from
config.config
import
TABLE_PRE
import
json
import
json
import
logging
import
logging
import
kronos
from
datetime
import
datetime
,
timedelta
"""定时任务
"""定时任务
参考:https://github.com/jgorset/django-kronos
参考:https://github.com/jgorset/django-kronos
"""
"""
logger
=
logging
.
getLogger
(
"app_file"
)
logger
=
logging
.
getLogger
(
'app_file'
)
score_item_zero
=
{
'违规则零分'
:
100
,
'敏感词'
:
100
}
score_item_zero
=
{
'违规则零分'
:
100
,
'敏感词'
:
100
}
score_item_service
=
{
'异议处理'
:
10
,
'业务促成'
:
15
,
'预约及流转'
:
15
,
'服务介绍'
:
5
,
'6_引导流程_2个场景'
:
0
,
'未提供报价'
:
5
,
score_item_service
=
{
'异议处理'
:
10
,
'业务促成'
:
15
,
'预约及流转'
:
15
,
'服务介绍'
:
5
,
'6_引导流程_2个场景'
:
0
,
'未提供报价'
:
5
,
'未做优惠费率介绍'
:
5
}
'未做优惠费率介绍'
:
5
}
...
@@ -15,11 +17,16 @@ score_item_business = {'结束语': 5, '服务态度': 10, '服务用语': 10, '
...
@@ -15,11 +17,16 @@ score_item_business = {'结束语': 5, '服务态度': 10, '服务用语': 10, '
'开场白'
:
10
}
'开场白'
:
10
}
def
rule_stat
(
start_date
,
end_date
):
@
kronos
.
register
(
'0 1 * * *'
)
def
rule_stat
(
start_date
=
None
,
end_date
=
None
):
"""
"""
首页概述-违规项统计
首页概述-违规项统计
:return:
:return:
"""
"""
if
not
start_date
and
not
end_date
:
start_date
=
(
datetime
.
now
()
+
timedelta
(
days
=-
1
))
.
strftime
(
'
%
Y-
%
m-
%
d'
)
end_date
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
logger
.
info
(
'[rule_stat]rule stat start...'
)
task_condition
=
{
'hasCheck'
:
1
,
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
task_condition
=
{
'hasCheck'
:
1
,
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'name'
,
'sessionCollectionId'
)
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'name'
,
'sessionCollectionId'
)
stat_count
=
0
stat_count
=
0
...
@@ -47,18 +54,24 @@ def rule_stat(start_date, end_date):
...
@@ -47,18 +54,24 @@ def rule_stat(start_date, end_date):
'session_table_id'
:
check
[
'id'
]}
'session_table_id'
:
check
[
'id'
]}
rules_list
.
append
(
RulesStat
(
**
rule_obj
))
rules_list
.
append
(
RulesStat
(
**
rule_obj
))
stat_count
+=
1
stat_count
+=
1
logger
.
info
(
'统计数量为:
%
s'
%
stat_count
)
RulesStat
.
objects
.
bulk_create
(
rules_list
)
RulesStat
.
objects
.
bulk_create
(
rules_list
)
logger
.
info
(
'[rule_stat]rule stat num: [
%
s]'
,
stat_count
)
logger
.
info
(
'[rule_stat]rule stat end.'
)
def
seat_stat
(
start_date
,
end_date
):
@
kronos
.
register
(
'0 1 * * *'
)
def
seat_stat
(
start_date
=
None
,
end_date
=
None
):
"""
"""
首页概述-违规
项
统计
首页概述-违规
坐席
统计
:return:
:return:
"""
"""
if
not
start_date
and
not
end_date
:
start_date
=
(
datetime
.
now
()
+
timedelta
(
days
=-
1
))
.
strftime
(
'
%
Y-
%
m-
%
d'
)
end_date
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
logger
.
info
(
'[seat_stat]violate seat stat start...'
)
task_condition
=
{
'hasCheck'
:
1
,
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
task_condition
=
{
'hasCheck'
:
1
,
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'name'
,
'sessionCollectionId'
)
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'name'
,
'sessionCollectionId'
)
stat_count
=
0
for
t
in
tasks
:
for
t
in
tasks
:
if
SeatStat
.
objects
.
filter
(
taskId
=
t
[
'id'
])
.
exists
():
if
SeatStat
.
objects
.
filter
(
taskId
=
t
[
'id'
])
.
exists
():
continue
continue
...
@@ -69,6 +82,7 @@ def seat_stat(start_date, end_date):
...
@@ -69,6 +82,7 @@ def seat_stat(start_date, end_date):
seat_dict
=
{}
seat_dict
=
{}
seat_list
=
[]
seat_list
=
[]
for
check
in
checks
:
for
check
in
checks
:
stat_count
+=
1
if
check
[
'agentName'
]
in
seat_dict
.
keys
():
if
check
[
'agentName'
]
in
seat_dict
.
keys
():
seat
=
seat_dict
.
get
(
check
[
'agentName'
])
seat
=
seat_dict
.
get
(
check
[
'agentName'
])
seat
[
'total_session'
]
+=
1
seat
[
'total_session'
]
+=
1
...
@@ -83,16 +97,23 @@ def seat_stat(start_date, end_date):
...
@@ -83,16 +97,23 @@ def seat_stat(start_date, end_date):
seat_obj
.
update
(
v
)
seat_obj
.
update
(
v
)
seat_list
.
append
(
SeatStat
(
**
seat_obj
))
seat_list
.
append
(
SeatStat
(
**
seat_obj
))
SeatStat
.
objects
.
bulk_create
(
seat_list
)
SeatStat
.
objects
.
bulk_create
(
seat_list
)
logger
.
info
(
'[seat_stat]violate seat count: [
%
s]'
,
stat_count
)
logger
.
info
(
'[seat_stat]violate seat stat end.'
)
def
score_stat
(
start_date
,
end_date
):
@
kronos
.
register
(
'0 1 * * *'
)
def
score_stat
(
start_date
=
None
,
end_date
=
None
):
"""
"""
坐席
违规
统计
坐席
得分
统计
:return:
:return:
"""
"""
if
not
start_date
and
not
end_date
:
start_date
=
(
datetime
.
now
()
+
timedelta
(
days
=-
1
))
.
strftime
(
'
%
Y-
%
m-
%
d'
)
end_date
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
logger
.
info
(
'[score_stat]seat score stat start...'
)
task_condition
=
{
'hasCheck'
:
1
,
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
task_condition
=
{
'hasCheck'
:
1
,
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'name'
,
'sessionCollectionId'
)
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'name'
,
'sessionCollectionId'
)
stat_count
=
0
for
t
in
tasks
:
for
t
in
tasks
:
if
ScoreStat
.
objects
.
filter
(
taskId
=
t
[
'id'
])
.
exists
():
if
ScoreStat
.
objects
.
filter
(
taskId
=
t
[
'id'
])
.
exists
():
continue
continue
...
@@ -104,6 +125,7 @@ def score_stat(start_date, end_date):
...
@@ -104,6 +125,7 @@ def score_stat(start_date, end_date):
seat_dict
=
{}
seat_dict
=
{}
seat_list
=
[]
seat_list
=
[]
for
check
in
checks
:
for
check
in
checks
:
stat_count
+=
1
score_item
=
json
.
loads
(
check
[
'scoreItemRecord'
])
score_item
=
json
.
loads
(
check
[
'scoreItemRecord'
])
service_score
=
55
service_score
=
55
business_score
=
45
business_score
=
45
...
@@ -141,3 +163,5 @@ def score_stat(start_date, end_date):
...
@@ -141,3 +163,5 @@ def score_stat(start_date, end_date):
seat_obj
.
update
(
v
)
seat_obj
.
update
(
v
)
seat_list
.
append
(
ScoreStat
(
**
seat_obj
))
seat_list
.
append
(
ScoreStat
(
**
seat_obj
))
ScoreStat
.
objects
.
bulk_create
(
seat_list
)
ScoreStat
.
objects
.
bulk_create
(
seat_list
)
logger
.
info
(
'[score_stat]seat count: [
%
s]'
,
stat_count
)
logger
.
info
(
'[score_stat]seat score stat end.'
)
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