1. 修復帳號管理與角色權限頁面搜尋功能,支援 Enter 鍵快捷提交。 2. 完成 B013 (機台故障上報) API 實作,改用非同步隊列 (ProcessMachineError) 處理日誌上報。 3. 精簡 B013 API 參數,移除冗餘的 message 欄位,統一由雲端對照表翻譯。 4. 更新技術規格文件 (SKILL.md) 與系統 API 文件配置 (api-docs.php)。 5. 修正平台管理員帳號在搜尋過濾時的資料隔離邏輯。
57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs\Machine;
|
|
|
|
use App\Models\Machine\MachineLog;
|
|
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 ProcessStateLog implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
protected $machineId;
|
|
protected $companyId;
|
|
protected $message;
|
|
protected $level;
|
|
protected $type;
|
|
protected $context;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*/
|
|
public function __construct(int $machineId, ?int $companyId, string $message, string $level = 'info', array $context = [], string $type = 'status')
|
|
{
|
|
$this->machineId = $machineId;
|
|
$this->companyId = $companyId;
|
|
$this->message = $message;
|
|
$this->level = $level;
|
|
$this->context = $context;
|
|
$this->type = $type;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
try {
|
|
MachineLog::create([
|
|
'machine_id' => $this->machineId,
|
|
'company_id' => $this->companyId,
|
|
'type' => $this->type,
|
|
'level' => $this->level,
|
|
'message' => $this->message,
|
|
'context' => $this->context,
|
|
]);
|
|
} catch (\Exception $e) {
|
|
Log::error("Failed to create state log for machine {$this->machineId}: " . $e->getMessage());
|
|
throw $e;
|
|
}
|
|
}
|
|
}
|