[FEAT] 整合遠端管理指揮中心與 UI 佈局優化
All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 48s
All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 48s
1. 實作「遠端管理指揮中心」,整合重啟、結帳、鎖定、找零、出貨等指令至單一介面。 2. 對接 B010 心跳 API 與 B017 庫存 API,實作異步指令下發與效期/批號同步邏輯。 3. 修正 sidebar-menu.blade.php 中的舊版路由連結,解決 RouteNotFoundException 錯誤。 4. 修正 index.blade.php 中的 AJAX 請求名稱,補上 admin. 前綴以符合路由分群。 5. 優化主內容區頂部間距,將 pt-10 縮減為 pt-5,提昇介面緊湊度。
This commit is contained in:
@@ -4,22 +4,78 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Machine\Machine;
|
||||
use App\Models\Machine\RemoteCommand;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RemoteController extends Controller
|
||||
{
|
||||
// 機台庫存
|
||||
/**
|
||||
* 遠端管理指揮中心
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$machines = Machine::withCount(['slots'])->orderBy('name')->get();
|
||||
$selectedMachine = null;
|
||||
|
||||
if ($request->has('machine_id')) {
|
||||
$selectedMachine = Machine::with(['slots.product', 'commands' => function($query) {
|
||||
$query->latest()->limit(10);
|
||||
}])->find($request->machine_id);
|
||||
}
|
||||
|
||||
return view('admin.remote.index', [
|
||||
'machines' => $machines,
|
||||
'selectedMachine' => $selectedMachine,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 儲存遠端指令
|
||||
*/
|
||||
public function storeCommand(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'machine_id' => 'required|exists:machines,id',
|
||||
'command_type' => 'required|string|in:reboot,reboot_card,checkout,lock,unlock,change,dispense',
|
||||
'amount' => 'nullable|integer|min:0',
|
||||
'slot_no' => 'nullable|string',
|
||||
'note' => 'nullable|string|max:255',
|
||||
]);
|
||||
|
||||
$payload = [];
|
||||
if ($validated['command_type'] === 'change') {
|
||||
$payload['amount'] = $validated['amount'];
|
||||
} elseif ($validated['command_type'] === 'dispense') {
|
||||
$payload['slot_no'] = $validated['slot_no'];
|
||||
}
|
||||
|
||||
RemoteCommand::create([
|
||||
'machine_id' => $validated['machine_id'],
|
||||
'command_type' => $validated['command_type'],
|
||||
'payload' => $payload,
|
||||
'status' => 'pending',
|
||||
'note' => $validated['note'] ?? null,
|
||||
]);
|
||||
|
||||
return redirect()->back()->with('success', __('Command has been queued successfully.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 機台庫存管理 (現有功能保留)
|
||||
*/
|
||||
public function stock(Request $request)
|
||||
{
|
||||
$machines = \App\Models\Machine\Machine::withCount([
|
||||
$machines = Machine::withCount([
|
||||
'slots as slots_count',
|
||||
'slots as low_stock_count' => function ($query) {
|
||||
$query->where('stock', '<=', 5);
|
||||
}
|
||||
])->orderBy('name')->get();
|
||||
|
||||
$selectedMachine = null;
|
||||
|
||||
if ($request->has('machine_id')) {
|
||||
$selectedMachine = \App\Models\Machine\Machine::find($request->machine_id);
|
||||
$selectedMachine = Machine::with('slots.product')->find($request->machine_id);
|
||||
}
|
||||
|
||||
return view('admin.remote.stock', [
|
||||
@@ -27,58 +83,4 @@ class RemoteController extends Controller
|
||||
'selectedMachine' => $selectedMachine,
|
||||
]);
|
||||
}
|
||||
|
||||
// 機台重啟
|
||||
public function restart()
|
||||
{
|
||||
return view('admin.placeholder', [
|
||||
'title' => '遠端重啟機台',
|
||||
'description' => '遠端重啟機台系統',
|
||||
]);
|
||||
}
|
||||
|
||||
// 卡機重啟
|
||||
public function restartCardReader()
|
||||
{
|
||||
return view('admin.placeholder', [
|
||||
'title' => '遠端重啟刷卡機',
|
||||
'description' => '遠端重啟刷卡機設備',
|
||||
]);
|
||||
}
|
||||
|
||||
// 遠端結帳
|
||||
public function checkout()
|
||||
{
|
||||
return view('admin.placeholder', [
|
||||
'title' => '遠端結帳',
|
||||
'description' => '遠端執行結帳流程',
|
||||
]);
|
||||
}
|
||||
|
||||
// 遠端鎖定頁
|
||||
public function lock()
|
||||
{
|
||||
return view('admin.placeholder', [
|
||||
'title' => '遠端鎖定頁',
|
||||
'description' => '遠端鎖定機台頁面',
|
||||
]);
|
||||
}
|
||||
|
||||
// 遠端找零
|
||||
public function change()
|
||||
{
|
||||
return view('admin.placeholder', [
|
||||
'title' => '遠端找零',
|
||||
'description' => '遠端執行找零功能',
|
||||
]);
|
||||
}
|
||||
|
||||
// 遠端出貨
|
||||
public function dispense()
|
||||
{
|
||||
return view('admin.placeholder', [
|
||||
'title' => '遠端出貨',
|
||||
'description' => '遠端控制商品出貨',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user