star-cloud/app/Console/Commands/MqttSyncAuth.php
sky121113 315c226560 [FEAT] 倉儲管理系統模組實作與全站 UI/UX 標準化優化
1. 實作倉儲管理系統 (Warehouse Management):包含總覽、庫存、調撥、機台庫存與補貨模組。
2. 建立倉儲相關資料結構:新增 warehouses, warehouse_stocks, stock_in_orders, stock_movements, transfer_orders, replenishment_orders 等資料表。
3. 優化商品管理 (Product Management) 介面:調整商品與類別管理的分頁、搜尋與編輯邏輯,並導入極簡奢華風 UI。
4. 增強遠端機台管理 (Remote Machine Management):優化機台清單、庫存監控與遠端出貨介面,提升載入效能。
5. 更新全站導覽選單 (Sidebar):整合倉儲管理入口,並修復側邊欄語法錯誤。
6. 標準化分頁組件 (Pagination):套用 luxury 奢華風分頁樣式。
7. 補齊多語系語系檔 (i18n):更新 zh_TW.json,包含倉儲與商品模組相關詞彙。
2026-04-23 11:51:08 +08:00

54 lines
1.5 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Machine\Machine;
use App\Services\Machine\MachineService;
class MqttSyncAuth extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'mqtt:sync-auth';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Sync all machine API tokens to Redis for MQTT authentication';
/**
* Execute the console command.
*/
public function handle(MachineService $machineService)
{
// 1. 同步 Gateway 自身的認證資料 (與 mqtt-gateway/main.go 對應)
$this->info("Syncing star-cloud-gateway auth...");
$gatewayKey = "machine_auth:star-cloud-gateway";
$gatewayPass = hash('sha256', "StarCloudSecret999");
\Illuminate\Support\Facades\Redis::hSet($gatewayKey, 'password', $gatewayPass);
$this->info("Gateway auth synced.");
// 2. 同步所有機台的認證資料 (僅限未刪除的)
$machines = Machine::get();
$this->info("Syncing " . $machines->count() . " machines to Redis...");
$bar = $this->output->createProgressBar($machines->count());
$bar->start();
foreach ($machines as $machine) {
$machineService->syncMqttAuth($machine);
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info("Sync completed.");
}
}