Commit ba0f3f50 by 冯佳佳

update

parent 6f125435
......@@ -291,18 +291,36 @@ def run_tally_over():
json_data = request.get_json()
machine_no = json_data['machine_no']
hatch_no = json_data['hatch_no']
tally_type = json_data["type"] # 补货类型 1全部缺货锁 2打开指定仓号
user_id = g.user.id
tally_record = TallyRecord.query.filter(TallyRecord.user_no == g.user.user_no, TallyRecord.machine_no == machine_no,
TallyRecord.hatch_no == hatch_no,
TallyRecord.status == 1).order_by(TallyRecord.id.desc()).first()
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()
if hatch:
hatch.status = 1
db.session.add(hatch)
db.session.commit()
if tally_type == 1:
for i in hatch_no:
tally_record = TallyRecord.query.filter(TallyRecord.user_no == g.user.user_no,
TallyRecord.machine_no == machine_no,
TallyRecord.hatch_no == i,
TallyRecord.status == 1).order_by(TallyRecord.id.desc()).first()
if tally_record:
tally_record.status = 2
db.session.add(tally_record)
db.session.commit()
hatch = Hatch.query.filter_by(machine_no=machine_no, hatch_no=hatch_no, status=2).update({"status": 1})
db.session.commit()
elif tally_type == 2:
tally_record = TallyRecord.query.filter(TallyRecord.user_no == g.user.user_no, TallyRecord.machine_no == machine_no,
TallyRecord.hatch_no == hatch_no,
TallyRecord.status == 1).order_by(TallyRecord.id.desc()).first()
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()
if hatch:
hatch.status = 1
db.session.add(hatch)
db.session.commit()
else:
pass
return BaseResponse()
......
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