add logs api synclogs

This commit is contained in:
dongpd 2023-06-12 14:36:07 +07:00
parent ea202ccc3f
commit 21cc5f2050

View File

@ -122,6 +122,8 @@ class ApiController extends Controller {
if ($res && $res['status'] == 10000) { if ($res && $res['status'] == 10000) {
$logsInfo->sync_status = 1; $logsInfo->sync_status = 1;
$logsInfo->save(); $logsInfo->save();
} else {
file_put_contents("log_connect_server.txt", "\n[" . date("H:i:s d/m/Y") . "] /api/box/face_recognition_auth_v2 timeout " . $ip, FILE_APPEND);
} }
} }
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";
@ -362,25 +364,31 @@ class ApiController extends Controller {
if (file_exists("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)) { if (file_exists("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)) {
$staffInfo = ListManagement::findOne($value->staff_id); $staffInfo = ListManagement::findOne($value->staff_id);
$confidence = json_decode($value->confidence, true); $confidence = json_decode($value->confidence, true);
$res = json_decode(file_get_contents($ip . "/api/oem/face_recognition?token=" . $tk, false, stream_context_create([ $data = [];
'http' => [ $data[] = strval($id_camera); //camera_id
'header' => "Content-Type: application/json", $data[] = date("Y-m-d H:i:s", $value->time); //frametime
'method' => "POST", $data[] = $staffInfo ? strval($staffInfo->code) : "0"; //idCard
'content' => json_encode([ $data[] = $staffInfo ? $staffInfo->staff_id : ""; //idObject
'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)), $data[] = "123"; //person_id
'camera_id' => strval($id_camera), $data[] = "+7"; //timezone
'frametime' => date("Y-m-d H:i:s", $value->time), $text = implode("|", $data);
'idCard' => $staffInfo ? strval($staffInfo->code) : "0", $res = json_decode(@file_get_contents($ip . "/api/box/face_recognition_auth_v2?token=" . $tk, false, stream_context_create([
'idObject' => $staffInfo ? $staffInfo->staff_id : "", 'http' => [
"person_id" => "123", 'timeout' => Yii::$app->params['timeoutRequestServer'],
"timezone" => "+7", 'header' => "Content-Type: application/json",
'confidence' => isset($confidence['percent1']) ? floatval($confidence['percent1']) : 0 'method' => "POST",
]) 'content' => json_encode([
] 'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value->image)),
'data' => common::rsaEncode($text),
'confidence' => isset($confidence['percent1']) ? floatval($confidence['percent1']) : 0
])
]
])), true); ])), true);
if ($res['status'] == 10000) { if ($res && $res['status'] == 10000) {
$value->sync_status = 1; $value->sync_status = 1;
$value->save(); $value->save();
} else {
file_put_contents("log_connect_server.txt", "\n[" . date("H:i:s d/m/Y") . "][SYNC] face_recognition_auth_v2 timeout " . $ip, FILE_APPEND);
} }
} else { } else {
$value->delete(); $value->delete();