@cpzxrobot/sdk 1.3.98 → 1.3.100

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
+ ActiveAlarmRuleRequest,
18
+ ActiveAlarmRuleResponse,
17
19
  AlarmRuleListResponse,
18
20
  AlarmRuleDetailResponse,
19
21
  } from ".";
@@ -294,6 +296,34 @@ export class DeviceGateway extends Object {
294
296
  return res.data;
295
297
  });
296
298
  },
299
+
300
+ /**
301
+ * 激活报警规则
302
+ * @param request 激活报警规则的请求参数
303
+ * @returns Promise 包含激活结果
304
+ */
305
+ activeAlarmRule: async (request: ActiveAlarmRuleRequest): Promise<ActiveAlarmRuleResponse> => {
306
+ const axios = await this.context.ready;
307
+
308
+ // 参数验证
309
+ if (!request.id) {
310
+ throw new Error('规则ID不能为空');
311
+ }
312
+
313
+ // 设置默认值
314
+ const requestData: ActiveAlarmRuleRequest = {
315
+ id: request.id,
316
+ factoryIds: request.factoryIds || [],
317
+ allActive: (request.factoryIds?.length || 0) > 0 ? false : request.allActive !== undefined ? request.allActive : true
318
+ };
319
+
320
+ return axios.post(`/api/v2/device/stat/alarms/rule/activate`, requestData).then((res) => {
321
+ if (res.data.code !== 200) {
322
+ throw new Error(res.data.message || '激活报警规则失败');
323
+ }
324
+ return res.data;
325
+ });
326
+ },
297
327
  };
298
328
  }
299
329
 
@@ -1302,7 +1332,7 @@ export class DeviceGateway extends Object {
1302
1332
  */
1303
1333
  async getAlarmHistory(factoryId: number, category: number, pageNum: number = 1, pageSize: number = 5): Promise<AlarmHistoryResponse> {
1304
1334
  const axios = await this.context.ready;
1305
-
1335
+
1306
1336
  // 参数验证
1307
1337
  if (!factoryId) {
1308
1338
  throw new Error('工厂ID不能为空');
@@ -1312,7 +1342,7 @@ export class DeviceGateway extends Object {
1312
1342
  }
1313
1343
 
1314
1344
  return axios.get(`/api/v2/device/stat/alarms/history`, {
1315
- params: { factoryId, category, pageNum,pageSize}
1345
+ params: { factoryId, category, pageNum, pageSize }
1316
1346
  }).then((res) => {
1317
1347
  if (res.data.code !== 200) {
1318
1348
  throw new Error(res.data.message || '获取报警历史记录失败');
@@ -225,6 +225,31 @@ class DeviceGateway extends Object {
225
225
  return res.data;
226
226
  });
227
227
  }),
228
+ /**
229
+ * 激活报警规则
230
+ * @param request 激活报警规则的请求参数
231
+ * @returns Promise 包含激活结果
232
+ */
233
+ activeAlarmRule: (request) => __awaiter(this, void 0, void 0, function* () {
234
+ var _a;
235
+ const axios = yield this.context.ready;
236
+ // 参数验证
237
+ if (!request.id) {
238
+ throw new Error('规则ID不能为空');
239
+ }
240
+ // 设置默认值
241
+ const requestData = {
242
+ id: request.id,
243
+ factoryIds: request.factoryIds || [],
244
+ allActive: (((_a = request.factoryIds) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0 ? false : request.allActive !== undefined ? request.allActive : true
245
+ };
246
+ return axios.post(`/api/v2/device/stat/alarms/rule/activate`, requestData).then((res) => {
247
+ if (res.data.code !== 200) {
248
+ throw new Error(res.data.message || '激活报警规则失败');
249
+ }
250
+ return res.data;
251
+ });
252
+ }),
228
253
  };
229
254
  }
230
255
  constructor(context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.98",
3
+ "version": "1.3.100",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -711,6 +711,30 @@ interface AlarmRuleDetailResponse {
711
711
  message: string;
712
712
  }
713
713
 
714
+ /**
715
+ * 激活报警规则请求接口
716
+ */
717
+ interface ActiveAlarmRuleRequest {
718
+ /** 规则id */
719
+ id: number;
720
+ /** 工厂Ids */
721
+ factoryIds?: number[];
722
+ /** 是否全部激活 */
723
+ allActive?: boolean;
724
+ }
725
+
726
+ /**
727
+ * 激活报警规则响应接口
728
+ */
729
+ interface ActiveAlarmRuleResponse {
730
+ /** 响应码 */
731
+ code: number;
732
+ /** 响应数据 */
733
+ data: null;
734
+ /** 响应消息 */
735
+ message: string;
736
+ }
737
+
714
738
  declare class Cpzxrobot {
715
739
  transport: TransportGateway;
716
740
  ready: Promise<MyAxiosInstance>;
@@ -809,6 +833,8 @@ declare module "@cpzxrobot/sdk" {
809
833
  AlarmRuleAlarmConfig,
810
834
  CreateAlarmRuleRequest,
811
835
  CreateAlarmRuleResponse,
836
+ ActiveAlarmRuleRequest,
837
+ ActiveAlarmRuleResponse,
812
838
  AlarmRuleDetail,
813
839
  AlarmRuleListResponse,
814
840
  AlarmRuleDetailResponse,