Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. def get_eta(self, order):
  2. eta_calc = zhibin_eta
  3. curr_location = self.get_location()
  4.  
  5. # Is driver delivering (preassigned, or assigned order) ?
  6. if len(self.preassigned) or self.order:
  7. # Has order assigned ?
  8. if self.order:
  9. # Have enough Stock ?
  10. if self.have_enough_stock(order):
  11. # ETA Distance assigned order +
  12. # Buffer time +
  13. # ETA Distance assigned order to New Order
  14. return eta_calc(curr_location, self.order.location) + \
  15. self.order.arrival_to_deliver_buffer + \
  16. eta_calc(self.order.location, order.location)
  17. else:
  18. # ETA Distance assigned order +
  19. # Buffer time +
  20. # ETA Distance to Hub +
  21. # Buffer giving stock +
  22. # ETA Distance to New Order
  23. return eta_calc(curr_location, self.order.location) + \
  24. self.order.arrival_to_deliver_buffer + \
  25. eta_calc(self.order.location, HUB_LOCATION) + \
  26. HUB_GIVING_STOCK_BUFFER + \
  27. eta_calc(HUB_LOCATION, order.location)
  28. else:
  29. # No. (He has an order PREassigned)
  30. # ETA Distance to Hub +
  31. # Buffer giving stock +
  32. # ETA Distance to preassigned Order +
  33. # Buffer delivery +
  34. # ETA Distance to new order
  35. preassigned_order = self.preassigned[0]
  36. return eta_calc(curr_location, HUB_LOCATION) + \
  37. HUB_GIVING_STOCK_BUFFER + \
  38. eta_calc(HUB_LOCATION, preassigned_order.location) + \
  39. preassigned_order.arrival_to_deliver_buffer + \
  40. eta_calc(preassigned_order.location, order.location)
  41. else:
  42. if self.have_enough_stock(order):
  43. # ETA Distance to new order
  44. return eta_calc(curr_location, order.location)
  45. else:
  46. # ETA Distance to Hub +
  47. # Buffer giving stock +
  48. # ETA Distance to new order
  49. return eta_calc(curr_location, HUB_LOCATION) + \
  50. HUB_GIVING_STOCK_BUFFER + \
  51. eta_calc(HUB_LOCATION, order.location)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement