update save response req
This commit is contained in:
parent
aade992cf9
commit
db801e7d96
|
@ -30,29 +30,18 @@ class SyncController extends Controller {
|
||||||
if ($this->is_connected()) {
|
if ($this->is_connected()) {
|
||||||
$sync = \app\models\SyncUrl::find()->one();
|
$sync = \app\models\SyncUrl::find()->one();
|
||||||
if ($sync) {
|
if ($sync) {
|
||||||
$logs = \app\models\FaceLogs::find()->all();
|
$logs = \app\models\WaitingReq::find()->all();
|
||||||
foreach ($logs as $key => $value) {
|
foreach ($logs as $key => $value) {
|
||||||
$options = [
|
$options = [
|
||||||
'http' => [
|
'http' => [
|
||||||
'header' => "Content-Type: application/json",
|
'header' => "Content-Type: application/json",
|
||||||
'method' => "POST",
|
'method' => "POST",
|
||||||
'content' => json_encode([
|
'content' => $value->content
|
||||||
"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));
|
$res = json_decode(file_get_contents($sync->data, false, stream_context_create($options)), true);
|
||||||
|
$modelRes = new \app\models\ResponseReq();
|
||||||
|
$modelRes->create(json_encode($res));
|
||||||
$value->delete();
|
$value->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,10 +62,10 @@ class ApiController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionTest() {
|
public function actionTest() {
|
||||||
$ls = \app\models\WaitingReq::find()->limit(10)->all();
|
$test1 = \app\models\WaitingReq::find()->count();
|
||||||
$c = \app\models\WaitingReq::find()->count();
|
$test = \app\models\ResponseReq::find()->count();
|
||||||
echo "<pre>";
|
echo "<pre>";
|
||||||
var_dump($c, $ls);
|
var_dump($test1, $test);
|
||||||
echo "</pre>";
|
echo "</pre>";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
60
models/ResponseReq.php
Normal file
60
models/ResponseReq.php
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the model class for table "response_req".
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property string $content
|
||||||
|
* @property int $time
|
||||||
|
*/
|
||||||
|
class ResponseReq extends \yii\db\ActiveRecord {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function tableName() {
|
||||||
|
return 'response_req';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function rules() {
|
||||||
|
return [
|
||||||
|
[['content', 'time'], 'required'],
|
||||||
|
[['content'], 'string'],
|
||||||
|
[['time'], 'integer'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function attributeLabels() {
|
||||||
|
return [
|
||||||
|
'id' => 'ID',
|
||||||
|
'content' => 'Content',
|
||||||
|
'time' => 'Time',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create($data) {
|
||||||
|
$r = $this->load([
|
||||||
|
'content' => json_encode($data),
|
||||||
|
'time' => time()
|
||||||
|
], '');
|
||||||
|
if ($r) {
|
||||||
|
try {
|
||||||
|
$this->save();
|
||||||
|
return $this->id;
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
copy.src.files=false
|
copy.src.files=false
|
||||||
copy.src.on.open=false
|
copy.src.on.open=false
|
||||||
copy.src.target=
|
copy.src.target=
|
||||||
remote.connection=bf_local-799e1d
|
remote.connection=BiFace-99bab6
|
||||||
remote.directory=/BiFace_Server_Lite
|
remote.directory=/BiFace_Server_Lite
|
||||||
remote.upload=ON_SAVE
|
remote.upload=ON_SAVE
|
||||||
run.as=REMOTE
|
run.as=REMOTE
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// comment out the following two lines when deployed to production
|
// comment out the following two lines when deployed to production
|
||||||
//defined('YII_DEBUG') or define('YII_DEBUG', true);
|
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||||
//defined('YII_ENV') or define('YII_ENV', 'dev');
|
defined('YII_ENV') or define('YII_ENV', 'dev');
|
||||||
|
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
|
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user