làm lại quy trình đồng bộ dữ liệu
This commit is contained in:
@@ -347,10 +347,11 @@ class DeviceController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function actionGetDataSync() {
|
||||
public function actionSyncSchedule() {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$device_id = Yii::$app->request->post("data");
|
||||
$deviceInfo = $this->findModel($device_id);
|
||||
$doors = Door::find()->andWhere(["device_id" => $device_id])->all();
|
||||
$filter = ["OR"];
|
||||
foreach ($doors as $key => $value) {
|
||||
@@ -362,20 +363,8 @@ class DeviceController extends Controller {
|
||||
foreach ($staffs as $key => $value) {
|
||||
$schedule[] = $value->schedule_id;
|
||||
}
|
||||
$schedule_lists = array_unique($schedule);
|
||||
|
||||
$schedule = array_unique($schedule);
|
||||
return [
|
||||
"IP" => $this->findModel($device_id)->ip_address,
|
||||
"schedule" => $schedule
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionSyncSchedule() {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$post = Yii::$app->request->post();
|
||||
$schedule_lists = $post["data"];
|
||||
$TimeZoneInfos = [];
|
||||
foreach ($schedule_lists as $key => $value) {
|
||||
$schedule = Schedule::findOne($value);
|
||||
@@ -394,28 +383,29 @@ class DeviceController extends Controller {
|
||||
];
|
||||
}
|
||||
$res = json_decode(common::requestToCardService("/SetDeviceData/TimeZone", [
|
||||
"DeviceIP" => $post["ip"],
|
||||
"DeviceIP" => $deviceInfo->ip_address,
|
||||
"TimeZoneInfos" => $TimeZoneInfos
|
||||
]), true);
|
||||
return [
|
||||
"IP" => $deviceInfo->ip_address,
|
||||
"res" => $res,
|
||||
"IP" => $post["ip"]
|
||||
"staffs" => count($staffs)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function actionSyncStaffs() {
|
||||
public function actionSyncStaff($page = 1) {
|
||||
if (Yii::$app->request->post()) {
|
||||
Yii::$app->response->format = "json";
|
||||
$post = Yii::$app->request->post();
|
||||
$device_id = Device::findOne(['ip_address' => $post['ip']])->id;
|
||||
$device_id = Yii::$app->request->post("data");
|
||||
$deviceInfo = $this->findModel($device_id);
|
||||
$doors = Door::find()->andWhere(["device_id" => $device_id])->all();
|
||||
$filter = ["OR"];
|
||||
foreach ($doors as $key => $value) {
|
||||
$filter[] = ["LIKE", "door_access", '"' . $value->id . '"'];
|
||||
}
|
||||
$staff_lists = Staff::find()->andWhere($filter)->all();
|
||||
|
||||
$offset = ($page - 1) * 200;
|
||||
$staff_lists = Staff::find()->andWhere($filter)->limit(200)->offset($offset)->all();
|
||||
$UserInfos = [];
|
||||
$UserAuthorizeInfos = [];
|
||||
|
||||
@@ -441,17 +431,19 @@ class DeviceController extends Controller {
|
||||
}
|
||||
}
|
||||
}
|
||||
$resUser = json_decode(common::requestToCardService("/SetDeviceData/User", [
|
||||
"DeviceIP" => $post["ip"],
|
||||
json_decode(common::requestToCardService("/SetDeviceData/User", [
|
||||
"DeviceIP" => $deviceInfo->ip_address,
|
||||
"UserInfos" => $UserInfos
|
||||
]), true);
|
||||
common::requestToCardService("/SetDeviceData/UserAuthorize", [
|
||||
"DeviceIP" => $post["ip"],
|
||||
"DeviceIP" => $deviceInfo->ip_address,
|
||||
"UserAuthorizeInfos" => $UserAuthorizeInfos
|
||||
]);
|
||||
return [
|
||||
"resUser" => $resUser,
|
||||
"IP" => $post["ip"]
|
||||
"IP" => $deviceInfo->ip_address,
|
||||
"staff" => count($UserInfos),
|
||||
"from" => $offset + 1,
|
||||
"to" => $offset + count($UserInfos)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user