@cpzxrobot/sdk 1.3.103 → 1.3.105
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 +45 -0
- package/dist/device_gateway.js +38 -0
- package/package.json +1 -1
- package/types.d.ts +15 -0
package/device_gateway.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
UpdateAlarmRuleResponse,
|
|
19
19
|
ActiveAlarmRuleRequest,
|
|
20
20
|
ActiveAlarmRuleResponse,
|
|
21
|
+
ActivatedFactoriesResponse,
|
|
21
22
|
AlarmRuleListResponse,
|
|
22
23
|
AlarmRuleDetailResponse,
|
|
23
24
|
} from ".";
|
|
@@ -353,6 +354,50 @@ export class DeviceGateway extends Object {
|
|
|
353
354
|
return res.data;
|
|
354
355
|
});
|
|
355
356
|
},
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* 激活报警规则
|
|
360
|
+
* @param request 激活报警规则的请求参数
|
|
361
|
+
* @returns Promise 包含激活结果
|
|
362
|
+
*/
|
|
363
|
+
deactiveAlarmRule: async (request: ActiveAlarmRuleRequest): Promise<ActiveAlarmRuleResponse> => {
|
|
364
|
+
const axios = await this.context.ready;
|
|
365
|
+
|
|
366
|
+
// 参数验证
|
|
367
|
+
if (!request.id) {
|
|
368
|
+
throw new Error('规则ID不能为空');
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return axios.post(`/api/v2/device/stat/alarms/rule/deactivate`, request).then((res) => {
|
|
372
|
+
if (res.data.code !== 200) {
|
|
373
|
+
throw new Error(res.data.message || '停用报警规则失败');
|
|
374
|
+
}
|
|
375
|
+
return res.data;
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* 获取已激活工厂列表
|
|
381
|
+
* @param ruleId 规则ID
|
|
382
|
+
* @returns Promise 包含已激活的工厂ID列表
|
|
383
|
+
*/
|
|
384
|
+
getActivatedFactories: async (ruleId: number): Promise<ActivatedFactoriesResponse> => {
|
|
385
|
+
const axios = await this.context.ready;
|
|
386
|
+
|
|
387
|
+
// 参数验证
|
|
388
|
+
if (!ruleId) {
|
|
389
|
+
throw new Error('规则ID不能为空');
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return axios.get(`/api/v2/device/stat/alarms/rule/list`, {
|
|
393
|
+
params: { id: ruleId }
|
|
394
|
+
}).then((res) => {
|
|
395
|
+
if (res.data.code !== 200) {
|
|
396
|
+
throw new Error(res.data.message || '获取已激活工厂列表失败');
|
|
397
|
+
}
|
|
398
|
+
return res.data;
|
|
399
|
+
});
|
|
400
|
+
},
|
|
356
401
|
};
|
|
357
402
|
}
|
|
358
403
|
|
package/dist/device_gateway.js
CHANGED
|
@@ -270,6 +270,44 @@ class DeviceGateway extends Object {
|
|
|
270
270
|
return res.data;
|
|
271
271
|
});
|
|
272
272
|
}),
|
|
273
|
+
/**
|
|
274
|
+
* 激活报警规则
|
|
275
|
+
* @param request 激活报警规则的请求参数
|
|
276
|
+
* @returns Promise 包含激活结果
|
|
277
|
+
*/
|
|
278
|
+
deactiveAlarmRule: (request) => __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
const axios = yield this.context.ready;
|
|
280
|
+
// 参数验证
|
|
281
|
+
if (!request.id) {
|
|
282
|
+
throw new Error('规则ID不能为空');
|
|
283
|
+
}
|
|
284
|
+
return axios.post(`/api/v2/device/stat/alarms/rule/deactivate`, request).then((res) => {
|
|
285
|
+
if (res.data.code !== 200) {
|
|
286
|
+
throw new Error(res.data.message || '停用报警规则失败');
|
|
287
|
+
}
|
|
288
|
+
return res.data;
|
|
289
|
+
});
|
|
290
|
+
}),
|
|
291
|
+
/**
|
|
292
|
+
* 获取已激活工厂列表
|
|
293
|
+
* @param ruleId 规则ID
|
|
294
|
+
* @returns Promise 包含已激活的工厂ID列表
|
|
295
|
+
*/
|
|
296
|
+
getActivatedFactories: (ruleId) => __awaiter(this, void 0, void 0, function* () {
|
|
297
|
+
const axios = yield this.context.ready;
|
|
298
|
+
// 参数验证
|
|
299
|
+
if (!ruleId) {
|
|
300
|
+
throw new Error('规则ID不能为空');
|
|
301
|
+
}
|
|
302
|
+
return axios.get(`/api/v2/device/stat/alarms/rule/list`, {
|
|
303
|
+
params: { id: ruleId }
|
|
304
|
+
}).then((res) => {
|
|
305
|
+
if (res.data.code !== 200) {
|
|
306
|
+
throw new Error(res.data.message || '获取已激活工厂列表失败');
|
|
307
|
+
}
|
|
308
|
+
return res.data;
|
|
309
|
+
});
|
|
310
|
+
}),
|
|
273
311
|
};
|
|
274
312
|
}
|
|
275
313
|
constructor(context) {
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -681,6 +681,8 @@ interface UpdateAlarmRuleRequest {
|
|
|
681
681
|
thresholdConfigs?: AlarmRuleThresholdConfig[];
|
|
682
682
|
/** 报警配置列表 */
|
|
683
683
|
alarmConfigs?: AlarmRuleAlarmConfig[];
|
|
684
|
+
/** 激活规则的工厂数量 */
|
|
685
|
+
upperActiveSum?: number;
|
|
684
686
|
}
|
|
685
687
|
|
|
686
688
|
/**
|
|
@@ -785,6 +787,18 @@ interface ActiveAlarmRuleResponse {
|
|
|
785
787
|
message: string;
|
|
786
788
|
}
|
|
787
789
|
|
|
790
|
+
/**
|
|
791
|
+
* 已激活工厂列表响应接口
|
|
792
|
+
*/
|
|
793
|
+
interface ActivatedFactoriesResponse {
|
|
794
|
+
/** 响应码 */
|
|
795
|
+
code: number;
|
|
796
|
+
/** 已激活的工厂ID列表 */
|
|
797
|
+
data: number[];
|
|
798
|
+
/** 响应消息 */
|
|
799
|
+
message: string;
|
|
800
|
+
}
|
|
801
|
+
|
|
788
802
|
declare class Cpzxrobot {
|
|
789
803
|
transport: TransportGateway;
|
|
790
804
|
ready: Promise<MyAxiosInstance>;
|
|
@@ -887,6 +901,7 @@ declare module "@cpzxrobot/sdk" {
|
|
|
887
901
|
UpdateAlarmRuleResponse,
|
|
888
902
|
ActiveAlarmRuleRequest,
|
|
889
903
|
ActiveAlarmRuleResponse,
|
|
904
|
+
ActivatedFactoriesResponse,
|
|
890
905
|
AlarmRuleDetail,
|
|
891
906
|
AlarmRuleListResponse,
|
|
892
907
|
AlarmRuleDetailResponse,
|