コード例 #1
0
ファイル: tool.py プロジェクト: khanh585/PRM_Server
def getToolById(id):
    try:
        tool = ToolDAO.dbGet(id)
        if tool:
            return jsonify(tool.serialize()), 200
        else:
            return jsonify(tool), 200
    except Exception as e:
        print(e)
        return "Server error", 500
コード例 #2
0
def enoughQuantity(tool_id, tribulation_id, quantity):
    tribulation = TribulationDAO.dbGet(tribulation_id)
    tool_quantity = ToolDAO.dbGet(tool_id).quantity
    result = False
    try:
        list_tool = tft.query.filter(
            tft.tool_id == tool_id, tft.time_start >= tribulation.time_start,
            tft.time_end <= tribulation.time_end).all()
        #sum quantity
        sum = 0
        for tool in list_tool:
            sum += tool.quantity
        print('tool quantity = ', tool_quantity)
        print('sum           = ', sum)
        print('quantity      = ', quantity)
        result = (tool_quantity >= (sum + quantity))
    except Exception as e:
        raise e
    return result