Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Automat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冯佳佳
Automat
Commits
53a0abe5
Commit
53a0abe5
authored
Jan 19, 2022
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
45662561
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
13 deletions
+16
-13
myapps/automat/api/tallyman_portal.py
+3
-4
myapps/pc_management/api/machine_portal.py
+6
-4
service/admin_service.py
+2
-1
service/tallyman_service.py
+3
-2
utils/jwt_util.py
+2
-2
No files found.
myapps/automat/api/tallyman_portal.py
View file @
53a0abe5
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
datetime
import
datetime
import
logging
import
logging
import
time
import
time
...
@@ -340,13 +340,12 @@ def get_tally_report():
...
@@ -340,13 +340,12 @@ def get_tally_report():
machine_info
=
TallymanService
.
get_machine_info
(
g
.
user
,
machine_no
)
machine_info
=
TallymanService
.
get_machine_info
(
g
.
user
,
machine_no
)
if
not
machine_info
:
if
not
machine_info
:
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
empty_number
=
int
(
machine_info
[
"empty_number"
])
empty_number
=
machine_info
[
"empty_number"
]
over_number
=
db
.
session
.
query
(
func
.
sum
(
TallyRecord
.
tally_count
))
.
filter
(
TallyRecord
.
user_no
==
g
.
user
.
user_no
,
over_number
=
db
.
session
.
query
(
func
.
sum
(
TallyRecord
.
tally_count
))
.
filter
(
TallyRecord
.
user_no
==
g
.
user
.
user_no
,
TallyRecord
.
machine_no
==
machine_no
,
TallyRecord
.
machine_no
==
machine_no
,
TallyRecord
.
status
==
2
)
.
scalar
()
TallyRecord
.
status
==
2
)
.
scalar
()
return
BaseResponse
(
data
=
{
"empty_number"
:
empty_number
,
"over_number"
:
over_number
})
return
BaseResponse
(
data
=
{
"empty_number"
:
empty_number
,
"over_number"
:
over_number
if
over_number
else
0
})
@tallyman_route.route
(
'machine_activate'
,
methods
=
[
"post"
])
@tallyman_route.route
(
'machine_activate'
,
methods
=
[
"post"
])
...
...
myapps/pc_management/api/machine_portal.py
View file @
53a0abe5
...
@@ -45,11 +45,13 @@ def run_machine_list():
...
@@ -45,11 +45,13 @@ def run_machine_list():
from_sql
=
""" from machine
from_sql
=
""" from machine
left join place on machine.place_id = place.id
left join place on machine.place_id = place.id
left join business on machine.business_id = business.id
left join business on machine.business_id = business.id
where machine.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = {user_id} and admin_machine.status = 1)
"""
.
format
(
user_id
=
admin
.
id
)
where_sql
=
" "
"""
if
g
.
user
.
level
==
1
:
where_sql
=
" where 0=0 "
else
:
where_sql
=
""" where machine.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = {user_id} and admin_machine.status = 1)"""
.
format
(
user_id
=
admin
.
id
)
if
keyword
:
if
keyword
:
where_sql
+=
"""
where_sql
+=
"""
and CONCAT(machine.machine_no,ifnull(machine.qrcode_no,'')) LIKE '
%
{keyword}
%
'
and CONCAT(machine.machine_no,ifnull(machine.qrcode_no,'')) LIKE '
%
{keyword}
%
'
...
...
service/admin_service.py
View file @
53a0abe5
...
@@ -171,8 +171,9 @@ class AdminService(object):
...
@@ -171,8 +171,9 @@ class AdminService(object):
for
info
in
result
:
for
info
in
result
:
return_data
.
append
(
return_data
.
append
(
{
"user_name"
:
info
.
user_name
,
"phone"
:
info
.
phone
,
"level"
:
info
.
level
,
"status"
:
info
.
status
,
{
"user_name"
:
info
.
user_name
,
"phone"
:
info
.
phone
,
"level"
:
info
.
level
,
"status"
:
info
.
status
,
"comment"
:
info
.
comment
,
"id"
:
info
.
id
,
"user_no"
:
info
.
user_no
,
"business_id"
:
info
.
business_id
,
"comment"
:
info
.
comment
,
"id"
:
info
.
id
,
"user_no"
:
info
.
user_no
,
"create_time"
:
info
.
created_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"create_time"
:
info
.
created_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"update_time"
:
info
.
updated_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"update_time"
:
info
.
updated_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"business_id"
:
info
.
business_id
,
"business_name"
:
info
.
business_name
,
})
})
return
{
"list"
:
return_data
,
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
total_count
}
return
{
"list"
:
return_data
,
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
total_count
}
service/tallyman_service.py
View file @
53a0abe5
...
@@ -48,7 +48,8 @@ class TallymanService(object):
...
@@ -48,7 +48,8 @@ class TallymanService(object):
cur_machine
[
'short_address'
]
=
machine_info
.
short_address
cur_machine
[
'short_address'
]
=
machine_info
.
short_address
cur_machine
[
'address'
]
=
machine_info
.
address
cur_machine
[
'address'
]
=
machine_info
.
address
cur_machine
[
'place_id'
]
=
machine_info
.
place_id
cur_machine
[
'place_id'
]
=
machine_info
.
place_id
cur_machine
[
'empty_number'
]
=
db
.
session
.
query
(
func
.
sum
(
Hatch
.
total_count
-
Hatch
.
left_count
))
.
filter
(
empty_number
=
db
.
session
.
query
(
func
.
sum
(
Hatch
.
total_count
-
Hatch
.
left_count
))
.
filter
(
Hatch
.
machine_no
==
machine_info
.
machine_no
,
Hatch
.
machine_no
==
machine_info
.
machine_no
,
Hatch
.
status
==
2
)
.
scalar
()
Hatch
.
status
.
in_
([
1
,
2
]))
.
scalar
()
cur_machine
[
'empty_number'
]
=
empty_number
if
empty_number
else
0
return
cur_machine
return
cur_machine
utils/jwt_util.py
View file @
53a0abe5
#!usr/bin/.env python # -*- coding:utf-8 _*- """ @version: author:Aeolus @time: 2021/03/30 @file: jwt_util.py @function: @modify: """ import jwt from flask import current_app def generate_jwt(payload, expiry, secret=None): """ 生成jwt :param payload: dict 载荷 :param expiry: datetime 有效期 :param secret: 密钥 :return: jwt """ _payload = {'exp': expiry} _payload.update(payload) if not secret: secret = current_app.config['SECRET_KEY'] token = jwt.encode(_payload, secret, algorithm='HS256') return token def verify_jwt(token, secret=None): """ 检验jwt :param token: jwt :param secret: 密钥 :return: dict: payload """ if not secret: secret = current_app.config['SECRET_KEY'] try: payload = jwt.decode(token, secret, algorithms=['HS256']) except jwt.PyJWTError: payload = None return payload if __name__ == '__main__': import time from config.env_path_config import env_path from dotenv import load_dotenv load_dotenv(dotenv_path=env_path, verbose=True, override=True) import os SECRET_KEY = os.getenv('SECRET_KEY') token = generate_jwt({"user_id": 10}, time.time() + 6000, SECRET_KEY) # token = generate_jwt({"user_no": 'SK000007'}, time.time() + 6000, SECRET_KEY) print(token) # for i in range(10): # result = verify_jwt(token, 'secret') # print(result) # print(time.time()) # time.sleep(1)
#!usr/bin/.env python # -*- coding:utf-8 _*- """ @version: author:Aeolus @time: 2021/03/30 @file: jwt_util.py @function: @modify: """ import jwt from flask import current_app def generate_jwt(payload, expiry, secret=None): """ 生成jwt :param payload: dict 载荷 :param expiry: datetime 有效期 :param secret: 密钥 :return: jwt """ _payload = {'exp': expiry} _payload.update(payload) if not secret: secret = current_app.config['SECRET_KEY'] token = jwt.encode(_payload, secret, algorithm='HS256') return token def verify_jwt(token, secret=None): """ 检验jwt :param token: jwt :param secret: 密钥 :return: dict: payload """ if not secret: secret = current_app.config['SECRET_KEY'] try: payload = jwt.decode(token, secret, algorithms=['HS256']) except jwt.PyJWTError: payload = None return payload if __name__ == '__main__': import time from config.env_path_config import env_path from dotenv import load_dotenv load_dotenv(dotenv_path=env_path, verbose=True, override=True) import os SECRET_KEY = os.getenv('SECRET_KEY') # token = generate_jwt({"user_id": 1}, time.time() + 6000, SECRET_KEY) token = generate_jwt({"user_no": 'XXTM000015'}, time.time() + 6000, SECRET_KEY) print(token) # for i in range(10): # result = verify_jwt(token, 'secret') # print(result) # print(time.time()) # time.sleep(1)
\ No newline at end of file
\ No newline at end of file
...
...
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