đồng bộ dữ liệu từ cloud
This commit is contained in:
@@ -307,8 +307,80 @@ class ListManagementController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function actionTest() {
|
||||
return base64_encode(file_get_contents("http://api.demo.beetai.com/view/image/5fd0845d9a4eb65bcfb0ea3b"));
|
||||
public function actionSyncFromServer() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
$datas = json_decode(file_get_contents("https://dev-dc.beetai.com/api/oem/get_all_image", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
"id_camera" => 209,
|
||||
"ids_staff" => []
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
Yii::$app->response->format = "json";
|
||||
return [
|
||||
"title" => "<i class='fa fa-download'></i> Đồng bộ từ máy chủ",
|
||||
"form" => $this->renderPartial("list-server", [
|
||||
"datas" => $datas['data']
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionSyncFeature() {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$res = json_decode(file_get_contents("https://dev-dc.beetai.com/api/oem/get_all_image", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
"id_camera" => 209,
|
||||
"ids_staff" => [strval(Yii::$app->request->post("id"))]
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
$data = $res['data'][0];
|
||||
$ft = [];
|
||||
$RootFolder = Yii::getAlias('@webroot') . "/data/uploads";
|
||||
$targetPath = $RootFolder . "/face";
|
||||
FileHelper::createDirectory($targetPath, 0777);
|
||||
foreach ($data['images'] as $key => $value) {
|
||||
$key = common::generateRandomString();
|
||||
$fileName = "face_" . $key . "_" . time() . ".png";
|
||||
file_put_contents($targetPath . "/" . $fileName, file_get_contents($value));
|
||||
$features = json_decode(common::requestToEngine("/get-feature", [
|
||||
"image_paths" => [
|
||||
["url" => "/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $fileName, "type" => "raw"]
|
||||
]
|
||||
]), true);
|
||||
$ft[] = ["url" => $fileName, "features" => $features['results'][0]['feature']];
|
||||
}
|
||||
|
||||
$model = new ListManagement();
|
||||
$model->create([
|
||||
'code' => $data['idStaff'],
|
||||
'type' => "wl",
|
||||
'name' => $data['name'],
|
||||
'image' => json_encode($ft),
|
||||
'gender' => "",
|
||||
'birthday' => "",
|
||||
'telephone' => "",
|
||||
'address' => ""
|
||||
]);
|
||||
// file_get_contents("http://localhost:2305/update-feature");
|
||||
return ["status" => true];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionUpdateFeature() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
Yii::$app->response->format = "json";
|
||||
file_get_contents("http://localhost:2305/update-feature");
|
||||
return ["status" => true];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user