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
6df67ee0
Commit
6df67ee0
authored
Jan 09, 2022
by
yanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
7b2fe02d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
21 deletions
+50
-21
myapps/management/api/machine_portal.py
+14
-13
myapps/management/api/tallyman_portal.py
+36
-8
No files found.
myapps/management/api/machine_portal.py
View file @
6df67ee0
...
...
@@ -118,22 +118,23 @@ def machine_query():
user_info
=
Management
.
query
.
filter_by
()
.
first
()
if
not
user_info
:
return
TOKEN_NOT_VALID_ERROR
if
"machine_no"
in
json_date
:
machine_no
=
json_date
[
"machine_no"
]
machine_no
=
json_date
[
"machine_no"
]
if
"machine_no"
in
json_date
else
""
machine_mac
=
json_date
[
"machine_mac"
]
if
"machine_mac"
in
json_date
else
""
place_name
=
json_date
[
"place_name"
]
if
"place_name"
in
json_date
else
""
if
"status"
in
json_date
:
status
=
json_date
[
"status"
]
query1
=
"select a.* ,b.management_id FROM machine as a JOIN management_machine as b ON "
\
"a.machine_no = b.machine_no WHERE management_id='{}' and a.machine_no like '{}' limit {},{}"
.
\
format
(
user_id
,
"
%
"
+
machine_no
+
"
%
"
,
(
page
-
1
)
*
page_size
,
page
*
page_size
)
elif
"machine_mac"
in
json_date
:
machine_mac
=
json_date
[
"machine_mac"
]
# machine_result = Machine.query.filter(Machine.mac.like("%"+machine_mac+"%")).offset((page-1)*page_size).limit(page_size)
query1
=
"select a.* ,b.management_id FROM machine as a JOIN management_machine as b ON "
\
"a.machine_no = b.machine_no WHERE management_id='{}' and mac like '{}' limit {},{}"
.
\
format
(
user_id
,
"
%
"
+
machine_mac
+
"
%
"
,
(
page
-
1
)
*
page_size
,
page
*
page_size
)
"a.machine_no = b.machine_no WHERE management_id='{}' and a.machine_no like '{}' and "
\
"a.mac like '{}' and a.address like '{}' and a.status ={} limit {},{}"
.
\
format
(
user_id
,
"
%
"
+
machine_no
+
"
%
"
,
"
%
"
+
machine_mac
+
"
%
"
,
"
%
"
+
place_name
+
"
%
"
,
status
,
(
page
-
1
)
*
page_size
,
page
*
page_size
)
else
:
query1
=
"select a.* ,b.management_id FROM machine as a JOIN management_machine as b ON "
\
"a.machine_no = b.machine_no WHERE management_id={} limit {},{}"
.
\
format
(
user_id
,
(
page
-
1
)
*
page_size
,
page
*
page_size
)
machine_result
=
db
.
session
.
execute
(
query1
)
.
fetchall
()
"a.machine_no = b.machine_no WHERE management_id='{}' and a.machine_no like '{}' and "
\
"a.mac like '{}' and a.address like '{}' limit {},{}"
.
\
format
(
user_id
,
"
%
"
+
machine_no
+
"
%
"
,
"
%
"
+
machine_mac
+
"
%
"
,
"
%
"
+
place_name
+
"
%
"
,
(
page
-
1
)
*
page_size
,
page
*
page_size
)
machine_result
=
db
.
session
.
execute
(
query1
)
.
fetchall
()
result_date
=
[]
# # 将数据遍历和筛选
for
i
in
machine_result
:
...
...
myapps/management/api/tallyman_portal.py
View file @
6df67ee0
...
...
@@ -11,7 +11,7 @@ from config.commen_config import LOGIN_TYPE
from
models.base_model
import
db
from
models.models
import
TallymanAccount
,
TallymanMachine
,
TallymanLoginRecord
,
Machine
,
Hatch
,
TallyRecord
,
\
TallymanPlace
,
Management
TallymanPlace
,
Management
,
TallymanMachine
from
service.tallyman_service
import
TallymanService
from
utils.error_code
import
TALLYMAN_ACCOUNT_EXIST
,
PHONE_NOT_VALID_ERROR
,
TOKEN_NOT_VALID_ERROR
,
PASSWORD_ERROR
,
\
TALLYMAN_ACCOUNT_NOT_EXIST
,
MACHINE_NOT_EXIST_ERROR
,
HATCH_NOT_EXIST_ERROR
,
MACHINE_ACTIVATED_ERROR
,
\
...
...
@@ -86,11 +86,20 @@ def tallyman():
if
not
user_res
:
return
TOKEN_NOT_VALID_ERROR
# 多表查询
query1
=
"SELECT a.*,b.management_id,c.place_id , d.place_name FROM ((tallyman_account as a JOIN "
\
"management_tallyman as b on a.id = b.tallyman_id) JOIN tallyman_place as c on c.user_id = a.id) "
\
"JOIN place as d ON d.id = c.place_id WHERE b.management_id = {} and a.user_name like '{}' and"
\
" d.place_name like '{}' limit {},{}"
\
.
format
(
user_id
,
"
%
"
+
tallyman
+
"
%
"
,
"
%
"
+
place_name
+
"
%
"
,
(
page
-
1
)
*
page_size
,
page
*
page_size
)
if
"status"
in
json_date
:
status
=
json_date
[
"status"
]
query1
=
"SELECT a.*,b.management_id,c.place_id , d.place_name FROM ((tallyman_account as a JOIN "
\
"management_tallyman as b on a.id = b.tallyman_id) JOIN tallyman_place as c on c.user_id = a.id) "
\
"JOIN place as d ON d.id = c.place_id WHERE b.management_id = {} and a.user_name like '{}' and"
\
" d.place_name like '{}' and a.status = {} LIMIT {},{}"
\
.
format
(
user_id
,
"
%
"
+
tallyman
+
"
%
"
,
"
%
"
+
place_name
+
"
%
"
,
status
,(
page
-
1
)
*
page_size
,
page
*
page_size
)
else
:
query1
=
"SELECT a.*,b.management_id,c.place_id , d.place_name FROM ((tallyman_account as a JOIN "
\
"management_tallyman as b on a.id = b.tallyman_id) JOIN tallyman_place as c on c.user_id = a.id) "
\
"JOIN place as d ON d.id = c.place_id WHERE b.management_id = {} and a.user_name like '{}' and"
\
" d.place_name like '{}' LIMIT {},{}"
\
.
format
(
user_id
,
"
%
"
+
tallyman
+
"
%
"
,
"
%
"
+
place_name
+
"
%
"
,
(
page
-
1
)
*
page_size
,
page
*
page_size
)
tallyman_result
=
db
.
session
.
execute
(
query1
)
.
fetchall
()
result_date
=
[]
for
i
in
tallyman_result
:
...
...
@@ -128,4 +137,24 @@ def edit_man():
db
.
session
.
add
(
man_result
)
return
BaseResponse
(
date
=
{
"success"
:
True
})
# 为补货员添加机器
\ No newline at end of file
# 为补货员添加机器,需要tally_id,machine,place_id
@tallyman_route.route
(
"/give_machine"
,
methods
=
[
"POST"
])
def
for_machine
():
json_date
=
request
.
get_json
()
tallyman_id
=
json_date
[
"tallyman_id"
]
machine
=
json_date
[
"machine"
]
place_id
=
json_date
[
"place_id"
]
for
i
in
machine
:
tallYman_machine
=
TallymanMachine
()
tallYman_machine
.
user_id
=
tallyman_id
tallYman_machine
.
machine_no
=
i
tallYman_machine
.
status
=
1
db
.
session
.
add
(
tallYman_machine
)
db
.
session
.
commit
()
tallyman_place
=
TallymanPlace
()
tallyman_place
.
place_id
=
place_id
tallyman_place
.
user_id
=
tallyman_id
tallyman_place
.
status
=
1
db
.
session
.
add
(
tallyman_place
)
db
.
session
.
commit
()
return
BaseResponse
(
date
=
{
"success"
:
True
})
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