import { ApiClientFactory } from "../core/api.client.factory"; import { SpraySettingsSaveModel, SpraySettingsDevicesModel, SprayDevicesInformationModel } from "../model/spraySettings.model"; export class SpraySettings { constructor(private factory: ApiClientFactory) {} // 根据项目id获取后台配置信息 async loadSpraySettingsConfig(projectId: string): Promise { const url = `/api/web/projects/${projectId}/spray/spraySettings `; const result = await this.factory.entity.get(url); return result; } // 根据项目id取控制箱信息、环境设备信息 async loadSpraySettingsDevices(projectId: string): Promise { const url = `/api/web/projects/${projectId}/spray/devices `; const result = await this.factory.entity.get(url); return result; } // 后台保存配置信息,包括增加和编辑 async loadSpraySettingsSave(projectId: string, data: SpraySettingsSaveModel): Promise { const url = `/api/web/projects/${projectId}/spray`; const result = await this.factory.entity.post(url, data); return result; } // 删除保存配置类单一记录数据 async deleteSprayListItem(projectId: string, id: string): Promise { const result = await this.factory.entity.delete( `/api/web/projects/${projectId}/spray/spraySetting/${id}` ); return result; } // 保存喷淋设备运行模式(手动:0;自动:1;定时:2) async loadSprayRunMode(projectId: string, deviceId: string, sprayRunMode: number): Promise { const url = `/api/web/projects/${projectId}/spray/sprayRunInfo/runMode/${deviceId}/${sprayRunMode}`; const result = await this.factory.entity.put(url); return result; } // 手动切换喷淋状态(关闭:0;开启:1) async loadSprayState(projectId: string, deviceId: string, sprayState: number): Promise { const url = `/api/web/projects/${projectId}/spray/sprayRunInfo/sprayState/${deviceId}/${sprayState}`; const result = await this.factory.entity.put(url); return result; } // 根据喷淋设备id取喷淋信息 async loadSprayDevicesInformation(projectId: string, deviceId: string): Promise { const url = `/api/web/projects/${projectId}/spray/sprayInfo/deviceId/${deviceId}`; const result = await this.factory.entity.get(url); return result; } }