argument('supplier')) { // 移动千里眼 case 'yidong': $this->checkHealthBySupplierYidong(); break; // 电信魔镜 case 'dianxin': $this->checkHealthBySupplierDianxin(); break; } } public function checkHealthBySupplierYidong() { $client = new QlyHttpClient( config('services.ydqly.appid'), config('services.ydqly.secret'), config('services.ydqly.rsa'), ); $page = 1; $pageSize = 100; do { $result = $client->post( '/v3/open/api/device/list', [ 'page' => $page, 'pageSize' => $pageSize, ], ); foreach ($result['data'] as $item) { Device::where('sn', str_replace('xxxxS_', '', $item['deviceId'])) ->where('supplier_key', 'device-supplier-yidong') ->where('type', DeviceType::Monitor) ->whereIn('status', [DeviceStatus::Online, DeviceStatus::Offline]) ->update([ 'status' => $item['deviceStatus'] === 1 ? DeviceStatus::Online : DeviceStatus::Offline, 'updated_at' => now(), ]); } $page++; sleep(1); } while (count($result['data']) === $pageSize); } protected function checkHealthBySupplierDianxin(): void { $client = new MoJingHttpClient( config('services.dxmj.app_id'), config('services.dxmj.app_secret'), ); $result = $client->get( "/api/v3/channel/listByOrgId", [ 'id' => '1736649747126530049', ], ); foreach ($result['data'] as $item) { Device::where('sn', $item['channelcode']) ->where('supplier_key', 'device-supplier-dianxin') ->where('type', DeviceType::Monitor) ->whereIn('status', [DeviceStatus::Online, DeviceStatus::Offline]) ->update([ 'extends' => json_encode([ 'ip' => '', 'port' => '', 'username' => '', 'password' => '', 'passage' => $item['citId'], 'rtsp_url' => '', ]), 'status' => $item['channelstatus'] === 1 ? DeviceStatus::Online : DeviceStatus::Offline, 'updated_at' => now(), ]); } } }