Add round robin flag to HubCriteria. #575
This commit is contained in:
parent
b4c8da134c
commit
e61c3f1762
5 changed files with 29 additions and 2 deletions
|
|
@ -294,3 +294,5 @@ services:
|
||||||
App\Service\HubFilterLogger:
|
App\Service\HubFilterLogger:
|
||||||
arguments:
|
arguments:
|
||||||
$em: "@doctrine.orm.entity_manager"
|
$em: "@doctrine.orm.entity_manager"
|
||||||
|
|
||||||
|
# TODO: add the HubFilteringGeoChecker here
|
||||||
|
|
|
||||||
|
|
@ -1023,6 +1023,8 @@ class APIController extends Controller implements LoggedController
|
||||||
|
|
||||||
// TODO: set this properly, since the other flags
|
// TODO: set this properly, since the other flags
|
||||||
// are on default values
|
// 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 = new HubCriteria();
|
||||||
$hub_criteria->setPoint($jo->getCoordinates())
|
$hub_criteria->setPoint($jo->getCoordinates())
|
||||||
->setJoType($jo->getServiceType());
|
->setJoType($jo->getServiceType());
|
||||||
|
|
@ -2580,6 +2582,8 @@ class APIController extends Controller implements LoggedController
|
||||||
{
|
{
|
||||||
// TODO: set this properly, since the other flags
|
// TODO: set this properly, since the other flags
|
||||||
// are on default values
|
// 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 = new HubCriteria();
|
||||||
$hub_criteria->setPoint($jo->getCoordinates())
|
$hub_criteria->setPoint($jo->getCoordinates())
|
||||||
->setJoType($jo->getServiceType());
|
->setJoType($jo->getServiceType());
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ class HubCriteria
|
||||||
protected $items; // array of items: items[sku] = quantity to check for
|
protected $items; // array of items: items[sku] = quantity to check for
|
||||||
protected $payment_method; // payment method of JO
|
protected $payment_method; // payment method of JO
|
||||||
protected $flag_emergency; // flag if emergency or not
|
protected $flag_emergency; // flag if emergency or not
|
||||||
|
protected $flag_round_robin; // flag if we use round robin or not
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
@ -29,6 +30,7 @@ class HubCriteria
|
||||||
$this->items = [];
|
$this->items = [];
|
||||||
$this->payment_method = '';
|
$this->payment_method = '';
|
||||||
$flag_emergency = false;
|
$flag_emergency = false;
|
||||||
|
$flag_round_robin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPoint(Point $point)
|
public function setPoint(Point $point)
|
||||||
|
|
@ -131,5 +133,17 @@ class HubCriteria
|
||||||
{
|
{
|
||||||
return $this->flag_emergency;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ class HubSelector
|
||||||
$date_time = $criteria->getDateTime();
|
$date_time = $criteria->getDateTime();
|
||||||
$payment_method = $criteria->getPaymentMethod();
|
$payment_method = $criteria->getPaymentMethod();
|
||||||
$flag_emergency = $criteria->isEmergency();
|
$flag_emergency = $criteria->isEmergency();
|
||||||
|
$flag_round_robin = $criteria->isRoundRobin();
|
||||||
|
|
||||||
$results = [];
|
$results = [];
|
||||||
|
|
||||||
|
|
@ -86,7 +87,7 @@ class HubSelector
|
||||||
//error_log('inventory hubs ' . json_encode($filtered_hubs));
|
//error_log('inventory hubs ' . json_encode($filtered_hubs));
|
||||||
|
|
||||||
// round robin filter
|
// 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;
|
$filtered_hubs = $hubs_round_robin;
|
||||||
|
|
||||||
//error_log('round robin hubs ' . json_encode($filtered_hubs));
|
//error_log('round robin hubs ' . json_encode($filtered_hubs));
|
||||||
|
|
@ -103,10 +104,12 @@ class HubSelector
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function filterHubsByRoundRobin($hubs)
|
protected function filterHubsByRoundRobin($hubs, $flag_round_robin)
|
||||||
{
|
{
|
||||||
if (empty($hubs))
|
if (empty($hubs))
|
||||||
return $hubs;
|
return $hubs;
|
||||||
|
if (!$flag_round_robin)
|
||||||
|
return $hubs;
|
||||||
|
|
||||||
$results = [];
|
$results = [];
|
||||||
// call hub distributor service
|
// call hub distributor service
|
||||||
|
|
|
||||||
|
|
@ -1974,6 +1974,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
|
|
||||||
// get closest hubs
|
// get closest hubs
|
||||||
// set hub criteria
|
// set hub criteria
|
||||||
|
// TODO: check the new service HubFilteringGeoChecker
|
||||||
|
// if true, set other values for HubCriteria
|
||||||
$hub_criteria->setPoint($obj->getCoordinates())
|
$hub_criteria->setPoint($obj->getCoordinates())
|
||||||
->setLimitResults(50)
|
->setLimitResults(50)
|
||||||
->setPaymentMethod($obj->getModeOfPayment())
|
->setPaymentMethod($obj->getModeOfPayment())
|
||||||
|
|
@ -2260,6 +2262,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// get closest hubs
|
// get closest hubs
|
||||||
|
// TODO: check the new service HubFilteringGeoChecker
|
||||||
|
// if true, set other values for HubCriteria
|
||||||
$hub_criteria->setPoint($obj->getCoordinates())
|
$hub_criteria->setPoint($obj->getCoordinates())
|
||||||
->setLimitResults(50);
|
->setLimitResults(50);
|
||||||
$hubs = $hub_selector->find($hub_criteria);
|
$hubs = $hub_selector->find($hub_criteria);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue