@cpzxrobot/sdk 1.3.97 → 1.3.99
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 +63 -2
- package/dist/device_gateway.js +56 -2
- package/package.json +1 -1
- package/types.d.ts +68 -0
package/device_gateway.ts
CHANGED
|
@@ -11,8 +11,11 @@ import type {
|
|
|
11
11
|
DeviceAlarmStatisticsResponse,
|
|
12
12
|
AlarmStatisticsByTypeResponse,
|
|
13
13
|
AlarmTrendResponse,
|
|
14
|
+
AlarmHistoryResponse,
|
|
14
15
|
CreateAlarmRuleRequest,
|
|
15
16
|
CreateAlarmRuleResponse,
|
|
17
|
+
ActiveAlarmRuleRequest,
|
|
18
|
+
ActiveAlarmRuleResponse,
|
|
16
19
|
AlarmRuleListResponse,
|
|
17
20
|
AlarmRuleDetailResponse,
|
|
18
21
|
} from ".";
|
|
@@ -293,6 +296,34 @@ export class DeviceGateway extends Object {
|
|
|
293
296
|
return res.data;
|
|
294
297
|
});
|
|
295
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/active`, requestData).then((res) => {
|
|
321
|
+
if (res.data.code !== 200) {
|
|
322
|
+
throw new Error(res.data.message || '激活报警规则失败');
|
|
323
|
+
}
|
|
324
|
+
return res.data;
|
|
325
|
+
});
|
|
326
|
+
},
|
|
296
327
|
};
|
|
297
328
|
}
|
|
298
329
|
|
|
@@ -1089,9 +1120,10 @@ export class DeviceGateway extends Object {
|
|
|
1089
1120
|
/**
|
|
1090
1121
|
* 获取设备告警统计信息
|
|
1091
1122
|
* @param factoryId 工厂ID
|
|
1123
|
+
* @param faultTypeId 故障类型ID(可选),如果指定则返回该故障类型的统计信息,如果不指定则返回所有故障类型的统计信息
|
|
1092
1124
|
* @returns Promise 包含告警统计信息的数据
|
|
1093
1125
|
*/
|
|
1094
|
-
async getAlarmStats(factoryId: number | undefined = undefined): Promise<DeviceAlarmStatsResponse> {
|
|
1126
|
+
async getAlarmStats(factoryId: number | undefined = undefined, faultTypeId: number | undefined = undefined): Promise<DeviceAlarmStatsResponse> {
|
|
1095
1127
|
const axios = await this.context.ready;
|
|
1096
1128
|
var _factoryId = factoryId || 0;
|
|
1097
1129
|
if (!factoryId) {
|
|
@@ -1100,7 +1132,7 @@ export class DeviceGateway extends Object {
|
|
|
1100
1132
|
}
|
|
1101
1133
|
|
|
1102
1134
|
return axios.get(`/api/v2/device/stat/alarms`, {
|
|
1103
|
-
params: { factoryId: _factoryId }
|
|
1135
|
+
params: { factoryId: _factoryId, category: faultTypeId }
|
|
1104
1136
|
}).then((res) => {
|
|
1105
1137
|
if (res.data.code !== 200) {
|
|
1106
1138
|
throw new Error(res.data.message || '获取设备告警统计信息失败');
|
|
@@ -1290,4 +1322,33 @@ export class DeviceGateway extends Object {
|
|
|
1290
1322
|
});
|
|
1291
1323
|
}
|
|
1292
1324
|
|
|
1325
|
+
/**
|
|
1326
|
+
* 按工厂ID和故障种类查询最近报警记录
|
|
1327
|
+
* @param factoryId 工厂ID
|
|
1328
|
+
* @param category 故障类型
|
|
1329
|
+
* @param pageNum 页码
|
|
1330
|
+
* @param pageSize 每页数量
|
|
1331
|
+
* @returns Promise 包含报警历史记录数据
|
|
1332
|
+
*/
|
|
1333
|
+
async getAlarmHistory(factoryId: number, category: number, pageNum: number = 1, pageSize: number = 5): Promise<AlarmHistoryResponse> {
|
|
1334
|
+
const axios = await this.context.ready;
|
|
1335
|
+
|
|
1336
|
+
// 参数验证
|
|
1337
|
+
if (!factoryId) {
|
|
1338
|
+
throw new Error('工厂ID不能为空');
|
|
1339
|
+
}
|
|
1340
|
+
if (!category && category !== 0) {
|
|
1341
|
+
throw new Error('故障类型不能为空');
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
return axios.get(`/api/v2/device/stat/alarms/history`, {
|
|
1345
|
+
params: { factoryId, category, pageNum, pageSize }
|
|
1346
|
+
}).then((res) => {
|
|
1347
|
+
if (res.data.code !== 200) {
|
|
1348
|
+
throw new Error(res.data.message || '获取报警历史记录失败');
|
|
1349
|
+
}
|
|
1350
|
+
return res.data;
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1293
1354
|
}
|
package/dist/device_gateway.js
CHANGED
|
@@ -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/active`, 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) {
|
|
@@ -863,10 +888,11 @@ class DeviceGateway extends Object {
|
|
|
863
888
|
/**
|
|
864
889
|
* 获取设备告警统计信息
|
|
865
890
|
* @param factoryId 工厂ID
|
|
891
|
+
* @param faultTypeId 故障类型ID(可选),如果指定则返回该故障类型的统计信息,如果不指定则返回所有故障类型的统计信息
|
|
866
892
|
* @returns Promise 包含告警统计信息的数据
|
|
867
893
|
*/
|
|
868
894
|
getAlarmStats() {
|
|
869
|
-
return __awaiter(this, arguments, void 0, function* (factoryId = undefined) {
|
|
895
|
+
return __awaiter(this, arguments, void 0, function* (factoryId = undefined, faultTypeId = undefined) {
|
|
870
896
|
const axios = yield this.context.ready;
|
|
871
897
|
var _factoryId = factoryId || 0;
|
|
872
898
|
if (!factoryId) {
|
|
@@ -874,7 +900,7 @@ class DeviceGateway extends Object {
|
|
|
874
900
|
_factoryId = (farm === null || farm === void 0 ? void 0 : farm.id) || 0;
|
|
875
901
|
}
|
|
876
902
|
return axios.get(`/api/v2/device/stat/alarms`, {
|
|
877
|
-
params: { factoryId: _factoryId }
|
|
903
|
+
params: { factoryId: _factoryId, category: faultTypeId }
|
|
878
904
|
}).then((res) => {
|
|
879
905
|
if (res.data.code !== 200) {
|
|
880
906
|
throw new Error(res.data.message || '获取设备告警统计信息失败');
|
|
@@ -1041,5 +1067,33 @@ class DeviceGateway extends Object {
|
|
|
1041
1067
|
});
|
|
1042
1068
|
});
|
|
1043
1069
|
}
|
|
1070
|
+
/**
|
|
1071
|
+
* 按工厂ID和故障种类查询最近报警记录
|
|
1072
|
+
* @param factoryId 工厂ID
|
|
1073
|
+
* @param category 故障类型
|
|
1074
|
+
* @param pageNum 页码
|
|
1075
|
+
* @param pageSize 每页数量
|
|
1076
|
+
* @returns Promise 包含报警历史记录数据
|
|
1077
|
+
*/
|
|
1078
|
+
getAlarmHistory(factoryId_1, category_1) {
|
|
1079
|
+
return __awaiter(this, arguments, void 0, function* (factoryId, category, pageNum = 1, pageSize = 5) {
|
|
1080
|
+
const axios = yield this.context.ready;
|
|
1081
|
+
// 参数验证
|
|
1082
|
+
if (!factoryId) {
|
|
1083
|
+
throw new Error('工厂ID不能为空');
|
|
1084
|
+
}
|
|
1085
|
+
if (!category && category !== 0) {
|
|
1086
|
+
throw new Error('故障类型不能为空');
|
|
1087
|
+
}
|
|
1088
|
+
return axios.get(`/api/v2/device/stat/alarms/history`, {
|
|
1089
|
+
params: { factoryId, category, pageNum, pageSize }
|
|
1090
|
+
}).then((res) => {
|
|
1091
|
+
if (res.data.code !== 200) {
|
|
1092
|
+
throw new Error(res.data.message || '获取报警历史记录失败');
|
|
1093
|
+
}
|
|
1094
|
+
return res.data;
|
|
1095
|
+
});
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1044
1098
|
}
|
|
1045
1099
|
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
|
/** 设备类型列表 */
|
|
@@ -671,6 +711,30 @@ interface AlarmRuleDetailResponse {
|
|
|
671
711
|
message: string;
|
|
672
712
|
}
|
|
673
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
|
+
|
|
674
738
|
declare class Cpzxrobot {
|
|
675
739
|
transport: TransportGateway;
|
|
676
740
|
ready: Promise<MyAxiosInstance>;
|
|
@@ -763,10 +827,14 @@ declare module "@cpzxrobot/sdk" {
|
|
|
763
827
|
AlarmStatisticsByTypeResponse,
|
|
764
828
|
AlarmTrendItem,
|
|
765
829
|
AlarmTrendResponse,
|
|
830
|
+
AlarmHistoryItem,
|
|
831
|
+
AlarmHistoryResponse,
|
|
766
832
|
AlarmRuleThresholdConfig,
|
|
767
833
|
AlarmRuleAlarmConfig,
|
|
768
834
|
CreateAlarmRuleRequest,
|
|
769
835
|
CreateAlarmRuleResponse,
|
|
836
|
+
ActiveAlarmRuleRequest,
|
|
837
|
+
ActiveAlarmRuleResponse,
|
|
770
838
|
AlarmRuleDetail,
|
|
771
839
|
AlarmRuleListResponse,
|
|
772
840
|
AlarmRuleDetailResponse,
|