fix send logs realtime
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user