{ "properties" : { }, "id" : "c3d4e5f678901234567890abcdef0123", "script" : null, "groupId" : "f8e3d2c1b0a94e5f8a7b6c5d4e3f2a1", "name" : "市场实时监控", "createTime" : 1781199600000, "updateTime" : 1781378000000, "lock" : null, "createBy" : "admin", "updateBy" : "admin", "path" : "/market-realtime-monitor", "method" : "GET", "parameters" : [ ], "options" : [ ], "requestBody" : "", "headers" : [ ], "paths" : [ ], "responseBody" : null, "description" : "市场实时监控:iot_device_video + iot_video_account,萤石 ezopen 播放地址与 accessToken。", "requestBodyDefinition" : null, "responseBodyDefinition" : null } ================================ // iot_device_video + iot_video_account(萤石云) // play_url / hd_play_url:ezopen://open.ys7.com/{serial}/{channel}.live // accessToken:iot_video_account.token var sql = """ SELECT v.id, v.name, v.number, v.location, v.address, v.status, v.serial_number, v.channel_number, v.play_url, v.hd_play_url, v.preview_img_url, v.img, v.video_account_id, v."index" AS sort_index, v.last_capture_time, a.app_key, a.token AS access_token FROM iot_device_video v LEFT JOIN iot_video_account a ON a.id::text = v.video_account_id AND COALESCE(a.del_flag, '0') = '0' WHERE COALESCE(v.del_flag, '0') = '0' AND COALESCE(v.is_show, true) = true ORDER BY v."index" NULLS LAST, v.name """ var rows = db.select(sql) var cameras = [] var pickText = (row, camelKey, snakeKey) => { if (!row) { return '' } if (row[camelKey]) { return row[camelKey] } if (row[snakeKey]) { return row[snakeKey] } return '' } var toUpperText = (text) => { if (!text) { return '' } return ('' + text).toUpperCase() } var mapStatus = (row) => { var deviceStatus = pickText(row, 'status', 'status') var deviceUpper = toUpperText(deviceStatus) if (deviceUpper === 'OFFLINE') { return 'offline' } if (deviceUpper === 'ERROR' || deviceUpper === 'FAULT') { return 'error' } return 'online' } var pickEzopenUrl = (row) => { var hd = pickText(row, 'hdPlayUrl', 'hd_play_url') if (hd) { return hd } var play = pickText(row, 'playUrl', 'play_url') if (play) { return play } var serial = pickText(row, 'serialNumber', 'serial_number') var channel = row.channelNumber != null ? row.channelNumber : row.channel_number if (channel == null) { channel = 1 } if (serial) { return 'ezopen://open.ys7.com/' + serial + '/' + channel + '.hd.live' } return '' } var pickPreviewUrl = (row) => { var preview = pickText(row, 'previewImgUrl', 'preview_img_url') if (preview) { return preview } return pickText(row, 'img', 'img') } if (rows && rows.length > 0) { for (row in rows) { cameras.push({ id: pickText(row, 'id', 'id'), name: pickText(row, 'name', 'name'), number: pickText(row, 'number', 'number'), location: pickText(row, 'location', 'location'), address: pickText(row, 'address', 'address'), serialNumber: pickText(row, 'serialNumber', 'serial_number'), channelNumber: row.channelNumber != null ? row.channelNumber : row.channel_number, videoAccountId: pickText(row, 'videoAccountId', 'video_account_id'), sortIndex: row.sortIndex != null ? row.sortIndex : row.sort_index, status: mapStatus(row), resolution: '1920x1080', url: pickPreviewUrl(row), preview: pickPreviewUrl(row), playUrl: pickText(row, 'playUrl', 'play_url'), hdPlayUrl: pickText(row, 'hdPlayUrl', 'hd_play_url'), ezopenUrl: pickEzopenUrl(row), accessToken: pickText(row, 'accessToken', 'access_token'), appKey: pickText(row, 'appKey', 'app_key') }) } } return { pageSize: 2, autoPlayInterval: 10000, cameras: cameras }