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
aa14c113
Commit
aa14c113
authored
Jan 17, 2022
by
Aeolus
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'aeolus'
parents
21fdc72c
3441538c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
98 deletions
+70
-98
models/models.py
+2
-2
myapps/pc_management/api/__init__.py
+2
-0
myapps/pc_management/api/hatch_portal.py
+66
-96
No files found.
models/models.py
View file @
aa14c113
...
@@ -334,8 +334,8 @@ class RentDetail(Base):
...
@@ -334,8 +334,8 @@ class RentDetail(Base):
title
=
Column
(
String
(
200
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品标题'
)
title
=
Column
(
String
(
200
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品标题'
)
brand_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'品牌ID'
)
brand_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'品牌ID'
)
brand_name
=
Column
(
String
(
100
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品名称'
)
brand_name
=
Column
(
String
(
100
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品名称'
)
cat
e_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'分类ID'
)
production_typ
e_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'分类ID'
)
cat
e_name
=
Column
(
String
(
200
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品标题'
)
production_typ
e_name
=
Column
(
String
(
200
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
comment
=
'商品标题'
)
price
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'价格'
)
price
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'价格'
)
rent_count
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'数量'
)
rent_count
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'数量'
)
img
=
Column
(
String
(
200
,
'utf8mb4_unicode_ci'
))
img
=
Column
(
String
(
200
,
'utf8mb4_unicode_ci'
))
...
...
myapps/pc_management/api/__init__.py
View file @
aa14c113
...
@@ -16,6 +16,7 @@ from myapps.pc_management.api.place_portal import place_route
...
@@ -16,6 +16,7 @@ from myapps.pc_management.api.place_portal import place_route
from
myapps.pc_management.api.machine_portal
import
machine_route
from
myapps.pc_management.api.machine_portal
import
machine_route
from
myapps.pc_management.api.file_protal
import
file_route
from
myapps.pc_management.api.file_protal
import
file_route
from
myapps.pc_management.api.production_portal
import
production_route
from
myapps.pc_management.api.production_portal
import
production_route
from
myapps.pc_management.api.hatch_portal
import
hatch_route
def
register_sukang_blueprint
(
app
:
Flask
):
def
register_sukang_blueprint
(
app
:
Flask
):
...
@@ -25,3 +26,4 @@ def register_sukang_blueprint(app: Flask):
...
@@ -25,3 +26,4 @@ def register_sukang_blueprint(app: Flask):
app
.
register_blueprint
(
machine_route
,
url_prefix
=
prefix
+
"/machine"
)
app
.
register_blueprint
(
machine_route
,
url_prefix
=
prefix
+
"/machine"
)
app
.
register_blueprint
(
file_route
,
url_prefix
=
prefix
+
"/file"
)
app
.
register_blueprint
(
file_route
,
url_prefix
=
prefix
+
"/file"
)
app
.
register_blueprint
(
production_route
,
url_prefix
=
prefix
+
"/production"
)
app
.
register_blueprint
(
production_route
,
url_prefix
=
prefix
+
"/production"
)
app
.
register_blueprint
(
hatch_route
,
url_prefix
=
prefix
+
"/hatch"
)
myapps/pc_management/api/hatch_portal.py
View file @
aa14c113
...
@@ -15,7 +15,8 @@ from flask import Blueprint, g, request, jsonify
...
@@ -15,7 +15,8 @@ from flask import Blueprint, g, request, jsonify
from
config.commen_config
import
DISCOUNTS_TYPES
from
config.commen_config
import
DISCOUNTS_TYPES
from
models.base_model
import
db
from
models.base_model
import
db
from
models.models
import
AdminMachine
,
Machine
,
Hatch
from
models.models
import
AdminMachine
,
Machine
,
Hatch
from
utils.error_code
import
MACHINE_NOT_EXIST_ERROR
,
HATCH_COUNT_MAX_ERROR
,
HATCH_NO_DUPLICATE_ERROR
from
utils.error_code
import
MACHINE_NOT_EXIST_ERROR
,
HATCH_COUNT_MAX_ERROR
,
HATCH_NO_DUPLICATE_ERROR
,
\
HATCH_NOT_EXIST_ERROR
from
utils.my_response
import
BaseResponse
from
utils.my_response
import
BaseResponse
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -30,8 +31,8 @@ def run_hatch_list():
...
@@ -30,8 +31,8 @@ def run_hatch_list():
:return:
:return:
"""
"""
json_data
=
request
.
get_json
()
json_data
=
request
.
get_json
()
page
=
json_data
.
get
(
"page"
,
None
)
page
=
json_data
.
get
(
"page"
,
1
)
page_size
=
json_data
.
get
(
"pageSize"
,
None
)
page_size
=
json_data
.
get
(
"pageSize"
,
10
)
keyword
=
json_data
.
get
(
"keyword"
,
None
)
keyword
=
json_data
.
get
(
"keyword"
,
None
)
admin
=
g
.
user
admin
=
g
.
user
...
@@ -99,7 +100,7 @@ def run_add_machine():
...
@@ -99,7 +100,7 @@ def run_add_machine():
admin_machine
=
AdminMachine
.
query
.
filter_by
(
machine_no
=
machine_no
,
user_id
=
g
.
user
.
id
,
status
=
1
)
.
first
()
admin_machine
=
AdminMachine
.
query
.
filter_by
(
machine_no
=
machine_no
,
user_id
=
g
.
user
.
id
,
status
=
1
)
.
first
()
if
not
admin_machine
:
if
not
admin_machine
:
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
machine
=
Machine
.
query
.
filter
_by
(
machine_no
=
machine_no
,
status
=
1
)
.
first
()
machine
=
Machine
.
query
.
filter
(
Machine
.
machine_no
==
machine_no
,
Machine
.
status
!=
-
1
)
.
first
()
if
not
machine
:
if
not
machine
:
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
...
@@ -174,107 +175,76 @@ def run_edit_hatch():
...
@@ -174,107 +175,76 @@ def run_edit_hatch():
hatch_id
=
json_data
[
"hatch_id"
]
hatch_id
=
json_data
[
"hatch_id"
]
hatch
=
Hatch
.
query
.
filter_by
(
id
=
hatch_id
)
.
first
()
hatch
=
Hatch
.
query
.
filter_by
(
id
=
hatch_id
)
.
first
()
if
not
hatch
:
if
not
hatch
:
return
jsonify
()
return
jsonify
(
HATCH_NOT_EXIST_ERROR
)
machine_no
=
json_data
[
"machine_no"
]
admin_machine
=
AdminMachine
.
query
.
filter_by
(
machine_no
=
hatch
.
machine_no
,
user_id
=
g
.
user
.
id
,
status
=
1
)
.
first
()
admin_machine
=
AdminMachine
.
query
.
filter_by
(
machine_no
=
machine_no
,
user_id
=
g
.
user
.
id
,
status
=
1
)
.
first
()
if
not
admin_machine
:
if
not
admin_machine
:
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
machine
=
Machine
.
query
.
filter
_by
(
machine_no
=
machine_no
,
status
=
1
)
.
first
()
machine
=
Machine
.
query
.
filter
(
Machine
.
machine_no
==
hatch
.
machine_no
,
Machine
.
status
!=
-
1
)
.
first
()
if
not
machine
:
if
not
machine
:
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
hatch_num
=
machine
.
hatch_number
production_id
=
json_data
.
get
(
"production_id"
,
None
)
hatchs
=
Hatch
.
query
.
filter_by
(
machine_no
=
machine_no
)
.
all
()
production_name
=
json_data
.
get
(
"production_name"
,
None
)
if
len
(
hatchs
)
>=
hatch_num
:
title
=
json_data
.
get
(
"title"
,
None
)
return
jsonify
(
HATCH_COUNT_MAX_ERROR
)
brand_id
=
json_data
.
get
(
"brand_id"
,
None
)
brand_name
=
json_data
.
get
(
"brand_name"
,
None
)
hatch_no
=
int
(
json_data
[
"hatch_no"
])
production_type_id
=
json_data
.
get
(
"production_type_id"
,
None
)
for
i
in
hatchs
:
production_type_name
=
json_data
.
get
(
"production_type_name"
,
None
)
if
i
.
hatch_no
==
hatch_no
:
price
=
json_data
.
get
(
"price"
,
None
)
return
jsonify
(
HATCH_NO_DUPLICATE_ERROR
)
original_price
=
json_data
.
get
(
"original_price"
,
None
)
weight
=
json_data
.
get
(
"weight"
,
None
)
production_id
=
json_data
[
"production_id"
]
weight_unit
=
json_data
.
get
(
"weight_unit"
,
None
)
production_name
=
json_data
[
"production_name"
]
weight_error
=
json_data
.
get
(
"weight_error"
,
None
)
title
=
json_data
.
get
(
"title"
,
""
)
expiration_date
=
json_data
.
get
(
"expiration_date"
,
None
)
brand_id
=
json_data
.
get
(
"brand_id"
,
0
)
expiration_date_unit
=
json_data
.
get
(
"expiration_date_unit"
,
None
)
brand_name
=
json_data
.
get
(
"brand_name"
,
0
)
is_expiration_date
=
json_data
.
get
(
"is_expiration_date"
,
None
)
production_type_id
=
json_data
.
get
(
"production_type_id"
,
0
)
production_type_name
=
json_data
.
get
(
"production_type_name"
,
0
)
price
=
json_data
.
get
(
"price"
,
0
)
original_price
=
json_data
.
get
(
"original_price"
,
0
)
weight
=
json_data
.
get
(
"weight"
,
0
)
weight_unit
=
json_data
.
get
(
"weight_unit"
,
"g"
)
weight_error
=
json_data
.
get
(
"weight_error"
,
0
)
expiration_date
=
json_data
.
get
(
"expiration_date"
,
0
)
expiration_date_unit
=
json_data
.
get
(
"expiration_date_unit"
,
"月"
)
is_expiration_date
=
json_data
.
get
(
"is_expiration_date"
,
0
)
img
=
json_data
.
get
(
"img"
,
None
)
img
=
json_data
.
get
(
"img"
,
None
)
tags
=
json_data
.
get
(
"tags"
,
None
)
tags
=
json_data
.
get
(
"tags"
,
None
)
content
=
json_data
.
get
(
"content"
,
None
)
content
=
json_data
.
get
(
"content"
,
None
)
summary
=
json_data
.
get
(
"summary"
,
None
)
summary
=
json_data
.
get
(
"summary"
,
None
)
left_count
=
json_data
.
get
(
"left_count"
,
0
)
left_count
=
json_data
.
get
(
"left_count"
,
None
)
total_count
=
json_data
.
get
[
"total_count"
]
total_count
=
json_data
.
get
(
"total_count"
,
None
)
hatch_model
=
Hatch
()
if
production_id
:
hatch_model
.
machine_no
=
machine_no
hatch
.
production_id
=
production_id
hatch_model
.
hatch_no
=
hatch_no
hatch
.
production_name
=
production_name
hatch_model
.
production_id
=
production_id
if
title
:
hatch_model
.
production_name
=
production_name
hatch
.
title
=
title
hatch_model
.
title
=
title
if
brand_id
:
hatch_model
.
left_count
=
left_count
hatch
.
brand_id
=
brand_id
hatch_model
.
total_count
=
total_count
hatch
.
brand_name
=
brand_name
hatch_model
.
brand_id
=
brand_id
if
production_type_id
:
hatch_model
.
brand_name
=
brand_name
hatch
.
production_type_id
=
production_type_id
hatch_model
.
production_type_id
=
production_type_id
hatch
.
production_type_name
=
production_type_name
hatch_model
.
production_type_name
=
production_type_name
if
price
:
hatch_model
.
price
=
price
hatch
.
price
=
price
hatch_model
.
original_price
=
original_price
if
original_price
:
hatch_model
.
weight
=
weight
hatch
.
original_price
=
original_price
hatch_model
.
weight_unit
=
weight_unit
if
weight
:
hatch_model
.
weight_error
=
weight_error
hatch
.
weight
=
weight
hatch_model
.
expiration_date
=
expiration_date
if
weight_unit
:
hatch_model
.
expiration_date_unit
=
expiration_date_unit
hatch
.
weight_unit
=
weight_unit
hatch_model
.
is_expiration_date
=
is_expiration_date
if
weight_error
:
hatch_model
.
img
=
img
hatch
.
weight_error
=
weight_error
hatch_model
.
tags
=
tags
if
expiration_date
:
hatch_model
.
content
=
content
hatch
.
expiration_date
=
expiration_date
hatch_model
.
summary
=
summary
if
expiration_date_unit
:
db
.
session
.
add
(
hatch_model
)
hatch
.
expiration_date_unit
=
expiration_date_unit
if
is_expiration_date
:
hatch
.
is_expiration_date
=
is_expiration_date
if
img
:
hatch
.
img
=
img
if
tags
:
hatch
.
tags
=
tags
if
content
:
hatch
.
content
=
content
if
summary
:
hatch
.
summary
=
summary
if
left_count
:
hatch
.
left_count
=
left_count
if
total_count
:
hatch
.
total_count
=
total_count
db
.
session
.
add
(
hatch
)
db
.
session
.
commit
()
db
.
session
.
commit
()
return
BaseResponse
()
return
BaseResponse
()
@hatch_route.route
(
"machine_detail"
,
methods
=
[
"POST"
])
def
get_machine_detail
():
"""
:return:
"""
json_data
=
request
.
get_json
()
machine_no
=
json_data
[
"machine_no"
]
admin
=
g
.
user
select_sql
=
"""select machine.id, machine.machine_no, machine.device_id, machine.qrcode_no,machine.status,
machine.mac, machine.power, machine.hatch_number, machine.type,machine.place_id,
place.place_name, machine.discounts_id
"""
from_sql
=
""" from machine left join place on machine.place_id = place.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
=
" and machine.machine_no = {}"
.
format
(
machine_no
)
result
=
db
.
session
.
execute
(
select_sql
+
from_sql
+
where_sql
)
.
fetchall
()
if
not
result
or
len
(
result
)
!=
1
:
return
jsonify
(
MACHINE_NOT_EXIST_ERROR
)
info
=
result
[
0
]
return
BaseResponse
(
data
=
{
"machine_no"
:
info
.
machine_no
,
"device_id"
:
info
.
device_id
,
"place_name"
:
info
.
place_name
,
"mac"
:
info
.
mac
,
"power"
:
info
.
power
,
"hatch_number"
:
info
.
hatch_number
,
"type"
:
info
.
type
,
"status"
:
info
.
status
,
"place_id"
:
info
.
place_id
,
"discounts_id"
:
info
.
discounts_id
,
"discounts_name"
:
DISCOUNTS_TYPES
.
get
(
int
(
info
.
discounts_id
),
"无此优惠"
),
})
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