Commit ba55c42b by Aeolus

补货逻辑修改

parent 1b09c945
......@@ -114,7 +114,7 @@ def run_hatch_open():
rent_detail.is_take = 1
db.session.add(rent_detail)
# 查询到柜子中的物品 数量减一
sql = "update earphone_hatch set left_count = left_count - 1 where machine_no = '{}' and hatch_no='{}'".format(
sql = "update hatch set left_count = left_count - 1 where machine_no = '{}' and hatch_no='{}'".format(
machine_no, hatch_no)
db.session.execute(sql)
db.session.commit()
......
......@@ -263,8 +263,8 @@ def run_tally_start():
elif tally_type == 2:
hatch_nos = json_data['hatch_nos']
hatch_list = Hatch.query.filter(Hatch.machine_no == machine_no, Hatch.status == 2,
Hatch.hatch_no.in_(hatch_nos)).order_by(Hatch.hatch_no.asc()).all()
hatch_list = Hatch.query.filter(Hatch.machine_no == machine_no, Hatch.hatch_no.in_(hatch_nos)).order_by(
Hatch.hatch_no.asc()).all()
if not hatch_list:
return jsonify(HATCH_NOT_EXIST_ERROR)
else:
......@@ -306,9 +306,9 @@ def run_tally_over():
if tally_record:
tally_record.status = 2
db.session.add(tally_record)
db.session.commit()
hatch = Hatch.query.filter(Hatch.machine_no == machine_no, Hatch.hatch_no.in_(hatch_no),
Hatch.status == 2).update({"status": 1})
sql = "update hatch set left_count = total_count , status=1 where machine_no = '{}' and hatch_no='{}'".format(
machine_no, i)
db.session.execute(sql)
db.session.commit()
elif tally_type == 2:
......@@ -319,9 +319,10 @@ def run_tally_over():
if tally_record:
tally_record.status = 2
db.session.add(tally_record)
hatch = Hatch.query.filter_by(machine_no=machine_no, hatch_no=hatch_no, status=2).first()
hatch = Hatch.query.filter_by(machine_no=machine_no, hatch_no=hatch_no).first()
if hatch:
hatch.status = 1
hatch.left_count = hatch.total_count
db.session.add(hatch)
db.session.commit()
else:
......
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