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
5b1bca4d
Commit
5b1bca4d
authored
Mar 25, 2020
by
lvshibao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页数据隔离
parent
e2914e25
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
11 deletions
+32
-11
dataapi.py
src/inspect_report/api/dataapi.py
+6
-1
tasksapi.py
src/inspect_report/api/tasksapi.py
+5
-1
group.html
src/inspect_report/templates/inspect/group.html
+1
-1
account.py
src/inspect_report/utils/account.py
+6
-1
group.js
static/inspect/js/group.js
+14
-7
No files found.
src/inspect_report/api/dataapi.py
View file @
5b1bca4d
...
@@ -6,7 +6,7 @@ from rest_framework.request import Request
...
@@ -6,7 +6,7 @@ from rest_framework.request import Request
from
inspect_report.models
import
Tasks
,
CheckSession
,
RulesStat
,
SeatStat
,
ScoreStat
,
Round
from
inspect_report.models
import
Tasks
,
CheckSession
,
RulesStat
,
SeatStat
,
ScoreStat
,
Round
import
json
import
json
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
config.config
import
TABLE_PRE
from
config.config
import
TABLE_PRE
,
name_list
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
import
logging
import
logging
from
pypinyin
import
Style
,
pinyin
from
pypinyin
import
Style
,
pinyin
...
@@ -14,6 +14,7 @@ import csv
...
@@ -14,6 +14,7 @@ import csv
import
codecs
import
codecs
from
django.utils.http
import
urlquote
from
django.utils.http
import
urlquote
from
inspect_report.utils.account
import
get_account_info
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -23,12 +24,14 @@ class DataApi(viewsets.ViewSet):
...
@@ -23,12 +24,14 @@ class DataApi(viewsets.ViewSet):
permission_classes
=
()
permission_classes
=
()
@
action
([
'get'
],
detail
=
False
)
@
action
([
'get'
],
detail
=
False
)
@
get_account_info
def
static_score_export
(
self
,
req
:
Request
):
def
static_score_export
(
self
,
req
:
Request
):
"""
"""
概览-地市得分统计-导出
概览-地市得分统计-导出
:param req:
:param req:
:return:
:return:
"""
"""
username
=
req
.
data
.
get
(
'username'
,
''
)
task_id
=
req
.
GET
.
get
(
'task'
,
''
)
task_id
=
req
.
GET
.
get
(
'task'
,
''
)
sort
=
req
.
GET
.
get
(
'sort'
,
'-avg_score'
)
sort
=
req
.
GET
.
get
(
'sort'
,
'-avg_score'
)
start_date
=
req
.
GET
.
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'
))
...
@@ -38,6 +41,8 @@ class DataApi(viewsets.ViewSet):
...
@@ -38,6 +41,8 @@ class DataApi(viewsets.ViewSet):
task_condition
=
{
'create_date__gte'
:
q_start_date
,
'create_date__lt'
:
q_end_date
}
task_condition
=
{
'create_date__gte'
:
q_start_date
,
'create_date__lt'
:
q_end_date
}
if
task_id
:
if
task_id
:
task_condition
[
'task'
]
=
task_id
task_condition
[
'task'
]
=
task_id
if
username
in
name_list
:
task_condition
[
'task'
]
=
username
rules
=
ScoreStat
.
objects
.
filter
(
**
task_condition
)
.
extra
(
select
=
{
'area'
:
"task"
})
\
rules
=
ScoreStat
.
objects
.
filter
(
**
task_condition
)
.
extra
(
select
=
{
'area'
:
"task"
})
\
.
values
(
'area'
)
.
annotate
(
avg_score_svc
=
Round
(
Avg
(
'service_score'
),
2
),
.
values
(
'area'
)
.
annotate
(
avg_score_svc
=
Round
(
Avg
(
'service_score'
),
2
),
avg_score_bus
=
Round
(
Avg
(
'business_score'
),
2
),
avg_score_bus
=
Round
(
Avg
(
'business_score'
),
2
),
...
...
src/inspect_report/api/tasksapi.py
View file @
5b1bca4d
...
@@ -440,18 +440,22 @@ class TasksApi(viewsets.ViewSet):
...
@@ -440,18 +440,22 @@ class TasksApi(viewsets.ViewSet):
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'count'
:
total_count
,
'data'
:
seats
.
object_list
})
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'count'
:
total_count
,
'data'
:
seats
.
object_list
})
@
action
([
'post'
],
detail
=
False
)
@
action
([
'post'
],
detail
=
False
)
@
get_account_info
def
static_rule
(
self
,
req
:
Request
):
def
static_rule
(
self
,
req
:
Request
):
"""
"""
首页概述-违规项统计
首页概述-违规项统计
:param req:
:param req:
:return:
:return:
"""
"""
username
=
req
.
data
.
get
(
'username'
,
''
)
task_id
=
req
.
data
.
get
(
'task'
,
''
)
task_id
=
req
.
data
.
get
(
'task'
,
''
)
start_date
=
req
.
data
.
get
(
'start_date'
,
(
datetime
.
now
()
+
timedelta
(
days
=-
1
))
.
strftime
(
'
%
Y-
%
m-
%
d'
))
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'
))
end_date
=
req
.
data
.
get
(
'end_date'
,
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
))
task_condition
=
{
'hasCheck'
:
1
,
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
+
' 23:59:59'
}
task_condition
=
{
'hasCheck'
:
1
,
'createdAt__gte'
:
start_date
,
'createdAt__lt'
:
end_date
+
' 23:59:59'
}
if
task_id
:
if
task_id
:
task_condition
[
'name__startswith'
]
=
task_id
task_condition
[
'name__startswith'
]
=
task_id
if
username
in
name_list
:
task_condition
[
'name__startswith'
]
=
username
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'sessionCollectionId'
)
tasks
=
Tasks
.
objects
.
filter
(
**
task_condition
)
.
values
(
'id'
,
'sessionCollectionId'
)
task_dict
=
{}
task_dict
=
{}
for
t
in
tasks
:
for
t
in
tasks
:
...
@@ -493,7 +497,7 @@ class TasksApi(viewsets.ViewSet):
...
@@ -493,7 +497,7 @@ class TasksApi(viewsets.ViewSet):
v
[
'call_count'
]
=
call_count
v
[
'call_count'
]
=
call_count
data_sort
.
append
(
v
)
data_sort
.
append
(
v
)
# data_sort = sorted(data_sort, key=lambda x: x['count'], reverse=True)
# data_sort = sorted(data_sort, key=lambda x: x['count'], reverse=True)
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'data'
:
data_sort
})
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'data'
:
data_sort
,
'username'
:
username
})
@
action
([
'post'
],
detail
=
False
)
@
action
([
'post'
],
detail
=
False
)
def
rule_detail
(
self
,
req
:
Request
):
def
rule_detail
(
self
,
req
:
Request
):
...
...
src/inspect_report/templates/inspect/group.html
View file @
5b1bca4d
...
@@ -87,7 +87,7 @@
...
@@ -87,7 +87,7 @@
end-placeholder=
"结束日期"
end-placeholder=
"结束日期"
:default-time=
"['00:00:00', '23:59:59']"
>
:default-time=
"['00:00:00', '23:59:59']"
>
</el-date-picker>
</el-date-picker>
<el-select
v-model=
"taskvalue"
filterable
placeholder=
"请选择"
@
change=
"changeTask"
>
<el-select
v-
if=
"sel_is_show == true"
v-
model=
"taskvalue"
filterable
placeholder=
"请选择"
@
change=
"changeTask"
>
<el-option
<el-option
v-for=
"item in taskList"
v-for=
"item in taskList"
:key=
"item.id"
:key=
"item.id"
...
...
src/inspect_report/utils/account.py
View file @
5b1bca4d
...
@@ -38,7 +38,12 @@ def get_account_info(func):
...
@@ -38,7 +38,12 @@ def get_account_info(func):
cookie_jar
=
transfer_cookie
(
req
.
COOKIES
)
cookie_jar
=
transfer_cookie
(
req
.
COOKIES
)
info
=
requests
.
get
(
USER_INFO_URL
,
cookies
=
cookie_jar
)
info
=
requests
.
get
(
USER_INFO_URL
,
cookies
=
cookie_jar
)
# logger.info('req中的query_params为: ', req.query_params)
# logger.info('req中的query_params为: ', req.query_params)
try
:
if
info
.
json
()[
'code'
]
!=
200
:
if
info
.
json
()[
'code'
]
!=
200
:
logger
.
info
(
'未能获取用户信息: '
+
info
.
text
)
return
Response
({
'code'
:
-
1
,
'msg'
:
'未能获取用户信息'
})
except
Exception
:
logger
.
info
(
'未能获取用户信息: '
+
info
.
text
)
return
Response
({
'code'
:
-
1
,
'msg'
:
'未能获取用户信息'
})
return
Response
({
'code'
:
-
1
,
'msg'
:
'未能获取用户信息'
})
req
.
data
[
'username'
]
=
info
.
json
()[
'data'
][
'userInfo'
][
'name'
]
req
.
data
[
'username'
]
=
info
.
json
()[
'data'
][
'userInfo'
][
'name'
]
return
func
(
obj
,
req
,
*
args
,
**
kw
)
return
func
(
obj
,
req
,
*
args
,
**
kw
)
...
...
static/inspect/js/group.js
View file @
5b1bca4d
...
@@ -35,6 +35,7 @@ new Vue({
...
@@ -35,6 +35,7 @@ new Vue({
"
validate_session
"
:
0
,
"
validate_session
"
:
0
,
"
ratio
"
:
0
,
"
ratio
"
:
0
,
},
},
sel_is_show
:
true
,
loading
:
true
,
loading
:
true
,
poptableData
:
[],
poptableData
:
[],
tableData
:
[]
tableData
:
[]
...
@@ -183,6 +184,12 @@ new Vue({
...
@@ -183,6 +184,12 @@ new Vue({
return
false
;
return
false
;
}
}
that
.
titleInfo
=
data
.
data
;
that
.
titleInfo
=
data
.
data
;
if
([
'
合肥
'
,
'
芜湖
'
,
'
淮北
'
,
'
安庆
'
,
'
黄山
'
,
'
滁州
'
,
'
阜阳
'
,
'
亳州
'
,
'
宿州
'
,
'
六安
'
,
'
宣城
'
,
'
巢湖
'
,
'
池州
'
,
'
淮南
'
,
'
安徽省营业部
'
,
'
蚌埠
'
,
'
马鞍山
'
,
'
铜陵
'
].
indexOf
(
data
.
username
)
!==
-
1
)
{
that
.
sel_is_show
=
false
;
that
.
taskvalue
=
data
.
username
;
}
else
{
that
.
sel_is_show
=
true
;
}
//this.$loading().close();
//this.$loading().close();
})
})
},
},
...
...
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