update script đồng bộ dữ liệu tới máy chủ

This commit is contained in:
dongpd 2020-12-11 15:11:26 +07:00
parent 5d5de05f85
commit 237f658e16

View File

@ -12,6 +12,7 @@ use yii\console\Controller;
use yii\console\ExitCode;
use app\models\CaptureLogs;
use app\models\ListManagement;
use Yii;
/**
* This command echoes the first argument that you have entered.
@ -38,8 +39,7 @@ class SyncController extends Controller {
$id_camera = 209;
if ($device_id)
$id_camera = intval($device_id->data);
$ls = CaptureLogs::find()->andWhere(['<>', 'staff_id', 0])->andWhere(['sync_status' => 0])->all();
$ls = CaptureLogs::find()->andWhere(['<>', 'staff_id', 0])->andWhere(['sync_status' => null])->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([
@ -47,10 +47,12 @@ class SyncController extends Controller {
'header' => "Content-Type: application/json",
'method' => "POST",
'content' => json_encode([
'image' => base64_encode(file_get_contents(Yii::getAlias('@webroot') . "/data/uploads/face/" . $value->image)),
'image' => base64_encode(file_get_contents("/var/www/html/BiFace_Server_Lite/web/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"
'frametime' => date("Y-m-d H:i:s", $value->time + 60 * 60 * 7),
'idCard' => $staffInfo ? strval($staffInfo->code) : "0",
"person_id" => "123",
"timezone" => "+7"
])
]
])), true);