import { ApiClientFactory } from '../core/api.client.factory'; import { VideoList, CreateGateway, GatewayList, Docs, CreateVideo, GroupList, CreateGroup, VendorList, CategoryList, DeviceDetail, EventTypes, } from '../model/atlasConfig.model'; export class AtlasConfigService { constructor(private factory: ApiClientFactory) {} /** * @function syncDeviceInfo 同步设备 * @param projectId 项目ID */ async syncDeviceInfo(projectId: string): Promise { const result = await this.factory.surveillance.put( `/config/atlas/projects/${projectId}/devices/syncDeviceInfo` ); return result; } /** * @function syncDeviceStatus 同步设备状态 */ async syncDeviceStatus(projectId: string): Promise { const result = await this.factory.surveillance.get( `/config/atlas/projects/${projectId}/devices/syncDeviceStatus` ); return result; } /** * @function loadDocs 获取文档 * @param projectId 项目ID */ async loadDocs(projectId: string): Promise { const result = await this.factory.surveillance.get( `/config/atlas/projects/${projectId}/devices/download/getUrl` ); return result; } /** * @function loadGatewayList 获取网关列表 * @param projectId 项目ID */ async loadGatewayList(projectId: string): Promise { const result = await this.factory.surveillance.get( `/config/atlas/projects/${projectId}/devices/listGateway` ); return result; } /** * @function loadVideoList 获取相关设备列表 * @param projectId 项目ID * @param type 列表类型 * type:NVR,获取视频NVR列表 * type:Camera,获取摄像机列表 */ async loadVideoList(projectId: string, type: string, params?: object): Promise { const result = await this.factory.surveillance.get( `/config/atlas/projects/${projectId}/devices/list?type=${type}`, params ); return result; } /** * @function createVideoGateway 新建和更新网关 * @param projectId 项目ID * @param gateway 更新的数据,具体参数查看CreateGateway */ async createVideoGateway(projectId: string, gateway: CreateGateway): Promise { return await this.factory.surveillance.post( `/config/atlas/projects/${projectId}/devices/saveGateway`, gateway ); } /** * @function createVideo 新建和更新视频相关设备 * @param projectId 项目ID * @param type 类型 NVR,Camera */ async createVideo(projectId: string, req: CreateVideo, type: string): Promise { return await this.factory.surveillance.put(`/config/atlas/projects/${projectId}/devices/save`, { ...req, type, }); } /** * @function deleteVideoDevice 删除视频相关设备 * @param projectId 项目ID * @param id 数据ID */ async deleteVideoDevice(projectId: string, id: string): Promise { return await this.factory.surveillance.delete(`/config/atlas/projects/${projectId}/devices/${id}`); } /** * @function loadGroupList 获取群组列表 * @param projectId 项目ID */ async loadGroupList(projectId: string): Promise { const result = await this.factory.surveillance.get(`/projects/${projectId}/groups`); return result; } /** * @function createGroup 添加修改群组信息 * @param projectId 项目ID * @param group 更新的数据,具体参数查看CreateGroup */ async createGroup(projectId: string, group: CreateGroup): Promise { const result = await this.factory.surveillance.put(`/projects/${projectId}/groups`, group); return result; } /** * @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/atlas/projects/${projectId}/devices/${deviceId}/detail` ); return result; } /** * @function deleteGroup 删除摄像机分组 * @param projectId 项目ID * @param id 数据ID */ async deleteGroup(projectId: string, id: string): Promise { return await this.factory.surveillance.delete(`/projects/${projectId}/groups/${id}`); } /** * @function sendGatewayConfig 下发网关配置 */ async sendGatewayConfig(projectId: string, id: string): Promise { const result = await this.factory.surveillance.get(`/config/atlas/projects/${projectId}/devices/config/${id}`); return result; } /** * 获取算法类型 * @param projectId */ async loadEventTypes(projectId: string): Promise { const result = await this.factory.surveillance.get( `/config/atlas/projects/${projectId}/devices/eventTypes` ); return result; } /** * 开启摄像机事件 * @param projectId * @param id * @param gatewayId */ async openCamemraEvent(projectId: string, id: string, gatewayId: string): Promise { const result = await this.factory.surveillance.get( `/config/atlas/projects/${projectId}/devices/saveJob/${id}`, { gatewayId } ); return result; } /** * 关闭摄像机事件 * @param projectId * @param id * @param gatewayId */ async closeCamemraEvent(projectId: string, id: string): Promise { const result = await this.factory.surveillance.get( `/config/atlas/projects/${projectId}/devices/stopJob/${id}` ); return result; } }