@cpzxrobot/sdk 1.3.68 → 1.3.70
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/company_gateway.ts +16 -0
- package/device_filter.ts +4 -4
- package/device_gateway.ts +2 -2
- package/device_types/feedtower.ts +5 -5
- package/dist/camera_gateway.js +61 -42
- package/dist/car_gateway.js +54 -31
- package/dist/chickenfarm_gateway.js +11 -2
- package/dist/company_gateway.js +130 -90
- package/dist/device_gateway.js +200 -181
- package/dist/device_types/feedtower.js +130 -101
- package/dist/energy_gateway.js +33 -20
- package/dist/factory_gateway.js +129 -90
- package/dist/index.js +1 -1
- package/dist/mobile_platform.js +70 -43
- package/dist/pigfarm_gateway.js +51 -42
- package/dist/production_gateway.js +31 -18
- package/dist/project_gateway.js +12 -3
- package/dist/purchase_gateway.js +73 -38
- package/dist/sensor_datas.js +23 -11
- package/dist/sparepart_gateway.js +27 -18
- package/dist/test_strict.js +18 -0
- package/dist/user_gateway.js +131 -100
- package/dist/warehouse_gateway.js +34 -15
- package/dist/web_platform.js +213 -194
- package/dist/windows_platform.js +15 -5
- package/factory_gateway.ts +2 -2
- package/index.ts +3 -3
- package/mobile_platform.ts +3 -3
- package/news_gateway.ts +1 -1
- package/package.json +1 -1
- package/sensor_datas.ts +27 -16
- package/test_strict.ts +22 -0
- package/tsconfig.json +19 -19
- package/types.d.ts +13 -49
- package/web_platform.ts +15 -15
- package/windows_platform.ts +3 -3
package/dist/device_gateway.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.DeviceGateway = void 0;
|
|
4
13
|
const device_type_gateway_1 = require("./device_type_gateway");
|
|
@@ -53,26 +62,26 @@ const normal_type_1 = require("./device_types/normal_type");
|
|
|
53
62
|
class DeviceGateway extends Object {
|
|
54
63
|
get v2() {
|
|
55
64
|
return {
|
|
56
|
-
update:
|
|
57
|
-
let axios =
|
|
65
|
+
update: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
let axios = yield this.context.ready;
|
|
58
67
|
return axios.post(`/api/v2/device/update`, data).then((res) => {
|
|
59
68
|
return res.data;
|
|
60
69
|
});
|
|
61
|
-
},
|
|
62
|
-
add:
|
|
63
|
-
let axios =
|
|
70
|
+
}),
|
|
71
|
+
add: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
let axios = yield this.context.ready;
|
|
64
73
|
return axios.post(`/api/v2/device/add`, data).then((res) => {
|
|
65
74
|
return res.data;
|
|
66
75
|
});
|
|
67
|
-
},
|
|
68
|
-
delete:
|
|
69
|
-
let axios =
|
|
76
|
+
}),
|
|
77
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
let axios = yield this.context.ready;
|
|
70
79
|
return axios.post(`/api/v2/device/delete?id=${id}`).then((res) => {
|
|
71
80
|
return res.data;
|
|
72
81
|
});
|
|
73
|
-
},
|
|
74
|
-
list:
|
|
75
|
-
let axios =
|
|
82
|
+
}),
|
|
83
|
+
list: (condition_1, ...args_1) => __awaiter(this, [condition_1, ...args_1], void 0, function* (condition, params = undefined) {
|
|
84
|
+
let axios = yield this.context.ready;
|
|
76
85
|
var url = `/api/v2/device/list`;
|
|
77
86
|
if (params) {
|
|
78
87
|
//if params is string
|
|
@@ -89,53 +98,53 @@ class DeviceGateway extends Object {
|
|
|
89
98
|
return axios.post(url, condition).then((res) => {
|
|
90
99
|
return res.data;
|
|
91
100
|
});
|
|
92
|
-
},
|
|
93
|
-
preview:
|
|
94
|
-
let axios =
|
|
101
|
+
}),
|
|
102
|
+
preview: (type, sn) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
let axios = yield this.context.ready;
|
|
95
104
|
return axios.get(`/api/v2/device/iotValue/${type}/${sn}`).then((res) => {
|
|
96
105
|
return res.data;
|
|
97
106
|
});
|
|
98
|
-
},
|
|
107
|
+
}),
|
|
99
108
|
};
|
|
100
109
|
}
|
|
101
110
|
get thresholdConfig() {
|
|
102
111
|
return {
|
|
103
|
-
list:
|
|
104
|
-
let axios =
|
|
112
|
+
list: (factory) => __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
let axios = yield this.context.ready;
|
|
105
114
|
return axios.get(`/api/v2/threshold/config`, {
|
|
106
115
|
params: {
|
|
107
116
|
factoryId: factory === null || factory === void 0 ? void 0 : factory.id
|
|
108
117
|
},
|
|
109
118
|
});
|
|
110
|
-
},
|
|
119
|
+
}),
|
|
111
120
|
//新增或更新阈值配置,用于基础信息的更新或新增
|
|
112
|
-
post:
|
|
113
|
-
let axios =
|
|
121
|
+
post: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
let axios = yield this.context.ready;
|
|
114
123
|
return axios.post(`/api/v2/threshold/config`, data);
|
|
115
|
-
},
|
|
124
|
+
}),
|
|
116
125
|
//向阈值配置中新增一条规则
|
|
117
|
-
addRule:
|
|
118
|
-
let axios =
|
|
126
|
+
addRule: (configId, data) => __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
let axios = yield this.context.ready;
|
|
119
128
|
return axios.post(`/api/v2/threshold`, Object.assign(Object.assign({}, data), { configId: configId }));
|
|
120
|
-
},
|
|
129
|
+
}),
|
|
121
130
|
//删除阈值配置
|
|
122
|
-
deleteRule:
|
|
123
|
-
let axios =
|
|
131
|
+
deleteRule: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
let axios = yield this.context.ready;
|
|
124
133
|
return axios.post(`/api/v2/threshold/delete`, {
|
|
125
134
|
id: id,
|
|
126
135
|
});
|
|
127
|
-
},
|
|
136
|
+
}),
|
|
128
137
|
//读取阈值配置,包括阈值规则列表
|
|
129
|
-
get:
|
|
130
|
-
let axios =
|
|
138
|
+
get: (configId) => __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
let axios = yield this.context.ready;
|
|
131
140
|
return axios.get(`/api/v2/threshold/config/${configId}`);
|
|
132
|
-
},
|
|
133
|
-
delete:
|
|
134
|
-
let axios =
|
|
141
|
+
}),
|
|
142
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
let axios = yield this.context.ready;
|
|
135
144
|
return axios.post(`/api/v2/threshold/config/delete`, {
|
|
136
145
|
id: id
|
|
137
146
|
});
|
|
138
|
-
},
|
|
147
|
+
}),
|
|
139
148
|
};
|
|
140
149
|
}
|
|
141
150
|
constructor(context) {
|
|
@@ -173,19 +182,21 @@ class DeviceGateway extends Object {
|
|
|
173
182
|
show(id, type = "datapoint") {
|
|
174
183
|
this.context.platform.showInDeviceManager(id, type);
|
|
175
184
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
watch(ids_1, fn_1) {
|
|
186
|
+
return __awaiter(this, arguments, void 0, function* (ids, fn, showLast = true) {
|
|
187
|
+
var axios = yield this.context.ready;
|
|
188
|
+
var idQuery = "";
|
|
189
|
+
if (Array.isArray(ids)) {
|
|
190
|
+
idQuery = ids.map(x => `ids=${x}`).join("&");
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
idQuery = `ids=${ids}`;
|
|
194
|
+
}
|
|
195
|
+
if (showLast) {
|
|
196
|
+
idQuery += "&show-last=true";
|
|
197
|
+
}
|
|
198
|
+
return axios.getAsSse(`/api/v1/device/watch?` + idQuery, fn);
|
|
199
|
+
});
|
|
189
200
|
}
|
|
190
201
|
getFilter(type, cls) {
|
|
191
202
|
// 如果filters中已经有对应type的过滤器,则直接返回该过滤器
|
|
@@ -226,61 +237,69 @@ class DeviceGateway extends Object {
|
|
|
226
237
|
}) {
|
|
227
238
|
return this.normalFilter.getData(id, args);
|
|
228
239
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
240
|
+
info(id) {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
let axios = yield this.context.ready;
|
|
243
|
+
return axios.get(`/api/v1/device/info/${id}`);
|
|
244
|
+
});
|
|
232
245
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
246
|
+
validate(serialNumbers_1) {
|
|
247
|
+
return __awaiter(this, arguments, void 0, function* (serialNumbers, type = "pywl") {
|
|
248
|
+
let axios = yield this.context.ready;
|
|
249
|
+
return axios.post(`/api/v2/device/validateSerialNumber`, {
|
|
250
|
+
serialNumbers,
|
|
251
|
+
type,
|
|
252
|
+
});
|
|
238
253
|
});
|
|
239
254
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
255
|
+
batchValidate(serialNumbers_1) {
|
|
256
|
+
return __awaiter(this, arguments, void 0, function* (serialNumbers, type = "pywl") {
|
|
257
|
+
let axios = yield this.context.ready;
|
|
258
|
+
return axios.upload(`/api/v2/device/batchValidate`, {
|
|
259
|
+
serialNumbers,
|
|
260
|
+
type,
|
|
261
|
+
});
|
|
245
262
|
});
|
|
246
263
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
var
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
else if (arr[i] != "") {
|
|
274
|
-
if (inAnnotation) {
|
|
275
|
-
inAnnotation = false;
|
|
276
|
-
columns = values;
|
|
264
|
+
faults(deviceId, startTime, endTime) {
|
|
265
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
+
let axios = yield this.context.ready;
|
|
267
|
+
const startTimeRfc3339 = startTime.toISOString();
|
|
268
|
+
const endTimeRfc3339 = endTime.toISOString();
|
|
269
|
+
const response = yield axios.get(`/api/v1/device/${deviceId}/faults?start=${startTimeRfc3339}&stop=${endTimeRfc3339}`);
|
|
270
|
+
const json = response.data;
|
|
271
|
+
var faultsData = json.faults;
|
|
272
|
+
// #group,false,false,true,true,false,false,true,true,true,true,true,true
|
|
273
|
+
// #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,boolean,string,string,string,string,string,string
|
|
274
|
+
// #default,last,,,,,,,,,,,
|
|
275
|
+
// ,result,table,_start,_stop,_time,_value,DeviceId,_field,_measurement,category,field,status
|
|
276
|
+
// ,,0,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:27:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,bool_value,DeviceStatus,离线报警,online,fault
|
|
277
|
+
// ,,0,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:30:00Z,true,004a05c1-7b5b-471c-ab68-f583039ddcfe,bool_value,DeviceStatus,离线报警,online,fault
|
|
278
|
+
// ,,1,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:27:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,repeated,DeviceStatus,离线报警,online,fault
|
|
279
|
+
// ,,1,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:30:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,repeated,DeviceStatus,离线报警,online,fault
|
|
280
|
+
// ,,2,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:27:00Z,false,004a05c1-7b5b-471c-ab68-f583039ddcfe,resolved,DeviceStatus,离线报警,online,fault
|
|
281
|
+
// ,,2,2025-04-20T22:07:43.623582865Z,2025-04-21T04:07:43.623582865Z,2025-04-21T00:30:00Z,true,004a05c1-7b5b-471c-ab68-f583039ddcfe,resolved,DeviceStatus,离线报警,online,fault
|
|
282
|
+
faultsData = faultsData.replace(/\r/g, "");
|
|
283
|
+
var arr = faultsData.split("\n");
|
|
284
|
+
var inAnnotation = false;
|
|
285
|
+
var columns = [];
|
|
286
|
+
var faults = [];
|
|
287
|
+
for (var i = 0; i < arr.length; i++) {
|
|
288
|
+
var values = arr[i].split(",");
|
|
289
|
+
if (arr[i].startsWith("#")) {
|
|
277
290
|
}
|
|
278
|
-
else {
|
|
279
|
-
|
|
291
|
+
else if (arr[i] != "") {
|
|
292
|
+
if (inAnnotation) {
|
|
293
|
+
inAnnotation = false;
|
|
294
|
+
columns = values;
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
faults.push(new DeviceFault(values, columns));
|
|
298
|
+
}
|
|
280
299
|
}
|
|
281
300
|
}
|
|
282
|
-
|
|
283
|
-
|
|
301
|
+
return faults;
|
|
302
|
+
});
|
|
284
303
|
}
|
|
285
304
|
// 报告设备问题
|
|
286
305
|
report(id, status, description) {
|
|
@@ -405,9 +424,9 @@ class DeviceGateway extends Object {
|
|
|
405
424
|
//v1的设备实际是点位,v3的设备才是真正的设备
|
|
406
425
|
return {
|
|
407
426
|
list: (args = {}) => {
|
|
408
|
-
return this.context.ready.then(
|
|
427
|
+
return this.context.ready.then(() => __awaiter(this, void 0, void 0, function* () {
|
|
409
428
|
if (args.factoryId == undefined) {
|
|
410
|
-
var farm =
|
|
429
|
+
var farm = yield this.context.user.getSelectedFarm();
|
|
411
430
|
args.factoryId = farm.id;
|
|
412
431
|
}
|
|
413
432
|
return this.context.axios.get(`/api/v3/device/list`, {
|
|
@@ -417,7 +436,7 @@ class DeviceGateway extends Object {
|
|
|
417
436
|
factory_id: args.factoryId
|
|
418
437
|
}
|
|
419
438
|
});
|
|
420
|
-
});
|
|
439
|
+
}));
|
|
421
440
|
},
|
|
422
441
|
detail: (id) => {
|
|
423
442
|
return this.context.ready.then(() => {
|
|
@@ -537,18 +556,18 @@ class DeviceGateway extends Object {
|
|
|
537
556
|
}
|
|
538
557
|
get trouble() {
|
|
539
558
|
return {
|
|
540
|
-
list:
|
|
559
|
+
list: (...args_1) => __awaiter(this, [...args_1], void 0, function* (args = {
|
|
541
560
|
sourceType: "device",
|
|
542
561
|
pageNum: 1,
|
|
543
562
|
pageSize: 10,
|
|
544
|
-
})
|
|
545
|
-
const axios =
|
|
563
|
+
}) {
|
|
564
|
+
const axios = yield this.context.ready;
|
|
546
565
|
return axios.get('/api/v3/device/trouble/list', {
|
|
547
566
|
params: args
|
|
548
567
|
});
|
|
549
|
-
},
|
|
550
|
-
create:
|
|
551
|
-
const axios =
|
|
568
|
+
}),
|
|
569
|
+
create: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
570
|
+
const axios = yield this.context.ready;
|
|
552
571
|
return axios.post('/api/v3/device/trouble/create', data)
|
|
553
572
|
.then((res) => {
|
|
554
573
|
if (res.data.code !== 200) {
|
|
@@ -556,9 +575,9 @@ class DeviceGateway extends Object {
|
|
|
556
575
|
}
|
|
557
576
|
return res.data;
|
|
558
577
|
});
|
|
559
|
-
},
|
|
560
|
-
history:
|
|
561
|
-
const axios =
|
|
578
|
+
}),
|
|
579
|
+
history: (troubleId) => __awaiter(this, void 0, void 0, function* () {
|
|
580
|
+
const axios = yield this.context.ready;
|
|
562
581
|
return axios.get(`/api/v3/device/trouble/${troubleId}/handle-records`)
|
|
563
582
|
.then((res) => {
|
|
564
583
|
if (res.data.code !== 200) {
|
|
@@ -566,9 +585,9 @@ class DeviceGateway extends Object {
|
|
|
566
585
|
}
|
|
567
586
|
return res.data;
|
|
568
587
|
});
|
|
569
|
-
},
|
|
570
|
-
delete:
|
|
571
|
-
const axios =
|
|
588
|
+
}),
|
|
589
|
+
delete: (troubleIds) => __awaiter(this, void 0, void 0, function* () {
|
|
590
|
+
const axios = yield this.context.ready;
|
|
572
591
|
return axios.delete('/api/v3/device/trouble/delete', troubleIds)
|
|
573
592
|
.then((res) => {
|
|
574
593
|
if (res.data.code !== 200) {
|
|
@@ -576,112 +595,112 @@ class DeviceGateway extends Object {
|
|
|
576
595
|
}
|
|
577
596
|
return res.data;
|
|
578
597
|
});
|
|
579
|
-
},
|
|
598
|
+
}),
|
|
580
599
|
};
|
|
581
600
|
}
|
|
582
601
|
get troubleType() {
|
|
583
602
|
return {
|
|
584
603
|
// 获取根节点(原list方法)
|
|
585
|
-
list:
|
|
586
|
-
var axios =
|
|
604
|
+
list: () => __awaiter(this, void 0, void 0, function* () {
|
|
605
|
+
var axios = yield this.context.ready;
|
|
587
606
|
return axios.get('/api/v3/device/trouble-type');
|
|
588
|
-
},
|
|
607
|
+
}),
|
|
589
608
|
// 获取直接子节点
|
|
590
|
-
getDirectChildren:
|
|
591
|
-
var axios =
|
|
609
|
+
getDirectChildren: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
610
|
+
var axios = yield this.context.ready;
|
|
592
611
|
return axios.get(`/api/v3/device/trouble-type/${id}`);
|
|
593
|
-
},
|
|
612
|
+
}),
|
|
594
613
|
// 获取所有子节点
|
|
595
|
-
getAllChildren:
|
|
596
|
-
var axios =
|
|
614
|
+
getAllChildren: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
615
|
+
var axios = yield this.context.ready;
|
|
597
616
|
return axios.get(`/api/v3/device/trouble-type/${id}/all`);
|
|
598
|
-
},
|
|
617
|
+
}),
|
|
599
618
|
// 获取完整树结构
|
|
600
|
-
getTree:
|
|
601
|
-
var axios =
|
|
619
|
+
getTree: () => __awaiter(this, void 0, void 0, function* () {
|
|
620
|
+
var axios = yield this.context.ready;
|
|
602
621
|
return axios.get('/api/v3/device/trouble-type/tree');
|
|
603
|
-
},
|
|
622
|
+
}),
|
|
604
623
|
// 创建节点
|
|
605
|
-
create:
|
|
606
|
-
var axios =
|
|
624
|
+
create: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
625
|
+
var axios = yield this.context.ready;
|
|
607
626
|
return axios.post('/api/v3/device/trouble-type', data);
|
|
608
|
-
},
|
|
627
|
+
}),
|
|
609
628
|
// 删除节点(根据Java控制器的DeleteMapping)
|
|
610
|
-
delete:
|
|
611
|
-
var axios =
|
|
629
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
630
|
+
var axios = yield this.context.ready;
|
|
612
631
|
return axios.delete(`/api/v3/device/trouble-type/${id}`);
|
|
613
|
-
}
|
|
632
|
+
})
|
|
614
633
|
};
|
|
615
634
|
}
|
|
616
635
|
get model() {
|
|
617
636
|
return {
|
|
618
|
-
list:
|
|
619
|
-
var axios =
|
|
637
|
+
list: (manufacturerId) => __awaiter(this, void 0, void 0, function* () {
|
|
638
|
+
var axios = yield this.context.ready;
|
|
620
639
|
if (manufacturerId === undefined) {
|
|
621
640
|
return axios.get('/api/v3/device/model');
|
|
622
641
|
}
|
|
623
642
|
else {
|
|
624
643
|
return axios.get(`/api/v3/device/manufacturer/${manufacturerId}/models`);
|
|
625
644
|
}
|
|
626
|
-
},
|
|
627
|
-
create:
|
|
628
|
-
var axios =
|
|
645
|
+
}),
|
|
646
|
+
create: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
647
|
+
var axios = yield this.context.ready;
|
|
629
648
|
return axios.post('/api/v3/device/model', data);
|
|
630
|
-
},
|
|
631
|
-
update:
|
|
632
|
-
var axios =
|
|
649
|
+
}),
|
|
650
|
+
update: (id, data) => __awaiter(this, void 0, void 0, function* () {
|
|
651
|
+
var axios = yield this.context.ready;
|
|
633
652
|
return axios.put(`/api/v3/device/model/${id}`, data);
|
|
634
|
-
},
|
|
635
|
-
delete:
|
|
636
|
-
var axios =
|
|
653
|
+
}),
|
|
654
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
655
|
+
var axios = yield this.context.ready;
|
|
637
656
|
return axios.delete(`/api/v3/device/model/${id}`);
|
|
638
|
-
},
|
|
639
|
-
detail:
|
|
640
|
-
var axios =
|
|
657
|
+
}),
|
|
658
|
+
detail: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
659
|
+
var axios = yield this.context.ready;
|
|
641
660
|
return axios.get(`/api/v3/device/model/${id}`);
|
|
642
|
-
}
|
|
661
|
+
})
|
|
643
662
|
};
|
|
644
663
|
}
|
|
645
664
|
get maintenanceGroup() {
|
|
646
665
|
return {
|
|
647
666
|
// 获取维护组列表
|
|
648
|
-
list:
|
|
649
|
-
const axios =
|
|
667
|
+
list: (factoryId) => __awaiter(this, void 0, void 0, function* () {
|
|
668
|
+
const axios = yield this.context.ready;
|
|
650
669
|
return axios.get('/api/v3/device/maintenance-groups', {
|
|
651
670
|
params: { factoryId }
|
|
652
671
|
});
|
|
653
|
-
},
|
|
672
|
+
}),
|
|
654
673
|
// 创建维护组
|
|
655
|
-
create:
|
|
656
|
-
const axios =
|
|
674
|
+
create: (factoryId, group) => __awaiter(this, void 0, void 0, function* () {
|
|
675
|
+
const axios = yield this.context.ready;
|
|
657
676
|
return axios.post(`/api/v3/device/maintenance-groups?factoryId=${factoryId}`, group);
|
|
658
|
-
},
|
|
677
|
+
}),
|
|
659
678
|
// 删除维护组
|
|
660
|
-
delete:
|
|
661
|
-
const axios =
|
|
679
|
+
delete: (factoryId, groupId) => __awaiter(this, void 0, void 0, function* () {
|
|
680
|
+
const axios = yield this.context.ready;
|
|
662
681
|
return axios.delete(`/api/v3/device/maintenance-groups/${groupId}`, {
|
|
663
682
|
params: { factoryId }
|
|
664
683
|
});
|
|
665
|
-
},
|
|
684
|
+
}),
|
|
666
685
|
};
|
|
667
686
|
}
|
|
668
687
|
generateFunctionsForDict(dictName) {
|
|
669
688
|
return {
|
|
670
689
|
// 获取维护类型列表
|
|
671
|
-
list:
|
|
672
|
-
const axios =
|
|
690
|
+
list: (factoryId) => __awaiter(this, void 0, void 0, function* () {
|
|
691
|
+
const axios = yield this.context.ready;
|
|
673
692
|
return axios.get(`/api/v3/device/${dictName}`, {
|
|
674
693
|
params: { factoryId }
|
|
675
694
|
});
|
|
676
|
-
},
|
|
677
|
-
create:
|
|
678
|
-
var axios =
|
|
695
|
+
}),
|
|
696
|
+
create: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
697
|
+
var axios = yield this.context.ready;
|
|
679
698
|
return axios.post(`/api/v3/device/${dictName}`, data);
|
|
680
|
-
},
|
|
681
|
-
delete:
|
|
682
|
-
var axios =
|
|
699
|
+
}),
|
|
700
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
701
|
+
var axios = yield this.context.ready;
|
|
683
702
|
return axios.delete(`/api/v3/device/${dictName}/${id}`);
|
|
684
|
-
}
|
|
703
|
+
})
|
|
685
704
|
};
|
|
686
705
|
}
|
|
687
706
|
get usage() {
|
|
@@ -691,8 +710,8 @@ class DeviceGateway extends Object {
|
|
|
691
710
|
* @param deviceId 设备ID
|
|
692
711
|
* @returns Promise 包含设备使用情况的数据
|
|
693
712
|
*/
|
|
694
|
-
get:
|
|
695
|
-
const axios =
|
|
713
|
+
get: (deviceId) => __awaiter(this, void 0, void 0, function* () {
|
|
714
|
+
const axios = yield this.context.ready;
|
|
696
715
|
return axios.get(`/api/v3/device/usage/${deviceId}`)
|
|
697
716
|
.then((res) => {
|
|
698
717
|
if (res.data.code !== 200) {
|
|
@@ -700,15 +719,15 @@ class DeviceGateway extends Object {
|
|
|
700
719
|
}
|
|
701
720
|
return res.data;
|
|
702
721
|
});
|
|
703
|
-
},
|
|
722
|
+
}),
|
|
704
723
|
/**
|
|
705
724
|
* 更新设备使用情况
|
|
706
725
|
* @param deviceId 设备ID
|
|
707
726
|
* @param usageData 使用情况数据
|
|
708
727
|
* @returns Promise 包含更新后的设备使用情况数据
|
|
709
728
|
*/
|
|
710
|
-
update:
|
|
711
|
-
const axios =
|
|
729
|
+
update: (deviceId, usageData) => __awaiter(this, void 0, void 0, function* () {
|
|
730
|
+
const axios = yield this.context.ready;
|
|
712
731
|
return axios.put(`/api/v3/device/usage/${deviceId}`, usageData)
|
|
713
732
|
.then((res) => {
|
|
714
733
|
if (res.data.code !== 200) {
|
|
@@ -716,39 +735,39 @@ class DeviceGateway extends Object {
|
|
|
716
735
|
}
|
|
717
736
|
return res.data;
|
|
718
737
|
});
|
|
719
|
-
}
|
|
738
|
+
})
|
|
720
739
|
};
|
|
721
740
|
}
|
|
722
741
|
get disinfect() {
|
|
723
742
|
return {
|
|
724
|
-
openDoor:
|
|
725
|
-
var axios =
|
|
743
|
+
openDoor: (deviceId, door, open) => __awaiter(this, void 0, void 0, function* () {
|
|
744
|
+
var axios = yield this.context.ready;
|
|
726
745
|
return axios.post(`/api/v2/disinfect/${deviceId}`, { door, open });
|
|
727
|
-
},
|
|
728
|
-
action:
|
|
729
|
-
var axios =
|
|
746
|
+
}),
|
|
747
|
+
action: (deviceId, action) => __awaiter(this, void 0, void 0, function* () {
|
|
748
|
+
var axios = yield this.context.ready;
|
|
730
749
|
return axios.post(`/api/v2/disinfect/${deviceId}`, { action });
|
|
731
|
-
},
|
|
750
|
+
}),
|
|
732
751
|
config: {
|
|
733
|
-
set:
|
|
734
|
-
let axios =
|
|
752
|
+
set: (deviceId, config) => __awaiter(this, void 0, void 0, function* () {
|
|
753
|
+
let axios = yield this.context.ready;
|
|
735
754
|
return axios.post(`/api/v2/disinfect/${deviceId}/params`, config).then((res) => {
|
|
736
755
|
return res.data;
|
|
737
756
|
});
|
|
738
|
-
},
|
|
739
|
-
get:
|
|
740
|
-
let axios =
|
|
757
|
+
}),
|
|
758
|
+
get: (deviceId) => __awaiter(this, void 0, void 0, function* () {
|
|
759
|
+
let axios = yield this.context.ready;
|
|
741
760
|
return axios.get(`/api/v2/disinfect/${deviceId}/params`).then((res) => {
|
|
742
761
|
return res.data;
|
|
743
762
|
});
|
|
744
|
-
}
|
|
763
|
+
})
|
|
745
764
|
},
|
|
746
|
-
history:
|
|
747
|
-
let axios =
|
|
765
|
+
history: (deviceId, pageNum, pageSize) => __awaiter(this, void 0, void 0, function* () {
|
|
766
|
+
let axios = yield this.context.ready;
|
|
748
767
|
return axios.get(`/api/v2/disinfect/${deviceId}`, { params: { pageNum, pageSize } }).then((res) => {
|
|
749
768
|
return res.data;
|
|
750
769
|
});
|
|
751
|
-
}
|
|
770
|
+
})
|
|
752
771
|
};
|
|
753
772
|
}
|
|
754
773
|
}
|