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";
|
$ip = "https://dev-dc.beetai.com";
|
||||||
if ($server_ip)
|
if ($server_ip)
|
||||||
$ip = $server_ip->data;
|
$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']);
|
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||||
$id_camera = 209;
|
$id_camera = 209;
|
||||||
if ($device_id)
|
if ($device_id)
|
||||||
|
@ -104,6 +104,7 @@ class ApiController extends Controller {
|
||||||
'camera_id' => strval($id_camera),
|
'camera_id' => strval($id_camera),
|
||||||
'frametime' => date("Y-m-d H:i:s", $time),
|
'frametime' => date("Y-m-d H:i:s", $time),
|
||||||
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
|
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
|
||||||
|
'idObject' => $staffInfo ? $staffInfo->staff_id : "",
|
||||||
"person_id" => "123",
|
"person_id" => "123",
|
||||||
"timezone" => "+7"
|
"timezone" => "+7"
|
||||||
])
|
])
|
||||||
|
@ -353,6 +354,7 @@ class ApiController extends Controller {
|
||||||
'camera_id' => strval($id_camera),
|
'camera_id' => strval($id_camera),
|
||||||
'frametime' => date("Y-m-d H:i:s", $value->time),
|
'frametime' => date("Y-m-d H:i:s", $value->time),
|
||||||
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
|
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
|
||||||
|
'idObject' => $staffInfo ? $staffInfo->staff_id : "",
|
||||||
"person_id" => "123",
|
"person_id" => "123",
|
||||||
"timezone" => "+7"
|
"timezone" => "+7"
|
||||||
])
|
])
|
||||||
|
|
|
@ -417,7 +417,8 @@ class ListManagementController extends Controller {
|
||||||
'method' => "POST",
|
'method' => "POST",
|
||||||
'content' => json_encode([
|
'content' => json_encode([
|
||||||
"id_camera" => $id_camera,
|
"id_camera" => $id_camera,
|
||||||
"ids_staff" => []
|
"ids_staff" => [],
|
||||||
|
"objs_staff" => []
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
])), true);
|
])), true);
|
||||||
|
@ -443,11 +444,22 @@ class ListManagementController extends Controller {
|
||||||
return $time[1] + $time[0];
|
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 = [];
|
$extractFeature = [];
|
||||||
$ft = [];
|
$ft = [];
|
||||||
|
$currentArr = [];
|
||||||
|
if ($currentImg) {
|
||||||
|
foreach ($currentImg as $key => $value) {
|
||||||
|
if (isset($value['serverKey']))
|
||||||
|
$currentArr[] = $value['serverKey'];
|
||||||
|
}
|
||||||
|
$ft = $currentImg;
|
||||||
|
}
|
||||||
foreach ($images as $key => $value) {
|
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";
|
$fileName = "face_" . $staff_id . "_" . common::generateRandomString() . "_" . time() . ".png";
|
||||||
$start = $this->getCurrentTime();
|
$start = $this->getCurrentTime();
|
||||||
$img = false;
|
$img = false;
|
||||||
|
@ -476,6 +488,7 @@ class ListManagementController extends Controller {
|
||||||
$finish = $this->getCurrentTime();
|
$finish = $this->getCurrentTime();
|
||||||
$temp["extract"] = round(($finish - $start), 4);
|
$temp["extract"] = round(($finish - $start), 4);
|
||||||
$ft[] = [
|
$ft[] = [
|
||||||
|
"serverKey" => $files_name[$key],
|
||||||
"url" => $fileName,
|
"url" => $fileName,
|
||||||
"urlOld" => $fileName,
|
"urlOld" => $fileName,
|
||||||
"features" => $features['results'][0]['feature'],
|
"features" => $features['results'][0]['feature'],
|
||||||
|
@ -499,20 +512,23 @@ class ListManagementController extends Controller {
|
||||||
$totals = intval(Yii::$app->request->post("totals"));
|
$totals = intval(Yii::$app->request->post("totals"));
|
||||||
|
|
||||||
$data = Yii::$app->request->post("id"); //$res['data'][0];
|
$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();
|
$start = $this->getCurrentTime();
|
||||||
$model = ListManagement::findOne(['staff_id' => $data['id']]);
|
$model = ListManagement::findOne(['staff_id' => $data['id']]);
|
||||||
$finish = $this->getCurrentTime();
|
$finish = $this->getCurrentTime();
|
||||||
$processTime["getLM"] = round(($finish - $start), 4);
|
$processTime["getLM"] = round(($finish - $start), 4);
|
||||||
|
$ft = [];
|
||||||
if ($model) {
|
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->abbreviated_name = $data['abbreviated_name'];
|
||||||
$model->code = $data['code'];
|
$model->code = $data['code'];
|
||||||
$model->name = $data['name'];
|
$model->name = $data['name'];
|
||||||
$model->address = $data['department'];
|
$model->address = $data['department'];
|
||||||
// $model->image = json_encode($ft);
|
$model->image = json_encode($ft);
|
||||||
$model->last_modified = time();
|
$model->last_modified = time();
|
||||||
$model->save();
|
$model->save();
|
||||||
// if ($totals <= 10)
|
// if ($totals <= 10)
|
||||||
|
@ -523,9 +539,8 @@ class ListManagementController extends Controller {
|
||||||
// "features" => $model->allFeatures
|
// "features" => $model->allFeatures
|
||||||
// ]);
|
// ]);
|
||||||
} else {
|
} else {
|
||||||
$ft = [];
|
|
||||||
if (isset($data['images'])) {
|
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'];
|
$processTime["extractFeature"] = $extractFeature['time'];
|
||||||
$ft = $extractFeature['features'];
|
$ft = $extractFeature['features'];
|
||||||
}
|
}
|
||||||
|
@ -689,7 +704,7 @@ class ListManagementController extends Controller {
|
||||||
if ($device_id)
|
if ($device_id)
|
||||||
$id_camera = intval($device_id->data);
|
$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);
|
$lsImgs = json_decode($StaffInfo->image, true);
|
||||||
$images = [];
|
$images = [];
|
||||||
foreach ($lsImgs as $key => $value) {
|
foreach ($lsImgs as $key => $value) {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>Tên</th>
|
<th>Tên</th>
|
||||||
|
<th>Tên hiển thị</th>
|
||||||
<th>Giới tính</th>
|
<th>Giới tính</th>
|
||||||
<th>Hình ảnh đăng kí</th>
|
<th>Hình ảnh đăng kí</th>
|
||||||
<th>Ngày sinh</th>
|
<th>Ngày sinh</th>
|
||||||
|
@ -31,9 +32,10 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="sync-lists">
|
<tbody id="sync-lists">
|
||||||
{foreach from=$datas item=arr}
|
{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->code}</td>
|
||||||
<td>{$arr->name}</td>
|
<td>{$arr->name}</td>
|
||||||
|
<td>{$arr.abbreviated_name}</td>
|
||||||
<td>{$arr->gender}</td>
|
<td>{$arr->gender}</td>
|
||||||
<td>
|
<td>
|
||||||
{$images = json_decode($arr->image, true)}
|
{$images = json_decode($arr->image, true)}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user