diff --git a/controllers/ApiController.php b/controllers/ApiController.php index 5f2dd819..576f2483 100644 --- a/controllers/ApiController.php +++ b/controllers/ApiController.php @@ -78,7 +78,7 @@ class ApiController extends Controller { "Staff" => $post["id"], "Time" => $time, "Image" => $fileName, - "Confidence" => strval($post["confidence"]) + "Confidence" => json_encode($post["confidence"]) ]); $server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']); $ip = "https://dev-dc.beetai.com"; @@ -259,13 +259,21 @@ class ApiController extends Controller { ]); $updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']); } + $currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true); if ($updating->data === "true") { - $txt = "\n" . date("H:i:s d/m/Y") . " " . "updating"; - file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND); - return ["status" => false]; + if ($currentCache['n_128'] == $currentCache['n_512']) { + $updating->data = "false"; + $updating->save(); + $txt = "\n" . date("H:i:s d/m/Y") . " " . "success"; + file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND); + return ["status" => false]; + } else { + $txt = "\n" . date("H:i:s d/m/Y") . " " . "updating"; + file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND); + return ["status" => false]; + } } - $currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true); if ($currentCache['n_128'] == $currentCache['n_512']) { $txt = "\n" . date("H:i:s d/m/Y") . " " . "success"; file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND); @@ -407,6 +415,17 @@ class ApiController extends Controller { 'data' => $post['token'] ]); } + $version = \app\models\SyncUrl::findOne(['key_config' => 'version']); + if ($version) { + $token->data = $post['version']; + $token->save(); + } else { + $model = new \app\models\SyncUrl(); + $model->create([ + 'key_config' => "version", + 'data' => $post['version'] + ]); + } Yii::$app->response->format = "json"; return ["status" => true]; } diff --git a/helpers/CaptureLogsGrid.php b/helpers/CaptureLogsGrid.php index 49627a77..3bd6115d 100644 --- a/helpers/CaptureLogsGrid.php +++ b/helpers/CaptureLogsGrid.php @@ -63,7 +63,34 @@ class CaptureLogsGrid { public static function confidence() { return function($model) { - return number_format($model->confidence, 2); + $confidence = json_decode($model->confidence, true); + $person1_html = $person2_html = ""; + $person1 = \app\models\ListManagement::findOne($confidence['id1']); + if ($person1) { + $images = json_decode($person1->image, true); + $person1_html = "