check exitst images

This commit is contained in:
dongpd 2020-12-16 13:39:07 +07:00
parent 04d467a73c
commit 4d6f1cbed8
5 changed files with 41 additions and 13 deletions

View File

@ -159,6 +159,7 @@ class ApiController extends Controller {
}
public function actionResetData() {
return file_get_contents("https://bischool.beetai.com/view/image/5f7c1b22dfe5aaf427a6dfa1");
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
\Yii::$app->db->createCommand()->truncateTable('list_management')->execute();
}

View File

@ -308,7 +308,8 @@ class ListManagementController extends Controller {
return [
"title" => "<i class='fa fa-download'></i> Đồng bộ từ máy chủ",
"form" => $this->renderPartial("list-server", [
"datas" => $datas['data']
"datas" => $datas['data'],
"allID" => ListManagement::getAllID()
])
];
}
@ -343,13 +344,16 @@ class ListManagementController extends Controller {
foreach ($data['images'] as $key => $value) {
$key = common::generateRandomString();
$fileName = "face_" . $key . "_" . time() . ".png";
file_put_contents($targetPath . "/" . $fileName, file_get_contents($value));
$features = json_decode(common::requestToEngine("/get-feature", [
"image_paths" => [
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
]
]), true);
$ft[] = ["url" => $fileName, "features" => $features['results'][0]['feature']];
$img = file_get_contents($value);
if ($img !== "null") {
file_put_contents($targetPath . "/" . $fileName, $img);
$features = json_decode(common::requestToEngine("/get-feature", [
"image_paths" => [
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
]
]), true);
$ft[] = ["url" => $fileName, "features" => $features['results'][0]['feature']];
}
}
$model = ListManagement::findOne(['code' => $data['idStaff']]);
if ($model) {

View File

@ -98,4 +98,13 @@ class ListManagement extends \yii\db\ActiveRecord {
return $res;
}
public static function getAllID() {
$res = [];
$ls = self::find()->all();
foreach ($ls as $key => $value) {
$res[] = $value->code;
}
return $res;
}
}

View File

@ -12,8 +12,13 @@
</thead>
<tbody id="sync-lists">
{foreach from=$datas item=arr}
<tr onclick="choooseToSync(this);" style="cursor: pointer;" data-stt="false" data-id="{$arr.idStaff}">
<td>{$arr.idStaff}</td>
<tr onclick="choooseToSync(this);" style="cursor: pointer;" class="{if !in_array($arr.idStaff,$allID)}not-in-list{/if}" data-stt="false" data-id="{$arr.idStaff}">
<td>
{$arr.idStaff}
{if in_array($arr.idStaff,$allID)}
<i class="fa fa-check-circle text-green"></i>
{/if}
</td>
<td>{$arr.name}</td>
<td>{$arr.department}</td>
<td>
@ -35,7 +40,7 @@
<div class="col-md-2">
<i class="fa fa-info-circle"></i> Đã lựa chọn <b class="text-red" id="totals-choose">0</b> đối tượng.
</div>
<div class="col-md-6">
<div class="col-md-5">
<div class="hidden" id="progress-form">
Đồng bộ <b id="progress-current" class="text-green">0</b>/<b id="progress-totals" class="text-red">0</b> đối tượng.
<div class="progress">
@ -45,7 +50,10 @@
</div>
</div>
</div>
<div class="col-md-4 text-right">
<div class="col-md-5 text-right">
<button class="btn btn-default" onclick="checkAllNotInList();">
Chọn đối tượng chưa tồn tại
</button>
<button class="btn btn-default" onclick="checkAllSync(true);">
Chọn tất cả
</button>

View File

@ -332,6 +332,12 @@ function checkAllSync(stt) {
}
}
function checkAllNotInList() {
$("#sync-lists").find("tr").removeClass("success").attr("data-stt", "false");
$(".not-in-list").addClass("success").attr("data-stt", "true");
$("#totals-choose").html($(".not-in-list").length);
}
var progress = 0;
var totals = 0;
function _sync() {
@ -348,7 +354,7 @@ function _sync() {
$("#progress-form").removeClass("hidden");
totals = lists.length;
for (var i = 0; i < lists.length; i++) {
syncFeatureFromDevice(lists[i]);
syncFeatureFromDevice(lists[i]);
}
}