update đồng bộ tất cả thiết bị

This commit is contained in:
2020-11-04 17:24:56 +07:00
parent 72dfa46c94
commit fa10b73a3d
3 changed files with 38 additions and 5 deletions

View File

@@ -87,6 +87,9 @@ class DeviceController extends Controller {
if ($requestToCardService["Status"] === "ERROR")
return ["status" => false, "type" => "connect"];
if (intval($requestToCardService["LockCount"]) < 1)
return ["status" => false, "type" => "connect"];
$device_id = $model->create([
'name' => $data["Name"],
'serial' => isset($device['SN']) ? $device['SN'] : "",
@@ -378,10 +381,20 @@ class DeviceController extends Controller {
public function actionSync() {
if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
$post = Yii::$app->request->post("lists");
$lists = $post["lists"];
if ($post["all"] && count($lists) >= 20) {
$temp = [];
$devices = Device::find()->all();
foreach ($devices as $key => $value) {
$temp[] = $value->id;
}
$lists = $temp;
}
return [
"title" => Html::tag("i", "", ["class" => "fa fa-refresh"]) . " Đồng bộ dữ liệu đến thiết bị",
"form" => $this->renderPartial("sync"),
"lists" => Yii::$app->request->post("lists")
"lists" => $lists
];
}
}
@@ -533,10 +546,20 @@ class DeviceController extends Controller {
public function actionGetLogs() {
if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
$post = Yii::$app->request->post("lists");
$lists = $post["lists"];
if ($post["all"] && count($lists) >= 20) {
$temp = [];
$devices = Device::find()->all();
foreach ($devices as $key => $value) {
$temp[] = $value->id;
}
$lists = $temp;
}
return [
"title" => Html::tag("i", "", ["class" => "fa fa-exchange"]) . " Lấy các sự kiện",
"form" => $this->renderPartial("logs"),
"lists" => Yii::$app->request->post("lists")
"lists" => $lists
];
}
}