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