diff --git a/config/services.yaml b/config/services.yaml index 12ee9e94..91e1996b 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -294,3 +294,5 @@ services: App\Service\HubFilterLogger: arguments: $em: "@doctrine.orm.entity_manager" + + # TODO: add the HubFilteringGeoChecker here diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index f5b49f00..4b8e9cf1 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -1023,6 +1023,8 @@ class APIController extends Controller implements LoggedController // TODO: set this properly, since the other flags // are on default values + // TODO: check the new service HubFilteringGeoChecker + // if true, set other values for HubCriteria, if any $hub_criteria = new HubCriteria(); $hub_criteria->setPoint($jo->getCoordinates()) ->setJoType($jo->getServiceType()); @@ -2580,6 +2582,8 @@ class APIController extends Controller implements LoggedController { // TODO: set this properly, since the other flags // are on default values + // TODO: check the new service HubFilteringGeoChecker + // if true, set other values for HubCriteria, if any $hub_criteria = new HubCriteria(); $hub_criteria->setPoint($jo->getCoordinates()) ->setJoType($jo->getServiceType()); diff --git a/src/Ramcar/HubCriteria.php b/src/Ramcar/HubCriteria.php index b0b5fcfe..76f00eb6 100644 --- a/src/Ramcar/HubCriteria.php +++ b/src/Ramcar/HubCriteria.php @@ -17,6 +17,7 @@ class HubCriteria protected $items; // array of items: items[sku] = quantity to check for protected $payment_method; // payment method of JO protected $flag_emergency; // flag if emergency or not + protected $flag_round_robin; // flag if we use round robin or not public function __construct() { @@ -29,6 +30,7 @@ class HubCriteria $this->items = []; $this->payment_method = ''; $flag_emergency = false; + $flag_round_robin = false; } public function setPoint(Point $point) @@ -131,5 +133,17 @@ class HubCriteria { return $this->flag_emergency; } + + public function setRoundRobin($flag_round_robin = true) + { + $this->flag_round_robin = $flag_round_robin; + return $this; + } + + public function isRoundRobin() + { + return $this->flag_round_robin; + } + } diff --git a/src/Service/HubSelector.php b/src/Service/HubSelector.php index 66506b90..a0f78213 100644 --- a/src/Service/HubSelector.php +++ b/src/Service/HubSelector.php @@ -50,6 +50,7 @@ class HubSelector $date_time = $criteria->getDateTime(); $payment_method = $criteria->getPaymentMethod(); $flag_emergency = $criteria->isEmergency(); + $flag_round_robin = $criteria->isRoundRobin(); $results = []; @@ -86,7 +87,7 @@ class HubSelector //error_log('inventory hubs ' . json_encode($filtered_hubs)); // round robin filter - $hubs_round_robin = $this->filterHubsByRoundRobin($filtered_hubs); + $hubs_round_robin = $this->filterHubsByRoundRobin($filtered_hubs, $flag_round_robin); $filtered_hubs = $hubs_round_robin; //error_log('round robin hubs ' . json_encode($filtered_hubs)); @@ -103,10 +104,12 @@ class HubSelector return $results; } - protected function filterHubsByRoundRobin($hubs) + protected function filterHubsByRoundRobin($hubs, $flag_round_robin) { if (empty($hubs)) return $hubs; + if (!$flag_round_robin) + return $hubs; $results = []; // call hub distributor service diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index ec1533e2..6888afe4 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -1974,6 +1974,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // get closest hubs // set hub criteria + // TODO: check the new service HubFilteringGeoChecker + // if true, set other values for HubCriteria $hub_criteria->setPoint($obj->getCoordinates()) ->setLimitResults(50) ->setPaymentMethod($obj->getModeOfPayment()) @@ -2260,6 +2262,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface } // get closest hubs + // TODO: check the new service HubFilteringGeoChecker + // if true, set other values for HubCriteria $hub_criteria->setPoint($obj->getCoordinates()) ->setLimitResults(50); $hubs = $hub_selector->find($hub_criteria);