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
8a1a71fa
Commit
8a1a71fa
authored
Jan 04, 2020
by
zhengjinlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
统计时长
parent
13dd2df8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
2 deletions
+47
-2
cron.py
src/inspect_report/cron.py
+30
-0
models.py
src/inspect_report/models.py
+1
-0
urls.py
src/inspect_report/urls.py
+2
-1
views.py
src/inspect_report/views.py
+14
-1
No files found.
src/inspect_report/cron.py
View file @
8a1a71fa
...
@@ -165,3 +165,33 @@ def score_stat(start_date=None, end_date=None):
...
@@ -165,3 +165,33 @@ def score_stat(start_date=None, end_date=None):
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 count: [
%
s]'
,
stat_count
)
logger
.
info
(
'[score_stat]seat score stat end.'
)
logger
.
info
(
'[score_stat]seat score stat end.'
)
def
seat_time_stat
(
start_date
=
None
,
end_date
=
None
):
"""
首页概述-违规坐席统计
: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]seat time stat start...'
)
logger
.
info
(
start_date
)
logger
.
info
(
end_date
)
task_condition
=
{
'create_date__gte'
:
start_date
,
'create_date__lt'
:
end_date
}
seats
=
SeatStat
.
objects
.
filter
(
**
task_condition
)
stat_count
=
0
for
t
in
seats
:
if
not
t
.
remainTime
:
stat_count
+=
1
table_name
=
TABLE_PRE
+
t
.
sessionCollectionId
tn
=
CheckSession
.
set_table
(
table_name
)
session_condition
=
{
'taskId'
:
t
.
taskId
,
'agentName'
:
t
.
agentName
}
checks
=
tn
.
objects
.
filter
(
**
session_condition
)
.
values
(
'remainTime'
)
total_time
=
0
for
check
in
checks
:
total_time
+=
check
[
'remainTime'
]
t
.
remainTime
=
total_time
t
.
save
(
update_fields
=
[
'remainTime'
])
logger
.
info
(
'[seat_stat]seat time count: [
%
s]'
,
stat_count
)
logger
.
info
(
'[seat_stat]seat time stat end.'
)
src/inspect_report/models.py
View file @
8a1a71fa
...
@@ -56,6 +56,7 @@ class SeatStat(models.Model):
...
@@ -56,6 +56,7 @@ class SeatStat(models.Model):
create_date
=
models
.
DateField
(
'统计日期'
,
null
=
True
)
create_date
=
models
.
DateField
(
'统计日期'
,
null
=
True
)
agentName
=
models
.
CharField
(
'坐席名称'
,
null
=
True
,
max_length
=
64
)
agentName
=
models
.
CharField
(
'坐席名称'
,
null
=
True
,
max_length
=
64
)
taskId
=
models
.
IntegerField
(
'质检任务标识'
)
taskId
=
models
.
IntegerField
(
'质检任务标识'
)
remainTime
=
models
.
IntegerField
(
'通话时长'
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
agentName
return
self
.
agentName
...
...
src/inspect_report/urls.py
View file @
8a1a71fa
...
@@ -16,7 +16,7 @@ Including another URLconf
...
@@ -16,7 +16,7 @@ Including another URLconf
from
django.contrib
import
admin
from
django.contrib
import
admin
from
django.urls
import
path
from
django.urls
import
path
from
.api.tasksapi
import
rule
,
seat
,
group
,
score
,
check
from
.api.tasksapi
import
rule
,
seat
,
group
,
score
,
check
from
.views
import
stat_rules_every
,
stat_seats_every
,
stat_scores_every
from
.views
import
stat_rules_every
,
stat_seats_every
,
stat_scores_every
,
stat_time_every
urlpatterns
=
[
urlpatterns
=
[
# path('admin/', admin.site.urls),
# path('admin/', admin.site.urls),
...
@@ -28,4 +28,5 @@ urlpatterns = [
...
@@ -28,4 +28,5 @@ urlpatterns = [
path
(
'inspect/stat/rule/'
,
stat_rules_every
),
path
(
'inspect/stat/rule/'
,
stat_rules_every
),
path
(
'inspect/stat/seat/'
,
stat_seats_every
),
path
(
'inspect/stat/seat/'
,
stat_seats_every
),
path
(
'inspect/stat/score/'
,
stat_scores_every
),
path
(
'inspect/stat/score/'
,
stat_scores_every
),
path
(
'inspect/stat/time/'
,
stat_time_every
),
]
]
src/inspect_report/views.py
View file @
8a1a71fa
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
.cron
import
rule_stat
,
seat_stat
,
score_stat
from
.cron
import
rule_stat
,
seat_stat
,
score_stat
,
seat_time_stat
from
django.http.response
import
JsonResponse
from
django.http.response
import
JsonResponse
from
dateutil.rrule
import
rrule
,
DAILY
from
dateutil.rrule
import
rrule
,
DAILY
...
@@ -42,3 +42,16 @@ def stat_scores_every(request):
...
@@ -42,3 +42,16 @@ def stat_scores_every(request):
end_date
=
datetime
.
strptime
(
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
+
' 23:59:59'
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
end_date
=
datetime
.
strptime
(
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
+
' 23:59:59'
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
score_stat
(
start_date
,
end_date
)
score_stat
(
start_date
,
end_date
)
return
JsonResponse
({
'code'
:
0
,
'msg'
:
'stat success'
})
return
JsonResponse
({
'code'
:
0
,
'msg'
:
'stat success'
})
def
stat_time_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
,
'
%
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
()
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