@cpzxrobot/sdk 1.3.102 → 1.3.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/device_gateway.ts CHANGED
@@ -14,6 +14,8 @@ import type {
14
14
  AlarmHistoryResponse,
15
15
  CreateAlarmRuleRequest,
16
16
  CreateAlarmRuleResponse,
17
+ UpdateAlarmRuleRequest,
18
+ UpdateAlarmRuleResponse,
17
19
  ActiveAlarmRuleRequest,
18
20
  ActiveAlarmRuleResponse,
19
21
  AlarmRuleListResponse,
@@ -283,6 +285,40 @@ export class DeviceGateway extends Object {
283
285
  return res.data;
284
286
  });
285
287
  },
288
+
289
+ /**
290
+ * 修改报警规则
291
+ * @param request 修改报警规则的请求参数
292
+ * @returns Promise 包含修改结果
293
+ */
294
+ update: async (request: UpdateAlarmRuleRequest): Promise<UpdateAlarmRuleResponse> => {
295
+ const axios = await this.context.ready;
296
+
297
+ // 参数验证
298
+ if (!request.id) {
299
+ throw new Error('规则ID不能为空');
300
+ }
301
+ if (!request.factoryId) {
302
+ let farm = await this.context.user.getSelectedFarm();
303
+ request.factoryId = farm?.id || 0;
304
+ }
305
+ if (!request.ruleName) {
306
+ throw new Error('规则名称不能为空');
307
+ }
308
+
309
+ // 设置默认值
310
+ const requestData: UpdateAlarmRuleRequest = {
311
+ ...request,
312
+ ruleActive: request.ruleActive !== undefined ? request.ruleActive : true
313
+ };
314
+
315
+ return axios.post(`/api/v2/device/stat/alarms/rule/update`, requestData).then((res) => {
316
+ if (res.data.code !== 200) {
317
+ throw new Error(res.data.message || '修改报警规则失败');
318
+ }
319
+ return res.data;
320
+ });
321
+ },
286
322
  /**
287
323
  * 删除报警规则
288
324
  * @param id - 报警规则ID
@@ -212,6 +212,33 @@ class DeviceGateway extends Object {
212
212
  return res.data;
213
213
  });
214
214
  }),
215
+ /**
216
+ * 修改报警规则
217
+ * @param request 修改报警规则的请求参数
218
+ * @returns Promise 包含修改结果
219
+ */
220
+ update: (request) => __awaiter(this, void 0, void 0, function* () {
221
+ const axios = yield this.context.ready;
222
+ // 参数验证
223
+ if (!request.id) {
224
+ throw new Error('规则ID不能为空');
225
+ }
226
+ if (!request.factoryId) {
227
+ let farm = yield this.context.user.getSelectedFarm();
228
+ request.factoryId = (farm === null || farm === void 0 ? void 0 : farm.id) || 0;
229
+ }
230
+ if (!request.ruleName) {
231
+ throw new Error('规则名称不能为空');
232
+ }
233
+ // 设置默认值
234
+ const requestData = Object.assign(Object.assign({}, request), { ruleActive: request.ruleActive !== undefined ? request.ruleActive : true });
235
+ return axios.post(`/api/v2/device/stat/alarms/rule/update`, requestData).then((res) => {
236
+ if (res.data.code !== 200) {
237
+ throw new Error(res.data.message || '修改报警规则失败');
238
+ }
239
+ return res.data;
240
+ });
241
+ }),
215
242
  /**
216
243
  * 删除报警规则
217
244
  * @param id - 报警规则ID
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.102",
3
+ "version": "1.3.103",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -653,6 +653,48 @@ interface CreateAlarmRuleResponse {
653
653
  message: string;
654
654
  }
655
655
 
656
+ /**
657
+ * 修改报警规则请求接口
658
+ */
659
+ interface UpdateAlarmRuleRequest {
660
+ /** 规则id */
661
+ id: number;
662
+ /** 工厂id */
663
+ factoryId: number;
664
+ /** 规则名称 */
665
+ ruleName: string;
666
+ /** 规则描述 */
667
+ ruleDescription?: string;
668
+ /** 规则是否启用 */
669
+ ruleActive?: boolean;
670
+ /** 单元id列表 */
671
+ unitIds?: number[];
672
+ /** 栋舍id列表 */
673
+ workshopIds?: number[];
674
+ /** 栋舍类型列表 */
675
+ workshopTypes?: number[];
676
+ /** 报警方式 */
677
+ alarmType?: "OFFLINE" | "FAULT" | "THRESHOLD" | "TREND";
678
+ /** 设备类型列表 */
679
+ deviceTypes?: ("GATEWAY" | "SENSOR" | "DEVICE")[];
680
+ /** 阈值配置列表 */
681
+ thresholdConfigs?: AlarmRuleThresholdConfig[];
682
+ /** 报警配置列表 */
683
+ alarmConfigs?: AlarmRuleAlarmConfig[];
684
+ }
685
+
686
+ /**
687
+ * 修改报警规则响应接口
688
+ */
689
+ interface UpdateAlarmRuleResponse {
690
+ /** 响应码 */
691
+ code: number;
692
+ /** 响应数据 */
693
+ data: null;
694
+ /** 响应消息 */
695
+ message: string;
696
+ }
697
+
656
698
  /**
657
699
  * 报警规则详情接口
658
700
  */
@@ -841,6 +883,8 @@ declare module "@cpzxrobot/sdk" {
841
883
  AlarmRuleAlarmConfig,
842
884
  CreateAlarmRuleRequest,
843
885
  CreateAlarmRuleResponse,
886
+ UpdateAlarmRuleRequest,
887
+ UpdateAlarmRuleResponse,
844
888
  ActiveAlarmRuleRequest,
845
889
  ActiveAlarmRuleResponse,
846
890
  AlarmRuleDetail,