Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def move_item(item, reasonCode, WarehouseID):
- reason_dict = {1 : ["Warehouse" + " " + WarehouseID + ": " + "weight cap for" + " " + item.get_type() + " " + "reached", "Item ID:" + " " + str(item.get_number())],
- 2 : ["Warehouse" + " " + WarehouseID + ": " + "too many of type:" + " " + item.get_type() + " " + "in this warehouse" + " " + "Item ID: " + str(item.get_number())],
- 3 : ["Warehouse" + " " + WarehouseID + ": " + "Cannot add due to the insurance cap being exceeded" + " " + "Item ID:" + " " + str(item.get_number())]}
- print()
- print(reason_dict.get(reasonCode)[0])
- wh_list = [WarehouseA, WarehouseB, WarehouseC, WarehouseD]
- wh_dict = {"A" : WarehouseA, "B" : WarehouseB, "C" : WarehouseC, "D" : WarehouseD}
- if reasonCode == 1: #shape to heavy for warehouse
- temp_list = []
- for warehouse in wh_list:
- if warehouse != wh_dict.get(WarehouseID): # all warehouse BUT the one the item is coming from
- if warehouse.get_weight_capacity(item.get_type())[0] > wh_dict.get(WarehouseID).get_weight_capacity(item.get_type())[0]: #compares candidate wh to original wh
- warehouse.add_item_to_warehouse(item)
- if warehouse.add_item_to_warehouse(item):
- print(" Moved item to the next available warehouse", "Warehouse", warehouse.ID)
- break
- if reasonCode == 2: #shape capacity full in this warehouse
- temp_list = []
- for warehouse in wh_list:
- if warehouse != wh_dict.get(WarehouseID): # all warehouse BUT the one the item is coming from
- if warehouse.get_shape_capacity(item.get_type())[0] - warehouse.get_shape_capacity(item.get_type())[1] > 0: # is there space for this shape in the warehouse?
- if item.get_weight() <= warehouse.get_weight_capacity(item.get_type())[0]: # can the warehouse max shape weight accomodate this shape?
- if warehouse.add_item_to_warehouse(item):
- print(" Moved item to the next available warehouse", "Warehouse", warehouse.ID)
- break
- if reasonCode == 3: # insurance capacity exceeded
- temp_list = []
- for warehouse in wh_list:
- if warehouse != wh_dict.get(WarehouseID): # all warehouse BUT the one the item is coming from
- if item.get_value() >= warehouse.get_insurance(): #warehouse.get_insurance():
- print(" Item" + " " + "ID:" + " " + str(item.get_number()) + ": " + "Has been rejected due to it being higher insurance")
- break
- if (warehouse.get_insurance() - warehouse.get_insured_capacity()) >= item.get_value(): # is there space for this shape in the warehouse
- #print("1 bow")
- if warehouse.get_shape_capacity(item.get_type())[0] - warehouse.get_shape_capacity(item.get_type())[1] > 0:
- #print("2 bow")
- if item.get_weight() <= warehouse.get_weight_capacity(item.get_type())[0]:
- #print("3 bow")
- if warehouse.add_item_to_warehouse(item):
- print(" Moved item to the next available warehouse", "Warehouse", warehouse.ID)
- break
- else:
- print(" This item cannot be accomodated in any warehouse and therefore has been discarded")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement