Commit e4fdc820 by Aeolus

update

parent e48d50f4
...@@ -7,9 +7,10 @@ author:Aeolus ...@@ -7,9 +7,10 @@ author:Aeolus
""" """
import logging import logging
from flask import Blueprint, request, jsonify from flask import Blueprint, request, jsonify, g
from models.models import Machine, Production, Hatch from models.base_model import db
from models.models import Machine, Production, Hatch, RentDetail
from utils.error_code import MACHINE_NOT_EXIST_ERROR, HATCH_NOT_EXIST_ERROR from utils.error_code import MACHINE_NOT_EXIST_ERROR, HATCH_NOT_EXIST_ERROR
from utils.my_response import BaseResponse from utils.my_response import BaseResponse
...@@ -93,3 +94,21 @@ def get_production_info(): ...@@ -93,3 +94,21 @@ def get_production_info():
} }
return BaseResponse(data=hatch_data) return BaseResponse(data=hatch_data)
@hatch_route.route("/hatch_open", methods=["POST"])
def run_hatch_open():
json_data = request.get_json()
machine_no = json_data['machine_no']
hatch_no = json_data['hatch_no']
user_id = g.user.id
rent_detail = RentDetail.query.filter(RentDetail.user_id == user_id, RentDetail.machine_no == machine_no,
RentDetail.hatch_no == hatch_no,
RentDetail.status != -1,
RentDetail.is_take == 0).order_by(RentDetail.id.desc()).first()
if rent_detail:
rent_detail.is_take = 1
db.session.add(rent_detail)
db.session.commit()
return BaseResponse()
...@@ -281,6 +281,7 @@ def get_user_detail_record(): ...@@ -281,6 +281,7 @@ def get_user_detail_record():
detail_data = [] detail_data = []
for i in rent_detail: for i in rent_detail:
tmp_data = {} tmp_data = {}
tmp_data["machine_no"] = i.machine_no
tmp_data["hatch_no"] = i.hatch_no tmp_data["hatch_no"] = i.hatch_no
tmp_data["production_id"] = i.production_id tmp_data["production_id"] = i.production_id
tmp_data["is_take"] = i.is_take tmp_data["is_take"] = i.is_take
......
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