update confidence + version

This commit is contained in:
dongpd 2021-04-23 16:58:19 +07:00
parent 1b1162f3c2
commit b006af4e1f
7 changed files with 63 additions and 12 deletions

View File

@ -78,7 +78,7 @@ class ApiController extends Controller {
"Staff" => $post["id"], "Staff" => $post["id"],
"Time" => $time, "Time" => $time,
"Image" => $fileName, "Image" => $fileName,
"Confidence" => strval($post["confidence"]) "Confidence" => json_encode($post["confidence"])
]); ]);
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']); $server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
$ip = "https://dev-dc.beetai.com"; $ip = "https://dev-dc.beetai.com";
@ -259,13 +259,21 @@ class ApiController extends Controller {
]); ]);
$updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']); $updating = \app\models\SyncUrl::findOne(['key_config' => 'updating']);
} }
$currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true);
if ($updating->data === "true") { if ($updating->data === "true") {
$txt = "\n" . date("H:i:s d/m/Y") . " " . "updating"; if ($currentCache['n_128'] == $currentCache['n_512']) {
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND); $updating->data = "false";
return ["status" => 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']) { if ($currentCache['n_128'] == $currentCache['n_512']) {
$txt = "\n" . date("H:i:s d/m/Y") . " " . "success"; $txt = "\n" . date("H:i:s d/m/Y") . " " . "success";
file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND); file_put_contents(date('Ymd') . "_logs.txt", $txt, FILE_APPEND);
@ -407,6 +415,17 @@ class ApiController extends Controller {
'data' => $post['token'] '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"; Yii::$app->response->format = "json";
return ["status" => true]; return ["status" => true];
} }

View File

@ -63,7 +63,34 @@ class CaptureLogsGrid {
public static function confidence() { public static function confidence() {
return function($model) { 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 = "<div class='feature-img'>" . Html::img("/data/uploads/face/" . $images[0]['url'], [
"class" => "img-thumbnail",
"style" => "width: 100px;height:100px;"
]) . "<br>" . $person1->name . " [" . $confidence['percent1'] . "]" . "</div>";
}
if ($confidence['id2'] !== "0" && $confidence['id2'] != $confidence['id1']) {
$person2 = \app\models\ListManagement::findOne($confidence['id2']);
if ($person2) {
$images = json_decode($person2->image, true);
$person2_html = "<div class='feature-img'>" . Html::img("/data/uploads/face/" . $images[0]['url'], [
"class" => "img-thumbnail",
"style" => "width: 100px;height:100px;"
]) . "<br>" . $person2->name . " [" . $confidence['percent2'] . "]" . "</div>";
}
}
return $person1_html . $person2_html;
};
}
public static function confidenceControlLogs() {
return function($model) {
$confidence = json_decode($model->confidence, true);
return $confidence['percent1'] . ($confidence['percent2'] > 0 ? " [" . $confidence['percent2'] . "]" : "");
}; };
} }

View File

@ -4,5 +4,5 @@ copy.src.target=
remote.connection=BiFace-99bab6 remote.connection=BiFace-99bab6
remote.directory=/BiFace_Server_Lite remote.directory=/BiFace_Server_Lite
remote.upload=ON_SAVE remote.upload=ON_SAVE
run.as=LOCAL run.as=REMOTE
url=http://localhost/ url=http://localhost/

View File

@ -17,13 +17,17 @@ use dmstr\widgets\Alert;
<section class="content" style="padding: 0 0 15px 0;"> <section class="content" style="padding: 0 0 15px 0;">
<input type="hidden" value="<?php echo Yii::$app->user->id; ?>" name="current_user_id"> <input type="hidden" value="<?php echo Yii::$app->user->id; ?>" name="current_user_id">
<?= Alert::widget() ?> <?= Alert::widget() ?>
<?= $content ?> <?= $content ?>
</section> </section>
</div> </div>
<footer class="main-footer"> <footer class="main-footer">
<div class="pull-right hidden-xs"> <div class="pull-right hidden-xs">
<b>Version</b> <?php echo Yii::$app->params["version"]; ?> <b>Version: </b>
<?php
$version = \app\models\SyncUrl::findOne(['key_config' => 'version']);
echo $version ? $version->data : Yii::$app->params["version"];
?>
</div> </div>
<!--<strong>Copyright &copy; 2020 <a href="https://beetinnovators.com/"><img src="/images/BI_Logo.png" width="80px"></a> & <a href="https://tctech.vn/"><img src="/images/TCTech.jpg" width="80px"></a>.</strong> All rights reserved.--> <!--<strong>Copyright &copy; 2020 <a href="https://beetinnovators.com/"><img src="/images/BI_Logo.png" width="80px"></a> & <a href="https://tctech.vn/"><img src="/images/TCTech.jpg" width="80px"></a>.</strong> All rights reserved.-->
<strong>Copyright &copy; 2020 <a href="https://beetinnovators.com/">BEETINNOVATORS</a>.</strong> All rights reserved. <strong>Copyright &copy; 2020 <a href="https://beetinnovators.com/">BEETINNOVATORS</a>.</strong> All rights reserved.

View File

@ -55,6 +55,7 @@
'attribute' => 'confidence', 'attribute' => 'confidence',
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center'], 'headerOptions' => ['class' => 'text-center'],
'format' => "raw",
'value' => \app\helpers\CaptureLogsGrid::confidence() 'value' => \app\helpers\CaptureLogsGrid::confidence()
], ],
[ [

View File

@ -62,7 +62,7 @@
'attribute' => 'confidence', 'attribute' => 'confidence',
'contentOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center'], 'headerOptions' => ['class' => 'text-center'],
'value' => \app\helpers\CaptureLogsGrid::confidence() 'value' => \app\helpers\CaptureLogsGrid::confidenceControlLogs()
], ],
'listManagement.name', 'listManagement.name',
'listManagement.gender', 'listManagement.gender',

View File

@ -1,8 +1,8 @@
<?php <?php
// comment out the following two lines when deployed to production // comment out the following two lines when deployed to production
//defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_DEBUG') or define('YII_DEBUG', true);
//defined('YII_ENV') or define('YII_ENV', 'dev'); defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php'; require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';