From 64d9ad0b88f6c872c76221d76694f1482d9e70b7 Mon Sep 17 00:00:00 2001 From: dongpd Date: Tue, 5 Jul 2022 10:05:58 +0700 Subject: [PATCH] update fault_information --- controllers/ApiController.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/controllers/ApiController.php b/controllers/ApiController.php index 12b9327e..6ef4e1a8 100644 --- a/controllers/ApiController.php +++ b/controllers/ApiController.php @@ -514,6 +514,7 @@ class ApiController extends Controller { } public function actionCheckLogs() { + set_time_limit(5000); Yii::$app->response->format = "json"; $server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']); $ip = "https://dev-dc.beetai.com"; @@ -537,6 +538,7 @@ class ApiController extends Controller { if ($datas['status'] == 10000) { $logs = $datas['data']; $infomation = []; + $fault_information = []; foreach ($logs as $key => $value) { $result = true; if ($value['action'] == "insert_image") @@ -557,12 +559,19 @@ class ApiController extends Controller { array_map('unlink', glob("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/*.*")); } - if ($result && in_array($value['action'], ['insert_image', 'remove_image', 'insert_info', 'remove_info', 'reset_all'])) { - $infomation[] = [ - "obj_Log" => $value['obj_Log'], - "action" => $value['action'], - "idCamera" => $id_camera - ]; + if (in_array($value['action'], ['insert_image', 'remove_image', 'insert_info', 'remove_info', 'reset_all'])) { + if ($result) + $infomation[] = [ + "obj_Log" => $value['obj_Log'], + "action" => $value['action'], + "idCamera" => $id_camera + ]; + else + $fault_information[] = [ + "obj_Log" => $value['obj_Log'], + "action" => $value['action'], + "idCamera" => $id_camera + ]; } } if (count($infomation) > 0) @@ -571,7 +580,8 @@ class ApiController extends Controller { 'header' => "Content-Type: application/json", 'method' => "POST", 'content' => json_encode([ - "infomation" => $infomation + "infomation" => $infomation, + "fault_information" => $fault_information ]) ] ])); @@ -642,7 +652,7 @@ class ApiController extends Controller { $images = json_decode($model->image, true); $ft = []; foreach ($images as $key => $value) { - if ($value['serverKey'] !== $files_name) + if (isset($value['serverKey']) && $value['serverKey'] !== $files_name) $ft[] = $value; else @unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $value['url']);