@cpzxrobot/sdk 1.3.80 → 1.3.82
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 +11 -34
- package/dist/device_gateway.js +2 -24
- package/package.json +1 -1
package/device_gateway.ts
CHANGED
|
@@ -79,14 +79,14 @@ export class DeviceGateway extends Object {
|
|
|
79
79
|
public normalFilter: NormalGateway;
|
|
80
80
|
context: Cpzxrobot;
|
|
81
81
|
public categories = [
|
|
82
|
-
{ id: 0, name: '网关',order: 4 }, //排序时网关优先级不高
|
|
83
|
-
{ id: 1, name: '传感器',order: 1 },
|
|
84
|
-
{ id: 2, name: '执行器',order: 2 },
|
|
85
|
-
{ id: 3, name: 'AI设备',order: 3 },
|
|
86
|
-
{ id: 4, name: '业务数据',order: 5 },
|
|
87
|
-
{ id: 5, name: '设备参数',order: 6 },
|
|
88
|
-
{ id: 8, name: '生产设备',order: 7 },
|
|
89
|
-
{ id: 9, name: '设备部件',order: 8 },
|
|
82
|
+
{ id: 0, name: '网关', order: 4 }, //排序时网关优先级不高
|
|
83
|
+
{ id: 1, name: '传感器', order: 1 },
|
|
84
|
+
{ id: 2, name: '执行器', order: 2 },
|
|
85
|
+
{ id: 3, name: 'AI设备', order: 3 },
|
|
86
|
+
{ id: 4, name: '业务数据', order: 5 },
|
|
87
|
+
{ id: 5, name: '设备参数', order: 6 },
|
|
88
|
+
{ id: 8, name: '生产设备', order: 7 },
|
|
89
|
+
{ id: 9, name: '设备部件', order: 8 },
|
|
90
90
|
];
|
|
91
91
|
|
|
92
92
|
get v2() {
|
|
@@ -1093,10 +1093,10 @@ export class DeviceGateway extends Object {
|
|
|
1093
1093
|
* @returns Promise 包含报警分类统计数据
|
|
1094
1094
|
*/
|
|
1095
1095
|
async getAlarmStatisticsByType(
|
|
1096
|
-
factoryId: number | undefined = undefined,
|
|
1097
|
-
topN?: number,
|
|
1098
1096
|
fromDate?: string,
|
|
1099
|
-
toDate?: string
|
|
1097
|
+
toDate?: string,
|
|
1098
|
+
factoryId?: number,
|
|
1099
|
+
topN?: number
|
|
1100
1100
|
): Promise<AlarmStatisticsByTypeResponse> {
|
|
1101
1101
|
const axios = await this.context.ready;
|
|
1102
1102
|
var _factoryId = factoryId || 0;
|
|
@@ -1112,15 +1112,6 @@ export class DeviceGateway extends Object {
|
|
|
1112
1112
|
if (topN !== undefined && topN <= 0) {
|
|
1113
1113
|
throw new Error('topN参数必须大于0');
|
|
1114
1114
|
}
|
|
1115
|
-
if (fromDate && !this.isValidDateTime(fromDate)) {
|
|
1116
|
-
throw new Error('fromDate参数格式错误,应为YYYY-MM-DD HH:mm:ss格式');
|
|
1117
|
-
}
|
|
1118
|
-
if (toDate && !this.isValidDateTime(toDate)) {
|
|
1119
|
-
throw new Error('toDate参数格式错误,应为YYYY-MM-DD HH:mm:ss格式');
|
|
1120
|
-
}
|
|
1121
|
-
if (fromDate && toDate && fromDate > toDate) {
|
|
1122
|
-
throw new Error('fromDate不能晚于toDate');
|
|
1123
|
-
}
|
|
1124
1115
|
|
|
1125
1116
|
// 构建请求参数
|
|
1126
1117
|
const params: any = { factoryId: _factoryId };
|
|
@@ -1144,19 +1135,5 @@ export class DeviceGateway extends Object {
|
|
|
1144
1135
|
});
|
|
1145
1136
|
}
|
|
1146
1137
|
|
|
1147
|
-
/**
|
|
1148
|
-
* 验证日期时间格式(YYYY-MM-DD HH:mm:ss)
|
|
1149
|
-
* @param dateTime 日期时间字符串
|
|
1150
|
-
* @returns 是否有效
|
|
1151
|
-
*/
|
|
1152
|
-
private isValidDateTime(dateTime: string): boolean {
|
|
1153
|
-
const regex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
|
|
1154
|
-
if (!regex.test(dateTime)) {
|
|
1155
|
-
return false;
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
const date = new Date(dateTime);
|
|
1159
|
-
return !isNaN(date.getTime());
|
|
1160
|
-
}
|
|
1161
1138
|
|
|
1162
1139
|
}
|
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(fromDate, toDate, factoryId, topN) {
|
|
881
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
882
882
|
const axios = yield this.context.ready;
|
|
883
883
|
var _factoryId = factoryId || 0;
|
|
884
884
|
if (!factoryId) {
|
|
@@ -892,15 +892,6 @@ class DeviceGateway extends Object {
|
|
|
892
892
|
if (topN !== undefined && topN <= 0) {
|
|
893
893
|
throw new Error('topN参数必须大于0');
|
|
894
894
|
}
|
|
895
|
-
if (fromDate && !this.isValidDateTime(fromDate)) {
|
|
896
|
-
throw new Error('fromDate参数格式错误,应为YYYY-MM-DD HH:mm:ss格式');
|
|
897
|
-
}
|
|
898
|
-
if (toDate && !this.isValidDateTime(toDate)) {
|
|
899
|
-
throw new Error('toDate参数格式错误,应为YYYY-MM-DD HH:mm:ss格式');
|
|
900
|
-
}
|
|
901
|
-
if (fromDate && toDate && fromDate > toDate) {
|
|
902
|
-
throw new Error('fromDate不能晚于toDate');
|
|
903
|
-
}
|
|
904
895
|
// 构建请求参数
|
|
905
896
|
const params = { factoryId: _factoryId };
|
|
906
897
|
if (topN !== undefined) {
|
|
@@ -922,18 +913,5 @@ class DeviceGateway extends Object {
|
|
|
922
913
|
});
|
|
923
914
|
});
|
|
924
915
|
}
|
|
925
|
-
/**
|
|
926
|
-
* 验证日期时间格式(YYYY-MM-DD HH:mm:ss)
|
|
927
|
-
* @param dateTime 日期时间字符串
|
|
928
|
-
* @returns 是否有效
|
|
929
|
-
*/
|
|
930
|
-
isValidDateTime(dateTime) {
|
|
931
|
-
const regex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
|
|
932
|
-
if (!regex.test(dateTime)) {
|
|
933
|
-
return false;
|
|
934
|
-
}
|
|
935
|
-
const date = new Date(dateTime);
|
|
936
|
-
return !isNaN(date.getTime());
|
|
937
|
-
}
|
|
938
916
|
}
|
|
939
917
|
exports.DeviceGateway = DeviceGateway;
|