Have admin panel use the HubSelector service when getting closest hubs. #543
This commit is contained in:
parent
c69a18d89b
commit
0ecc55cf56
6 changed files with 42 additions and 14 deletions
|
|
@ -17,8 +17,9 @@ use DateTime;
|
|||
|
||||
use Catalyst\MenuBundle\Annotation\Menu;
|
||||
|
||||
use App\Service\MapTools;
|
||||
use App\Service\RiderTracker;
|
||||
use App\Service\HubSelector;
|
||||
use App\Ramcar\HubCriteria;
|
||||
|
||||
class HubController extends Controller
|
||||
{
|
||||
|
|
@ -295,7 +296,7 @@ class HubController extends Controller
|
|||
$response->send();
|
||||
}
|
||||
|
||||
public function nearest(MapTools $map_tools, Request $req)
|
||||
public function nearest(HubSelector $hub_selector, Request $req)
|
||||
{
|
||||
// get lat / long
|
||||
$lat = $req->query->get('lat');
|
||||
|
|
@ -303,7 +304,12 @@ class HubController extends Controller
|
|||
|
||||
// get nearest hubs according to position
|
||||
$point = new Point($long, $lat);
|
||||
$result = $map_tools->getClosestHubs($point, 10, date("H:i:s"));
|
||||
|
||||
// set up hub criteria
|
||||
$hub_criteria = new HubCriteria();
|
||||
$hub_criteria->setPoint($point);
|
||||
$hub_selector->find($hub_criteria);
|
||||
//$result = $map_tools->getClosestHubs($point, 10, date("H:i:s"));
|
||||
|
||||
$hubs = [];
|
||||
foreach ($result as $hub_res)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ use App\Service\MapTools;
|
|||
use App\Service\MQTTClient;
|
||||
use App\Service\APNSClient;
|
||||
use App\Service\InventoryManager;
|
||||
use App\Service\HubSelector;
|
||||
|
||||
use App\Service\RiderTracker;
|
||||
use App\Service\MotivConnector;
|
||||
|
|
@ -315,13 +316,13 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_proc")
|
||||
*/
|
||||
public function processingForm(MapTools $map_tools, $id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis, MotivConnector $motiv)
|
||||
public function processingForm(HubSelector $hub_selector, $id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis, MotivConnector $motiv)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
|
||||
|
||||
try
|
||||
{
|
||||
$params = $jo_handler->initializeProcessingForm($id, $map_tools, $motiv);
|
||||
$params = $jo_handler->initializeProcessingForm($id, $hub_selector, $motiv);
|
||||
}
|
||||
catch (AccessDeniedHttpException $e)
|
||||
{
|
||||
|
|
@ -504,14 +505,14 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_open")
|
||||
*/
|
||||
public function openHubForm(MapTools $map_tools, $id, JobOrderHandlerInterface $jo_handler,
|
||||
public function openHubForm(HubSelector $hub_selector, $id, JobOrderHandlerInterface $jo_handler,
|
||||
GISManagerInterface $gis)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_open.list', null, 'No access.');
|
||||
|
||||
try
|
||||
{
|
||||
$params = $jo_handler->initializeHubForm($id, $map_tools);
|
||||
$params = $jo_handler->initializeHubForm($id, $hub_selector);
|
||||
}
|
||||
catch (NotFoundHttpException $e)
|
||||
{
|
||||
|
|
@ -1204,6 +1205,7 @@ class JobOrderController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
// this is uncalled or does not display in admin panel
|
||||
/**
|
||||
* @Menu(selected="jo_autoassign")
|
||||
*/
|
||||
|
|
@ -1223,6 +1225,7 @@ class JobOrderController extends Controller
|
|||
return $this->render($template, $params);
|
||||
}
|
||||
|
||||
// this is uncalled or does not display in admin panel
|
||||
public function autoAssignSubmit(Request $req, JobOrderHandlerInterface $jo_handler,
|
||||
EntityManagerInterface $em, MapTools $map_tools,
|
||||
InventoryManager $im)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ class HubCriteria
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
$this->limit_results = 10;
|
||||
$this->limit_distance = 500;
|
||||
$this->jo_type = '';
|
||||
$this->date_time = null;
|
||||
$this->has_inventory = false;
|
||||
$this->items = [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ class HubSelector
|
|||
// get all the hubs within distance
|
||||
$filtered_hubs = $this->getClosestHubs($point, $limit_distance);
|
||||
|
||||
//error_log('closest hubs ' . json_encode($filtered_hubs));
|
||||
|
||||
// filter the first hub results for date and opening times
|
||||
$hubs_date_time = $this->filterHubsByDateAndTime($filtered_hubs, $date_time);
|
||||
$filtered_hubs = $hubs_date_time;
|
||||
|
|
@ -68,7 +70,7 @@ class HubSelector
|
|||
|
||||
$results = $filtered_hubs;
|
||||
|
||||
//error_log(json_encode($results));
|
||||
error_log(json_encode($results));
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ use App\Ramcar\JORejectionReason;
|
|||
use App\Ramcar\CustomerNotWaitReason;
|
||||
use App\Ramcar\NoTradeInReason;
|
||||
use App\Ramcar\WillingToWaitContent;
|
||||
use App\Ramcar\HubCriteria;
|
||||
|
||||
use App\Service\InvoiceGeneratorInterface;
|
||||
use App\Service\JobOrderHandlerInterface;
|
||||
|
|
@ -49,6 +50,7 @@ use App\Service\MQTTClient;
|
|||
use App\Service\APNSClient;
|
||||
use App\Service\MapTools;
|
||||
use App\Service\RisingTideGateway;
|
||||
use App\Service\HubSelector;
|
||||
use App\Service\HubDistributor;
|
||||
|
||||
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||
|
|
@ -1647,6 +1649,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
return $params;
|
||||
}
|
||||
|
||||
// CMB code
|
||||
public function initializeOneStepEditForm($id, $map_tools)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
|
@ -1827,7 +1830,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// initialize dispatch/processing job order form
|
||||
public function initializeProcessingForm($id, $map_tools, $motiv)
|
||||
public function initializeProcessingForm($id, HubSelector $hub_selector, $motiv)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
||||
|
|
@ -1894,7 +1897,12 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$params['rejection_reasons'] = JORejectionReason::getCollection();
|
||||
|
||||
// get closest hubs
|
||||
$hubs = $map_tools->getClosestHubs($obj->getCoordinates(), 50, date("H:i:s"));
|
||||
// set hub criteria
|
||||
$hub_criteria = new HubCriteria();
|
||||
$hub_criteria->setPoint($obj->getCoordinates())
|
||||
->setLimitResults(50);
|
||||
$hubs = $hub_selector->find($hub_criteria);
|
||||
//$hubs = $map_tools->getClosestHubs($obj->getCoordinates(), 50, date("H:i:s"));
|
||||
|
||||
$params['hubs'] = [];
|
||||
|
||||
|
|
@ -2118,7 +2126,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// initialize hub form
|
||||
public function initializeHubForm($id, $map_tools)
|
||||
public function initializeHubForm($id, HubSelector $hub_selector)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
||||
|
|
@ -2143,7 +2151,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$params['rejection_reasons'] = JORejectionReason::getCollection();
|
||||
|
||||
// get closest hubs
|
||||
$hubs = $map_tools->getClosestHubs($obj->getCoordinates(), 50, date("H:i:s"));
|
||||
$hub_criteria = new HubCriteria();
|
||||
$hub_criteria->setPoint($obj->getCoordinates())
|
||||
->setLimitResults(50);
|
||||
$hubs = $hub_selector->find($hub_criteria);
|
||||
//$hubs = $map_tools->getClosestHubs($obj->getCoordinates(), 50, date("H:i:s"));
|
||||
|
||||
$params['status_cancelled'] = JOStatus::CANCELLED;
|
||||
$params['hubs'] = [];
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
use App\Service\MQTTClient;
|
||||
use App\Service\APNSClient;
|
||||
use App\Service\MapTools;
|
||||
use App\Service\HubSelector;
|
||||
|
||||
use App\Entity\JobOrder;
|
||||
|
||||
|
|
@ -67,7 +68,7 @@ interface JobOrderHandlerInterface
|
|||
public function initializeAllForm(int $id);
|
||||
|
||||
// initialize dispatch/processing job order form
|
||||
public function initializeProcessingForm(int $id, MapTools $map_tools, $motiv);
|
||||
public function initializeProcessingForm(int $id, HubSelector $hub_selector, $motiv);
|
||||
|
||||
// initialize assign job order form
|
||||
public function initializeAssignForm(int $id);
|
||||
|
|
@ -76,7 +77,7 @@ interface JobOrderHandlerInterface
|
|||
public function initializeFulfillmentForm(int $id);
|
||||
|
||||
// initialize hub form
|
||||
public function initializeHubForm(int $id, MapTools $map_tools);
|
||||
public function initializeHubForm(int $id, HubSelector $hub_selector);
|
||||
|
||||
// initialize rider form
|
||||
public function initializeRiderForm(int $id);
|
||||
|
|
|
|||
Loading…
Reference in a new issue