Commit 43d88d7c by 冯佳佳

update

parent 5a9dc40c
......@@ -19,15 +19,12 @@ logger = logging.getLogger(__name__)
machine_route = Blueprint('machine', __name__)
@machine_route.route('mac_upload', methods=["post"])
def run_machine_mac_upload():
json_data = request.get_json()
machine_no = json_data["machine_no"]
mac = json_data["mac"]
machine = Machine.query.filter_by(machine_no=machine_no, status=1).first()
if not machine:
return jsonify(MACHINE_NOT_EXIST_ERROR)
......@@ -42,7 +39,7 @@ def run_machine_power_upload():
json_data = request.get_json()
machine_no = json_data["machine_no"]
power = json_data["power"]
machine = Machine.query.filter_by(machine_no=machine_no, status=1).first()
if not machine:
return jsonify(MACHINE_NOT_EXIST_ERROR)
......@@ -57,7 +54,7 @@ def run_machine_hatch_number_upload():
json_data = request.get_json()
machine_no = json_data["machine_no"]
hatch_number = json_data["hatch_number"]
machine = Machine.query.filter_by(machine_no=machine_no, status=1).first()
if not machine:
return jsonify(MACHINE_NOT_EXIST_ERROR)
......@@ -72,13 +69,25 @@ def run_machine_hatch_data_upload():
json_data = request.get_json()
machine_no = json_data["machine_no"]
hatch_data = json_data["in_stock"]
machine = Machine.query.filter_by(machine_no=machine_no, status=1).first()
if not machine:
return jsonify(MACHINE_NOT_EXIST_ERROR)
Hatch.query.filter(Hatch.hatch_no.in_(hatch_data)).update({"status": 1})
db.session.commit()
Hatch.query.filter(Hatch.hatch_no.notin_(hatch_data)).update({"status": 2})
db.session.commit()
return BaseResponse()
@machine_route.route('get_machine_no', methods=["post"])
def run_get_machine_no():
json_data = request.get_json()
qrcode_no = json_data["qrcode_no"]
machine = Machine.query.filter_by(qrcode_no=qrcode_no, status=1).first()
if machine:
return BaseResponse(data={"machine_no": machine.machine_no})
else:
return jsonify(MACHINE_NOT_EXIST_ERROR)
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