import { ApiClientFactory } from '../core/api.client.factory'; import { AiTemplateReq, AiTemplate, HummingbirdList, HummingbirdListReq, TaskList, TaskReq, TenantList, ProjectList, } from '../model/AlgorithmConfig.model'; export class AlgorithmConfigService { constructor(private factory: ApiClientFactory) {} /** * 添加算法模板 * @param options * @returns */ async createAiTemplate(options: AiTemplateReq): Promise { const result = await this.factory.amis.post(`/box/algo/template`, options); return result; } /** * 获取算法模板列表 * @returns */ async loadAiTemplate(): Promise { const result = await this.factory.amis.get(`/box/algo/template/list`); return result; } /** * 删除算法模板 * @param id * @returns */ async deleteAiTemplate(id: string): Promise { const result = await this.factory.amis.delete(`/box/algo/template/${id}`); return result; } /** * 获取盒子列表 * @param optons * @returns */ async loadHummingbirdList(options: HummingbirdListReq): Promise { const result = await this.factory.amis.get(`/box/list`, options); return result; } /** * 获取盒子任务列表 * @returns */ async loadTaskList(templateId?: string): Promise { const result = await this.factory.amis.get(`/box/algo/task/list`, { templateId }); return result; } /** * 创建盒子任务 * @param options * @returns */ async createTask(options: TaskReq): Promise { const result = await this.factory.amis.post(`/box/algo/task`, options); return result; } /** * 下发盒子任务 * @param options * @returns */ async sendTask(taskIds: string[]): Promise { const result = await this.factory.amis.post(`/box/algo/task/send2Box`, { taskIds }); return result; } /** * 删除盒子任务 * @param id * @returns */ async deleteTask(taskIds: string[]): Promise { const result = await this.factory.amis.delete(`/box/algo/task`, { taskIds }); return result; } /** * 获取租户列表 * @returns */ async loadTenantList(): Promise { const result = await this.factory.amis.get(`/query/gatewayDeviceQuery`); return result; } /** * 获取租户下的项目列表 * @param tenantId * @returns */ async loadProjectList(tenantId: string): Promise { const result = await this.factory.amis.get(`/query/projects`, { tenantId }); return result; } fetchBoxAndMonitorDevices(projectId: string) { return this.factory.entity.get(`/api/safe/rectification/boxAndMonitorDevices?projectId=${projectId}`); } }