change code in some item
This commit is contained in:
27
app/Enums/FMSResultCode.php
Normal file
27
app/Enums/FMSResultCode.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum FMSResultCode: int
|
||||||
|
{
|
||||||
|
case SUCCESSFUL = 0;
|
||||||
|
case INVALID_CREDENTIAL = 1;
|
||||||
|
case NO_GPS_DEVICE_CONNECTED = 2;
|
||||||
|
case UNAUTHORIZE = 3;
|
||||||
|
case RATE_LIMIT = 4;
|
||||||
|
case INVALID_PARAMETERS = 5;
|
||||||
|
|
||||||
|
public static function name(int $state): string
|
||||||
|
{
|
||||||
|
$mapArray = [
|
||||||
|
0 => "اﺟﺮاي ﺗﺎﺑﻊ ﻣﻮﻓﻘﯿﺖ آﻣﯿﺰ ﺑﻮد.",
|
||||||
|
1 => "نام ﮐﺎرﺑﺮي ﯾﺎ ﮐﻠﻤﻪ ﻋﺒﻮر ﺻﺤﯿﺢ ﻧﯿﺴﺖ.",
|
||||||
|
2 => "خودرو با کد مورد نظر وجود ندارد یا دستگاه ردیاب به آن متصل نیست.",
|
||||||
|
3 => "کاربر به خودرو مورد نظر دسترسی ندارد.",
|
||||||
|
4 => "ﺗﻌﺪاد دﻓﻌﺎت ﺟﺮاي ﺗﺎﺑﻊ ﺑﯿﺶ از ﺣﺪ ﻣﺠﺎز اﺳﺖ(اﯾﻦ ﺳﺮوﯾﺲ را در ﻫﺮ ثاﻧﯿﻪ ﻓﻘﻂ ﯾﮏ ﺑﺎر ﻣﯽﺗﻮان اﺟﺮاﮐﺮد)",
|
||||||
|
5 => "پارامتر های داده شده صحیح نیستند",
|
||||||
|
];
|
||||||
|
|
||||||
|
return $mapArray[$state];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,20 +28,22 @@ class SendDataToFMSListener implements ShouldQueue
|
|||||||
$mission = $event->mission;
|
$mission = $event->mission;
|
||||||
|
|
||||||
$this->getErrorRateService->setInputParameters([
|
$this->getErrorRateService->setInputParameters([
|
||||||
|
'url' => config('fms_web_services.Error_Rate.url'),
|
||||||
|
'password' => config('fms_web_services.Error_Rate.password'),
|
||||||
'missionArea' => $mission->area['coordinates'],
|
'missionArea' => $mission->area['coordinates'],
|
||||||
'missionStartDT' => $mission->start_time->format('Y-m-d\TH:i:s'),
|
'missionStartDT' => $mission->start_time->format('Y-m-d\TH:i:s'),
|
||||||
'missionEndDT' => $mission->finish_time->format('Y-m-d\TH:i:s'),
|
'missionEndDT' => $mission->finish_time->format('Y-m-d\TH:i:s'),
|
||||||
'machineCode' => $mission->machines()->first('cmms_machines.machine_code'),
|
'machineCode' => $mission->machines()->first()->value('machine_code'),
|
||||||
'areaType' => $mission->area['type'] === 'polygon' ? 1 : 2,
|
'areaType' => $mission->area['type'] === 'polygon' ? 1 : 2,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$responseData = $this->getErrorRateService->run();
|
$responseData = $this->getErrorRateService->run();
|
||||||
|
|
||||||
$mission->update([
|
$mission->update([
|
||||||
'in_area_duration' => $responseData['TimeInAreaSeconds'],
|
'in_area_duration' => $responseData['timeInAreaSeconds'],
|
||||||
'first_enter' => $responseData['FirstEnter'],
|
'first_enter' => $responseData['firstEnter'],
|
||||||
'last_exit' => $responseData['LastExit'],
|
'last_exit' => $responseData['lastExit'],
|
||||||
'point_number_sent' => $responseData['NoOfPointsInMission'],
|
'point_number_sent' => $responseData['noOfPointsInMission'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,4 +126,18 @@ class Accident extends Model
|
|||||||
get: fn ($value) => env("PAYMENT_LINK")."/#/pay/".explode("/", $this->bill_code)[0]."/{$this->final_amount}",
|
get: fn ($value) => env("PAYMENT_LINK")."/#/pay/".explode("/", $this->bill_code)[0]."/{$this->final_amount}",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function depositInsuranceImage(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => $value == null ? null : Storage::disk('public')->url($value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function depositIdaghiImage(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: fn($value) => $value == null ? null : Storage::disk('public')->url($value)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ class Mission extends Model
|
|||||||
|
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
protected $hidden = ['pivot'];
|
protected $hidden = ['pivot'];
|
||||||
|
protected $casts = [
|
||||||
|
'start_time' => 'datetime',
|
||||||
|
'finish_time' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
protected function requestedMachines(): Attribute
|
protected function requestedMachines(): Attribute
|
||||||
{
|
{
|
||||||
@@ -26,7 +30,7 @@ class Mission extends Model
|
|||||||
protected function area(): Attribute
|
protected function area(): Attribute
|
||||||
{
|
{
|
||||||
return Attribute::make(
|
return Attribute::make(
|
||||||
get: fn($value) => json_decode($value)
|
get: fn($value) => json_decode($value, true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ class GetErrorRateService
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->url = config('fms_web_services.Error_Rate.url');
|
|
||||||
$this->password = config('fms_web_services.Error_Rate.password');
|
|
||||||
$this->username = config('fms_web_services.Error_Rate.username');
|
$this->username = config('fms_web_services.Error_Rate.username');
|
||||||
$this->channelName = 'fms_error_rate';
|
$this->channelName = 'fms_error_rate';
|
||||||
}
|
}
|
||||||
@@ -49,22 +47,10 @@ class GetErrorRateService
|
|||||||
|
|
||||||
public function sendRequest(): array
|
public function sendRequest(): array
|
||||||
{
|
{
|
||||||
$inputData = $this->makeInputParameters();
|
return Http::withHeaders(['Content-Type' => 'application/json'])
|
||||||
|
|
||||||
return Http::withBody($inputData)
|
|
||||||
->throw()
|
->throw()
|
||||||
->withoutVerifying()
|
->withoutVerifying()
|
||||||
->post($this->url)
|
->post($this->url, $this->inputParameters)
|
||||||
->json();
|
->json();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function makeInputParameters(): string
|
|
||||||
{
|
|
||||||
$inputData = $this->inputParameters + array(
|
|
||||||
"username" => $this->username,
|
|
||||||
"password" => $this->password,
|
|
||||||
);
|
|
||||||
|
|
||||||
return json_encode($inputData);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user