filter dong bo du lieu giua cac thiet bi

This commit is contained in:
dongpd 2020-12-30 11:43:03 +07:00
parent d296533184
commit 09604d1cb8
4 changed files with 107 additions and 8 deletions

View File

@ -223,6 +223,62 @@ class ApiController extends Controller {
return $str; return $str;
} }
public function getCurrentTime() {
$time = microtime();
$time = explode(' ', $time);
return $time[1] + $time[0];
}
public function actionAutoGenFeature() {
Yii::$app->response->format = "json";
$processTime = [];
$start = $this->getCurrentTime();
$lists = ListManagement::find()->all();
$finish = $this->getCurrentTime();
$processTime["getAllLM"] = round(($finish - $start), 4);
$extract = false;
foreach ($lists as $key => $value) {
$images = json_decode($value->image, true);
$newImgs = [];
$temp = [];
foreach ($images as $k => $v) {
if (!isset($v['features512']) || (isset($v['features512']) && count($v['features512']) == 0)) {
$start = $this->getCurrentTime();
$features = json_decode(common::requestToEngine("/get-feature", [
"image_paths" => [
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $v['url'], "type" => "raw"]
],
"type" => "512"
]), true);
$finish = $this->getCurrentTime();
$temp[] = round(($finish - $start), 4);
$v['features512'] = $features['results'][0]['feature512'];
$extract = true;
}
$newImgs[] = $v;
}
if ($extract) {
$processTime['extract'] = $temp;
$value->image = json_encode($newImgs);
$start = $this->getCurrentTime();
$value->save();
$finish = $this->getCurrentTime();
$processTime["updateDB"] = round(($finish - $start), 4);
$txt = "\n" . json_encode($processTime);
file_put_contents(date('Ymd') . ".txt", $txt, FILE_APPEND);
common::updateFeature([
"cmd" => "update",
"id" => $value->id,
"name" => common::convert_vi_to_en($value->name),
"features" => $value->allFeatures
]);
return ["status" => true, "time" => $processTime];
}
}
return ["status" => false];
}
public function actionSync() { public function actionSync() {
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";
if ($this->is_connected()) { if ($this->is_connected()) {
@ -276,4 +332,20 @@ class ApiController extends Controller {
return ListManagement::find()->count(); return ListManagement::find()->count();
} }
public function actionGetTotalFeature() {
Yii::$app->response->format = "json";
$lists = ListManagement::find()->all();
$total128 = $total512 = 0;
foreach ($lists as $key => $value) {
$images = json_decode($value->image, true);
foreach ($images as $k => $v) {
if (isset($v['features']) && count($v['features']) > 0)
$total128++;
if (isset($v['features512']) && count($v['features512']) > 0)
$total512++;
}
}
return ["total" => count($lists), "128" => $total128, "512" => $total512];
}
} }

View File

@ -114,7 +114,7 @@ class ListManagementController extends Controller {
return ["status" => false, "text" => "Mỗi đối tượng chỉ nhận tối đa " . \Yii::$app->params['maxPicture'] . " hình ảnh mẫu"]; return ["status" => false, "text" => "Mỗi đối tượng chỉ nhận tối đa " . \Yii::$app->params['maxPicture'] . " hình ảnh mẫu"];
$add = true; $add = true;
foreach ($images as $key => $value) { foreach ($images as $key => $value) {
if ($value['urlOld'] === $url) if (isset($value['urlOld']) && $value['urlOld'] === $url)
$add = false; $add = false;
} }
if ($add) { if ($add) {
@ -368,12 +368,17 @@ class ListManagementController extends Controller {
'content' => json_encode(ListManagement::nameArray()) 'content' => json_encode(ListManagement::nameArray())
] ]
])), true); ])), true);
$filters = [];
foreach ($results as $key => $value) {
$filters[$value['code']] = $value['code'] . " - " . $value['name'] . " - " . $value['address'];
}
Yii::$app->response->format = "json"; Yii::$app->response->format = "json";
return [ return [
"title" => $data['ip'], "title" => $data['ip'],
"form" => $this->renderPartial("list", [ "form" => $this->renderPartial("list", [
"results" => $results, "results" => $results,
"typeArray" => ListManagement::$typeArray, "typeArray" => ListManagement::$typeArray,
"filters" => $filters,
"ip" => $data['ip'] "ip" => $data['ip']
]) ])
]; ];
@ -477,7 +482,8 @@ class ListManagementController extends Controller {
$features = json_decode(common::requestToEngine("/get-feature", [ $features = json_decode(common::requestToEngine("/get-feature", [
"image_paths" => [ "image_paths" => [
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"] ["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
] ],
"type" => "128"
]), true); ]), true);
$finish = $this->getCurrentTime(); $finish = $this->getCurrentTime();
$temp["extract"] = round(($finish - $start), 4); $temp["extract"] = round(($finish - $start), 4);
@ -575,7 +581,7 @@ class ListManagementController extends Controller {
$model->name = $value['name']; $model->name = $value['name'];
$model->image = json_encode($images); $model->image = json_encode($images);
$model->gender = $value['gender']; $model->gender = $value['gender'];
$model->birthday = date("d/m/Y", $value['birthday']); $model->birthday = $value['birthday'];
$model->telephone = $value['telephone']; $model->telephone = $value['telephone'];
$model->address = $value['department']; $model->address = $value['department'];
$model->save(); $model->save();

View File

@ -1,3 +1,21 @@
<div class="row">
<div class="col-md-4">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">Tìm kiếm</div>
<select class="form-control" id="filter-from-server" onchange="filters(this);">
<option value=""></option>
{html_options options=$filters}
</select>
<div class="input-group-btn">
<button class="btn btn-default" data-toggle="tooltip" title="Hủy bỏ tìm kiếm" onclick="removeFilters();">
<i class="fa fa-remove"></i>
</button>
</div>
</div>
</div>
</div>
</div>
<div style="max-height: 750px;overflow-y: auto;"> <div style="max-height: 750px;overflow-y: auto;">
<table class="table table-bordered table-striped"> <table class="table table-bordered table-striped">
<thead> <thead>
@ -15,7 +33,7 @@
</thead> </thead>
<tbody id="sync-lists"> <tbody id="sync-lists">
{foreach from=$results item=arr} {foreach from=$results item=arr}
<tr onclick="choooseToSync(this);" style="cursor: pointer;" data-stt="false" data-id="{$arr.code}"> <tr id="filters-{$arr.code}" class="filters" onclick="choooseToSync(this);" style="cursor: pointer;" data-stt="false" data-id="{$arr.code}">
<td>{$arr.code}</td> <td>{$arr.code}</td>
<td>{$typeArray[$arr.type]}</td> <td>{$typeArray[$arr.type]}</td>
<td>{$arr.name}</td> <td>{$arr.name}</td>
@ -53,10 +71,10 @@
</div> </div>
</div> </div>
<div class="col-md-4 text-right"> <div class="col-md-4 text-right">
<button class="btn btn-default" onclick="checkAllSync(true);"> <button class="btn btn-default btn-select" onclick="checkAllSync(true);">
Chọn tất cả Chọn tất cả
</button> </button>
<button class="btn btn-default" onclick="checkAllSync(false);"> <button class="btn btn-default btn-select" onclick="checkAllSync(false);">
Bỏ chọn tất cả Bỏ chọn tất cả
</button> </button>
<button class="btn btn-primary" onclick="_sync();"> <button class="btn btn-primary" onclick="_sync();">

View File

@ -312,6 +312,9 @@ function _syncForm(e) {
success: function (data) { success: function (data) {
common.modalBlock(false); common.modalBlock(false);
common.modalOpenFullScreen(data.form, data.title); common.modalOpenFullScreen(data.form, data.title);
$("#filter-from-server").select2({
placeholder: "Tìm kiếm theo ID hoặc tên"
});
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false); common.modalBlock(false);
@ -569,7 +572,7 @@ function syncFeatureToServer(id, fullData) {
window.location.reload(true); window.location.reload(true);
}, 2000) }, 2000)
} else { } else {
syncFeature(fullData[progressToServer], fullData); syncFeatureToServer(fullData[progressToServer], fullData);
} }
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {