diff --git a/app/Console/Commands/GetMachinesInfoListCommand.php b/app/Console/Commands/GetMachinesInfoListCommand.php index 4f01d45d..a11742cd 100644 --- a/app/Console/Commands/GetMachinesInfoListCommand.php +++ b/app/Console/Commands/GetMachinesInfoListCommand.php @@ -35,9 +35,9 @@ class GetMachinesInfoListCommand extends Command $updatedRows = 0; - if (isset($response['vw_MachBankFull'])) { + if (isset($response['vw_MachBankFull2'])) { - foreach ($response['vw_MachBankFull'] as $entry) { + foreach ($response['vw_MachBankFull2'] as $entry) { // Insert data into the database CMMSMachine::query()->updateOrCreate( [ @@ -54,8 +54,12 @@ class GetMachinesInfoListCommand extends Command 'car_id' => $entry['Id'], 'unit_group' => $entry['UnitGroup'] == [] ? null : $entry['UnitGroup'], 'plak_number' => $entry['PlakNumber'] ?? null, + 'province_id' => $entry['UnitGroupCode'] ?? null, + 'city_id' => $entry['UnitCode'] ?? null, + 'station_id' => $entry['Layer3Code'] ?? null, ]); - $updatedRows += 1; + + ++$updatedRows; } } diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php index 69dd473d..bcee0cf0 100644 --- a/app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmGuaranteeLetterNeedListener.php @@ -23,7 +23,24 @@ class ConfirmGuaranteeLetterNeedListener implements ShouldQueue */ public function handle(ConfirmGuaranteeLetterNeedEvent $event, SendAccessRoadStatusService $sendAccessRoadStatusService): void { - $sendAccessRoadStatusService->makeInputParameters($event->harim->data); + + $arrayData = json_decode($event->harim->data, true); + + $sendAccessRoadStatusService->makeInputParameters([ + 'data' => [ + 'actionId' => $arrayData['actionId'], + 'ruleId' => $arrayData['ruleId'], + 'activityId' => $arrayData['activityId'], + 'requestId' => $arrayData['requestId'], + 'taskId' => $arrayData['taskId'], + 'code' => $event->harim->id, + 'resultStatus' => 1, + 'Description' => $event->harim->last_description, + ], + + 'token' => $arrayData['token'], + ]); + $sendAccessRoadStatusService->run(); } } diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php index 6161f4bc..7c779d46 100644 --- a/app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmNoRoadAccessNeedListener.php @@ -23,7 +23,24 @@ class ConfirmNoRoadAccessNeedListener implements ShouldQueue */ public function handle(ConfirmNoRoadAccessNeedEvent $event, SendAccessRoadStatusService $sendAccessRoadStatusService): void { - $sendAccessRoadStatusService->makeInputParameters($event->harim->data); + + $arrayData = json_decode($event->harim->data, true); + + $sendAccessRoadStatusService->makeInputParameters([ + 'data' => [ + 'actionId' => $arrayData['actionId'], + 'ruleId' => $arrayData['ruleId'], + 'activityId' => $arrayData['activityId'], + 'requestId' => $arrayData['requestId'], + 'taskId' => $arrayData['taskId'], + 'code' => $event->harim->id, + 'resultStatus' => 1, + 'Description' => $event->harim->last_description, + ], + + 'token' => $arrayData['token'], + ]); + $sendAccessRoadStatusService->run(); } } diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php index 81844a0b..ad5903ab 100644 --- a/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessEditNeedListener.php @@ -23,7 +23,24 @@ class ConfirmRoadAccessEditNeedListener implements ShouldQueue */ public function handle(ConfirmRoadAccessEditNeedEvent $event, SendAccessRoadStatusService $sendAccessRoadStatusService): void { - $sendAccessRoadStatusService->makeInputParameters($event->harim->data); + + $arrayData = json_decode($event->harim->data, true); + + $sendAccessRoadStatusService->makeInputParameters([ + 'data' => [ + 'actionId' => $arrayData['actionId'], + 'ruleId' => $arrayData['ruleId'], + 'activityId' => $arrayData['activityId'], + 'requestId' => $arrayData['requestId'], + 'taskId' => $arrayData['taskId'], + 'code' => $event->harim->id, + 'resultStatus' => 1, + 'Description' => $event->harim->last_description, + ], + + 'token' => $arrayData['token'], + ]); + $sendAccessRoadStatusService->run(); } } diff --git a/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php index 60104829..fb8e1cc9 100644 --- a/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php +++ b/app/Listeners/V3/Dashboard/Harim/ConfirmRoadAccessNeedListener.php @@ -3,6 +3,7 @@ namespace App\Listeners\V3\Dashboard\Harim; use App\Events\V3\Dashboard\Harim\ConfirmRoadAccessNeedEvent; +use App\Models\Harim; use App\Services\PanjarehVahed\SendAccessRoadStatusService; use Exception; use Illuminate\Contracts\Queue\ShouldQueue; @@ -25,7 +26,23 @@ class ConfirmRoadAccessNeedListener implements ShouldQueue */ public function handle(ConfirmRoadAccessNeedEvent $event, SendAccessRoadStatusService $sendAccessRoadStatusService): void { - $sendAccessRoadStatusService->makeInputParameters($event->harim->data); + $arrayData = json_decode($event->harim->data, true); + + $sendAccessRoadStatusService->makeInputParameters([ + 'data' => [ + 'actionId' => $arrayData['actionId'], + 'ruleId' => $arrayData['ruleId'], + 'activityId' => $arrayData['activityId'], + 'requestId' => $arrayData['requestId'], + 'taskId' => $arrayData['taskId'], + 'code' => $event->harim->id, + 'resultStatus' => 1, + 'Description' => $event->harim->last_description, + ], + + 'token' => $arrayData['token'], + ]); + $sendAccessRoadStatusService->run(); } } diff --git a/app/Listeners/V3/Dashboard/Harim/PaymentExecutedListener.php b/app/Listeners/V3/Dashboard/Harim/PaymentExecutedListener.php index 69a5234c..e78975d9 100644 --- a/app/Listeners/V3/Dashboard/Harim/PaymentExecutedListener.php +++ b/app/Listeners/V3/Dashboard/Harim/PaymentExecutedListener.php @@ -24,7 +24,24 @@ class PaymentExecutedListener implements ShouldQueue */ public function handle(PaymentExecutedEvent $event, SendPaymentInfoService $sendPaymentInfoService): void { - $sendPaymentInfoService->makeInputParameters($event->harim->data); + + $arrayData = json_decode($event->harim->data, true); + + $sendPaymentInfoService->makeInputParameters([ + 'data' => [ + 'actionId' => $arrayData['actionId'], + 'ruleId' => $arrayData['ruleId'], + 'activityId' => $arrayData['activityId'], + 'requestId' => $arrayData['requestId'], + 'taskId' => $arrayData['taskId'], + 'code' => $event->harim->id, + 'warrantStatus' => $event->harim->need_payment , + 'amountPaid' => $arrayData['amountPaid'], + ], + + 'token' => $arrayData['token'], + ]); + $sendPaymentInfoService->run(); } } diff --git a/app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php b/app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php index 84534c51..6c1a148a 100644 --- a/app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php +++ b/app/Listeners/V3/Dashboard/Harim/RejectRequestListener.php @@ -23,7 +23,24 @@ class RejectRequestListener implements ShouldQueue */ public function handle(RejectRequestEvent $event, SendAccessRoadStatusService $sendAccessRoadStatusService): void { - $sendAccessRoadStatusService->makeInputParameters($event->harim->data); + + $arrayData = json_decode($event->harim->data, true); + + $sendAccessRoadStatusService->makeInputParameters([ + 'data' => [ + 'actionId' => $arrayData['actionId'], + 'ruleId' => $arrayData['ruleId'], + 'activityId' => $arrayData['activityId'], + 'requestId' => $arrayData['requestId'], + 'taskId' => $arrayData['taskId'], + 'code' => $event->harim->id, + 'resultStatus' => 3, + 'Description' => $event->harim->last_description, + ], + + 'token' => $arrayData['token'], + ]); + $sendAccessRoadStatusService->run(); } } diff --git a/app/Models/Harim.php b/app/Models/Harim.php index 2af054c4..95f97ebf 100644 --- a/app/Models/Harim.php +++ b/app/Models/Harim.php @@ -62,4 +62,11 @@ class Harim extends Model }, ); } + + public function latestDescription() + { + return $this->hasMany(HarimHistory::class) + ->latestOfMany() + ->value('expert_description'); + } } diff --git a/app/Services/PanjarehVahed/SendAccessRoadStatusService.php b/app/Services/PanjarehVahed/SendAccessRoadStatusService.php index c9704dcd..0cdd351e 100644 --- a/app/Services/PanjarehVahed/SendAccessRoadStatusService.php +++ b/app/Services/PanjarehVahed/SendAccessRoadStatusService.php @@ -48,27 +48,11 @@ class SendAccessRoadStatusService ->json(); } - public function makeInputParameters($data): void + public function makeInputParameters($input): void { - $arrayData = json_decode($data, true); - - $inputParameters = [ - 'data' => [ - 'actionId' => $arrayData['actionId'], - 'ruleId' => $arrayData['ruleId'], - 'activityId' => $arrayData['activityId'], - 'requestId' => $arrayData['requestId'], - 'taskId' => $arrayData['taskId'], - 'code' => $arrayData['code'], - 'resultStatus' => $arrayData['resultStatus'], - 'Description' => $arrayData['Description'], - ], - 'token' => $arrayData['token'], - ]; - $key = config('harim_web_services.Harim_Info.key'); $iv = config('harim_web_services.Harim_Info.iv'); - $this->inputParameters = openssl_encrypt(json_encode($inputParameters), 'aes-256-cbc', $key, false, $iv); + $this->inputParameters = openssl_encrypt(json_encode($input), 'aes-256-cbc', $key, false, $iv); } } \ No newline at end of file diff --git a/app/Services/PanjarehVahed/SendPaymentInfoService.php b/app/Services/PanjarehVahed/SendPaymentInfoService.php index cfd09b97..2a591e2c 100644 --- a/app/Services/PanjarehVahed/SendPaymentInfoService.php +++ b/app/Services/PanjarehVahed/SendPaymentInfoService.php @@ -48,27 +48,11 @@ class SendPaymentInfoService ->json(); } - public function makeInputParameters($data): void + public function makeInputParameters($input): void { - $arrayData = json_decode($data, true); - - $inputParameters = [ - 'data' => [ - 'actionId' => $arrayData['actionId'], - 'ruleId' => $arrayData['ruleId'], - 'activityId' => $arrayData['activityId'], - 'requestId' => $arrayData['requestId'], - 'taskId' => $arrayData['taskId'], - 'code' => $arrayData['code'], - 'warrantStatus' => $arrayData['warrantStatus'], - 'amountPaid' => $arrayData['amountPaid'], - ], - 'token' => $arrayData['token'], - ]; - $key = config('harim_web_services.Harim_Info.key'); $iv = config('harim_web_services.Harim_Info.iv'); - $this->inputParameters = openssl_encrypt(json_encode($inputParameters), 'aes-256-cbc', $key, false, $iv); + $this->inputParameters = openssl_encrypt(json_encode($input), 'aes-256-cbc', $key, false, $iv); } } \ No newline at end of file diff --git a/database/migrations/2025_11_18_153636_add_column_to_cmms_machines_table.php b/database/migrations/2025_11_18_153636_add_column_to_cmms_machines_table.php new file mode 100644 index 00000000..970d867e --- /dev/null +++ b/database/migrations/2025_11_18_153636_add_column_to_cmms_machines_table.php @@ -0,0 +1,35 @@ +foreignId('province_id')->nullable()->constrained('provinces'); + $table->foreignId('city_id')->nullable()->constrained('cities'); + $table->foreignId('station_id')->nullable()->constrained('rahdari_points'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('cmms_machines', function (Blueprint $table) { + $table->dropForeign('cmms_machines_province_id_foreign'); + $table->dropForeign('cmms_machines_city_id_foreign'); + $table->dropForeign('cmms_machines_station_id_foreign'); + $table->dropColumn('province_id'); + $table->dropColumn('city_id'); + $table->dropColumn('station_id'); + }); + } +};