Commit ba55c42b by Aeolus

补货逻辑修改

parent 1b09c945
...@@ -114,7 +114,7 @@ def run_hatch_open(): ...@@ -114,7 +114,7 @@ def run_hatch_open():
rent_detail.is_take = 1 rent_detail.is_take = 1
db.session.add(rent_detail) 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) machine_no, hatch_no)
db.session.execute(sql) db.session.execute(sql)
db.session.commit() db.session.commit()
......
...@@ -263,8 +263,8 @@ def run_tally_start(): ...@@ -263,8 +263,8 @@ def run_tally_start():
elif tally_type == 2: elif tally_type == 2:
hatch_nos = json_data['hatch_nos'] hatch_nos = json_data['hatch_nos']
hatch_list = Hatch.query.filter(Hatch.machine_no == machine_no, Hatch.status == 2, hatch_list = Hatch.query.filter(Hatch.machine_no == machine_no, Hatch.hatch_no.in_(hatch_nos)).order_by(
Hatch.hatch_no.in_(hatch_nos)).order_by(Hatch.hatch_no.asc()).all() Hatch.hatch_no.asc()).all()
if not hatch_list: if not hatch_list:
return jsonify(HATCH_NOT_EXIST_ERROR) return jsonify(HATCH_NOT_EXIST_ERROR)
else: else:
...@@ -306,10 +306,10 @@ def run_tally_over(): ...@@ -306,10 +306,10 @@ def run_tally_over():
if tally_record: if tally_record:
tally_record.status = 2 tally_record.status = 2
db.session.add(tally_record) db.session.add(tally_record)
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() db.session.commit()
hatch = Hatch.query.filter(Hatch.machine_no == machine_no, Hatch.hatch_no.in_(hatch_no),
Hatch.status == 2).update({"status": 1})
db.session.commit()
elif tally_type == 2: elif tally_type == 2:
tally_record = TallyRecord.query.filter(TallyRecord.user_no == g.user.user_no, tally_record = TallyRecord.query.filter(TallyRecord.user_no == g.user.user_no,
...@@ -319,11 +319,12 @@ def run_tally_over(): ...@@ -319,11 +319,12 @@ def run_tally_over():
if tally_record: if tally_record:
tally_record.status = 2 tally_record.status = 2
db.session.add(tally_record) 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: if hatch:
hatch.status = 1 hatch.status = 1
db.session.add(hatch) hatch.left_count = hatch.total_count
db.session.commit() db.session.add(hatch)
db.session.commit()
else: else:
pass pass
......
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