Add rider availability interface and single JO rider availability service. #316
This commit is contained in:
parent
41a6801c19
commit
4366f77a2e
7 changed files with 84 additions and 17 deletions
|
|
@ -196,6 +196,12 @@ services:
|
|||
# rider assignment interface
|
||||
App\Service\RiderAssignmentHandlerInterface: "@App\\Service\\RiderAssignmentHandler\\CMBRiderAssignmentHandler"
|
||||
|
||||
# rider availability
|
||||
App\Service\RiderAvailability\SingleJORiderAvailability: ~
|
||||
|
||||
# rider availability interface
|
||||
App\Service\RiderAvailabilityInterface: "@App\\Service\\RiderAvailability\\SingleJORiderAvailability"
|
||||
|
||||
# map manager
|
||||
#App\Service\GISManager\Bing: ~
|
||||
App\Service\GISManager\OpenStreet: ~
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use App\Entity\JobOrder;
|
|||
use App\Service\InvoiceGeneratorInterface;
|
||||
use App\Service\JobOrderHandlerInterface;
|
||||
use App\Service\GISManagerInterface;
|
||||
use App\Service\RiderAvailabilityInterface;
|
||||
use App\Service\MapTools;
|
||||
use App\Service\MQTTClient;
|
||||
use App\Service\APNSClient;
|
||||
|
|
@ -295,13 +296,14 @@ class JobOrderController extends Controller
|
|||
/**
|
||||
* @Menu(selected="jo_proc")
|
||||
*/
|
||||
public function processingForm(MapTools $map_tools, $id, JobOrderHandlerInterface $jo_handler, GISManagerInterface $gis)
|
||||
public function processingForm(MapTools $map_tools, $id, JobOrderHandlerInterface $jo_handler,
|
||||
GISManagerInterface $gis, RiderAvailabilityInterface $rider_avail_service)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
|
||||
|
||||
try
|
||||
{
|
||||
$params = $jo_handler->initializeProcessingForm($id, $map_tools);
|
||||
$params = $jo_handler->initializeProcessingForm($id, $map_tools, $rider_avail_service);
|
||||
}
|
||||
catch (AccessDeniedHttpException $e)
|
||||
{
|
||||
|
|
@ -878,11 +880,12 @@ class JobOrderController extends Controller
|
|||
* @Menu(selected="jo_onestep_edit_form")
|
||||
*/
|
||||
public function oneStepEditForm($id, JobOrderHandlerInterface $jo_handler,
|
||||
GISManagerInterface $gis, MapTools $map_tools)
|
||||
GISManagerInterface $gis, MapTools $map_tools,
|
||||
RiderAvailabilityInterface $rider_avail_service)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('jo_onestep.edit', null, 'No access.');
|
||||
|
||||
$params = $jo_handler->initializeOneStepEditForm($id, $map_tools);
|
||||
$params = $jo_handler->initializeOneStepEditForm($id, $map_tools, $rider_avail_service);
|
||||
$params['submit_url'] = $this->generateUrl('jo_onestep_edit_submit', ['id' => $id]);
|
||||
$params['return_url'] = $this->generateUrl('jo_open');
|
||||
$params['map_js_file'] = $gis->getJSJOFile();
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ use App\Ramcar\JORejectionReason;
|
|||
use App\Service\InvoiceGeneratorInterface;
|
||||
use App\Service\JobOrderHandlerInterface;
|
||||
use App\Service\RiderAssignmentHandlerInterface;
|
||||
use App\Service\RiderAvailabilityInterface;
|
||||
use App\Service\WarrantyHandler;
|
||||
use App\Service\MQTTClient;
|
||||
use App\Service\APNSClient;
|
||||
|
|
@ -1292,7 +1293,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
return $params;
|
||||
}
|
||||
|
||||
public function initializeOneStepEditForm($id, $map_tools)
|
||||
public function initializeOneStepEditForm($id, $map_tools, $rider_avail_service)
|
||||
{
|
||||
$em = $this->em;
|
||||
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||
|
|
@ -1335,7 +1336,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// counters
|
||||
$hub['rider_count'] = count($hub['hub']->getAvailableRiders());
|
||||
//$hub['rider_count'] = count($hub['hub']->getAvailableRiders());
|
||||
$hub['rider_count'] = count($rider_avail_service->getAvailableRiders($obj));
|
||||
$hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders());
|
||||
|
||||
// check for rejection
|
||||
|
|
@ -1460,7 +1462,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// initialize dispatch/processing job order form
|
||||
public function initializeProcessingForm($id, $map_tools)
|
||||
public function initializeProcessingForm($id, $map_tools, $rider_avail_service)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
||||
|
|
@ -1555,6 +1557,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// counters
|
||||
// TODO: clone the JO. store old value, set the hub id on the clone,
|
||||
// call the service to getAvailableRiders
|
||||
$hub['rider_count'] = count($hub['hub']->getAvailableRiders());
|
||||
$hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders());
|
||||
|
||||
|
|
@ -1706,7 +1710,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// initialize hub form
|
||||
public function initializeHubForm($id, $map_tools)
|
||||
public function initializeHubForm($id, $map_tools, $rider_avail_service)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
||||
|
|
@ -1760,6 +1764,8 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// counters
|
||||
// TODO: clone the JO. store old value, set the hub id on the clone,
|
||||
// call the service to getAvailableRiders
|
||||
$hub['rider_count'] = count($hub['hub']->getAvailableRiders());
|
||||
$hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders());
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ use App\Ramcar\JORejectionReason;
|
|||
|
||||
use App\Service\InvoiceGeneratorInterface;
|
||||
use App\Service\JobOrderHandlerInterface;
|
||||
use App\Service\RiderAvailabilityInterface;
|
||||
use App\Service\WarrantyHandler;
|
||||
use App\Service\MQTTClient;
|
||||
use App\Service\APNSClient;
|
||||
|
|
@ -1308,7 +1309,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
return $params;
|
||||
}
|
||||
|
||||
public function initializeOneStepEditForm($id, $map_tools)
|
||||
public function initializeOneStepEditForm($id, $map_tools, $rider_avail_service)
|
||||
{
|
||||
$em = $this->em;
|
||||
$obj = $em->getRepository(JobOrder::class)->find($id);
|
||||
|
|
@ -1351,7 +1352,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// counters
|
||||
$hub['rider_count'] = count($hub['hub']->getAvailableRiders());
|
||||
//$hub['rider_count'] = count($hub['hub']->getAvailableRiders());
|
||||
$hub['rider_count'] = count($rider_avail_service->getAvailableRiders($obj));
|
||||
$hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders());
|
||||
|
||||
// check for rejection
|
||||
|
|
@ -1476,7 +1478,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// initialize dispatch/processing job order form
|
||||
public function initializeProcessingForm($id, $map_tools)
|
||||
public function initializeProcessingForm($id, $map_tools, $rider_avail_service)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
||||
|
|
@ -1571,7 +1573,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// counters
|
||||
$hub['rider_count'] = count($hub['hub']->getAvailableRiders());
|
||||
//$hub['rider_count'] = count($hub['hub']->getAvailableRiders());
|
||||
$hub['rider_count'] = count($rider_avail_service->getAvailableRiders($obj));
|
||||
$hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders());
|
||||
|
||||
// check for rejection
|
||||
|
|
@ -1722,7 +1725,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// initialize hub form
|
||||
public function initializeHubForm($id, $map_tools)
|
||||
public function initializeHubForm($id, $map_tools, $rider_avail_service)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
||||
|
|
@ -1776,7 +1779,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
}
|
||||
|
||||
// counters
|
||||
$hub['rider_count'] = count($hub['hub']->getAvailableRiders());
|
||||
//$hub['rider_count'] = count($hub['hub']->getAvailableRiders());
|
||||
$hub['rider_count'] = count($rider_avail_service->getAvailableRiders($obj));
|
||||
$hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders());
|
||||
|
||||
// check for rejection
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
use App\Service\MQTTClient;
|
||||
use App\Service\APNSClient;
|
||||
use App\Service\MapTools;
|
||||
use App\Service\RiderAvailability;
|
||||
|
||||
interface JobOrderHandlerInterface
|
||||
{
|
||||
|
|
@ -65,7 +66,7 @@ interface JobOrderHandlerInterface
|
|||
public function initializeAllForm(int $id);
|
||||
|
||||
// initialize dispatch/processing job order form
|
||||
public function initializeProcessingForm(int $id, MapTools $map_tools);
|
||||
public function initializeProcessingForm(int $id, MapTools $map_tools, RiderAvailability $rider_avail_service);
|
||||
|
||||
// initialize assign job order form
|
||||
public function initializeAssignForm(int $id);
|
||||
|
|
@ -74,7 +75,7 @@ interface JobOrderHandlerInterface
|
|||
public function initializeFulfillmentForm(int $id);
|
||||
|
||||
// initialize hub form
|
||||
public function initializeHubForm(int $id, MapTools $map_tools);
|
||||
public function initializeHubForm(int $id, MapTools $map_tools, RiderAvailability $rider_avail_service);
|
||||
|
||||
// initialize rider form
|
||||
public function initializeRiderForm(int $id);
|
||||
|
|
@ -83,7 +84,7 @@ interface JobOrderHandlerInterface
|
|||
public function initializeOneStepForm();
|
||||
|
||||
// initialize one step edit form
|
||||
public function initializeOneStepEditForm(int $id, MapTools $map_tools);
|
||||
public function initializeOneStepEditForm(int $id, MapTools $map_tools, RiderAvailability $rider_avail_service);
|
||||
|
||||
// generate pdf form for job order
|
||||
public function generatePDFForm(Request $req, int $id, string $proj_path);
|
||||
|
|
|
|||
36
src/Service/RiderAvailability/SingleJORiderAvailability.php
Normal file
36
src/Service/RiderAvailability/SingleJORiderAvailability.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service\RiderAvailability;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\JobOrder;
|
||||
|
||||
use App\Service\RiderAvailabilityInterface;
|
||||
|
||||
class SingleJORiderAvailability implements RiderAvailabilityInterface
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getAvailableRiders(JobOrder $jo)
|
||||
{
|
||||
// get hub from JO
|
||||
$hub = $jo->getHub();
|
||||
|
||||
// get available riders from hub
|
||||
// TODO: for now, as-is behavior but will change
|
||||
// when we support multiple JOs per rider
|
||||
$riders = [];
|
||||
|
||||
if ($hub != null)
|
||||
$riders = $hub->getAvailableRiders();
|
||||
|
||||
return $riders;
|
||||
}
|
||||
|
||||
}
|
||||
11
src/Service/RiderAvailabilityInterface.php
Normal file
11
src/Service/RiderAvailabilityInterface.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\JobOrder;
|
||||
|
||||
interface RiderAvailabilityInterface
|
||||
{
|
||||
public function getAvailableRiders(JobOrder $jo);
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue