Commit 21635be2 by Aeolus

update

parent 1eff871a
...@@ -130,7 +130,7 @@ def run_bind_serial_num(): ...@@ -130,7 +130,7 @@ def run_bind_serial_num():
machine = Machine.query.filter_by(machine_no=machine_no).first() machine = Machine.query.filter_by(machine_no=machine_no).first()
if not machine: if not machine:
return jsonify(MACHINE_NOT_EXIST_ERROR) return jsonify(MACHINE_NOT_EXIST_ERROR)
machine.device_id = serial_num machine.qrcode_no = serial_num
db.session.add(machine) db.session.add(machine)
db.session.commit() db.session.commit()
return BaseResponse(data={"machine_no": machine_no, "serial_num": serial_num}) return BaseResponse(data={"machine_no": machine_no, "serial_num": serial_num})
...@@ -48,7 +48,13 @@ def run_hatch_list(): ...@@ -48,7 +48,13 @@ def run_hatch_list():
where hatch.machine_no in ( select machine_no from admin_machine where where hatch.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = {user_id} and admin_machine.status = 1) admin_machine.user_id = {user_id} and admin_machine.status = 1)
""".format(user_id=admin.id) """.format(user_id=admin.id)
if g.user.level == 1:
where_sql = " where 0=0"
else:
where_sql = """ where p.id in ( select production_type_id from admin_production_type where
admin_production_type.user_id = {} and admin_production_type.status = 1
)
)""".format(admin.id)
where_sql = " " where_sql = " "
if keyword: if keyword:
where_sql += """ where_sql += """
......
...@@ -413,8 +413,7 @@ def run_production_type_list(): ...@@ -413,8 +413,7 @@ def run_production_type_list():
if g.user.level == 1: if g.user.level == 1:
where_sql = " where 0=0" where_sql = " where 0=0"
else: else:
where_sql = """ where p.id in ( where_sql = """ where p.id in ( select production_type_id from admin_production_type where
select production_type_id from admin_production_type where
admin_production_type.user_id = {} and admin_production_type.status = 1 admin_production_type.user_id = {} and admin_production_type.status = 1
) )
)""".format(admin.id) )""".format(admin.id)
...@@ -505,8 +504,14 @@ def get_production_type_detail(): ...@@ -505,8 +504,14 @@ def get_production_type_detail():
select_sql = """select b.id,b.production_type_name,b.status select_sql = """select b.id,b.production_type_name,b.status
""" """
from_sql = """ from production_type b """ from_sql = """ from production_type b """
if g.user.level == 1:
where_sql = " where b.id ={}".format(production_type_id) where_sql = " where 0=0"
else:
where_sql = """ where p.id in ( select production_type_id from admin_production_type where
admin_production_type.user_id = {} and admin_production_type.status = 1
)
)""".format(admin.id)
where_sql += " and b.id ={}".format(production_type_id)
result = db.session.execute(select_sql + from_sql + where_sql).fetchall() result = db.session.execute(select_sql + from_sql + where_sql).fetchall()
if not result or len(result) != 1: if not result or len(result) != 1:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment