Restore legacy MQTTClient, add new MQTTClientApiv2 class for new customer api #730
This commit is contained in:
parent
1d278beb35
commit
4f06c02bd4
15 changed files with 213 additions and 81 deletions
|
|
@ -67,6 +67,11 @@ services:
|
||||||
$redis_client: "@App\\Service\\RedisClientProvider"
|
$redis_client: "@App\\Service\\RedisClientProvider"
|
||||||
$key: "mqtt_events"
|
$key: "mqtt_events"
|
||||||
|
|
||||||
|
App\Service\MQTTClientApiv2:
|
||||||
|
arguments:
|
||||||
|
$redis_client: "@App\\Service\\RedisClientProvider"
|
||||||
|
$key: "mqtt_events"
|
||||||
|
|
||||||
App\Service\APNSClient:
|
App\Service\APNSClient:
|
||||||
arguments:
|
arguments:
|
||||||
$redis_client: "@App\\Service\\RedisClientProvider"
|
$redis_client: "@App\\Service\\RedisClientProvider"
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
|
|
||||||
use App\Entity\JobOrder;
|
use App\Entity\JobOrder;
|
||||||
use App\Entity\Rider;
|
use App\Entity\Rider;
|
||||||
|
|
@ -21,11 +22,17 @@ class UpdateUnacceptedJobOrdersCommand extends Command
|
||||||
protected $em;
|
protected $em;
|
||||||
protected $mclient;
|
protected $mclient;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, MQTTClient $mclient)
|
// NOTE: for resq2 app
|
||||||
|
protected $mclientv2;
|
||||||
|
|
||||||
|
public function __construct(EntityManagerInterface $em, MQTTClient $mclient, MQTTClientApiv2 $mclientv2)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->mclient = $mclient;
|
$this->mclient = $mclient;
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$this->mclientv2 = $mclientv2;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,6 +48,9 @@ class UpdateUnacceptedJobOrdersCommand extends Command
|
||||||
$em = $this->em;
|
$em = $this->em;
|
||||||
$mclient = $this->mclient;
|
$mclient = $this->mclient;
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2 = $this->mclientv2;
|
||||||
|
|
||||||
// TODO: get the timeout limit from .env
|
// TODO: get the timeout limit from .env
|
||||||
$timeout = 3;
|
$timeout = 3;
|
||||||
$current_status = 'assigned';
|
$current_status = 'assigned';
|
||||||
|
|
@ -107,6 +117,9 @@ class UpdateUnacceptedJobOrdersCommand extends Command
|
||||||
'jo_id' => $id,
|
'jo_id' => $id,
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($jo, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rider = $jo->getRider();
|
$rider = $jo->getRider();
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ use App\Entity\ApiUser as APIUser;
|
||||||
use App\Service\RedisClientProvider;
|
use App\Service\RedisClientProvider;
|
||||||
use App\Service\RiderCache;
|
use App\Service\RiderCache;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
use App\Service\WarrantyHandler;
|
use App\Service\WarrantyHandler;
|
||||||
use App\Service\JobOrderHandlerInterface;
|
use App\Service\JobOrderHandlerInterface;
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
|
|
@ -437,7 +438,7 @@ class RiderAppController extends APIController
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancelJobOrder(Request $req, EntityManagerInterface $em, MQTTClient $mclient)
|
public function cancelJobOrder(Request $req, EntityManagerInterface $em, MQTTClient $mclient, MQTTClientApiv2 $mclientv2)
|
||||||
{
|
{
|
||||||
$required_params = ['jo_id'];
|
$required_params = ['jo_id'];
|
||||||
|
|
||||||
|
|
@ -483,6 +484,9 @@ class RiderAppController extends APIController
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
return new APIResponse(true, 'Job order requeued.', $data);
|
return new APIResponse(true, 'Job order requeued.', $data);
|
||||||
}
|
}
|
||||||
|
|
@ -648,7 +652,7 @@ class RiderAppController extends APIController
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function arrive(Request $req, EntityManagerInterface $em, MQTTClient $mclient)
|
public function arrive(Request $req, EntityManagerInterface $em, MQTTClient $mclient, MQTTClientApiv2 $mclientv2)
|
||||||
{
|
{
|
||||||
$required_params = ['jo_id'];
|
$required_params = ['jo_id'];
|
||||||
|
|
||||||
|
|
@ -698,6 +702,9 @@ class RiderAppController extends APIController
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
return new APIResponse(true, 'Rider arrived at customer location.', $data);
|
return new APIResponse(true, 'Rider arrived at customer location.', $data);
|
||||||
}
|
}
|
||||||
|
|
@ -749,7 +756,7 @@ class RiderAppController extends APIController
|
||||||
}
|
}
|
||||||
|
|
||||||
public function payment(Request $req, EntityManagerInterface $em, JobOrderHandlerInterface $jo_handler,
|
public function payment(Request $req, EntityManagerInterface $em, JobOrderHandlerInterface $jo_handler,
|
||||||
RisingTideGateway $rt, WarrantyHandler $wh, MQTTClient $mclient, TranslatorInterface $translator)
|
RisingTideGateway $rt, WarrantyHandler $wh, MQTTClient $mclient, MQTTClientApiv2 $mclientv2, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
$required_params = ['jo_id'];
|
$required_params = ['jo_id'];
|
||||||
|
|
||||||
|
|
@ -871,6 +878,9 @@ class RiderAppController extends APIController
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
return new APIResponse(true, 'Job order paid and fulfilled.', $data);
|
return new APIResponse(true, 'Job order paid and fulfilled.', $data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||||
|
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
use App\Service\RiderTracker;
|
use App\Service\RiderTracker;
|
||||||
use App\Service\GeofenceTracker;
|
use App\Service\GeofenceTracker;
|
||||||
use App\Service\MapTools;
|
use App\Service\MapTools;
|
||||||
|
|
@ -473,7 +474,7 @@ class JobOrderController extends ApiController
|
||||||
GeofenceTracker $geo,
|
GeofenceTracker $geo,
|
||||||
MapTools $map_tools,
|
MapTools $map_tools,
|
||||||
InventoryManager $im,
|
InventoryManager $im,
|
||||||
MQTTClient $mclient,
|
MQTTClientApiv2 $mclientv2,
|
||||||
RiderAssignmentHandlerInterface $rah,
|
RiderAssignmentHandlerInterface $rah,
|
||||||
PromoLogger $promo_logger,
|
PromoLogger $promo_logger,
|
||||||
HubSelector $hub_select,
|
HubSelector $hub_select,
|
||||||
|
|
@ -837,7 +838,7 @@ class JobOrderController extends ApiController
|
||||||
$payload = [
|
$payload = [
|
||||||
'event' => 'outlet_assign'
|
'event' => 'outlet_assign'
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
$rah->assignJobOrder($jo, $jo->getRider());
|
$rah->assignJobOrder($jo, $jo->getRider());
|
||||||
}
|
}
|
||||||
|
|
@ -855,7 +856,7 @@ class JobOrderController extends ApiController
|
||||||
$payload = [
|
$payload = [
|
||||||
'event' => 'outlet_assign'
|
'event' => 'outlet_assign'
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclientv2->sendEvent($jo, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
@ -929,7 +930,7 @@ class JobOrderController extends ApiController
|
||||||
GeofenceTracker $geo,
|
GeofenceTracker $geo,
|
||||||
MapTools $map_tools,
|
MapTools $map_tools,
|
||||||
InventoryManager $im,
|
InventoryManager $im,
|
||||||
MQTTClient $mclient,
|
MQTTClientApiv2 $mclientv2,
|
||||||
RiderAssignmentHandlerInterface $rah,
|
RiderAssignmentHandlerInterface $rah,
|
||||||
PromoLogger $promo_logger,
|
PromoLogger $promo_logger,
|
||||||
HubSelector $hub_select,
|
HubSelector $hub_select,
|
||||||
|
|
@ -1181,7 +1182,7 @@ class JobOrderController extends ApiController
|
||||||
$payload = [
|
$payload = [
|
||||||
'event' => 'outlet_assign'
|
'event' => 'outlet_assign'
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
$rah->assignJobOrder($jo, $jo->getRider());
|
$rah->assignJobOrder($jo, $jo->getRider());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ use App\Service\JobOrderHandlerInterface;
|
||||||
use App\Service\GISManagerInterface;
|
use App\Service\GISManagerInterface;
|
||||||
use App\Service\MapTools;
|
use App\Service\MapTools;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
use App\Service\APNSClient;
|
use App\Service\APNSClient;
|
||||||
use App\Service\InventoryManager;
|
use App\Service\InventoryManager;
|
||||||
use App\Service\HubSelector;
|
use App\Service\HubSelector;
|
||||||
|
|
@ -29,8 +30,6 @@ use App\Service\RiderTracker;
|
||||||
use App\Service\MotivConnector;
|
use App\Service\MotivConnector;
|
||||||
|
|
||||||
use App\Service\GeofenceTracker;
|
use App\Service\GeofenceTracker;
|
||||||
|
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
@ -355,7 +354,7 @@ class JobOrderController extends Controller
|
||||||
return $this->render($template, $params);
|
return $this->render($template, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processingSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id)
|
public function processingSubmit(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, MQTTClientApiv2 $mclientv2, $id)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
|
$this->denyAccessUnlessGranted('jo_proc.list', null, 'No access.');
|
||||||
|
|
||||||
|
|
@ -363,7 +362,7 @@ class JobOrderController extends Controller
|
||||||
$error_array = [];
|
$error_array = [];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$error_array = $jo_handler->dispatchJobOrder($req, $id, $mclient);
|
$error_array = $jo_handler->dispatchJobOrder($req, $id, $mclient, $mclientv2);
|
||||||
}
|
}
|
||||||
catch (AccessDeniedHttpException $e)
|
catch (AccessDeniedHttpException $e)
|
||||||
{
|
{
|
||||||
|
|
@ -682,7 +681,7 @@ class JobOrderController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancelJobOrder(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, $id)
|
public function cancelJobOrder(Request $req, JobOrderHandlerInterface $jo_handler, MQTTClient $mclient, MQTTClientApiv2 $mclientv2, $id)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('joborder.cancel', null, 'No access.');
|
$this->denyAccessUnlessGranted('joborder.cancel', null, 'No access.');
|
||||||
|
|
||||||
|
|
@ -699,7 +698,7 @@ class JobOrderController extends Controller
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$jo_handler->cancelJobOrder($req, $id, $mclient);
|
$jo_handler->cancelJobOrder($req, $id, $mclient, $mclientv2);
|
||||||
}
|
}
|
||||||
catch (NotFoundHttpException $e)
|
catch (NotFoundHttpException $e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ use App\Ramcar\DeliveryStatus;
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
use App\Service\RisingTideGateway;
|
use App\Service\RisingTideGateway;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
use App\Service\GeofenceTracker;
|
use App\Service\GeofenceTracker;
|
||||||
use App\Service\InventoryManager;
|
use App\Service\InventoryManager;
|
||||||
use App\Service\RiderAssignmentHandlerInterface;
|
use App\Service\RiderAssignmentHandlerInterface;
|
||||||
|
|
@ -72,7 +73,7 @@ class JobOrderController extends APIController
|
||||||
|
|
||||||
// TODO: break this monolithic method down
|
// TODO: break this monolithic method down
|
||||||
public function requestJobOrder(Request $req, InvoiceGeneratorInterface $ic, GeofenceTracker $geo,
|
public function requestJobOrder(Request $req, InvoiceGeneratorInterface $ic, GeofenceTracker $geo,
|
||||||
InventoryManager $im, MQTTClient $mclient,
|
InventoryManager $im, MQTTClient $mclient, MQTTClientApiv2 $mclientv2,
|
||||||
RiderAssignmentHandlerInterface $rah, PromoLogger $promo_logger,
|
RiderAssignmentHandlerInterface $rah, PromoLogger $promo_logger,
|
||||||
HubSelector $hub_select, HubDistributor $hub_dist, HubFilterLogger $hub_filter_logger,
|
HubSelector $hub_select, HubDistributor $hub_dist, HubFilterLogger $hub_filter_logger,
|
||||||
HubFilteringGeoChecker $hub_geofence, EntityManagerInterface $em)
|
HubFilteringGeoChecker $hub_geofence, EntityManagerInterface $em)
|
||||||
|
|
@ -353,6 +354,9 @@ class JobOrderController extends APIController
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
$rah->assignJobOrder($jo, $jo->getRider());
|
$rah->assignJobOrder($jo, $jo->getRider());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,6 +375,9 @@ class JobOrderController extends APIController
|
||||||
'event' => 'outlet_assign'
|
'event' => 'outlet_assign'
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($jo, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ use App\Service\RiderAssignmentHandlerInterface;
|
||||||
use App\Service\CustomerHandlerInterface;
|
use App\Service\CustomerHandlerInterface;
|
||||||
use App\Service\WarrantyHandler;
|
use App\Service\WarrantyHandler;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
use App\Service\APNSClient;
|
use App\Service\APNSClient;
|
||||||
use App\Service\MapTools;
|
use App\Service\MapTools;
|
||||||
|
|
||||||
|
|
@ -668,7 +669,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// dispatch job order
|
// dispatch job order
|
||||||
public function dispatchJobOrder(Request $req, int $id, MQTTClient $mclient)
|
public function dispatchJobOrder(Request $req, int $id, MQTTClient $mclient, MQTTClientApiv2 $mclientv2)
|
||||||
{
|
{
|
||||||
// get object data
|
// get object data
|
||||||
$em = $this->em;
|
$em = $this->em;
|
||||||
|
|
@ -793,6 +794,9 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
'event' => 'outlet_assign'
|
'event' => 'outlet_assign'
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($obj, $payload);
|
$mclient->sendEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($obj, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error_array;
|
return $error_array;
|
||||||
|
|
@ -1027,7 +1031,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// cancel job order
|
// cancel job order
|
||||||
public function cancelJobOrder(Request $req, int $id, MQTTClient $mclient)
|
public function cancelJobOrder(Request $req, int $id, MQTTClient $mclient, MQTTClientApiv2 $mclientv2)
|
||||||
{
|
{
|
||||||
// get object data
|
// get object data
|
||||||
$em = $this->em;
|
$em = $this->em;
|
||||||
|
|
@ -1068,10 +1072,13 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($obj, $payload);
|
$mclient->sendEvent($obj, $payload);
|
||||||
$mclient->sendRiderEvent($obj, $payload);
|
$mclient->sendRiderEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($obj, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set hub for job order
|
// set hub for job order
|
||||||
public function setHub($req, $id, $mclient)
|
public function setHub($req, $id, $mclient, $mclientv2)
|
||||||
{
|
{
|
||||||
// get object data
|
// get object data
|
||||||
$em = $this->em;
|
$em = $this->em;
|
||||||
|
|
@ -1171,6 +1178,9 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
'event' => 'outlet_assign'
|
'event' => 'outlet_assign'
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($obj, $payload);
|
$mclient->sendEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($obj, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error_array;
|
return $error_array;
|
||||||
|
|
@ -1272,7 +1282,7 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// set rider for job order
|
// set rider for job order
|
||||||
public function setRider($req, $id, $mclient)
|
public function setRider($req, $id, $mclient, $mclientv2)
|
||||||
{
|
{
|
||||||
// initialize error list
|
// initialize error list
|
||||||
$error_array = [];
|
$error_array = [];
|
||||||
|
|
@ -1372,6 +1382,9 @@ class CMBJobOrderHandler implements JobOrderHandlerInterface
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($obj, $payload);
|
$mclient->sendEvent($obj, $payload);
|
||||||
$mclient->sendRiderEvent($obj, $payload);
|
$mclient->sendRiderEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($obj, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error_array;
|
return $error_array;
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ use App\Service\JobOrderHandlerInterface;
|
||||||
use App\Service\RiderAssignmentHandlerInterface;
|
use App\Service\RiderAssignmentHandlerInterface;
|
||||||
use App\Service\WarrantyHandler;
|
use App\Service\WarrantyHandler;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
use App\Service\APNSClient;
|
use App\Service\APNSClient;
|
||||||
use App\Service\MapTools;
|
use App\Service\MapTools;
|
||||||
use App\Service\RisingTideGateway;
|
use App\Service\RisingTideGateway;
|
||||||
|
|
@ -803,7 +804,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// dispatch job order
|
// dispatch job order
|
||||||
public function dispatchJobOrder(Request $req, int $id, MQTTClient $mclient)
|
public function dispatchJobOrder(Request $req, int $id, MQTTClient $mclient, MQTTClientApiv2 $mclientv2)
|
||||||
{
|
{
|
||||||
// get object data
|
// get object data
|
||||||
$em = $this->em;
|
$em = $this->em;
|
||||||
|
|
@ -982,6 +983,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($obj, $payload);
|
$mclient->sendEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($obj, $payload);
|
||||||
|
|
||||||
|
|
||||||
// update redis hub jo count
|
// update redis hub jo count
|
||||||
$this->hub_dist->incrementJoCountForHub($hub);
|
$this->hub_dist->incrementJoCountForHub($hub);
|
||||||
}
|
}
|
||||||
|
|
@ -1337,7 +1342,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// cancel job order
|
// cancel job order
|
||||||
public function cancelJobOrder(Request $req, int $id, MQTTClient $mclient)
|
public function cancelJobOrder(Request $req, int $id, MQTTClient $mclient, MQTTClientApiv2 $mclientv2)
|
||||||
{
|
{
|
||||||
// get object data
|
// get object data
|
||||||
$em = $this->em;
|
$em = $this->em;
|
||||||
|
|
@ -1382,10 +1387,13 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($obj, $payload);
|
$mclient->sendEvent($obj, $payload);
|
||||||
$mclient->sendRiderEvent($obj, $payload);
|
$mclient->sendRiderEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($obj, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set hub for job order
|
// set hub for job order
|
||||||
public function setHub($req, $id, $mclient)
|
public function setHub($req, $id, $mclient, $mclientv2)
|
||||||
{
|
{
|
||||||
// get object data
|
// get object data
|
||||||
$em = $this->em;
|
$em = $this->em;
|
||||||
|
|
@ -1560,6 +1568,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($obj, $payload);
|
$mclient->sendEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($obj, $payload);
|
||||||
|
|
||||||
// update redis hub_jo_count for hub
|
// update redis hub_jo_count for hub
|
||||||
// decrement old hub's count and increment new hub's count
|
// decrement old hub's count and increment new hub's count
|
||||||
if ($old_hub != null)
|
if ($old_hub != null)
|
||||||
|
|
@ -1667,7 +1678,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// set rider for job order
|
// set rider for job order
|
||||||
public function setRider($req, $id, $mclient)
|
public function setRider($req, $id, $mclient, $mclientv2)
|
||||||
{
|
{
|
||||||
// initialize error list
|
// initialize error list
|
||||||
$error_array = [];
|
$error_array = [];
|
||||||
|
|
@ -1840,6 +1851,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($obj, $payload);
|
$mclient->sendEvent($obj, $payload);
|
||||||
$mclient->sendRiderEvent($obj, $payload);
|
$mclient->sendRiderEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$mclientv2->sendEvent($obj, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error_array;
|
return $error_array;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace App\Service;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
use App\Service\APNSClient;
|
use App\Service\APNSClient;
|
||||||
use App\Service\MapTools;
|
use App\Service\MapTools;
|
||||||
use App\Service\HubSelector;
|
use App\Service\HubSelector;
|
||||||
|
|
@ -29,7 +30,7 @@ interface JobOrderHandlerInterface
|
||||||
public function processOneStepJobOrder(Request $req, int $id);
|
public function processOneStepJobOrder(Request $req, int $id);
|
||||||
|
|
||||||
// dispatch job order
|
// dispatch job order
|
||||||
public function dispatchJobOrder(Request $req, int $id, MQTTClient $mclient);
|
public function dispatchJobOrder(Request $req, int $id, MQTTClient $mclient, MQTTClientApiv2 $mclientv2);
|
||||||
|
|
||||||
// assign job order
|
// assign job order
|
||||||
public function assignJobOrder(Request $req, int $id);
|
public function assignJobOrder(Request $req, int $id);
|
||||||
|
|
@ -38,16 +39,16 @@ interface JobOrderHandlerInterface
|
||||||
public function fulfillJobOrder(Request $req, int $id);
|
public function fulfillJobOrder(Request $req, int $id);
|
||||||
|
|
||||||
// cancel job order
|
// cancel job order
|
||||||
public function cancelJobOrder(Request $req, int $id, MQTTClient $mclient);
|
public function cancelJobOrder(Request $req, int $id, MQTTClient $mclient, MQTTClientApiv2 $mclientv2);
|
||||||
|
|
||||||
// set hub for job order
|
// set hub for job order
|
||||||
public function setHub(Request $req, int $id, MQTTClient $mclient);
|
public function setHub(Request $req, int $id, MQTTClient $mclient, MQTTClientApiv2 $mclientv2);
|
||||||
|
|
||||||
// reject hub for job order
|
// reject hub for job order
|
||||||
public function rejectHub(Request $req, int $id);
|
public function rejectHub(Request $req, int $id);
|
||||||
|
|
||||||
// set rider for job order
|
// set rider for job order
|
||||||
public function setRider(Request $req, int $id, MQTTClient $mclient);
|
public function setRider(Request $req, int $id, MQTTClient $mclient, MQTTClientApiv2 $mclientv2);
|
||||||
|
|
||||||
// unlock processor
|
// unlock processor
|
||||||
public function unlockProcessor(int $id);
|
public function unlockProcessor(int $id);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ use App\Entity\JobOrder;
|
||||||
class MQTTClient
|
class MQTTClient
|
||||||
{
|
{
|
||||||
const PREFIX = 'motolite.control.';
|
const PREFIX = 'motolite.control.';
|
||||||
const PREFIX_APIv2 = 'motolite.control.v2.';
|
|
||||||
const RIDER_PREFIX = 'motorider_';
|
const RIDER_PREFIX = 'motorider_';
|
||||||
|
|
||||||
// protected $mclient;
|
// protected $mclient;
|
||||||
|
|
@ -36,39 +35,11 @@ class MQTTClient
|
||||||
|
|
||||||
public function sendEvent(JobOrder $job_order, $payload)
|
public function sendEvent(JobOrder $job_order, $payload)
|
||||||
{
|
{
|
||||||
error_log("CUSTOMER ID: " . $job_order->getCustomer()->getID());
|
|
||||||
//error_log('sending mqtt event: ');
|
//error_log('sending mqtt event: ');
|
||||||
//error_log(print_r($payload, true));
|
//error_log(print_r($payload, true));
|
||||||
|
|
||||||
// get all new and legacy mobile sessions
|
$sessions = $job_order->getCustomer()->getMobileSessions();
|
||||||
$legacy_sessions = $job_order->getCustomer()->getMobileSessions();
|
if (count($sessions) == 0)
|
||||||
|
|
||||||
$new_sessions = [];
|
|
||||||
$cust_user = $job_order->getCustomer()->getCustomerUser();
|
|
||||||
if (!empty($cust_user)) {
|
|
||||||
error_log("CUSTOMER USER ID: " . $cust_user->getID());
|
|
||||||
$new_sessions = $cust_user->getMobileSessions();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: make this more elegant. looping through each instead of merging the two because doctrine returns PersistentCollection if empty, and array if not
|
|
||||||
$sessions = [];
|
|
||||||
foreach ($legacy_sessions as $sess) {
|
|
||||||
error_log("FOUND LEGACY SESSION: " . $sess->getID());
|
|
||||||
$sessions[] = [
|
|
||||||
'data' => $sess,
|
|
||||||
'legacy' => true,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($new_sessions as $sess) {
|
|
||||||
error_log("FOUND NEW SESSION: " . $sess->getID());
|
|
||||||
$sessions[] = [
|
|
||||||
'data' => $sess,
|
|
||||||
'legacy' => false,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($sessions))
|
|
||||||
{
|
{
|
||||||
error_log("no sessions to send mqtt event to");
|
error_log("no sessions to send mqtt event to");
|
||||||
return;
|
return;
|
||||||
|
|
@ -79,24 +50,11 @@ class MQTTClient
|
||||||
// send to every customer session
|
// send to every customer session
|
||||||
foreach ($sessions as $sess)
|
foreach ($sessions as $sess)
|
||||||
{
|
{
|
||||||
$phone_num = $sess['data']->getPhoneNumber();
|
$phone_num = $sess->getPhoneNumber();
|
||||||
|
$channel = self::PREFIX . $phone_num;
|
||||||
$channel_payload = $payload;
|
|
||||||
|
|
||||||
// keep channel and payload for legacy the same
|
|
||||||
if ($sess['legacy']) {
|
|
||||||
$prefix = self::PREFIX;
|
|
||||||
} else {
|
|
||||||
$prefix = self::PREFIX_APIv2;
|
|
||||||
$channel_payload['jo_id'] = $job_order->getID();
|
|
||||||
}
|
|
||||||
|
|
||||||
$channel = $prefix . $phone_num;
|
|
||||||
|
|
||||||
error_log("SENDING TO CHANNEL: " . $channel);
|
|
||||||
|
|
||||||
// gather channels, so we only send once
|
// gather channels, so we only send once
|
||||||
$channels[$channel] = json_encode($channel_payload);
|
$channels[$channel] = json_encode($payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($channels as $channel => $json_payload)
|
foreach ($channels as $channel => $json_payload)
|
||||||
|
|
|
||||||
71
src/Service/MQTTClientApiv2.php
Normal file
71
src/Service/MQTTClientApiv2.php
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Service;
|
||||||
|
|
||||||
|
use Mosquitto\Client as MosquittoClient;
|
||||||
|
use App\Entity\JobOrder;
|
||||||
|
|
||||||
|
class MQTTClientApiv2
|
||||||
|
{
|
||||||
|
const PREFIX = 'motolite.control.v2.';
|
||||||
|
|
||||||
|
// protected $mclient;
|
||||||
|
protected $redis;
|
||||||
|
protected $key;
|
||||||
|
|
||||||
|
public function __construct(RedisClientProvider $redis_client, $key)
|
||||||
|
{
|
||||||
|
$this->redis = $redis_client->getRedisClient();
|
||||||
|
$this->key = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
|
// $this->mclient->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publish($channel, $message)
|
||||||
|
{
|
||||||
|
// $this->mclient->publish($channel, $message);
|
||||||
|
|
||||||
|
$data = $channel . '|' . $message;
|
||||||
|
$this->redis->lpush($this->key, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendEvent(JobOrder $job_order, $payload)
|
||||||
|
{
|
||||||
|
//error_log('sending mqtt event: ');
|
||||||
|
//error_log(print_r($payload, true));
|
||||||
|
|
||||||
|
// get all v2 sessions
|
||||||
|
$sessions = [];
|
||||||
|
$cust_user = $job_order->getCustomer()->getCustomerUser();
|
||||||
|
if (!empty($cust_user)) {
|
||||||
|
$sessions = $cust_user->getMobileSessions();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($sessions)) {
|
||||||
|
error_log("no sessions to send mqtt event to");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$channels = [];
|
||||||
|
|
||||||
|
// send to every customer session
|
||||||
|
foreach ($sessions as $sess) {
|
||||||
|
$phone_num = $sess->getPhoneNumber();
|
||||||
|
$channel = self::PREFIX . $phone_num;
|
||||||
|
|
||||||
|
// attach jo id to all payloads
|
||||||
|
$payload['jo_id'] = $job_order->getID();
|
||||||
|
|
||||||
|
// gather channels, so we only send once
|
||||||
|
$channels[$channel] = json_encode($payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($channels as $channel => $json_payload) {
|
||||||
|
$this->publish($channel, $json_payload);
|
||||||
|
// error_log('sent to ' . $channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,6 +18,7 @@ use App\Service\RiderAPIHandlerInterface;
|
||||||
use App\Service\RedisClientProvider;
|
use App\Service\RedisClientProvider;
|
||||||
use App\Service\RiderCache;
|
use App\Service\RiderCache;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
use App\Service\WarrantyHandler;
|
use App\Service\WarrantyHandler;
|
||||||
use App\Service\JobOrderHandlerInterface;
|
use App\Service\JobOrderHandlerInterface;
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
|
|
@ -42,6 +43,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
protected $rcache;
|
protected $rcache;
|
||||||
protected $country_code;
|
protected $country_code;
|
||||||
protected $mclient;
|
protected $mclient;
|
||||||
|
protected $mclientv2;
|
||||||
protected $wh;
|
protected $wh;
|
||||||
protected $jo_handler;
|
protected $jo_handler;
|
||||||
protected $ic;
|
protected $ic;
|
||||||
|
|
@ -49,7 +51,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, RedisClientProvider $redis,
|
public function __construct(EntityManagerInterface $em, RedisClientProvider $redis,
|
||||||
EncoderFactoryInterface $ef, RiderCache $rcache,
|
EncoderFactoryInterface $ef, RiderCache $rcache,
|
||||||
string $country_code, MQTTClient $mclient,
|
string $country_code, MQTTClient $mclient, MQTTClientApiv2 $mclientv2,
|
||||||
WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler,
|
WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler,
|
||||||
InvoiceGeneratorInterface $ic)
|
InvoiceGeneratorInterface $ic)
|
||||||
{
|
{
|
||||||
|
|
@ -59,6 +61,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
$this->rcache = $rcache;
|
$this->rcache = $rcache;
|
||||||
$this->country_code = $country_code;
|
$this->country_code = $country_code;
|
||||||
$this->mclient = $mclient;
|
$this->mclient = $mclient;
|
||||||
|
$this->mclientv2 = $mclientv2;
|
||||||
$this->wh = $wh;
|
$this->wh = $wh;
|
||||||
$this->jo_handler = $jo_handler;
|
$this->jo_handler = $jo_handler;
|
||||||
$this->ic = $ic;
|
$this->ic = $ic;
|
||||||
|
|
@ -424,6 +427,9 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
];
|
];
|
||||||
$this->mclient->sendEvent($jo, $payload);
|
$this->mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$this->mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -465,6 +471,9 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
];
|
];
|
||||||
$this->mclient->sendEvent($jo, $payload);
|
$this->mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$this->mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -578,6 +587,9 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
];
|
];
|
||||||
$this->mclient->sendEvent($jo, $payload);
|
$this->mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$this->mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ use App\Service\RiderAPIHandlerInterface;
|
||||||
use App\Service\RedisClientProvider;
|
use App\Service\RedisClientProvider;
|
||||||
use App\Service\RiderCache;
|
use App\Service\RiderCache;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
use App\Service\WarrantyHandler;
|
use App\Service\WarrantyHandler;
|
||||||
use App\Service\JobOrderHandlerInterface;
|
use App\Service\JobOrderHandlerInterface;
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
|
|
@ -47,6 +48,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
protected $rcache;
|
protected $rcache;
|
||||||
protected $country_code;
|
protected $country_code;
|
||||||
protected $mclient;
|
protected $mclient;
|
||||||
|
protected $mclientv2;
|
||||||
protected $wh;
|
protected $wh;
|
||||||
protected $jo_handler;
|
protected $jo_handler;
|
||||||
protected $ic;
|
protected $ic;
|
||||||
|
|
@ -56,7 +58,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, RedisClientProvider $redis,
|
public function __construct(EntityManagerInterface $em, RedisClientProvider $redis,
|
||||||
EncoderFactoryInterface $ef, RiderCache $rcache,
|
EncoderFactoryInterface $ef, RiderCache $rcache,
|
||||||
string $country_code, MQTTClient $mclient,
|
string $country_code, MQTTClient $mclient, MQTTClientApiv2 $mclientv2,
|
||||||
WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler,
|
WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler,
|
||||||
InvoiceGeneratorInterface $ic, RisingTideGateway $rt,
|
InvoiceGeneratorInterface $ic, RisingTideGateway $rt,
|
||||||
RiderTracker $rider_tracker, TranslatorInterface $translator)
|
RiderTracker $rider_tracker, TranslatorInterface $translator)
|
||||||
|
|
@ -67,6 +69,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
$this->rcache = $rcache;
|
$this->rcache = $rcache;
|
||||||
$this->country_code = $country_code;
|
$this->country_code = $country_code;
|
||||||
$this->mclient = $mclient;
|
$this->mclient = $mclient;
|
||||||
|
$this->mclientv2 = $mclientv2;
|
||||||
$this->wh = $wh;
|
$this->wh = $wh;
|
||||||
$this->jo_handler = $jo_handler;
|
$this->jo_handler = $jo_handler;
|
||||||
$this->ic = $ic;
|
$this->ic = $ic;
|
||||||
|
|
@ -466,6 +469,9 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
];
|
];
|
||||||
$this->mclient->sendEvent($jo, $payload);
|
$this->mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$this->mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -507,6 +513,9 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
];
|
];
|
||||||
$this->mclient->sendEvent($jo, $payload);
|
$this->mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$this->mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -661,6 +670,9 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
];
|
];
|
||||||
$this->mclient->sendEvent($jo, $payload);
|
$this->mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$this->mclientv2->sendEvent($jo, $payload);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
use App\Service\RiderAssignmentHandlerInterface;
|
use App\Service\RiderAssignmentHandlerInterface;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
use App\Service\APNSClient;
|
use App\Service\APNSClient;
|
||||||
|
|
||||||
use App\Entity\JobOrder;
|
use App\Entity\JobOrder;
|
||||||
|
|
@ -18,12 +19,13 @@ class CMBRiderAssignmentHandler implements RiderAssignmentHandlerInterface
|
||||||
protected $em;
|
protected $em;
|
||||||
protected $aclient;
|
protected $aclient;
|
||||||
protected $mclient;
|
protected $mclient;
|
||||||
|
protected $mclientv2;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, MQTTClient $mclient,
|
public function __construct(EntityManagerInterface $em, MQTTClient $mclient, MQTTClientApiv2 $mclientv2, APNSClient $aclient)
|
||||||
APNSClient $aclient)
|
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->mclient = $mclient;
|
$this->mclient = $mclient;
|
||||||
|
$this->mclientv2 = $mclientv2;
|
||||||
$this->aclient = $aclient;
|
$this->aclient = $aclient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,6 +40,9 @@ class CMBRiderAssignmentHandler implements RiderAssignmentHandlerInterface
|
||||||
// send event
|
// send event
|
||||||
$this->mclient->sendEvent($obj, $payload);
|
$this->mclient->sendEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$this->mclientv2->sendEvent($obj, $payload);
|
||||||
|
|
||||||
// check if rider is available
|
// check if rider is available
|
||||||
if ($rider->isAvailable())
|
if ($rider->isAvailable())
|
||||||
{
|
{
|
||||||
|
|
@ -66,6 +71,9 @@ class CMBRiderAssignmentHandler implements RiderAssignmentHandlerInterface
|
||||||
];
|
];
|
||||||
$this->mclient->sendEvent($obj, $payload);
|
$this->mclient->sendEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$this->mclientv2->sendEvent($obj, $payload);
|
||||||
|
|
||||||
// send fulfill/complete event to rider
|
// send fulfill/complete event to rider
|
||||||
$this->mclient->sendRiderEvent($obj, $payload);
|
$this->mclient->sendRiderEvent($obj, $payload);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
use App\Service\RiderAssignmentHandlerInterface;
|
use App\Service\RiderAssignmentHandlerInterface;
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\MQTTClientApiv2;
|
||||||
use App\Service\APNSClient;
|
use App\Service\APNSClient;
|
||||||
|
|
||||||
use App\Entity\JobOrder;
|
use App\Entity\JobOrder;
|
||||||
|
|
@ -20,13 +21,14 @@ class ResqRiderAssignmentHandler implements RiderAssignmentHandlerInterface
|
||||||
protected $em;
|
protected $em;
|
||||||
protected $aclient;
|
protected $aclient;
|
||||||
protected $mclient;
|
protected $mclient;
|
||||||
|
protected $mclientv2;
|
||||||
protected $translator;
|
protected $translator;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, MQTTClient $mclient,
|
public function __construct(EntityManagerInterface $em, MQTTClient $mclient, MQTTClientApiv2 $mclientv2, APNSClient $aclient, TranslatorInterface $translator)
|
||||||
APNSClient $aclient, TranslatorInterface $translator)
|
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->mclient = $mclient;
|
$this->mclient = $mclient;
|
||||||
|
$this->mclientv2 = $mclientv2;
|
||||||
$this->aclient = $aclient;
|
$this->aclient = $aclient;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
@ -42,6 +44,9 @@ class ResqRiderAssignmentHandler implements RiderAssignmentHandlerInterface
|
||||||
// send event
|
// send event
|
||||||
$this->mclient->sendEvent($obj, $payload);
|
$this->mclient->sendEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$this->mclientv2->sendEvent($obj, $payload);
|
||||||
|
|
||||||
// check if rider is available
|
// check if rider is available
|
||||||
if ($rider->isAvailable())
|
if ($rider->isAvailable())
|
||||||
{
|
{
|
||||||
|
|
@ -72,6 +77,9 @@ class ResqRiderAssignmentHandler implements RiderAssignmentHandlerInterface
|
||||||
];
|
];
|
||||||
$this->mclient->sendEvent($obj, $payload);
|
$this->mclient->sendEvent($obj, $payload);
|
||||||
|
|
||||||
|
// NOTE: for resq2 app
|
||||||
|
$this->mclientv2->sendEvent($obj, $payload);
|
||||||
|
|
||||||
// send fulfill/complete event to rider
|
// send fulfill/complete event to rider
|
||||||
$this->mclient->sendRiderEvent($obj, $payload);
|
$this->mclient->sendRiderEvent($obj, $payload);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue