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
41285637
Commit
41285637
authored
May 18, 2020
by
lvshibao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改定时任务时间,和任务获取数据的方式
parent
dc66fb20
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
33 deletions
+27
-33
cron.py
src/inspect_report/cron.py
+16
-19
views.py
src/inspect_report/views.py
+11
-14
No files found.
src/inspect_report/cron.py
View file @
41285637
...
...
@@ -34,7 +34,7 @@ def team_seat():
@
kronos
.
register
(
'30 6 * * *'
)
def
rule_stat
(
start_date
=
None
,
end_date
=
None
):
def
rule_stat
(
date_str
=
None
):
"""
首页概述-违规项统计
...
...
@@ -44,13 +44,12 @@ def rule_stat(start_date=None, end_date=None):
:return:
"""
seat_code_team_name
=
team_seat
()
if
not
start_date
and
not
end_date
:
if
not
date_str
:
# 数据库中为utc时间
start_date
=
(
datetime
.
utcnow
()
+
timedelta
(
hours
=-
3
))
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
end_date
=
datetime
.
utcnow
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
create_date
=
(
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
+
timedelta
(
hours
=
8
))
.
strftime
(
'
%
Y-
%
m-
%
d'
)
date_str
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
create_date
=
date_str
logger
.
info
(
'[rule_stat]rule stat start...'
)
task_condition
=
{
'hasCheck'
:
1
,
'
createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
task_condition
=
{
'hasCheck'
:
1
,
'
name__endswith'
:
date_str
}
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'name'
,
'sessionCollectionId'
)
stat_count
=
0
for
t
in
tasks
:
...
...
@@ -89,18 +88,17 @@ def rule_stat(start_date=None, end_date=None):
@
kronos
.
register
(
'30 6 * * *'
)
def
seat_stat
(
start_date
=
None
,
end_date
=
None
):
def
seat_stat
(
date_str
=
None
):
"""
首页概述-违规坐席统计
:return:
"""
seat_code_team_name
=
team_seat
()
if
not
start_date
and
not
end_date
:
start_date
=
(
datetime
.
utcnow
()
+
timedelta
(
hours
=-
3
))
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
end_date
=
datetime
.
utcnow
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
create_date
=
(
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
+
timedelta
(
hours
=
8
))
.
strftime
(
'
%
Y-
%
m-
%
d'
)
if
not
date_str
:
date_str
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
create_date
=
date_str
logger
.
info
(
'[seat_stat]violate seat stat start...'
)
task_condition
=
{
'hasCheck'
:
1
,
'
createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
task_condition
=
{
'hasCheck'
:
1
,
'
name__endswith'
:
date_str
}
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'name'
,
'sessionCollectionId'
)
stat_count
=
0
for
t
in
tasks
:
...
...
@@ -137,19 +135,18 @@ def seat_stat(start_date=None, end_date=None):
logger
.
info
(
'[seat_stat]violate seat stat end.'
)
@
kronos
.
register
(
'30
1,6,12
* * *'
)
def
score_stat
(
start_date
=
None
,
end_date
=
None
):
@
kronos
.
register
(
'30
6
* * *'
)
def
score_stat
(
date_str
=
None
):
"""
坐席得分统计
:return:
"""
seat_code_team_name
=
team_seat
()
if
not
start_date
and
not
end_date
:
start_date
=
(
datetime
.
utcnow
()
+
timedelta
(
hours
=-
3
))
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
end_date
=
datetime
.
utcnow
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
create_date
=
(
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
+
timedelta
(
hours
=
8
))
.
strftime
(
'
%
Y-
%
m-
%
d'
)
if
not
date_str
:
date_str
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
create_date
=
date_str
logger
.
info
(
'[score_stat]seat score stat start...'
)
task_condition
=
{
'hasCheck'
:
1
,
'
createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
}
task_condition
=
{
'hasCheck'
:
1
,
'
name__endswith'
:
date_str
}
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'name'
,
'sessionCollectionId'
)
stat_count
=
0
for
t
in
tasks
:
...
...
src/inspect_report/views.py
View file @
41285637
...
...
@@ -9,12 +9,11 @@ def stat_rules_every(request):
start_date
=
request
.
GET
.
get
(
'start_date'
)
end_date
=
request
.
GET
.
get
(
'end_date'
)
s_date
=
datetime
.
strptime
(
start_date
,
'
%
Y-
%
m-
%
d'
)
e_date
=
datetime
.
strptime
(
end_date
+
' 23:59:59'
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S
'
)
e_date
=
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d
'
)
seed_dt
=
list
(
rrule
(
DAILY
,
byweekday
=
[
0
,
1
,
2
,
3
,
4
,
5
,
6
],
dtstart
=
s_date
,
until
=
e_date
))
for
date
in
seed_dt
:
start_date
=
date
end_date
=
datetime
.
strptime
(
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
+
' 23:59:59'
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
rule_stat
(
start_date
,
end_date
)
date_str
=
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
rule_stat
(
date_str
)
return
JsonResponse
({
'code'
:
0
,
'msg'
:
'stat success'
})
...
...
@@ -22,12 +21,11 @@ def stat_seats_every(request):
start_date
=
request
.
GET
.
get
(
'start_date'
)
end_date
=
request
.
GET
.
get
(
'end_date'
)
s_date
=
datetime
.
strptime
(
start_date
,
'
%
Y-
%
m-
%
d'
)
e_date
=
datetime
.
strptime
(
end_date
+
' 23:59:59'
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S
'
)
e_date
=
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d
'
)
seed_dt
=
list
(
rrule
(
DAILY
,
byweekday
=
[
0
,
1
,
2
,
3
,
4
,
5
,
6
],
dtstart
=
s_date
,
until
=
e_date
))
for
date
in
seed_dt
:
start_date
=
date
end_date
=
datetime
.
strptime
(
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
+
' 23:59:59'
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
seat_stat
(
start_date
,
end_date
)
date_str
=
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
seat_stat
(
date_str
)
return
JsonResponse
({
'code'
:
0
,
'msg'
:
'stat success'
})
...
...
@@ -35,12 +33,11 @@ def stat_scores_every(request):
start_date
=
request
.
GET
.
get
(
'start_date'
)
end_date
=
request
.
GET
.
get
(
'end_date'
)
s_date
=
datetime
.
strptime
(
start_date
,
'
%
Y-
%
m-
%
d'
)
e_date
=
datetime
.
strptime
(
end_date
+
' 23:59:59'
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S
'
)
e_date
=
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d
'
)
seed_dt
=
list
(
rrule
(
DAILY
,
byweekday
=
[
0
,
1
,
2
,
3
,
4
,
5
,
6
],
dtstart
=
s_date
,
until
=
e_date
))
for
date
in
seed_dt
:
start_date
=
date
end_date
=
datetime
.
strptime
(
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
+
' 23:59:59'
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
score_stat
(
start_date
,
end_date
)
date_str
=
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
score_stat
(
date_str
)
return
JsonResponse
({
'code'
:
0
,
'msg'
:
'stat success'
})
...
...
@@ -51,7 +48,7 @@ def stat_time_every(request):
e_date
=
datetime
.
strptime
(
end_date
,
'
%
Y-
%
m-
%
d'
)
seed_dt
=
list
(
rrule
(
DAILY
,
byweekday
=
[
0
,
1
,
2
,
3
,
4
,
5
,
6
],
dtstart
=
s_date
,
until
=
e_date
))
for
date
in
seed_dt
:
start_date
=
date
.
date
(
)
end_date
=
(
datetime
.
strptime
(
date
.
strftime
(
'
%
Y-
%
m-
%
d'
),
'
%
Y-
%
m-
%
d'
)
+
timedelta
(
days
=
1
))
.
date
()
start_date
=
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
end_date
=
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
+
' 23:59:59'
seat_time_stat
(
start_date
,
end_date
)
return
JsonResponse
({
'code'
:
0
,
'msg'
:
'stat success'
})
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