import { Pageable } from '../'; import { ApiClientFactory } from '../core/api.client.factory'; import { YsVideoList, CreateCamera, CreateLocalVideo, Docs, CreateNVR, VendorList, CategoryList, DeviceDetail, YsyAccountRep, YsyAccountReq, EventConfigs, YsyOnlineLogParam, YsyOnlineLogModel, RangingScene, Point3d, BImReq, } from '../model/ysConfig.model'; import { RangingConfigModel } from '..//model/ysConfig.model'; export class YsConfigService { constructor(private factory: ApiClientFactory) {} /** * @function loadDocs 获取文档 * @param projectId 项目ID */ async loadDocs(projectId: string): Promise { const result = await this.factory.surveillance.get( `/config/ysy/projects/${projectId}/devices/download/getUrl` ); return result; } /** * @function sync 同步设备状态 单一 */ // {{host}}/ivs/api/devices/status/613c5a23071f62001b1fd53a async sync(Id: string): Promise { const result = await this.factory.surveillance.put(`/devices/status/${Id}`); return result; } /** * @function loadYsVideoList 获取萤石NVR列表 * @param projectId 项目ID * @param type */ async loadYsVideoList(projectId: string, type: string, params?: any): Promise { const result = await this.factory.surveillance.get( `/config/ysy/projects/${projectId}/devices?type=${type}`, params ); return result; } /** * @function createVideoNVR 新建和更新NVR * @param projectId 项目ID * @param nvrData 更新的数据,具体参数查看CreateNVR */ async createVideoNVR(projectId: string, nvr: CreateNVR): Promise { return await this.factory.surveillance.put(`/config/ysy/projects/${projectId}/devices/nvr`, nvr); } /** * @function createVideoCamera 新建和更新camera * @param projectId 项目ID * @param camera 更新的数据,具体参数查看CreateCamera */ async createVideoCamera(projectId: string, camera: CreateCamera): Promise { return await this.factory.surveillance.put(`/config/ysy/projects/${projectId}/devices/ipc`, camera); } /** * @function createLocalVideo 新建和更新本地camera或nvr * @param projectId 项目ID */ async createLocalVideo(projectId: string, req: CreateLocalVideo): Promise { return await this.factory.surveillance.put(`/config/ysy/projects/${projectId}/devices/rtsp`, req); } /** * @function delteNvrDevice 删除nvr * @param projectId * @param id */ async deleteNvrDevice(projectId: string, id: string, unbind: boolean): Promise { return await this.factory.surveillance.delete( `config/ysy/projects/${projectId}/devices/${id}?unbind=${unbind}` ); } /** * @function deleteVideoDevice 删除视频相关设备 * @param projectId 项目ID * @param id 数据ID */ async deleteVideoDevice(projectId: string, id: string, unbind: boolean): Promise { return await this.factory.surveillance.delete( `/config/ysy/projects/${projectId}/devices/${id}?unbind=${unbind}` ); } /** * @function deleteDeviceLocalConfig 删除设备本地配置 * @param projectId * @param id */ async deleteDeviceLocalConfig(projectId: string, id: string): Promise { return await this.factory.surveillance.delete(`config/ysy/projects/${projectId}/devices/rtsp/${id}`); } /** * @function syncYsyData 同步筑联的数据 * @param projectId 项目ID */ async syncYsyData(projectId: string): Promise { return await this.factory.surveillance.put(`/config/ysy/projects/${projectId}/devices/syncDeviceInfo`); } /** * @function loadVendorList 获取vendor厂家信息列表 */ async loadVendorList(): Promise { const result = await this.factory.surveillance.get(`/system/dict/vendors`); return result; } /** * @function loadCategoryList 获取Category信息列表 */ async loadCategoryList(): Promise { const result = await this.factory.surveillance.get(`/system/dict/cameraTypes`); return result; } /** * @function loadDeviceDetail 获取设备详情信息 * @param projectId 项目ID * @param deviceId 设备ID */ async loadDeviceDetail(projectId: string, deviceId: string): Promise { const result = await this.factory.surveillance.get( `/config/ysy/projects/${projectId}/devices/${deviceId}` ); return result; } /** * @function 监控全部 */ async addAllMonitor(projectId: string) { return await this.factory.surveillance.put(`/config/ysy/projects/${projectId}/devices/monitor`); } /** * @function 取消监控全部 */ async cancelAllMonitor(projectId: string) { return await this.factory.surveillance.put(`/config/ysy/projects/${projectId}/devices/cancelMonitor`); } /** * @function 加入监控 */ async addMonitor(projectId: string, deviceId: string) { return await this.factory.surveillance.put(`config/ysy/projects/${projectId}/devices/${deviceId}/monitor`); } /** * @function 取消监控 */ async cancelMonitor(projectId: string, deviceId: string) { return await this.factory.surveillance.put( `config/ysy/projects/${projectId}/devices/${deviceId}/cancelMonitor` ); } /** * @function 加入Flv */ async addStartFlv(projectId: string, deviceId: string) { return await this.factory.surveillance.put(`config/ysy/projects/${projectId}/devices/${deviceId}/startFlv`); } /** * @function 取消Flv */ async cancelStopFlv(projectId: string, deviceId: string) { return await this.factory.surveillance.put(`config/ysy/projects/${projectId}/devices/${deviceId}/stopFlv`); } /** * @function 同步摄像头 */ async syncDeviceImage(projectId: string) { return await this.factory.surveillance.put(`config/ysy/projects/${projectId}/devices/syncDeviceImage`); } /** * @function updateYsyAccount 修改萤石云账号 */ async updateYsyAccount(projectId: string, ysyConfig: YsyAccountReq) { return await this.factory.surveillance.put(`project/video/source/config/ysy`, { projectId, ysyConfig, }); } /** * @function loadYsyAccount 修改萤石云账号 */ async loadYsyAccount(projectId: string) { return await this.factory.surveillance.get(`project/video/source/config`, { projectId, }); } /** * @function loadYsyEvent 萤石云事件列表 */ async loadYsyEvent() { return await this.factory.surveillance.get(`eventConfig/eventTypes/ysy`); } /** * @function updateYsyEvent 更新萤石云事件配置 */ async updateYsyEvent(param: EventConfigs) { return await this.factory.surveillance.put(`eventConfig/device/eventConfig`, param); } /** * @function deleteDeviceFromYsy 解绑萤石云设备 */ async deleteDeviceFromYsy(projectId: string, id: string) { return await this.factory.surveillance.put(`/config/ysy/projects/${projectId}/devices/deleteDeviceFromYsy`, { id, }); } /** * 绑定萤石云设备 */ async addDeviceToYsy(projectId: string, id: string) { return await this.factory.surveillance.put(`/config/ysy/projects/${projectId}/devices/addDeviceToYsy`, { id, }); } /** * @function loadYsyOnlineLog 萤石云在线日志 */ async loadYsyOnlineLog(param: YsyOnlineLogParam) { return await this.factory.surveillance.get>(`/ysy/log/online/query`, param); } /** * @function 萤石云重启设备 */ async restartDevice(deviceId: string) { return await this.factory.surveillance.post(`/ysy/device/reboot?deviceId=${deviceId}`); } /** * @function 萤石云设备资源信息 */ async fetchDeviceResourceStatus(deviceId: string) { return await this.factory.surveillance.get(`/ysy/device/status`, { deviceId }); } /** * @function 萤石云设备信息 */ async fetchDeviceSystemInfo(deviceId: string) { return await this.factory.surveillance.get(`/ysy/device/systemInfo?deviceId=${deviceId}`); } async fetchDeviceSystemInfoV2(deviceId: string) { return await this.factory.surveillance.get(`/ysy/device/systemInfoV2?deviceId=${deviceId}`); } /** * @function 转H264 */ async toh264(projectId: string, deviceId?: string): Promise { const result = await this.factory.surveillance.post(`/ysy/stream/to264`, { projectId, deviceId, }); return result; } /** * @function 转H265 */ async toh265(projectId: string, deviceId?: string): Promise { const result = await this.factory.surveillance.post(`/ysy/stream/to265`, { projectId, deviceId, }); return result; } /** * 获取萤石云设备远程配置信息 * @param deviceId * @returns */ async loadRemoteCofig(deviceId: string): Promise { const result = await this.factory.surveillance.get(`/ysy/remote/config/${deviceId}`); return result; } /** * @function 萤石云租户配置信息 */ async fetchAccountConfigInfo(tenantId: string): Promise { const result = await this.factory.surveillance.get(`/tenant/video/source/config`, { tenantId, }); return result; } async deleteYsyAccount(tenantId: string) { return await this.factory.surveillance.delete(`/tenant/video/source/config/ysy`, { tenantId, }); } /** * @function 转H264 */ async setAccountConfigInfo(tenantId: string, ysyConfig: YsyAccountReq): Promise { const result = await this.factory.surveillance.put(`/tenant/video/source/config/ysy`, { tenantId, ysyConfig, }); return result; } /** * 升级萤石云设备 * @param projectId * @param deviceId * @returns */ async upgradeYsyDevice(projectId: string, deviceId: string): Promise { const result = await this.factory.surveillance.post( `config/ysy/projects/${projectId}/devices/upgrade?deviceId=${deviceId}` ); return result; } // 👇测距配置 /** * 测距>保存测距配置 */ async saveRangingConfig(params: RangingConfigModel) { const url = `/ranging/config`; return await this.factory.surveillance.post(url, params); } /** * 测距>下发测距配置 */ async sendRangingConfig(id: string) { const url = `/ranging/config/sendConfigToIpc`; return await this.factory.surveillance.post(url, { id }); } /** * 测距>查询测距配置 */ async fetchRangingConfig(deviceId: string) { const url = `/ranging/config`; return await this.factory.surveillance.get(url, { deviceId }); } /** * 测距>删除配置 */ async deleteRangingConfig(deviceId: string) { const url = `/ranging/config`; return await this.factory.surveillance.delete(url, { deviceId }); } /** * 测距>检测类型 */ async fetchDetectTypes() { const url = `/ranging/config/detectTypes`; return await this.factory.surveillance.get(url); } /** * 测距>场景列表 */ async fetchRangingScenes(deviceId: string) { const url = `/ranging/scenes`; return await this.factory.surveillance.get(url, { deviceId }); } /** * 测距>场景列表 */ async renameRangingScene(params: { id: string; name: string }) { const url = `/ranging/scenes/updateName`; return await this.factory.surveillance.post(url, params); } /** * 测距>同步场景 */ async syncRangingScenes(deviceId: string) { const url = `/ranging/scenes/sync`; return await this.factory.surveillance.post(url, { deviceId }); } /** * 测距>手工测距 */ async rangingManualTrigger(deviceId: string, sceneId: string) { const url = `/ranging/scenes/manualTrigger`; return await this.factory.surveillance.post(url, { deviceId, sceneId }); } /** * 测距>修改场景名称 */ // async redefineScene(...) { // const url = ``; // return await this.factory.surveillance.post(url, { deviceId, sceneId }); // } /** * 测距>查询结果 */ async fetchRangingResults( projectId: string, params: { deviceId?: string; fromTime?: string; toTime?: string; timeSort?: 'asc' | 'desc'; pageSize: number; pageNo: number; } ) { const url = `/ranging/result/history?projectId=${projectId}`; return await this.factory.surveillance.get>(url, params); } /** * 测距>删除数据 */ async deleteRangingData(projectId: string, ids: string[]) { const url = `/ranging/result/deleteByIds`; return await this.factory.surveillance.delete(url, { projectId, ids, }); } /** * 测距>检测类型 */ async getDetectTypes() { const url = `/ranging/result/detectTypes`; return await this.factory.surveillance.get(url); } /** * 两点测距>添加配置/修改配置 */ async setTwoPointsConfig(params: any) { const url = `/ranging/points`; return await this.factory.surveillance.post(url, params); } /** * 两点测距>获取 */ async getTwoPointsConfig(deviceId: string) { const url = `/ranging/points`; return await this.factory.surveillance.get(url, { deviceId }); } async getTwoPointsConfigById(deviceId: string) { const url = `/ranging/points/${deviceId}`; return await this.factory.surveillance.get(url); } /** * 两点测距>配置点位 */ async setPoint3D(params: Point3d) { const url = `/ranging/ptz/position3D`; return await this.factory.surveillance.put(url, params); } /** * 两点测距>删除多条 */ async deletePointConfiguration(projectId: string, ids: any[]) { const url = `/ranging/points/batch`; return await this.factory.surveillance.delete(url, { projectId, ids, }); } /** * 两点测距>测量 */ async twoPointsManualTrigger(configId: string) { const url = `/ranging/points/manualTrigger`; return await this.factory.surveillance.post(url, { configId, }); } /** * 保存楼高场景BIM模型图 * @param BImReq * @returns */ async saveScenesBim(bImReq: BImReq) { const url = `/ranging/scenes/bim`; return await this.factory.surveillance.post(url, bImReq); } /** * 保存两点测距BIM模型图 * @param BImReq * @returns */ async savePointsBim(bImReq: BImReq) { const url = `/ranging/points/bim`; return await this.factory.surveillance.post(url, bImReq); } /** * 获取BIM的相关信息 * @param bimFileId * @returns */ async loadBimInfo(bimFileId: string) { const url = `/ranging/result/bim`; return await this.factory.surveillance.get(url, { bimFileId }); } setEntrence(deviceId: string, v: boolean) { return this.factory.surveillance.put(`/device/updateExport?deviceId=${deviceId}&export=${String(v)}`); } /** * 复制摄像机 * @param deviceConfig * @returns */ async copyCamera(projectId: string, deviceConfig: object) { const url = `/config/ysy/projects/${projectId}/devices/cloneIpc`; return await this.factory.surveillance.put(url, { ...deviceConfig }); } }