@cpzxrobot/sdk 1.3.70 → 1.3.72
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 +28 -0
- package/dist/device_gateway.js +28 -0
- package/package.json +1 -1
- package/types.d.ts +34 -4
package/device_gateway.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
DeviceV2,
|
|
8
8
|
Factory,
|
|
9
9
|
Supplier,
|
|
10
|
+
DeviceAlarmStatsResponse,
|
|
10
11
|
} from ".";
|
|
11
12
|
|
|
12
13
|
class DeviceFault {
|
|
@@ -75,6 +76,16 @@ export class DeviceGateway extends Object {
|
|
|
75
76
|
filters: Map<string, DeviceFilter<any>>;
|
|
76
77
|
public normalFilter: NormalGateway;
|
|
77
78
|
context: Cpzxrobot;
|
|
79
|
+
public categories = [
|
|
80
|
+
{ id: 0, name: '网关',order: 4 }, //排序时网关优先级不高
|
|
81
|
+
{ id: 1, name: '传感器',order: 1 },
|
|
82
|
+
{ id: 2, name: '执行器',order: 2 },
|
|
83
|
+
{ id: 3, name: 'AI设备',order: 3 },
|
|
84
|
+
{ id: 4, name: '业务数据',order: 5 },
|
|
85
|
+
{ id: 5, name: '设备参数',order: 6 },
|
|
86
|
+
{ id: 8, name: '生产设备',order: 7 },
|
|
87
|
+
{ id: 9, name: '设备部件',order: 8 },
|
|
88
|
+
];
|
|
78
89
|
|
|
79
90
|
get v2() {
|
|
80
91
|
return {
|
|
@@ -975,4 +986,21 @@ export class DeviceGateway extends Object {
|
|
|
975
986
|
}
|
|
976
987
|
}
|
|
977
988
|
|
|
989
|
+
/**
|
|
990
|
+
* 获取设备告警统计信息
|
|
991
|
+
* @param factoryId 工厂ID
|
|
992
|
+
* @returns Promise 包含告警统计信息的数据
|
|
993
|
+
*/
|
|
994
|
+
async getAlarmStats(factoryId: number): Promise<DeviceAlarmStatsResponse> {
|
|
995
|
+
const axios = await this.context.ready;
|
|
996
|
+
return axios.get(`/api/v2/device/stat/alarms`, {
|
|
997
|
+
params: { factoryId }
|
|
998
|
+
}).then((res) => {
|
|
999
|
+
if (res.data.code !== 200) {
|
|
1000
|
+
throw new Error(res.data.message || '获取设备告警统计信息失败');
|
|
1001
|
+
}
|
|
1002
|
+
return res.data;
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
|
|
978
1006
|
}
|
package/dist/device_gateway.js
CHANGED
|
@@ -149,6 +149,16 @@ class DeviceGateway extends Object {
|
|
|
149
149
|
}
|
|
150
150
|
constructor(context) {
|
|
151
151
|
super();
|
|
152
|
+
this.categories = [
|
|
153
|
+
{ id: 0, name: '网关', order: 4 }, //排序时网关优先级不高
|
|
154
|
+
{ id: 1, name: '传感器', order: 1 },
|
|
155
|
+
{ id: 2, name: '执行器', order: 2 },
|
|
156
|
+
{ id: 3, name: 'AI设备', order: 3 },
|
|
157
|
+
{ id: 4, name: '业务数据', order: 5 },
|
|
158
|
+
{ id: 5, name: '设备参数', order: 6 },
|
|
159
|
+
{ id: 8, name: '生产设备', order: 7 },
|
|
160
|
+
{ id: 9, name: '设备部件', order: 8 },
|
|
161
|
+
];
|
|
152
162
|
this.maintenanceLevels = this.generateFunctionsForDict('maintenance-levels');
|
|
153
163
|
this.maintenanceTypes = this.generateFunctionsForDict('maintenance-types');
|
|
154
164
|
this.maintenanceFeedbackTypes = this.generateFunctionsForDict('maintenance-feedback-types');
|
|
@@ -770,5 +780,23 @@ class DeviceGateway extends Object {
|
|
|
770
780
|
})
|
|
771
781
|
};
|
|
772
782
|
}
|
|
783
|
+
/**
|
|
784
|
+
* 获取设备告警统计信息
|
|
785
|
+
* @param factoryId 工厂ID
|
|
786
|
+
* @returns Promise 包含告警统计信息的数据
|
|
787
|
+
*/
|
|
788
|
+
getAlarmStats(factoryId) {
|
|
789
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
790
|
+
const axios = yield this.context.ready;
|
|
791
|
+
return axios.get(`/api/v2/device/stat/alarms`, {
|
|
792
|
+
params: { factoryId }
|
|
793
|
+
}).then((res) => {
|
|
794
|
+
if (res.data.code !== 200) {
|
|
795
|
+
throw new Error(res.data.message || '获取设备告警统计信息失败');
|
|
796
|
+
}
|
|
797
|
+
return res.data;
|
|
798
|
+
});
|
|
799
|
+
});
|
|
800
|
+
}
|
|
773
801
|
}
|
|
774
802
|
exports.DeviceGateway = DeviceGateway;
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -13,8 +13,6 @@ import { ProductGateway } from "@cpzxrobot/sdk/product_gateway";
|
|
|
13
13
|
import { ContractGateway } from "@cpzxrobot/sdk/contract_gateway";
|
|
14
14
|
import { CustomerGateway } from "@cpzxrobot/sdk/customer_gateway";
|
|
15
15
|
import { CompanyGateway } from "@cpzxrobot/sdk/company_gateway";
|
|
16
|
-
import { LogsGateway } from "@cpzxrobot/sdk/logs_gateway";
|
|
17
|
-
import { RobotGateway } from "@cpzxrobot/sdk/robot_gateway";
|
|
18
16
|
import { QuotationGateway } from "./quotation_gateway";
|
|
19
17
|
import { AiGateway } from "./ai_gateway";
|
|
20
18
|
import { EnergyGateway } from "./energy_gateway";
|
|
@@ -23,6 +21,9 @@ import { ConstructionGateway } from "./construction_gateway";
|
|
|
23
21
|
import { SystemGateway } from "./system_gateway";
|
|
24
22
|
import { PlatformInterface } from "./platform_interface";
|
|
25
23
|
import { WarehouseGateway } from "./warehouse_gateway";
|
|
24
|
+
import { ProductionGateway } from "./production_gateway";
|
|
25
|
+
import { SparePartGateway } from "./sparepart_gateway";
|
|
26
|
+
import { PurchaseGateway } from "./purchase_gateway";
|
|
26
27
|
|
|
27
28
|
type Device = {
|
|
28
29
|
id: number;
|
|
@@ -370,6 +371,34 @@ interface DataQueryArgs {
|
|
|
370
371
|
aggerate?: string;
|
|
371
372
|
}
|
|
372
373
|
|
|
374
|
+
/**
|
|
375
|
+
* 设备告警统计数据接口
|
|
376
|
+
*/
|
|
377
|
+
interface DeviceAlarmStats {
|
|
378
|
+
/** 告警总数 */
|
|
379
|
+
alarmAmount: number;
|
|
380
|
+
/** 已解决告警数 */
|
|
381
|
+
alarResolved: number;
|
|
382
|
+
/** 当前告警数 */
|
|
383
|
+
alarming: number;
|
|
384
|
+
/** 平均解决时间(秒) */
|
|
385
|
+
averageResolveTime: number;
|
|
386
|
+
/** 最大解决时间(秒) */
|
|
387
|
+
maxResolveTime: number;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* 设备告警统计响应接口
|
|
392
|
+
*/
|
|
393
|
+
interface DeviceAlarmStatsResponse {
|
|
394
|
+
/** 响应码 */
|
|
395
|
+
code: number;
|
|
396
|
+
/** 告警统计数据 */
|
|
397
|
+
data: DeviceAlarmStats;
|
|
398
|
+
/** 响应消息 */
|
|
399
|
+
message: string;
|
|
400
|
+
}
|
|
401
|
+
|
|
373
402
|
declare class Cpzxrobot {
|
|
374
403
|
transport: TransportGateway;
|
|
375
404
|
ready: Promise<MyAxiosInstance>;
|
|
@@ -381,7 +410,7 @@ declare class Cpzxrobot {
|
|
|
381
410
|
axios: MyAxiosInstance;
|
|
382
411
|
camera: CameraGateway;
|
|
383
412
|
pigfarm: PigfarmGateway;
|
|
384
|
-
chickenfarm:
|
|
413
|
+
chickenfarm: ChickenFarmGateway;;
|
|
385
414
|
car: CarGateway;
|
|
386
415
|
product: ProductGateway;
|
|
387
416
|
project: ProjectGateway;
|
|
@@ -453,7 +482,8 @@ declare module "@cpzxrobot/sdk" {
|
|
|
453
482
|
HeatLamp,
|
|
454
483
|
DeviceV2,
|
|
455
484
|
FieldDatas,
|
|
456
|
-
|
|
485
|
+
DeviceAlarmStats,
|
|
486
|
+
DeviceAlarmStatsResponse,
|
|
457
487
|
ElectricMeterRate,
|
|
458
488
|
DevicePurpose,
|
|
459
489
|
};
|