diff --git a/controllers/ApiController.php b/controllers/ApiController.php index 67b38698..483b4db1 100644 --- a/controllers/ApiController.php +++ b/controllers/ApiController.php @@ -347,25 +347,29 @@ class ApiController extends Controller { if ($token) $tk = $token->data; foreach ($ls as $key => $value) { - $staffInfo = ListManagement::findOne($value->staff_id); - $res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?token=" . $tk, false, stream_context_create([ - 'http' => [ - 'header' => "Content-Type: application/json", - 'method' => "POST", - 'content' => json_encode([ - 'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)), - 'camera_id' => strval($id_camera), - 'frametime' => date("Y-m-d H:i:s", $value->time), - 'idCard' => $staffInfo ? strval($staffInfo->code) : "0", - 'idObject' => $staffInfo ? $staffInfo->staff_id : "", - "person_id" => "123", - "timezone" => "+7" - ]) - ] - ])), true); - if ($res['status'] == 10000) { - $value->sync_status = 1; - $value->save(); + if (file_exists("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)) { + $staffInfo = ListManagement::findOne($value->staff_id); + $res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?token=" . $tk, false, stream_context_create([ + 'http' => [ + 'header' => "Content-Type: application/json", + 'method' => "POST", + 'content' => json_encode([ + 'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)), + 'camera_id' => strval($id_camera), + 'frametime' => date("Y-m-d H:i:s", $value->time), + 'idCard' => $staffInfo ? strval($staffInfo->code) : "0", + 'idObject' => $staffInfo ? $staffInfo->staff_id : "", + "person_id" => "123", + "timezone" => "+7" + ]) + ] + ])), true); + if ($res['status'] == 10000) { + $value->sync_status = 1; + $value->save(); + } + } else { + $value->delete(); } } }