fix send logs realtime
This commit is contained in:
parent
08266f3a5f
commit
821cf9463d
|
@ -84,7 +84,7 @@ class ApiController extends Controller {
|
|||
$ip = "https://dev-dc.beetai.com";
|
||||
if ($server_ip)
|
||||
$ip = $server_ip->data;
|
||||
if ($this->is_connected($ip) && $logs) {
|
||||
if ($this->is_connected() && $logs) {
|
||||
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||
$id_camera = 209;
|
||||
if ($device_id)
|
||||
|
@ -104,6 +104,7 @@ class ApiController extends Controller {
|
|||
'camera_id' => strval($id_camera),
|
||||
'frametime' => date("Y-m-d H:i:s", $time),
|
||||
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
|
||||
'idObject' => $staffInfo ? $staffInfo->staff_id : "",
|
||||
"person_id" => "123",
|
||||
"timezone" => "+7"
|
||||
])
|
||||
|
@ -353,6 +354,7 @@ class ApiController extends Controller {
|
|||
'camera_id' => strval($id_camera),
|
||||
'frametime' => date("Y-m-d H:i:s", $value->time),
|
||||
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
|
||||
'idObject' => $staffInfo ? $staffInfo->staff_id : "",
|
||||
"person_id" => "123",
|
||||
"timezone" => "+7"
|
||||
])
|
||||
|
@ -489,9 +491,9 @@ class ApiController extends Controller {
|
|||
if ($this->check512()) {
|
||||
$currentCache = json_decode(file_get_contents("http://localhost:2305/current-cache"), true);
|
||||
if ($currentCache['n_128'] == $currentCache['n_512']) {
|
||||
$updating->data = "true";
|
||||
$updating->data = "true";
|
||||
} else {
|
||||
$updating->data = "false";
|
||||
$updating->data = "false";
|
||||
}
|
||||
} else
|
||||
$updating->data = "false";
|
||||
|
|
|
@ -417,7 +417,8 @@ class ListManagementController extends Controller {
|
|||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
"id_camera" => $id_camera,
|
||||
"ids_staff" => []
|
||||
"ids_staff" => [],
|
||||
"objs_staff" => []
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
|
@ -443,11 +444,22 @@ class ListManagementController extends Controller {
|
|||
return $time[1] + $time[0];
|
||||
}
|
||||
|
||||
public function extractFeature($images, $staff_id) {
|
||||
public function extractFeature($images, $files_name, $staff_id, $currentImg = false) {
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
$extractFeature = [];
|
||||
$ft = [];
|
||||
$currentArr = [];
|
||||
if ($currentImg) {
|
||||
foreach ($currentImg as $key => $value) {
|
||||
if (isset($value['serverKey']))
|
||||
$currentArr[] = $value['serverKey'];
|
||||
}
|
||||
$ft = $currentImg;
|
||||
}
|
||||
foreach ($images as $key => $value) {
|
||||
if ($key < Yii::$app->params['maxPicture']) {
|
||||
if ($key < Yii::$app->params['maxPicture'] && !in_array($files_name[$key], $currentArr)) {
|
||||
$fileName = "face_" . $staff_id . "_" . common::generateRandomString() . "_" . time() . ".png";
|
||||
$start = $this->getCurrentTime();
|
||||
$img = false;
|
||||
|
@ -476,6 +488,7 @@ class ListManagementController extends Controller {
|
|||
$finish = $this->getCurrentTime();
|
||||
$temp["extract"] = round(($finish - $start), 4);
|
||||
$ft[] = [
|
||||
"serverKey" => $files_name[$key],
|
||||
"url" => $fileName,
|
||||
"urlOld" => $fileName,
|
||||
"features" => $features['results'][0]['feature'],
|
||||
|
@ -499,20 +512,23 @@ class ListManagementController extends Controller {
|
|||
$totals = intval(Yii::$app->request->post("totals"));
|
||||
|
||||
$data = Yii::$app->request->post("id"); //$res['data'][0];
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
|
||||
$start = $this->getCurrentTime();
|
||||
$model = ListManagement::findOne(['staff_id' => $data['id']]);
|
||||
$finish = $this->getCurrentTime();
|
||||
$processTime["getLM"] = round(($finish - $start), 4);
|
||||
$ft = [];
|
||||
if ($model) {
|
||||
if (isset($data['images'])) {
|
||||
$extractFeature = $this->extractFeature($data['images'], $data['files_name'], $data['id'], json_decode($model->image, true));
|
||||
$processTime["extractFeature"] = $extractFeature['time'];
|
||||
$ft = $extractFeature['features'];
|
||||
}
|
||||
$model->abbreviated_name = $data['abbreviated_name'];
|
||||
$model->code = $data['code'];
|
||||
$model->name = $data['name'];
|
||||
$model->address = $data['department'];
|
||||
// $model->image = json_encode($ft);
|
||||
$model->image = json_encode($ft);
|
||||
$model->last_modified = time();
|
||||
$model->save();
|
||||
// if ($totals <= 10)
|
||||
|
@ -523,9 +539,8 @@ class ListManagementController extends Controller {
|
|||
// "features" => $model->allFeatures
|
||||
// ]);
|
||||
} else {
|
||||
$ft = [];
|
||||
if (isset($data['images'])) {
|
||||
$extractFeature = $this->extractFeature($data['images'], $data['id']);
|
||||
$extractFeature = $this->extractFeature($data['images'], $data['files_name'], $data['id']);
|
||||
$processTime["extractFeature"] = $extractFeature['time'];
|
||||
$ft = $extractFeature['features'];
|
||||
}
|
||||
|
@ -689,7 +704,7 @@ class ListManagementController extends Controller {
|
|||
if ($device_id)
|
||||
$id_camera = intval($device_id->data);
|
||||
|
||||
$StaffInfo = ListManagement::findOne(["code" => Yii::$app->request->post("id")]);
|
||||
$StaffInfo = ListManagement::findOne(["staff_id" => Yii::$app->request->post("id")]);
|
||||
$lsImgs = json_decode($StaffInfo->image, true);
|
||||
$images = [];
|
||||
foreach ($lsImgs as $key => $value) {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Tên</th>
|
||||
<th>Tên hiển thị</th>
|
||||
<th>Giới tính</th>
|
||||
<th>Hình ảnh đăng kí</th>
|
||||
<th>Ngày sinh</th>
|
||||
|
@ -31,9 +32,10 @@
|
|||
</thead>
|
||||
<tbody id="sync-lists">
|
||||
{foreach from=$datas item=arr}
|
||||
<tr id="filters-{$arr.code}" class="filters" onclick="choooseToSync(this);" style="cursor: pointer;" data-stt="false" data-id="{$arr->code}">
|
||||
<tr id="filters-{$arr.staff_id}" class="filters" onclick="choooseToSync(this);" style="cursor: pointer;" data-stt="false" data-id="{$arr->staff_id}">
|
||||
<td>{$arr->code}</td>
|
||||
<td>{$arr->name}</td>
|
||||
<td>{$arr.abbreviated_name}</td>
|
||||
<td>{$arr->gender}</td>
|
||||
<td>
|
||||
{$images = json_decode($arr->image, true)}
|
||||
|
|
Loading…
Reference in New Issue
Block a user