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
e2914e25
Commit
e2914e25
authored
Mar 25, 2020
by
lvshibao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页数据隔离
parent
5faa05e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
config.example.py
src/config/config.example.py
+6
-1
tasksapi.py
src/inspect_report/api/tasksapi.py
+10
-4
account.py
src/inspect_report/utils/account.py
+4
-2
No files found.
src/config/config.example.py
View file @
e2914e25
# coding: utf-8
# 经常调整的配置文件参数
debug
=
True
\ No newline at end of file
debug
=
True
name_list
=
[
'合肥'
,
'芜湖'
,
'淮北'
,
'安庆'
,
'黄山'
,
'滁州'
,
'阜阳'
,
'亳州'
,
'宿州'
,
'六安'
,
'宣城'
,
'巢湖'
,
'池州'
,
'淮南'
,
'安徽省营业部'
,
'蚌埠'
,
'马鞍山'
,
'铜陵'
]
USER_INFO_URL
=
'http://172.17.1.74:8248/getUserInfo'
src/inspect_report/api/tasksapi.py
View file @
e2914e25
...
...
@@ -8,7 +8,7 @@ from rest_framework.response import Response
from
inspect_report.models
import
Tasks
,
CheckSession
,
RulesStat
,
SeatStat
,
ScoreStat
,
Round
import
json
from
datetime
import
datetime
,
timedelta
from
config.config
import
TABLE_PRE
from
config.config
import
TABLE_PRE
,
name_list
from
django.views.decorators.clickjacking
import
xframe_options_exempt
import
logging
from
pypinyin
import
Style
,
pinyin
...
...
@@ -243,7 +243,7 @@ class TasksApi(viewsets.ViewSet):
:return:
"""
username
=
req
.
data
.
get
(
'username'
,
''
)
logger
.
info
(
'username获取: '
+
username
)
#
logger.info('username获取: ' + username)
task_id
=
req
.
data
.
get
(
'task'
,
''
)
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'
))
...
...
@@ -252,6 +252,8 @@ class TasksApi(viewsets.ViewSet):
session_condition
=
{
'create_date__gte'
:
q_start_date
,
'create_date__lt'
:
q_end_date
}
if
task_id
:
session_condition
[
'task'
]
=
task_id
if
username
in
name_list
:
session_condition
[
'task'
]
=
username
seat_data
=
SeatStat
.
objects
.
filter
(
**
session_condition
)
.
aggregate
(
validate_session_sum
=
Sum
(
'validate_session'
),
total_session_sum
=
Sum
(
'total_session'
))
avg_score
=
ScoreStat
.
objects
.
filter
(
**
session_condition
)
.
aggregate
(
score_avg
=
Round
(
Avg
(
'score'
),
2
))
...
...
@@ -263,7 +265,7 @@ class TasksApi(viewsets.ViewSet):
else
:
return_data
[
'ratio'
]
=
0.0
return_data
[
'avg_score'
]
=
0.0
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'data'
:
return_data
})
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'data'
:
return_data
,
'username'
:
username
})
@
action
([
'post'
],
detail
=
False
)
def
static_date
(
self
,
req
:
Request
):
...
...
@@ -527,12 +529,14 @@ class TasksApi(viewsets.ViewSet):
return
Response
({
'code'
:
0
,
'msg'
:
'success'
,
'count'
:
total_count
,
'data'
:
seats
.
object_list
})
@
action
([
'post'
],
detail
=
False
)
@
get_account_info
def
static_score
(
self
,
req
:
Request
):
"""
概览-地市得分统计
:param req:
:return:
"""
username
=
req
.
data
.
get
(
'username'
,
''
)
task_id
=
req
.
data
.
get
(
'task'
,
''
)
page
=
req
.
data
.
get
(
'page'
,
'1'
)
page_size
=
req
.
data
.
get
(
'page_size'
,
'10'
)
...
...
@@ -544,6 +548,8 @@ class TasksApi(viewsets.ViewSet):
task_condition
=
{
'create_date__gte'
:
q_start_date
,
'create_date__lt'
:
q_end_date
}
if
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"
})
\
.
values
(
'area'
)
.
annotate
(
avg_score_svc
=
Round
(
Avg
(
'service_score'
),
2
),
avg_score_bus
=
Round
(
Avg
(
'business_score'
),
2
),
...
...
@@ -559,7 +565,7 @@ class TasksApi(viewsets.ViewSet):
except
EmptyPage
:
seats
=
paginator
.
page
(
paginator
.
num_pages
)
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
,
'username'
:
username
})
@
action
([
'post'
],
detail
=
False
)
def
score_detail
(
self
,
req
:
Request
):
...
...
src/inspect_report/utils/account.py
View file @
e2914e25
...
...
@@ -9,6 +9,8 @@ from functools import wraps
from
rest_framework.request
import
Request
from
rest_framework.response
import
Response
from
config.config
import
USER_INFO_URL
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -32,9 +34,9 @@ def get_account_info(func):
"""
@
wraps
(
func
)
def
account_info
(
obj
,
req
:
Request
,
*
args
,
**
kw
):
logger
.
info
(
'req中的data为: '
+
json
.
dumps
(
req
.
COOKIES
))
#
logger.info('req中的data为: ' + json.dumps(req.COOKIES))
cookie_jar
=
transfer_cookie
(
req
.
COOKIES
)
info
=
requests
.
get
(
'http://172.17.1.74:8248/getUserInfo'
,
cookies
=
cookie_jar
)
info
=
requests
.
get
(
USER_INFO_URL
,
cookies
=
cookie_jar
)
# logger.info('req中的query_params为: ', req.query_params)
if
info
.
json
()[
'code'
]
!=
200
:
return
Response
({
'code'
:
-
1
,
'msg'
:
'未能获取用户信息'
})
...
...
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