@cpzxrobot/sdk 1.3.101 → 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 +36 -0
- package/dist/device_gateway.js +27 -0
- package/package.json +1 -1
- package/types.d.ts +52 -0
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
|
package/dist/device_gateway.js
CHANGED
|
@@ -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
package/types.d.ts
CHANGED
|
@@ -587,6 +587,14 @@ interface AlarmRuleThresholdConfig {
|
|
|
587
587
|
thresholdMin?: number;
|
|
588
588
|
/** 阈值最大值 */
|
|
589
589
|
thresholdMax?: number;
|
|
590
|
+
/** 报警触发最小日龄 */
|
|
591
|
+
enabledAgeMin?: number;
|
|
592
|
+
/** 报警触发最大日龄 */
|
|
593
|
+
enabledAgeMax?: number;
|
|
594
|
+
/** 是否开启离线报警 */
|
|
595
|
+
offlineAlert?: boolean;
|
|
596
|
+
/** 是否开启恢复报警 */
|
|
597
|
+
restoreAlert?: boolean;
|
|
590
598
|
}
|
|
591
599
|
|
|
592
600
|
/**
|
|
@@ -645,6 +653,48 @@ interface CreateAlarmRuleResponse {
|
|
|
645
653
|
message: string;
|
|
646
654
|
}
|
|
647
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
|
+
|
|
648
698
|
/**
|
|
649
699
|
* 报警规则详情接口
|
|
650
700
|
*/
|
|
@@ -833,6 +883,8 @@ declare module "@cpzxrobot/sdk" {
|
|
|
833
883
|
AlarmRuleAlarmConfig,
|
|
834
884
|
CreateAlarmRuleRequest,
|
|
835
885
|
CreateAlarmRuleResponse,
|
|
886
|
+
UpdateAlarmRuleRequest,
|
|
887
|
+
UpdateAlarmRuleResponse,
|
|
836
888
|
ActiveAlarmRuleRequest,
|
|
837
889
|
ActiveAlarmRuleResponse,
|
|
838
890
|
AlarmRuleDetail,
|