Merge pull request #53 from witelgroup/feature/AddItemInMission

change code
This commit is contained in:
Amir Ghasempoor
2025-09-27 15:16:05 +03:30
committed by GitHub
3 changed files with 18 additions and 19 deletions

View File

@@ -2,24 +2,24 @@
namespace App\Enums;
enum FMSResultCode: int
enum FMSResultCode: string
{
case SUCCESSFUL = 0;
case INVALID_CREDENTIAL = 1;
case NO_GPS_DEVICE_CONNECTED = 2;
case UNAUTHORIZE = 3;
case RATE_LIMIT = 4;
case INVALID_PARAMETERS = 5;
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
public static function name(string $state): string
{
$mapArray = [
0 => "اﺟﺮاي ﺗﺎﺑﻊ ﻣﻮﻓﻘﯿﺖ آﻣﯿﺰ ﺑﻮد.",
1 => "نام ﮐﺎرﺑﺮي ﯾﺎ ﮐﻠﻤﻪ ﻋﺒﻮر ﺻﺤﯿﺢ ﻧﯿﺴﺖ.",
2 => "خودرو با کد مورد نظر وجود ندارد یا دستگاه ردیاب به آن متصل نیست.",
3 => "کاربر به خودرو مورد نظر دسترسی ندارد.",
4 => "ﺗﻌﺪاد دﻓﻌﺎت ﺟﺮاي ﺗﺎﺑﻊ ﺑﯿﺶ از ﺣﺪ ﻣﺠﺎز اﺳﺖ(اﯾﻦ ﺳﺮوﯾﺲ را در ﻫﺮ ثاﻧﯿﻪ ﻓﻘﻂ ﯾﮏ ﺑﺎر ﻣﯽﺗﻮان اﺟﺮاﮐﺮد)",
5 => "پارامتر های داده شده صحیح نیستند",
"0" => "اﺟﺮاي ﺗﺎﺑﻊ ﻣﻮﻓﻘﯿﺖ آﻣﯿﺰ ﺑﻮد.",
"-1" => "نام ﮐﺎرﺑﺮي ﯾﺎ ﮐﻠﻤﻪ ﻋﺒﻮر ﺻﺤﯿﺢ ﻧﯿﺴﺖ.",
"-2" => "خودرو با کد مورد نظر وجود ندارد یا دستگاه ردیاب به آن متصل نیست.",
"-3" => "کاربر به خودرو مورد نظر دسترسی ندارد.",
"-4" => "ﺗﻌﺪاد دﻓﻌﺎت ﺟﺮاي ﺗﺎﺑﻊ ﺑﯿﺶ از ﺣﺪ ﻣﺠﺎز اﺳﺖ(اﯾﻦ ﺳﺮوﯾﺲ را در ﻫﺮ ثاﻧﯿﻪ ﻓﻘﻂ ﯾﮏ ﺑﺎر ﻣﯽﺗﻮان اﺟﺮاﮐﺮد)",
"-5" => "پارامتر های داده شده صحیح نیستند",
];
return $mapArray[$state];

View File

@@ -29,7 +29,7 @@ class SendDataToFMSListener implements ShouldQueue
$mission = $event->mission;
$this->getErrorRateService->setInputParameters([
'url' => config('fms_web_services.Error_Rate.url'),
'username' => config('fms_web_services.Error_Rate.username'),
'password' => config('fms_web_services.Error_Rate.password'),
'missionArea' => $mission->area['coordinates'],
'missionStartDT' => $mission->start_time->format('Y-m-d\TH:i:s'),

View File

@@ -10,13 +10,11 @@ class GetErrorRateService
{
protected string $url;
protected string $channelName;
protected string $password;
protected string $username;
protected array $inputParameters;
public function __construct()
{
$this->username = config('fms_web_services.Error_Rate.username');
$this->url = config('fms_web_services.Error_Rate.url');
$this->channelName = 'fms_error_rate';
}
@@ -48,9 +46,10 @@ class GetErrorRateService
public function sendRequest(): array
{
return Http::withHeaders(['Content-Type' => 'application/json'])
->withBody(json_encode($this->inputParameters))
->throw()
->withoutVerifying()
->post($this->url, $this->inputParameters)
->post($this->url)
->json();
}
}