cleanup: remove redundant ProcessErrorLog job in favor of existing ProcessMachineError

This commit is contained in:
sky121113 2026-04-22 16:38:37 +08:00
parent 680d922e1f
commit 12591a55f2

View File

@ -1,60 +0,0 @@
<?php
namespace App\Jobs\Machine;
use App\Models\Machine\Machine;
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 ProcessErrorLog implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $serialNo;
protected $payload;
/**
* Create a new job instance.
*/
public function __construct(string $serialNo, array $payload)
{
$this->serialNo = $serialNo;
$this->payload = $payload;
}
/**
* Execute the job.
*/
public function handle(): void
{
$machine = Machine::withoutGlobalScopes()->where('serial_no', $this->serialNo)->first();
if (!$machine) {
Log::warning("MQTT ErrorLog: Machine not found", ['serial_no' => $this->serialNo]);
return;
}
$errorCode = $this->payload['error_code'] ?? 'Unknown';
$tid = $this->payload['tid'] ?? 'N/A';
// 這裡可以整合 i18n 翻譯,或是直接記錄
// 依照 SKILL.md 定義error_code 會被翻譯
ProcessStateLog::dispatch(
$machine->id,
$machine->company_id,
"Hardware Error reported: :code on slot :tid",
'error',
[
'code' => $errorCode,
'tid' => $tid,
'raw_payload' => $this->payload
],
'error'
);
}
}