Files
citrus-cms/app/Jobs/ExecuteWeldlogSyncJob.php
2026-04-28 21:14:25 +03:00

87 lines
2.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class ExecuteWeldlogSyncJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $timeout = 300;
public $tries = 1;
public $maxExceptions = 1;
protected $tableName;
protected $recordId;
/**
* @param string $tableName Log test type table name
* @param int $recordId Record ID in the table
*/
public function __construct(string $tableName, int $recordId)
{
$this->tableName = $tableName;
$this->recordId = $recordId;
$this->onQueue('save-trigger');
}
public function handle(): void
{
Log::info("=== ExecuteWeldlogSyncJob STARTED ===", [
'table_name' => $this->tableName,
'record_id' => $this->recordId,
]);
try {
// Kayıt verisini kuyruk içinde çek (response'u yavaşlatmaz)
$recordData = db($this->tableName)->where('id', $this->recordId)->first();
if (!$recordData) {
Log::warning("ExecuteWeldlogSyncJob: Record not found", [
'table_name' => $this->tableName,
'record_id' => $this->recordId,
]);
return;
}
$data = (array) $recordData;
if (function_exists('logToWeldlogUpdate')) {
logToWeldlogUpdate($data);
}
if (function_exists('logToWPQUpdate')) {
logToWPQUpdate($data, $this->tableName);
}
} catch (\Throwable $th) {
Log::error("ExecuteWeldlogSyncJob failed", [
'table_name' => $this->tableName,
'record_id' => $this->recordId,
'error' => $th->getMessage(),
]);
throw $th;
}
Log::info("=== ExecuteWeldlogSyncJob COMPLETED ===", [
'table_name' => $this->tableName,
'record_id' => $this->recordId,
]);
}
public function tags(): array
{
return [
"WeldlogSync:{$this->tableName}",
"RecordId:{$this->recordId}",
];
}
}