toi uu xu ly dong bo du lieu tu may chu
This commit is contained in:
parent
ddcf67ba9c
commit
c9d0c24218
|
@ -3,5 +3,5 @@
|
|||
return [
|
||||
'adminEmail' => 'admin@example.com',
|
||||
"maxLogs" => 100000,
|
||||
"maxPicture" => 5
|
||||
"maxPicture" => 2
|
||||
];
|
||||
|
|
|
@ -82,7 +82,7 @@ class ControlLogsController 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"];
|
||||
$add = true;
|
||||
foreach ($images as $key => $value) {
|
||||
if ($value['urlOld'] === $url)
|
||||
if (isset($value['urlOld']) && $value['urlOld'] === $url)
|
||||
$add = false;
|
||||
}
|
||||
if ($add) {
|
||||
|
|
|
@ -410,57 +410,86 @@ class ListManagementController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
public function getCurrentTime() {
|
||||
$time = microtime();
|
||||
$time = explode(' ', $time);
|
||||
return $time[1] + $time[0];
|
||||
}
|
||||
|
||||
public function actionSyncFeature() {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$processTime = [];
|
||||
$totalStart = $this->getCurrentTime();
|
||||
$totals = intval(Yii::$app->request->post("totals"));
|
||||
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||
$ip = "dev-dc.beetai.com";
|
||||
if ($server_ip)
|
||||
$ip = $server_ip->data;
|
||||
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||
$id_camera = 209;
|
||||
if ($device_id)
|
||||
$id_camera = intval($device_id->data);
|
||||
$res = json_decode(file_get_contents("https://" . $ip . "/api/oem/get_all_image", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
"id_camera" => $id_camera,
|
||||
"ids_staff" => [strval(Yii::$app->request->post("id"))]
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
$data = $res['data'][0];
|
||||
// $server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||
// $ip = "dev-dc.beetai.com";
|
||||
// if ($server_ip)
|
||||
// $ip = $server_ip->data;
|
||||
// $device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||
// $id_camera = 209;
|
||||
// if ($device_id)
|
||||
// $id_camera = intval($device_id->data);
|
||||
// $start = $this->getCurrentTime();
|
||||
// $res = json_decode(file_get_contents("https://" . $ip . "/api/oem/get_all_image", false, stream_context_create([
|
||||
// 'http' => [
|
||||
// 'header' => "Content-Type: application/json",
|
||||
// 'method' => "POST",
|
||||
// 'content' => json_encode([
|
||||
// "id_camera" => $id_camera,
|
||||
// "ids_staff" => [strval(Yii::$app->request->post("id"))]
|
||||
// ])
|
||||
// ]
|
||||
// ])), true);
|
||||
// $finish = $this->getCurrentTime();
|
||||
// $processTime["requestToAPI"] = round(($finish - $start), 4);
|
||||
|
||||
$data = Yii::$app->request->post("id"); //$res['data'][0];
|
||||
$ft = [];
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
foreach ($data['images'] as $key => $value) {
|
||||
if ($key < Yii::$app->params['maxPicture']) {
|
||||
$fileName = "face_" . common::generateRandomString() . "_" . time() . ".png";
|
||||
$img = file_get_contents($value);
|
||||
if ($img !== "null") {
|
||||
$fileTarget = $targetPath . "/" . $fileName;
|
||||
if (!$this->resizeImg($img, $fileTarget)) {
|
||||
file_put_contents($fileTarget, $img);
|
||||
$extractFeature = [];
|
||||
if (isset($data['images'])) {
|
||||
foreach ($data['images'] as $key => $value) {
|
||||
if ($key < Yii::$app->params['maxPicture']) {
|
||||
$fileName = "face_" . common::generateRandomString() . "_" . time() . ".png";
|
||||
$start = $this->getCurrentTime();
|
||||
$img = file_get_contents($value);
|
||||
$finish = $this->getCurrentTime();
|
||||
$temp["getIMG"] = round(($finish - $start), 4);
|
||||
if ($img !== "null") {
|
||||
$fileTarget = $targetPath . "/" . $fileName;
|
||||
$start = $this->getCurrentTime();
|
||||
if (!$this->resizeImg($img, $fileTarget)) {
|
||||
file_put_contents($fileTarget, $img);
|
||||
}
|
||||
$finish = $this->getCurrentTime();
|
||||
$temp["saveIMG"] = round(($finish - $start), 4);
|
||||
$start = $this->getCurrentTime();
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
|
||||
]
|
||||
]), true);
|
||||
$finish = $this->getCurrentTime();
|
||||
$temp["extract"] = round(($finish - $start), 4);
|
||||
$ft[] = [
|
||||
"url" => $fileName,
|
||||
"urlOld" => $fileName,
|
||||
"features" => $features['results'][0]['feature'],
|
||||
"features512" => isset($features['results'][0]['feature512']) ? $features['results'][0]['feature512'] : []
|
||||
];
|
||||
}
|
||||
$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,
|
||||
"urlOld" => $fileName,
|
||||
"features" => $features['results'][0]['feature'],
|
||||
"features512" => isset($features['results'][0]['feature512']) ? $features['results'][0]['feature512'] : []
|
||||
];
|
||||
$extractFeature[] = $temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
$processTime["extractFeature"] = $extractFeature;
|
||||
$start = $this->getCurrentTime();
|
||||
$model = ListManagement::findOne(['code' => $data['idStaff']]);
|
||||
$finish = $this->getCurrentTime();
|
||||
$processTime["getLM"] = round(($finish - $start), 4);
|
||||
if ($model) {
|
||||
$model->name = $data['name'];
|
||||
$model->address = $data['department'];
|
||||
|
@ -475,6 +504,7 @@ class ListManagementController extends Controller {
|
|||
"features" => $model->allFeatures
|
||||
]);
|
||||
} else {
|
||||
$start = $this->getCurrentTime();
|
||||
$model = new ListManagement();
|
||||
$model->create([
|
||||
'code' => strval($data['idStaff']),
|
||||
|
@ -486,6 +516,8 @@ class ListManagementController extends Controller {
|
|||
'telephone' => "",
|
||||
'address' => $data['department']
|
||||
]);
|
||||
$finish = $this->getCurrentTime();
|
||||
$processTime["insertDB"] = round(($finish - $start), 4);
|
||||
if ($totals <= 10)
|
||||
common::updateFeature([
|
||||
"cmd" => "create",
|
||||
|
@ -494,7 +526,9 @@ class ListManagementController extends Controller {
|
|||
"features" => $model->allFeatures
|
||||
]);
|
||||
}
|
||||
return ["status" => true];
|
||||
$totalFinish = $this->getCurrentTime();
|
||||
$processTime["total"] = round(($totalFinish - $totalStart), 4);
|
||||
return $processTime; //["status" => true];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
{foreach from=$datas item=arr}
|
||||
<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>
|
||||
<div id="full-data-{$arr.idStaff}" class="hidden">{json_encode($arr)}</div>
|
||||
{$arr.idStaff}
|
||||
{if in_array($arr.idStaff,$allID)}
|
||||
<i class="fa fa-check-circle text-green"></i>
|
||||
|
|
|
@ -421,7 +421,8 @@ function _syncFromServerForm(e) {
|
|||
function _syncFromServer() {
|
||||
var lists = [];
|
||||
$.each($("#sync-lists").find(".success"), function () {
|
||||
lists.push($(this).attr("data-id"));
|
||||
var id = $(this).attr("data-id");
|
||||
lists.push(JSON.parse($("#full-data-" + id).html()));
|
||||
});
|
||||
if (lists.length == 0) {
|
||||
alert("Không có dữ liệu đồng bộ!");
|
||||
|
|
Loading…
Reference in New Issue
Block a user