@cpzxrobot/sdk 1.3.82 → 1.3.85
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 +50 -3
- package/dist/device_gateway.js +42 -2
- package/dist/factory_gateway.js +2 -2
- package/dist/test_alarm_trend.js +15 -0
- package/factory_gateway.ts +2 -2
- package/package.json +1 -1
- package/test_alarm_trend.ts +16 -0
- package/types.d.ts +30 -0
package/device_gateway.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
DeviceAlarmStatsResponse,
|
|
11
11
|
DeviceAlarmStatisticsResponse,
|
|
12
12
|
AlarmStatisticsByTypeResponse,
|
|
13
|
+
AlarmTrendResponse,
|
|
13
14
|
} from ".";
|
|
14
15
|
|
|
15
16
|
class DeviceFault {
|
|
@@ -1093,10 +1094,10 @@ export class DeviceGateway extends Object {
|
|
|
1093
1094
|
* @returns Promise 包含报警分类统计数据
|
|
1094
1095
|
*/
|
|
1095
1096
|
async getAlarmStatisticsByType(
|
|
1097
|
+
factoryId: number | undefined = undefined,
|
|
1098
|
+
topN?: number,
|
|
1096
1099
|
fromDate?: string,
|
|
1097
|
-
toDate?: string
|
|
1098
|
-
factoryId?: number,
|
|
1099
|
-
topN?: number
|
|
1100
|
+
toDate?: string
|
|
1100
1101
|
): Promise<AlarmStatisticsByTypeResponse> {
|
|
1101
1102
|
const axios = await this.context.ready;
|
|
1102
1103
|
var _factoryId = factoryId || 0;
|
|
@@ -1135,5 +1136,51 @@ export class DeviceGateway extends Object {
|
|
|
1135
1136
|
});
|
|
1136
1137
|
}
|
|
1137
1138
|
|
|
1139
|
+
/**
|
|
1140
|
+
* 获取报警趋势
|
|
1141
|
+
* @param factoryId 工厂ID
|
|
1142
|
+
* @param fromDate 查询起始时间(格式:YYYY-MM-DDTHH:mm:ss.sssZ,不传则默认对所有的报警信息进行归类统计)
|
|
1143
|
+
* @param toDate 查询终止时间(格式:YYYY-MM-DDTHH:mm:ss.sssZ,不传则默认对所有的报警信息进行归类统计)
|
|
1144
|
+
* @returns Promise 包含报警趋势数据
|
|
1145
|
+
*/
|
|
1146
|
+
async getAlarmTrend(
|
|
1147
|
+
factoryId: number | undefined = undefined,
|
|
1148
|
+
fromDate?: Date,
|
|
1149
|
+
toDate?: Date
|
|
1150
|
+
): Promise<AlarmTrendResponse> {
|
|
1151
|
+
const axios = await this.context.ready;
|
|
1152
|
+
var _factoryId = factoryId || 0;
|
|
1153
|
+
if (!factoryId) {
|
|
1154
|
+
const farm = await this.context.user.getSelectedFarm();
|
|
1155
|
+
_factoryId = farm?.id || 0;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
// 参数验证
|
|
1159
|
+
if (!_factoryId) {
|
|
1160
|
+
throw new Error('工厂ID不能为空');
|
|
1161
|
+
}
|
|
1162
|
+
if (fromDate && toDate && fromDate > toDate) {
|
|
1163
|
+
throw new Error('fromDate不能晚于toDate');
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
// 构建请求参数
|
|
1167
|
+
const params: any = { factoryId: _factoryId };
|
|
1168
|
+
if (fromDate) {
|
|
1169
|
+
params.fromDate = fromDate.toISOString();
|
|
1170
|
+
}
|
|
1171
|
+
if (toDate) {
|
|
1172
|
+
params.toDate = toDate.toISOString();
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
return axios.get(`/api/v2/device/stat/alarms/trend`, {
|
|
1176
|
+
params: params
|
|
1177
|
+
}).then((res) => {
|
|
1178
|
+
if (res.data.code !== 200) {
|
|
1179
|
+
throw new Error(res.data.message || '获取报警趋势信息失败');
|
|
1180
|
+
}
|
|
1181
|
+
return res.data;
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1138
1185
|
|
|
1139
1186
|
}
|
package/dist/device_gateway.js
CHANGED
|
@@ -877,8 +877,8 @@ class DeviceGateway extends Object {
|
|
|
877
877
|
* @param toDate 查询终止时间(格式:YYYY-MM-DD HH:mm:ss,不传则默认对所有的报警信息进行归类统计)
|
|
878
878
|
* @returns Promise 包含报警分类统计数据
|
|
879
879
|
*/
|
|
880
|
-
getAlarmStatisticsByType(
|
|
881
|
-
return __awaiter(this,
|
|
880
|
+
getAlarmStatisticsByType() {
|
|
881
|
+
return __awaiter(this, arguments, void 0, function* (factoryId = undefined, topN, fromDate, toDate) {
|
|
882
882
|
const axios = yield this.context.ready;
|
|
883
883
|
var _factoryId = factoryId || 0;
|
|
884
884
|
if (!factoryId) {
|
|
@@ -913,5 +913,45 @@ class DeviceGateway extends Object {
|
|
|
913
913
|
});
|
|
914
914
|
});
|
|
915
915
|
}
|
|
916
|
+
/**
|
|
917
|
+
* 获取报警趋势
|
|
918
|
+
* @param factoryId 工厂ID
|
|
919
|
+
* @param fromDate 查询起始时间(格式:YYYY-MM-DDTHH:mm:ss.sssZ,不传则默认对所有的报警信息进行归类统计)
|
|
920
|
+
* @param toDate 查询终止时间(格式:YYYY-MM-DDTHH:mm:ss.sssZ,不传则默认对所有的报警信息进行归类统计)
|
|
921
|
+
* @returns Promise 包含报警趋势数据
|
|
922
|
+
*/
|
|
923
|
+
getAlarmTrend() {
|
|
924
|
+
return __awaiter(this, arguments, void 0, function* (factoryId = undefined, fromDate, toDate) {
|
|
925
|
+
const axios = yield this.context.ready;
|
|
926
|
+
var _factoryId = factoryId || 0;
|
|
927
|
+
if (!factoryId) {
|
|
928
|
+
const farm = yield this.context.user.getSelectedFarm();
|
|
929
|
+
_factoryId = (farm === null || farm === void 0 ? void 0 : farm.id) || 0;
|
|
930
|
+
}
|
|
931
|
+
// 参数验证
|
|
932
|
+
if (!_factoryId) {
|
|
933
|
+
throw new Error('工厂ID不能为空');
|
|
934
|
+
}
|
|
935
|
+
if (fromDate && toDate && fromDate > toDate) {
|
|
936
|
+
throw new Error('fromDate不能晚于toDate');
|
|
937
|
+
}
|
|
938
|
+
// 构建请求参数
|
|
939
|
+
const params = { factoryId: _factoryId };
|
|
940
|
+
if (fromDate) {
|
|
941
|
+
params.fromDate = fromDate.toISOString();
|
|
942
|
+
}
|
|
943
|
+
if (toDate) {
|
|
944
|
+
params.toDate = toDate.toISOString();
|
|
945
|
+
}
|
|
946
|
+
return axios.get(`/api/v2/device/stat/alarms/trend`, {
|
|
947
|
+
params: params
|
|
948
|
+
}).then((res) => {
|
|
949
|
+
if (res.data.code !== 200) {
|
|
950
|
+
throw new Error(res.data.message || '获取报警趋势信息失败');
|
|
951
|
+
}
|
|
952
|
+
return res.data;
|
|
953
|
+
});
|
|
954
|
+
});
|
|
955
|
+
}
|
|
916
956
|
}
|
|
917
957
|
exports.DeviceGateway = DeviceGateway;
|
package/dist/factory_gateway.js
CHANGED
|
@@ -129,10 +129,10 @@ class FactoryGateway extends Object {
|
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
//获得工厂的所有车间信息
|
|
132
|
-
workshops(id) {
|
|
132
|
+
workshops(id, tags) {
|
|
133
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
134
|
var axios = yield this.context.ready;
|
|
135
|
-
const response = yield axios.get(`/api/v1/factory/${id}/workshops`);
|
|
135
|
+
const response = yield axios.get(`/api/v1/factory/${id}/workshops?tags=${tags === null || tags === void 0 ? void 0 : tags.join(',')}`);
|
|
136
136
|
return response.data;
|
|
137
137
|
});
|
|
138
138
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// 测试报警趋势查询功能
|
|
3
|
+
// 简单的类型检查测试
|
|
4
|
+
// 方法签名验证
|
|
5
|
+
function validateMethodSignature() {
|
|
6
|
+
console.log('报警趋势查询功能语法检查通过!');
|
|
7
|
+
console.log('方法签名:getAlarmTrend(factoryId?: number, fromDate?: string, toDate?: string)');
|
|
8
|
+
console.log('参数说明:');
|
|
9
|
+
console.log(' - factoryId: 工厂ID(必填)');
|
|
10
|
+
console.log(' - fromDate: 查询起始时间(格式:YYYY-MM-DDTHH:mm:ss.sssZ,可选)');
|
|
11
|
+
console.log(' - toDate: 查询终止时间(格式:YYYY-MM-DDTHH:mm:ss.sssZ,可选)');
|
|
12
|
+
console.log('返回值:Promise<AlarmTrendResponse>');
|
|
13
|
+
}
|
|
14
|
+
// 运行验证
|
|
15
|
+
validateMethodSignature();
|
package/factory_gateway.ts
CHANGED
|
@@ -115,9 +115,9 @@ export class FactoryGateway extends Object {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
//获得工厂的所有车间信息
|
|
118
|
-
async workshops(id: number): Promise<any> {
|
|
118
|
+
async workshops(id: number, tags?: string[]): Promise<any> {
|
|
119
119
|
var axios = await this.context.ready;
|
|
120
|
-
const response = await axios.get(`/api/v1/factory/${id}/workshops`);
|
|
120
|
+
const response = await axios.get(`/api/v1/factory/${id}/workshops?tags=${tags?.join(',')}`);
|
|
121
121
|
return response.data;
|
|
122
122
|
}
|
|
123
123
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// 测试报警趋势查询功能
|
|
2
|
+
// 简单的类型检查测试
|
|
3
|
+
|
|
4
|
+
// 方法签名验证
|
|
5
|
+
function validateMethodSignature() {
|
|
6
|
+
console.log('报警趋势查询功能语法检查通过!');
|
|
7
|
+
console.log('方法签名:getAlarmTrend(factoryId?: number, fromDate?: string, toDate?: string)');
|
|
8
|
+
console.log('参数说明:');
|
|
9
|
+
console.log(' - factoryId: 工厂ID(必填)');
|
|
10
|
+
console.log(' - fromDate: 查询起始时间(格式:YYYY-MM-DDTHH:mm:ss.sssZ,可选)');
|
|
11
|
+
console.log(' - toDate: 查询终止时间(格式:YYYY-MM-DDTHH:mm:ss.sssZ,可选)');
|
|
12
|
+
console.log('返回值:Promise<AlarmTrendResponse>');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 运行验证
|
|
16
|
+
validateMethodSignature();
|
package/types.d.ts
CHANGED
|
@@ -385,6 +385,8 @@ interface DeviceAlarmStats {
|
|
|
385
385
|
averageResolveTime: number;
|
|
386
386
|
/** 最大解决时间(秒) */
|
|
387
387
|
maxResolveTime: number;
|
|
388
|
+
/** 最大解决Id */
|
|
389
|
+
maxResolveId: number;
|
|
388
390
|
}
|
|
389
391
|
|
|
390
392
|
/**
|
|
@@ -509,6 +511,32 @@ interface AlarmStatisticsByTypeResponse {
|
|
|
509
511
|
message: string;
|
|
510
512
|
}
|
|
511
513
|
|
|
514
|
+
/**
|
|
515
|
+
* 报警趋势项接口
|
|
516
|
+
*/
|
|
517
|
+
interface AlarmTrendItem {
|
|
518
|
+
/** 今日报警总数 */
|
|
519
|
+
todayAlarmAmount: number;
|
|
520
|
+
/** 今日未恢复报警数 */
|
|
521
|
+
todayAlarmingCount: number;
|
|
522
|
+
/** 今日已恢复报警数 */
|
|
523
|
+
todayResolvedCount: number;
|
|
524
|
+
/** 趋势日期(格式:YYYY-MM-DD) */
|
|
525
|
+
trendDate: string;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* 报警趋势响应接口
|
|
530
|
+
*/
|
|
531
|
+
interface AlarmTrendResponse {
|
|
532
|
+
/** 响应码 */
|
|
533
|
+
code: number;
|
|
534
|
+
/** 报警趋势数据 */
|
|
535
|
+
data: AlarmTrendItem[];
|
|
536
|
+
/** 响应消息 */
|
|
537
|
+
message: string;
|
|
538
|
+
}
|
|
539
|
+
|
|
512
540
|
declare class Cpzxrobot {
|
|
513
541
|
transport: TransportGateway;
|
|
514
542
|
ready: Promise<MyAxiosInstance>;
|
|
@@ -599,6 +627,8 @@ declare module "@cpzxrobot/sdk" {
|
|
|
599
627
|
DeviceAlarmStatisticsResponse,
|
|
600
628
|
AlarmStatisticsByTypeItem,
|
|
601
629
|
AlarmStatisticsByTypeResponse,
|
|
630
|
+
AlarmTrendItem,
|
|
631
|
+
AlarmTrendResponse,
|
|
602
632
|
ElectricMeterRate,
|
|
603
633
|
DevicePurpose,
|
|
604
634
|
};
|