check image exists

This commit is contained in:
dongpd 2021-11-29 10:42:02 +07:00
parent a27bf65303
commit c3d93f64c6

View File

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