Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_eta(self, order):
- eta_calc = zhibin_eta
- curr_location = self.get_location()
- # Is driver delivering (preassigned, or assigned order) ?
- if len(self.preassigned) or self.order:
- # Has order assigned ?
- if self.order:
- # Have enough Stock ?
- if self.have_enough_stock(order):
- # ETA Distance assigned order +
- # Buffer time +
- # ETA Distance assigned order to New Order
- return eta_calc(curr_location, self.order.location) + \
- self.order.arrival_to_deliver_buffer + \
- eta_calc(self.order.location, order.location)
- else:
- # ETA Distance assigned order +
- # Buffer time +
- # ETA Distance to Hub +
- # Buffer giving stock +
- # ETA Distance to New Order
- return eta_calc(curr_location, self.order.location) + \
- self.order.arrival_to_deliver_buffer + \
- eta_calc(self.order.location, HUB_LOCATION) + \
- HUB_GIVING_STOCK_BUFFER + \
- eta_calc(HUB_LOCATION, order.location)
- else:
- # No. (He has an order PREassigned)
- # ETA Distance to Hub +
- # Buffer giving stock +
- # ETA Distance to preassigned Order +
- # Buffer delivery +
- # ETA Distance to new order
- preassigned_order = self.preassigned[0]
- return eta_calc(curr_location, HUB_LOCATION) + \
- HUB_GIVING_STOCK_BUFFER + \
- eta_calc(HUB_LOCATION, preassigned_order.location) + \
- preassigned_order.arrival_to_deliver_buffer + \
- eta_calc(preassigned_order.location, order.location)
- else:
- if self.have_enough_stock(order):
- # ETA Distance to new order
- return eta_calc(curr_location, order.location)
- else:
- # ETA Distance to Hub +
- # Buffer giving stock +
- # ETA Distance to new order
- return eta_calc(curr_location, HUB_LOCATION) + \
- HUB_GIVING_STOCK_BUFFER + \
- eta_calc(HUB_LOCATION, order.location)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement