移除 Machine status forwarded 紀錄
修正問題 20250605
This commit is contained in:
parent
13b5e3e3e1
commit
e92848231d
@ -23,9 +23,8 @@ class CheckRoomOnlineStatus extends Command
|
|||||||
$rooms = Room::with('branch')->where('is_online',1)->get();
|
$rooms = Room::with('branch')->where('is_online',1)->get();
|
||||||
|
|
||||||
foreach ($rooms as $room) {
|
foreach ($rooms as $room) {
|
||||||
// 找出最近的一筆 MachineStatus 資料(比對 hostname 和 branch_name)
|
$branch = optional($room->branch);
|
||||||
$latestStatus = MachineStatus::where('hostname', $room->type->value.$room->name)
|
$latestStatus = MachineStatus::where('hostname', $room->type->value.$room->name)
|
||||||
//->where('branch_name', optional($room->branch)->name)
|
|
||||||
->latest('created_at')
|
->latest('created_at')
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
@ -34,12 +33,15 @@ class CheckRoomOnlineStatus extends Command
|
|||||||
$room->status = RoomStatus::Error;
|
$room->status = RoomStatus::Error;
|
||||||
$room->save();
|
$room->save();
|
||||||
|
|
||||||
$response = (new MachineStatusForwarder($rooms->branch->external_ip, "/api/room/receiveSwitch", [
|
$response = (new MachineStatusForwarder(
|
||||||
"branch_name"=>$rooms->branch->name,
|
$branch->external_ip ?? '',
|
||||||
"room_name"=>$rooms->type->value.$rooms->name,
|
'/api/room/receiveSwitch',
|
||||||
"command" =>"error",
|
[
|
||||||
|
'branch_name' => $branch->name,
|
||||||
]))->forward();
|
'room_name' => $room->type->value.$room->name,
|
||||||
|
'command' => 'error',
|
||||||
|
]
|
||||||
|
))->forward();
|
||||||
$this->info("Room [{$room->name}] marked as offline (no recent MachineStatus)");
|
$this->info("Room [{$room->name}] marked as offline (no recent MachineStatus)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ class MachineStatusForwarder
|
|||||||
$client = new ApiClient($mainDomainUrl, $this->user->api_plain_token);
|
$client = new ApiClient($mainDomainUrl, $this->user->api_plain_token);
|
||||||
$response = $client->post($this->endpoint, $this->validated);
|
$response = $client->post($this->endpoint, $this->validated);
|
||||||
|
|
||||||
Log::info('✅ Machine status forwarded', [
|
/* Log::info('✅ Machine status forwarded', [
|
||||||
'endpoint' => $this->endpoint,
|
'endpoint' => $this->endpoint,
|
||||||
'request' => $this->validated,
|
'request' => $this->validated,
|
||||||
'status' => $response->status(),
|
'status' => $response->status(),
|
||||||
'body' => $response->json(),
|
'body' => $response->json(),
|
||||||
]);
|
]); */
|
||||||
} else {
|
} else {
|
||||||
Log::warning("🔒 User with ID 2 not found or missing token");
|
Log::warning("🔒 User with ID 2 not found or missing token");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user