create new thing for mission acsses and event and listener
This commit is contained in:
@@ -8,7 +8,7 @@ use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class FinishRequestEvent
|
||||
class SendDataToFMSEvent
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Enums\MissionCategory;
|
||||
use App\Enums\MissionStates;
|
||||
use App\Enums\MissionTypes;
|
||||
use App\Enums\MissionZones;
|
||||
use App\Events\V3\Dashboard\Mission\SendDataToFMSEvent;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Mission\ControlUnit\FinishRequest;
|
||||
use App\Http\Requests\V3\Mission\ControlUnit\NoProcessRequest;
|
||||
@@ -63,6 +64,8 @@ class ControlUnitController extends Controller
|
||||
]);
|
||||
});
|
||||
|
||||
SendDataToFMSEvent::dispatch($mission);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,19 @@
|
||||
namespace App\Listeners\V3\Dashboard\Harim;
|
||||
|
||||
use App\Events\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedEvent;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class ConfirmGuaranteeLetterNeedListener
|
||||
class ConfirmGuaranteeLetterNeedListener implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* The name of the queue the job should be sent to.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $queue = 'harim';
|
||||
|
||||
protected string $url;
|
||||
protected string $password;
|
||||
protected string $username;
|
||||
@@ -17,6 +26,10 @@ class ConfirmGuaranteeLetterNeedListener
|
||||
$this->username = config('harim_web_services.reject.username');
|
||||
$this->password = config('harim_web_services.reject.password');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RequestException
|
||||
*/
|
||||
public function handle(ConfirmGuaranteeLetterNeedEvent $event): void
|
||||
{
|
||||
Http::post($this->url,
|
||||
@@ -27,7 +40,7 @@ class ConfirmGuaranteeLetterNeedListener
|
||||
'' => $event->harim->id,
|
||||
'' => $event->harim->id,
|
||||
'' => $event->harim->id,
|
||||
' ' => $event->harim->id,
|
||||
'' => $event->harim->id,
|
||||
))->throw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,19 @@
|
||||
namespace App\Listeners\V3\Dashboard\Harim;
|
||||
|
||||
use App\Events\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedEvent;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class ConfirmNoRoadAccessNeedListener
|
||||
class ConfirmNoRoadAccessNeedListener implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* The name of the queue the job should be sent to.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $queue = 'harim';
|
||||
|
||||
protected string $url;
|
||||
protected string $password;
|
||||
protected string $username;
|
||||
@@ -18,6 +27,9 @@ class ConfirmNoRoadAccessNeedListener
|
||||
$this->password = config('harim_web_services.reject.password');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RequestException
|
||||
*/
|
||||
public function handle(ConfirmNoRoadAccessNeedEvent $event): void
|
||||
{
|
||||
Http::post($this->url,
|
||||
|
||||
@@ -3,10 +3,19 @@
|
||||
namespace App\Listeners\V3\Dashboard\Harim;
|
||||
|
||||
use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessEditNeedEvent;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class ConfirmRoadAccessEditNeedListener
|
||||
class ConfirmRoadAccessEditNeedListener implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* The name of the queue the job should be sent to.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $queue = 'harim';
|
||||
|
||||
protected string $url;
|
||||
protected string $password;
|
||||
protected string $username;
|
||||
@@ -18,6 +27,9 @@ class ConfirmRoadAccessEditNeedListener
|
||||
$this->password = config('harim_web_services.reject.password');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RequestException
|
||||
*/
|
||||
public function handle(ConfirmRoadAccessEditNeedEvent $event): void
|
||||
{
|
||||
Http::post($this->url,
|
||||
|
||||
@@ -3,10 +3,19 @@
|
||||
namespace App\Listeners\V3\Dashboard\Harim;
|
||||
|
||||
use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessNeedEvent;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class ConfirmRoadAccessNeedListener
|
||||
class ConfirmRoadAccessNeedListener implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* The name of the queue the job should be sent to.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $queue = 'harim';
|
||||
|
||||
protected string $url;
|
||||
protected string $password;
|
||||
protected string $username;
|
||||
@@ -20,6 +29,7 @@ class ConfirmRoadAccessNeedListener
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
* @throws RequestException
|
||||
*/
|
||||
public function handle(ConfirmRoadAccessNeedEvent $event): void
|
||||
{
|
||||
|
||||
@@ -3,11 +3,19 @@
|
||||
namespace App\Listeners\V3\Dashboard\Harim;
|
||||
|
||||
use App\Events\V3\Dashboard\Harim\RejectRequestEvent;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class RejectRequestListener
|
||||
class RejectRequestListener implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* The name of the queue the job should be sent to.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $queue = 'harim';
|
||||
|
||||
protected string $url;
|
||||
protected string $password;
|
||||
protected string $username;
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\V3\Dashboard\Mission;
|
||||
|
||||
use App\Events\V3\Dashboard\Mission\FinishRequestEvent;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class FinishRequestListener
|
||||
{
|
||||
protected string $url;
|
||||
protected string $password;
|
||||
protected string $username;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = config('App\Services\FMSService.url');
|
||||
$this->username = config('App\Services\FMSService.username');
|
||||
$this->password = config('App\Services\FMSService.password');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RequestException
|
||||
*/
|
||||
public function handle(FinishRequestEvent $event): void
|
||||
{
|
||||
Http::post($this->url,
|
||||
array(
|
||||
'area' => $event->mission->area,
|
||||
'machine_code' => $event->mission->machines()->pluck('machines.machine_code'),
|
||||
'start_date' => $event->mission->start_date,
|
||||
'end_date' => $event->mission->end_date,
|
||||
))->throw();
|
||||
}
|
||||
}
|
||||
28
app/Listeners/V3/Dashboard/Mission/SendDataToFMSListener.php
Normal file
28
app/Listeners/V3/Dashboard/Mission/SendDataToFMSListener.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\V3\Dashboard\Mission;
|
||||
|
||||
use App\Events\V3\Dashboard\Mission\SendDataToFMSEvent;
|
||||
use App\Services\FMS\GetErrorRateService;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
|
||||
class SendDataToFMSListener implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* The name of the queue the job should be sent to.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $queue = 'fms';
|
||||
|
||||
/**
|
||||
* @throws RequestException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handle(SendDataToFMSEvent $event, GetErrorRateService $getErrorRateService): void
|
||||
{
|
||||
$getErrorRateService->run($event->mission);
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,13 @@ use App\Events\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedEvent;
|
||||
use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessEditNeedEvent;
|
||||
use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessNeedEvent;
|
||||
use App\Events\V3\Dashboard\Harim\RejectRequestEvent;
|
||||
use App\Events\V3\Dashboard\Mission\SendDataToFMSEvent;
|
||||
use App\Listeners\V3\Dashboard\Harim\ConfirmGuaranteeLetterNeedListener;
|
||||
use App\Listeners\V3\Dashboard\Harim\ConfirmNoRoadAccessNeedListener;
|
||||
use App\Listeners\V3\Dashboard\Harim\ConfirmRoadAccessEditNeedListener;
|
||||
use App\Listeners\V3\Dashboard\Harim\ConfirmRoadAccessNeedListener;
|
||||
use App\Listeners\V3\Dashboard\Harim\RejectRequestListener;
|
||||
use App\Listeners\V3\Dashboard\Mission\SendDataToFMSListener;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
@@ -50,6 +52,9 @@ class EventServiceProvider extends ServiceProvider
|
||||
],
|
||||
ConfirmGuaranteeLetterNeedEvent::class => [
|
||||
ConfirmGuaranteeLetterNeedListener::class
|
||||
],
|
||||
SendDataToFMSEvent::class => [
|
||||
SendDataToFMSListener::class
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
@@ -500,6 +500,7 @@ Route::prefix('missions')
|
||||
->controller(ControlUnitController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index');
|
||||
Route::post('/no_process','noProcess')->name('noProcess');
|
||||
Route::post('/start/{mission}', 'start')->name('start');
|
||||
Route::post('/finish/{mission}', 'finish')->name('finish');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user