đồng bộ dữ liệu lên máy chủ
This commit is contained in:
parent
e27b8de414
commit
5d5de05f85
|
@ -10,6 +10,8 @@ namespace app\commands;
|
||||||
|
|
||||||
use yii\console\Controller;
|
use yii\console\Controller;
|
||||||
use yii\console\ExitCode;
|
use yii\console\ExitCode;
|
||||||
|
use app\models\CaptureLogs;
|
||||||
|
use app\models\ListManagement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This command echoes the first argument that you have entered.
|
* This command echoes the first argument that you have entered.
|
||||||
|
@ -28,32 +30,33 @@ class SyncController extends Controller {
|
||||||
*/
|
*/
|
||||||
public function actionIndex() {
|
public function actionIndex() {
|
||||||
if ($this->is_connected()) {
|
if ($this->is_connected()) {
|
||||||
$sync = \app\models\SyncUrl::find()->one();
|
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
|
||||||
if ($sync) {
|
$ip = "dev-dc.beetai.com";
|
||||||
$logs = \app\models\FaceLogs::find()->all();
|
if ($server_ip)
|
||||||
foreach ($logs as $key => $value) {
|
$ip = $server_ip->data;
|
||||||
$options = [
|
$device_id = \app\models\SyncUrl::findOne(['key_config' => 'device_id']);
|
||||||
'http' => [
|
$id_camera = 209;
|
||||||
'header' => "Content-Type: application/json",
|
if ($device_id)
|
||||||
'method' => "POST",
|
$id_camera = intval($device_id->data);
|
||||||
'content' => json_encode([
|
|
||||||
"camera_id" => $value->camera_id,
|
$ls = CaptureLogs::find()->andWhere(['<>', 'staff_id', 0])->andWhere(['sync_status' => 0])->all();
|
||||||
"confidence" => $value->confidence,
|
foreach ($ls as $key => $value) {
|
||||||
"enable_door" => $value->enable_door,
|
$staffInfo = ListManagement::findOne($value->staff_id);
|
||||||
"encoded_person_image" => $value->encoded_person_image,
|
$res = json_decode(file_get_contents("https://" . $ip . "/api/box/oem_face_recognition", false, stream_context_create([
|
||||||
"frametime" => $value->frametime,
|
'http' => [
|
||||||
"id" => $value->face_id,
|
'header' => "Content-Type: application/json",
|
||||||
"image" => $value->image,
|
'method' => "POST",
|
||||||
"name" => $value->name,
|
'content' => json_encode([
|
||||||
"person_id" => $value->person_id,
|
'image' => base64_encode(file_get_contents(Yii::getAlias('@webroot') . "/data/uploads/face/" . $value->image)),
|
||||||
"status" => $value->status,
|
'camera_id' => strval($id_camera),
|
||||||
"stt" => $value->stt,
|
'frametime' => date("Y-m-d H:i:s", $value->time),
|
||||||
"timezone" => $value->timezone
|
'idCard' => $staffInfo ? strval($staffInfo->code) : "0"
|
||||||
]),
|
])
|
||||||
]
|
]
|
||||||
];
|
])), true);
|
||||||
file_get_contents($sync->data, false, stream_context_create($options));
|
if ($res['status'] == 10000) {
|
||||||
$value->delete();
|
$value->sync_status = 1;
|
||||||
|
$value->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,7 +339,7 @@ class ListManagementController extends Controller {
|
||||||
|
|
||||||
$model = ListManagement::findOne(['code' => $data['idStaff']]);
|
$model = ListManagement::findOne(['code' => $data['idStaff']]);
|
||||||
if ($model) {
|
if ($model) {
|
||||||
$model->name = $data['name'];
|
$model->name = $data['code'];
|
||||||
$model->image = json_encode($ft);
|
$model->image = json_encode($ft);
|
||||||
$model->last_modified = time();
|
$model->last_modified = time();
|
||||||
$model->save();
|
$model->save();
|
||||||
|
@ -348,7 +348,7 @@ class ListManagementController extends Controller {
|
||||||
$model->create([
|
$model->create([
|
||||||
'code' => $data['idStaff'],
|
'code' => $data['idStaff'],
|
||||||
'type' => "wl",
|
'type' => "wl",
|
||||||
'name' => $data['name'],
|
'name' => $data['code'],
|
||||||
'image' => json_encode($ft),
|
'image' => json_encode($ft),
|
||||||
'gender' => "",
|
'gender' => "",
|
||||||
'birthday' => "",
|
'birthday' => "",
|
||||||
|
|
|
@ -14,6 +14,7 @@ use Yii;
|
||||||
* @property int $status
|
* @property int $status
|
||||||
* @property string $remark
|
* @property string $remark
|
||||||
* @property string $confidence
|
* @property string $confidence
|
||||||
|
* @property int $sync_status
|
||||||
*/
|
*/
|
||||||
class CaptureLogs extends \yii\db\ActiveRecord {
|
class CaptureLogs extends \yii\db\ActiveRecord {
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ class CaptureLogs extends \yii\db\ActiveRecord {
|
||||||
*/
|
*/
|
||||||
public function rules() {
|
public function rules() {
|
||||||
return [
|
return [
|
||||||
[['staff_id', 'time', 'status'], 'integer'],
|
[['staff_id', 'time', 'status', 'sync_status'], 'integer'],
|
||||||
[['image', 'remark', 'confidence'], 'string'],
|
[['image', 'remark', 'confidence'], 'string'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -46,7 +47,8 @@ class CaptureLogs extends \yii\db\ActiveRecord {
|
||||||
'remark' => 'Remark',
|
'remark' => 'Remark',
|
||||||
'staff_name' => "Name",
|
'staff_name' => "Name",
|
||||||
'staff_image' => "Registration Image",
|
'staff_image' => "Registration Image",
|
||||||
'confidence' => 'Confidence'
|
'confidence' => 'Confidence',
|
||||||
|
'sync_status' => 'Sync Status'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th>Code</th>
|
||||||
<th>Department</th>
|
<th>Department</th>
|
||||||
<th>Registration Image</th>
|
<th>Registration Image</th>
|
||||||
<th>Code</th>
|
<th>Code</th>
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
<tr onclick="choooseToSync(this);" style="cursor: pointer;" data-stt="false" data-id="{$arr.idStaff}">
|
<tr onclick="choooseToSync(this);" style="cursor: pointer;" data-stt="false" data-id="{$arr.idStaff}">
|
||||||
<td>{$arr.idStaff}</td>
|
<td>{$arr.idStaff}</td>
|
||||||
<td>{$arr.name}</td>
|
<td>{$arr.name}</td>
|
||||||
|
<td>{$arr.code}</td>
|
||||||
<td>{$arr.department}</td>
|
<td>{$arr.department}</td>
|
||||||
<td>
|
<td>
|
||||||
{foreach from=$arr.images item=img}
|
{foreach from=$arr.images item=img}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user