From 79718d36c5a284eaa2e48b117abf540a6ca3a1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Tue, 29 Apr 2025 16:35:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86=20-=20?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GetAddResultedDevicesController.php | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Server/application/superadmin/controller/devices/GetAddResultedDevicesController.php b/Server/application/superadmin/controller/devices/GetAddResultedDevicesController.php index 71c85f51..cb266391 100644 --- a/Server/application/superadmin/controller/devices/GetAddResultedDevicesController.php +++ b/Server/application/superadmin/controller/devices/GetAddResultedDevicesController.php @@ -45,31 +45,34 @@ class GetAddResultedDevicesController extends Controller protected function migrateData(int $accountId): void { $companyId = $this->getCompanyIdByAccountId($accountId); - $ids = $this->getAllDevicesIdWithInCompany($companyId); + $deviceIds = $this->getAllDevicesIdWithInCompany($companyId); - // 从 s2_device 导入数据。 - $this->getNewDeviceFromS2_device($ids); + if ($deviceIds) { + // 从 s2_device 导入数据。 + $this->getNewDeviceFromS2_device($deviceIds, $companyId); + } } /** * 从 s2_device 导入数据。 * * @param array $ids - * @return array + * @param int $companyId + * @return void */ - protected function getNewDeviceFromS2_device(array $ids): array + protected function getNewDeviceFromS2_device(array $ids, int $companyId): void { + $ids = implode(',', $ids); + $sql = "insert into ck_device(`id`, `imei`, `model`, phone, operatingSystem,memo,alive,brand,rooted,xPosed,softwareVersion,extra,createTime,updateTime,deleteTime,companyId) select d.id,d.imei,d.model,d.phone,d.operatingSystem,d.memo,d.alive,d.brand,d.rooted,d.xPosed,d.softwareVersion,d.extra,d.createTime,d.lastUpdateTime,d.deleteTime,a.departmentId companyId from s2_device d join s2_company_account a on d.currentAccountId = a.id - where isDeleted = 0 and deletedAndStop = 0 and d.id not in (:ids) + where isDeleted = 0 and deletedAndStop = 0 and d.id not in ({$ids}) and a.departmentId = {$companyId} "; - dd($sql); - - Db::query($sql, ['ids' => implode(',', $ids)]); + Db::query($sql); } /** @@ -92,6 +95,8 @@ class GetAddResultedDevicesController extends Controller $result = json_decode($result, true); $result = $result['data']['results'][0]; + return true; + return ( // 125是前端延迟5秒 + 轮询120次 1次/s time() - strtotime($result['lastUpdateTime']) <= 125