@cpzxrobot/sdk 1.3.97 → 1.3.98
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 +33 -2
- package/dist/device_gateway.js +31 -2
- package/package.json +1 -1
- package/types.d.ts +42 -0
package/device_gateway.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
DeviceAlarmStatisticsResponse,
|
|
12
12
|
AlarmStatisticsByTypeResponse,
|
|
13
13
|
AlarmTrendResponse,
|
|
14
|
+
AlarmHistoryResponse,
|
|
14
15
|
CreateAlarmRuleRequest,
|
|
15
16
|
CreateAlarmRuleResponse,
|
|
16
17
|
AlarmRuleListResponse,
|
|
@@ -1089,9 +1090,10 @@ export class DeviceGateway extends Object {
|
|
|
1089
1090
|
/**
|
|
1090
1091
|
* 获取设备告警统计信息
|
|
1091
1092
|
* @param factoryId 工厂ID
|
|
1093
|
+
* @param faultTypeId 故障类型ID(可选),如果指定则返回该故障类型的统计信息,如果不指定则返回所有故障类型的统计信息
|
|
1092
1094
|
* @returns Promise 包含告警统计信息的数据
|
|
1093
1095
|
*/
|
|
1094
|
-
async getAlarmStats(factoryId: number | undefined = undefined): Promise<DeviceAlarmStatsResponse> {
|
|
1096
|
+
async getAlarmStats(factoryId: number | undefined = undefined, faultTypeId: number | undefined = undefined): Promise<DeviceAlarmStatsResponse> {
|
|
1095
1097
|
const axios = await this.context.ready;
|
|
1096
1098
|
var _factoryId = factoryId || 0;
|
|
1097
1099
|
if (!factoryId) {
|
|
@@ -1100,7 +1102,7 @@ export class DeviceGateway extends Object {
|
|
|
1100
1102
|
}
|
|
1101
1103
|
|
|
1102
1104
|
return axios.get(`/api/v2/device/stat/alarms`, {
|
|
1103
|
-
params: { factoryId: _factoryId }
|
|
1105
|
+
params: { factoryId: _factoryId, category: faultTypeId }
|
|
1104
1106
|
}).then((res) => {
|
|
1105
1107
|
if (res.data.code !== 200) {
|
|
1106
1108
|
throw new Error(res.data.message || '获取设备告警统计信息失败');
|
|
@@ -1290,4 +1292,33 @@ export class DeviceGateway extends Object {
|
|
|
1290
1292
|
});
|
|
1291
1293
|
}
|
|
1292
1294
|
|
|
1295
|
+
/**
|
|
1296
|
+
* 按工厂ID和故障种类查询最近报警记录
|
|
1297
|
+
* @param factoryId 工厂ID
|
|
1298
|
+
* @param category 故障类型
|
|
1299
|
+
* @param pageNum 页码
|
|
1300
|
+
* @param pageSize 每页数量
|
|
1301
|
+
* @returns Promise 包含报警历史记录数据
|
|
1302
|
+
*/
|
|
1303
|
+
async getAlarmHistory(factoryId: number, category: number, pageNum: number = 1, pageSize: number = 5): Promise<AlarmHistoryResponse> {
|
|
1304
|
+
const axios = await this.context.ready;
|
|
1305
|
+
|
|
1306
|
+
// 参数验证
|
|
1307
|
+
if (!factoryId) {
|
|
1308
|
+
throw new Error('工厂ID不能为空');
|
|
1309
|
+
}
|
|
1310
|
+
if (!category && category !== 0) {
|
|
1311
|
+
throw new Error('故障类型不能为空');
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
return axios.get(`/api/v2/device/stat/alarms/history`, {
|
|
1315
|
+
params: { factoryId, category, pageNum,pageSize}
|
|
1316
|
+
}).then((res) => {
|
|
1317
|
+
if (res.data.code !== 200) {
|
|
1318
|
+
throw new Error(res.data.message || '获取报警历史记录失败');
|
|
1319
|
+
}
|
|
1320
|
+
return res.data;
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1293
1324
|
}
|
package/dist/device_gateway.js
CHANGED
|
@@ -863,10 +863,11 @@ class DeviceGateway extends Object {
|
|
|
863
863
|
/**
|
|
864
864
|
* 获取设备告警统计信息
|
|
865
865
|
* @param factoryId 工厂ID
|
|
866
|
+
* @param faultTypeId 故障类型ID(可选),如果指定则返回该故障类型的统计信息,如果不指定则返回所有故障类型的统计信息
|
|
866
867
|
* @returns Promise 包含告警统计信息的数据
|
|
867
868
|
*/
|
|
868
869
|
getAlarmStats() {
|
|
869
|
-
return __awaiter(this, arguments, void 0, function* (factoryId = undefined) {
|
|
870
|
+
return __awaiter(this, arguments, void 0, function* (factoryId = undefined, faultTypeId = undefined) {
|
|
870
871
|
const axios = yield this.context.ready;
|
|
871
872
|
var _factoryId = factoryId || 0;
|
|
872
873
|
if (!factoryId) {
|
|
@@ -874,7 +875,7 @@ class DeviceGateway extends Object {
|
|
|
874
875
|
_factoryId = (farm === null || farm === void 0 ? void 0 : farm.id) || 0;
|
|
875
876
|
}
|
|
876
877
|
return axios.get(`/api/v2/device/stat/alarms`, {
|
|
877
|
-
params: { factoryId: _factoryId }
|
|
878
|
+
params: { factoryId: _factoryId, category: faultTypeId }
|
|
878
879
|
}).then((res) => {
|
|
879
880
|
if (res.data.code !== 200) {
|
|
880
881
|
throw new Error(res.data.message || '获取设备告警统计信息失败');
|
|
@@ -1041,5 +1042,33 @@ class DeviceGateway extends Object {
|
|
|
1041
1042
|
});
|
|
1042
1043
|
});
|
|
1043
1044
|
}
|
|
1045
|
+
/**
|
|
1046
|
+
* 按工厂ID和故障种类查询最近报警记录
|
|
1047
|
+
* @param factoryId 工厂ID
|
|
1048
|
+
* @param category 故障类型
|
|
1049
|
+
* @param pageNum 页码
|
|
1050
|
+
* @param pageSize 每页数量
|
|
1051
|
+
* @returns Promise 包含报警历史记录数据
|
|
1052
|
+
*/
|
|
1053
|
+
getAlarmHistory(factoryId_1, category_1) {
|
|
1054
|
+
return __awaiter(this, arguments, void 0, function* (factoryId, category, pageNum = 1, pageSize = 5) {
|
|
1055
|
+
const axios = yield this.context.ready;
|
|
1056
|
+
// 参数验证
|
|
1057
|
+
if (!factoryId) {
|
|
1058
|
+
throw new Error('工厂ID不能为空');
|
|
1059
|
+
}
|
|
1060
|
+
if (!category && category !== 0) {
|
|
1061
|
+
throw new Error('故障类型不能为空');
|
|
1062
|
+
}
|
|
1063
|
+
return axios.get(`/api/v2/device/stat/alarms/history`, {
|
|
1064
|
+
params: { factoryId, category, pageNum, pageSize }
|
|
1065
|
+
}).then((res) => {
|
|
1066
|
+
if (res.data.code !== 200) {
|
|
1067
|
+
throw new Error(res.data.message || '获取报警历史记录失败');
|
|
1068
|
+
}
|
|
1069
|
+
return res.data;
|
|
1070
|
+
});
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1044
1073
|
}
|
|
1045
1074
|
exports.DeviceGateway = DeviceGateway;
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -537,6 +537,44 @@ interface AlarmTrendResponse {
|
|
|
537
537
|
message: string;
|
|
538
538
|
}
|
|
539
539
|
|
|
540
|
+
/**
|
|
541
|
+
* 报警历史记录项接口
|
|
542
|
+
*/
|
|
543
|
+
interface AlarmHistoryItem {
|
|
544
|
+
/** 报警类型 */
|
|
545
|
+
category: number;
|
|
546
|
+
/** 设备ID */
|
|
547
|
+
deviceId: number;
|
|
548
|
+
/** 持续时间(秒) */
|
|
549
|
+
durationSeconds: number;
|
|
550
|
+
/** 报警结束时间 */
|
|
551
|
+
endTime: string | null;
|
|
552
|
+
/** 工厂ID */
|
|
553
|
+
factoryId: number;
|
|
554
|
+
/** 故障字段 */
|
|
555
|
+
field: string;
|
|
556
|
+
/** 报警记录ID */
|
|
557
|
+
id: number;
|
|
558
|
+
/** 是否已解决 */
|
|
559
|
+
resolved: boolean;
|
|
560
|
+
/** 报警开始时间 */
|
|
561
|
+
startTime: string;
|
|
562
|
+
/** 故障消息 */
|
|
563
|
+
troubleMessage: string;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* 报警历史记录响应接口
|
|
568
|
+
*/
|
|
569
|
+
interface AlarmHistoryResponse {
|
|
570
|
+
/** 响应码 */
|
|
571
|
+
code: number;
|
|
572
|
+
/** 报警历史记录数据 */
|
|
573
|
+
data: AlarmHistoryItem[];
|
|
574
|
+
/** 响应消息 */
|
|
575
|
+
message: string;
|
|
576
|
+
}
|
|
577
|
+
|
|
540
578
|
/**
|
|
541
579
|
* 报警规则阈值配置接口
|
|
542
580
|
*/
|
|
@@ -625,6 +663,8 @@ interface AlarmRuleDetail {
|
|
|
625
663
|
unitIds?: number[];
|
|
626
664
|
/** 栋舍id列表 */
|
|
627
665
|
workshopIds?: number[];
|
|
666
|
+
/** 栋舍类型列表 */
|
|
667
|
+
workshopTypes?: number[];
|
|
628
668
|
/** 报警方式 */
|
|
629
669
|
alarmType?: "OFFLINE" | "FAULT" | "THRESHOLD" | "TREND";
|
|
630
670
|
/** 设备类型列表 */
|
|
@@ -763,6 +803,8 @@ declare module "@cpzxrobot/sdk" {
|
|
|
763
803
|
AlarmStatisticsByTypeResponse,
|
|
764
804
|
AlarmTrendItem,
|
|
765
805
|
AlarmTrendResponse,
|
|
806
|
+
AlarmHistoryItem,
|
|
807
|
+
AlarmHistoryResponse,
|
|
766
808
|
AlarmRuleThresholdConfig,
|
|
767
809
|
AlarmRuleAlarmConfig,
|
|
768
810
|
CreateAlarmRuleRequest,
|