@cpzxrobot/sdk 1.3.69 → 1.3.71
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 +3 -2
- package/device_filter.ts +4 -4
- package/device_gateway.ts +12 -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 +120 -94
- package/dist/device_gateway.js +210 -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 +12 -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,57 +98,67 @@ 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) {
|
|
142
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
|
+
];
|
|
143
162
|
this.maintenanceLevels = this.generateFunctionsForDict('maintenance-levels');
|
|
144
163
|
this.maintenanceTypes = this.generateFunctionsForDict('maintenance-types');
|
|
145
164
|
this.maintenanceFeedbackTypes = this.generateFunctionsForDict('maintenance-feedback-types');
|
|
@@ -173,19 +192,21 @@ class DeviceGateway extends Object {
|
|
|
173
192
|
show(id, type = "datapoint") {
|
|
174
193
|
this.context.platform.showInDeviceManager(id, type);
|
|
175
194
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
watch(ids_1, fn_1) {
|
|
196
|
+
return __awaiter(this, arguments, void 0, function* (ids, fn, showLast = true) {
|
|
197
|
+
var axios = yield this.context.ready;
|
|
198
|
+
var idQuery = "";
|
|
199
|
+
if (Array.isArray(ids)) {
|
|
200
|
+
idQuery = ids.map(x => `ids=${x}`).join("&");
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
idQuery = `ids=${ids}`;
|
|
204
|
+
}
|
|
205
|
+
if (showLast) {
|
|
206
|
+
idQuery += "&show-last=true";
|
|
207
|
+
}
|
|
208
|
+
return axios.getAsSse(`/api/v1/device/watch?` + idQuery, fn);
|
|
209
|
+
});
|
|
189
210
|
}
|
|
190
211
|
getFilter(type, cls) {
|
|
191
212
|
// 如果filters中已经有对应type的过滤器,则直接返回该过滤器
|
|
@@ -226,61 +247,69 @@ class DeviceGateway extends Object {
|
|
|
226
247
|
}) {
|
|
227
248
|
return this.normalFilter.getData(id, args);
|
|
228
249
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
250
|
+
info(id) {
|
|
251
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
252
|
+
let axios = yield this.context.ready;
|
|
253
|
+
return axios.get(`/api/v1/device/info/${id}`);
|
|
254
|
+
});
|
|
232
255
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
256
|
+
validate(serialNumbers_1) {
|
|
257
|
+
return __awaiter(this, arguments, void 0, function* (serialNumbers, type = "pywl") {
|
|
258
|
+
let axios = yield this.context.ready;
|
|
259
|
+
return axios.post(`/api/v2/device/validateSerialNumber`, {
|
|
260
|
+
serialNumbers,
|
|
261
|
+
type,
|
|
262
|
+
});
|
|
238
263
|
});
|
|
239
264
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
265
|
+
batchValidate(serialNumbers_1) {
|
|
266
|
+
return __awaiter(this, arguments, void 0, function* (serialNumbers, type = "pywl") {
|
|
267
|
+
let axios = yield this.context.ready;
|
|
268
|
+
return axios.upload(`/api/v2/device/batchValidate`, {
|
|
269
|
+
serialNumbers,
|
|
270
|
+
type,
|
|
271
|
+
});
|
|
245
272
|
});
|
|
246
273
|
}
|
|
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;
|
|
274
|
+
faults(deviceId, startTime, endTime) {
|
|
275
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
276
|
+
let axios = yield this.context.ready;
|
|
277
|
+
const startTimeRfc3339 = startTime.toISOString();
|
|
278
|
+
const endTimeRfc3339 = endTime.toISOString();
|
|
279
|
+
const response = yield axios.get(`/api/v1/device/${deviceId}/faults?start=${startTimeRfc3339}&stop=${endTimeRfc3339}`);
|
|
280
|
+
const json = response.data;
|
|
281
|
+
var faultsData = json.faults;
|
|
282
|
+
// #group,false,false,true,true,false,false,true,true,true,true,true,true
|
|
283
|
+
// #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,boolean,string,string,string,string,string,string
|
|
284
|
+
// #default,last,,,,,,,,,,,
|
|
285
|
+
// ,result,table,_start,_stop,_time,_value,DeviceId,_field,_measurement,category,field,status
|
|
286
|
+
// ,,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
|
|
287
|
+
// ,,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
|
|
288
|
+
// ,,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
|
|
289
|
+
// ,,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
|
|
290
|
+
// ,,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
|
|
291
|
+
// ,,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
|
|
292
|
+
faultsData = faultsData.replace(/\r/g, "");
|
|
293
|
+
var arr = faultsData.split("\n");
|
|
294
|
+
var inAnnotation = false;
|
|
295
|
+
var columns = [];
|
|
296
|
+
var faults = [];
|
|
297
|
+
for (var i = 0; i < arr.length; i++) {
|
|
298
|
+
var values = arr[i].split(",");
|
|
299
|
+
if (arr[i].startsWith("#")) {
|
|
277
300
|
}
|
|
278
|
-
else {
|
|
279
|
-
|
|
301
|
+
else if (arr[i] != "") {
|
|
302
|
+
if (inAnnotation) {
|
|
303
|
+
inAnnotation = false;
|
|
304
|
+
columns = values;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
faults.push(new DeviceFault(values, columns));
|
|
308
|
+
}
|
|
280
309
|
}
|
|
281
310
|
}
|
|
282
|
-
|
|
283
|
-
|
|
311
|
+
return faults;
|
|
312
|
+
});
|
|
284
313
|
}
|
|
285
314
|
// 报告设备问题
|
|
286
315
|
report(id, status, description) {
|
|
@@ -405,9 +434,9 @@ class DeviceGateway extends Object {
|
|
|
405
434
|
//v1的设备实际是点位,v3的设备才是真正的设备
|
|
406
435
|
return {
|
|
407
436
|
list: (args = {}) => {
|
|
408
|
-
return this.context.ready.then(
|
|
437
|
+
return this.context.ready.then(() => __awaiter(this, void 0, void 0, function* () {
|
|
409
438
|
if (args.factoryId == undefined) {
|
|
410
|
-
var farm =
|
|
439
|
+
var farm = yield this.context.user.getSelectedFarm();
|
|
411
440
|
args.factoryId = farm.id;
|
|
412
441
|
}
|
|
413
442
|
return this.context.axios.get(`/api/v3/device/list`, {
|
|
@@ -417,7 +446,7 @@ class DeviceGateway extends Object {
|
|
|
417
446
|
factory_id: args.factoryId
|
|
418
447
|
}
|
|
419
448
|
});
|
|
420
|
-
});
|
|
449
|
+
}));
|
|
421
450
|
},
|
|
422
451
|
detail: (id) => {
|
|
423
452
|
return this.context.ready.then(() => {
|
|
@@ -537,18 +566,18 @@ class DeviceGateway extends Object {
|
|
|
537
566
|
}
|
|
538
567
|
get trouble() {
|
|
539
568
|
return {
|
|
540
|
-
list:
|
|
569
|
+
list: (...args_1) => __awaiter(this, [...args_1], void 0, function* (args = {
|
|
541
570
|
sourceType: "device",
|
|
542
571
|
pageNum: 1,
|
|
543
572
|
pageSize: 10,
|
|
544
|
-
})
|
|
545
|
-
const axios =
|
|
573
|
+
}) {
|
|
574
|
+
const axios = yield this.context.ready;
|
|
546
575
|
return axios.get('/api/v3/device/trouble/list', {
|
|
547
576
|
params: args
|
|
548
577
|
});
|
|
549
|
-
},
|
|
550
|
-
create:
|
|
551
|
-
const axios =
|
|
578
|
+
}),
|
|
579
|
+
create: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
580
|
+
const axios = yield this.context.ready;
|
|
552
581
|
return axios.post('/api/v3/device/trouble/create', data)
|
|
553
582
|
.then((res) => {
|
|
554
583
|
if (res.data.code !== 200) {
|
|
@@ -556,9 +585,9 @@ class DeviceGateway extends Object {
|
|
|
556
585
|
}
|
|
557
586
|
return res.data;
|
|
558
587
|
});
|
|
559
|
-
},
|
|
560
|
-
history:
|
|
561
|
-
const axios =
|
|
588
|
+
}),
|
|
589
|
+
history: (troubleId) => __awaiter(this, void 0, void 0, function* () {
|
|
590
|
+
const axios = yield this.context.ready;
|
|
562
591
|
return axios.get(`/api/v3/device/trouble/${troubleId}/handle-records`)
|
|
563
592
|
.then((res) => {
|
|
564
593
|
if (res.data.code !== 200) {
|
|
@@ -566,9 +595,9 @@ class DeviceGateway extends Object {
|
|
|
566
595
|
}
|
|
567
596
|
return res.data;
|
|
568
597
|
});
|
|
569
|
-
},
|
|
570
|
-
delete:
|
|
571
|
-
const axios =
|
|
598
|
+
}),
|
|
599
|
+
delete: (troubleIds) => __awaiter(this, void 0, void 0, function* () {
|
|
600
|
+
const axios = yield this.context.ready;
|
|
572
601
|
return axios.delete('/api/v3/device/trouble/delete', troubleIds)
|
|
573
602
|
.then((res) => {
|
|
574
603
|
if (res.data.code !== 200) {
|
|
@@ -576,112 +605,112 @@ class DeviceGateway extends Object {
|
|
|
576
605
|
}
|
|
577
606
|
return res.data;
|
|
578
607
|
});
|
|
579
|
-
},
|
|
608
|
+
}),
|
|
580
609
|
};
|
|
581
610
|
}
|
|
582
611
|
get troubleType() {
|
|
583
612
|
return {
|
|
584
613
|
// 获取根节点(原list方法)
|
|
585
|
-
list:
|
|
586
|
-
var axios =
|
|
614
|
+
list: () => __awaiter(this, void 0, void 0, function* () {
|
|
615
|
+
var axios = yield this.context.ready;
|
|
587
616
|
return axios.get('/api/v3/device/trouble-type');
|
|
588
|
-
},
|
|
617
|
+
}),
|
|
589
618
|
// 获取直接子节点
|
|
590
|
-
getDirectChildren:
|
|
591
|
-
var axios =
|
|
619
|
+
getDirectChildren: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
620
|
+
var axios = yield this.context.ready;
|
|
592
621
|
return axios.get(`/api/v3/device/trouble-type/${id}`);
|
|
593
|
-
},
|
|
622
|
+
}),
|
|
594
623
|
// 获取所有子节点
|
|
595
|
-
getAllChildren:
|
|
596
|
-
var axios =
|
|
624
|
+
getAllChildren: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
625
|
+
var axios = yield this.context.ready;
|
|
597
626
|
return axios.get(`/api/v3/device/trouble-type/${id}/all`);
|
|
598
|
-
},
|
|
627
|
+
}),
|
|
599
628
|
// 获取完整树结构
|
|
600
|
-
getTree:
|
|
601
|
-
var axios =
|
|
629
|
+
getTree: () => __awaiter(this, void 0, void 0, function* () {
|
|
630
|
+
var axios = yield this.context.ready;
|
|
602
631
|
return axios.get('/api/v3/device/trouble-type/tree');
|
|
603
|
-
},
|
|
632
|
+
}),
|
|
604
633
|
// 创建节点
|
|
605
|
-
create:
|
|
606
|
-
var axios =
|
|
634
|
+
create: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
635
|
+
var axios = yield this.context.ready;
|
|
607
636
|
return axios.post('/api/v3/device/trouble-type', data);
|
|
608
|
-
},
|
|
637
|
+
}),
|
|
609
638
|
// 删除节点(根据Java控制器的DeleteMapping)
|
|
610
|
-
delete:
|
|
611
|
-
var axios =
|
|
639
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
640
|
+
var axios = yield this.context.ready;
|
|
612
641
|
return axios.delete(`/api/v3/device/trouble-type/${id}`);
|
|
613
|
-
}
|
|
642
|
+
})
|
|
614
643
|
};
|
|
615
644
|
}
|
|
616
645
|
get model() {
|
|
617
646
|
return {
|
|
618
|
-
list:
|
|
619
|
-
var axios =
|
|
647
|
+
list: (manufacturerId) => __awaiter(this, void 0, void 0, function* () {
|
|
648
|
+
var axios = yield this.context.ready;
|
|
620
649
|
if (manufacturerId === undefined) {
|
|
621
650
|
return axios.get('/api/v3/device/model');
|
|
622
651
|
}
|
|
623
652
|
else {
|
|
624
653
|
return axios.get(`/api/v3/device/manufacturer/${manufacturerId}/models`);
|
|
625
654
|
}
|
|
626
|
-
},
|
|
627
|
-
create:
|
|
628
|
-
var axios =
|
|
655
|
+
}),
|
|
656
|
+
create: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
657
|
+
var axios = yield this.context.ready;
|
|
629
658
|
return axios.post('/api/v3/device/model', data);
|
|
630
|
-
},
|
|
631
|
-
update:
|
|
632
|
-
var axios =
|
|
659
|
+
}),
|
|
660
|
+
update: (id, data) => __awaiter(this, void 0, void 0, function* () {
|
|
661
|
+
var axios = yield this.context.ready;
|
|
633
662
|
return axios.put(`/api/v3/device/model/${id}`, data);
|
|
634
|
-
},
|
|
635
|
-
delete:
|
|
636
|
-
var axios =
|
|
663
|
+
}),
|
|
664
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
665
|
+
var axios = yield this.context.ready;
|
|
637
666
|
return axios.delete(`/api/v3/device/model/${id}`);
|
|
638
|
-
},
|
|
639
|
-
detail:
|
|
640
|
-
var axios =
|
|
667
|
+
}),
|
|
668
|
+
detail: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
669
|
+
var axios = yield this.context.ready;
|
|
641
670
|
return axios.get(`/api/v3/device/model/${id}`);
|
|
642
|
-
}
|
|
671
|
+
})
|
|
643
672
|
};
|
|
644
673
|
}
|
|
645
674
|
get maintenanceGroup() {
|
|
646
675
|
return {
|
|
647
676
|
// 获取维护组列表
|
|
648
|
-
list:
|
|
649
|
-
const axios =
|
|
677
|
+
list: (factoryId) => __awaiter(this, void 0, void 0, function* () {
|
|
678
|
+
const axios = yield this.context.ready;
|
|
650
679
|
return axios.get('/api/v3/device/maintenance-groups', {
|
|
651
680
|
params: { factoryId }
|
|
652
681
|
});
|
|
653
|
-
},
|
|
682
|
+
}),
|
|
654
683
|
// 创建维护组
|
|
655
|
-
create:
|
|
656
|
-
const axios =
|
|
684
|
+
create: (factoryId, group) => __awaiter(this, void 0, void 0, function* () {
|
|
685
|
+
const axios = yield this.context.ready;
|
|
657
686
|
return axios.post(`/api/v3/device/maintenance-groups?factoryId=${factoryId}`, group);
|
|
658
|
-
},
|
|
687
|
+
}),
|
|
659
688
|
// 删除维护组
|
|
660
|
-
delete:
|
|
661
|
-
const axios =
|
|
689
|
+
delete: (factoryId, groupId) => __awaiter(this, void 0, void 0, function* () {
|
|
690
|
+
const axios = yield this.context.ready;
|
|
662
691
|
return axios.delete(`/api/v3/device/maintenance-groups/${groupId}`, {
|
|
663
692
|
params: { factoryId }
|
|
664
693
|
});
|
|
665
|
-
},
|
|
694
|
+
}),
|
|
666
695
|
};
|
|
667
696
|
}
|
|
668
697
|
generateFunctionsForDict(dictName) {
|
|
669
698
|
return {
|
|
670
699
|
// 获取维护类型列表
|
|
671
|
-
list:
|
|
672
|
-
const axios =
|
|
700
|
+
list: (factoryId) => __awaiter(this, void 0, void 0, function* () {
|
|
701
|
+
const axios = yield this.context.ready;
|
|
673
702
|
return axios.get(`/api/v3/device/${dictName}`, {
|
|
674
703
|
params: { factoryId }
|
|
675
704
|
});
|
|
676
|
-
},
|
|
677
|
-
create:
|
|
678
|
-
var axios =
|
|
705
|
+
}),
|
|
706
|
+
create: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
707
|
+
var axios = yield this.context.ready;
|
|
679
708
|
return axios.post(`/api/v3/device/${dictName}`, data);
|
|
680
|
-
},
|
|
681
|
-
delete:
|
|
682
|
-
var axios =
|
|
709
|
+
}),
|
|
710
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
711
|
+
var axios = yield this.context.ready;
|
|
683
712
|
return axios.delete(`/api/v3/device/${dictName}/${id}`);
|
|
684
|
-
}
|
|
713
|
+
})
|
|
685
714
|
};
|
|
686
715
|
}
|
|
687
716
|
get usage() {
|
|
@@ -691,8 +720,8 @@ class DeviceGateway extends Object {
|
|
|
691
720
|
* @param deviceId 设备ID
|
|
692
721
|
* @returns Promise 包含设备使用情况的数据
|
|
693
722
|
*/
|
|
694
|
-
get:
|
|
695
|
-
const axios =
|
|
723
|
+
get: (deviceId) => __awaiter(this, void 0, void 0, function* () {
|
|
724
|
+
const axios = yield this.context.ready;
|
|
696
725
|
return axios.get(`/api/v3/device/usage/${deviceId}`)
|
|
697
726
|
.then((res) => {
|
|
698
727
|
if (res.data.code !== 200) {
|
|
@@ -700,15 +729,15 @@ class DeviceGateway extends Object {
|
|
|
700
729
|
}
|
|
701
730
|
return res.data;
|
|
702
731
|
});
|
|
703
|
-
},
|
|
732
|
+
}),
|
|
704
733
|
/**
|
|
705
734
|
* 更新设备使用情况
|
|
706
735
|
* @param deviceId 设备ID
|
|
707
736
|
* @param usageData 使用情况数据
|
|
708
737
|
* @returns Promise 包含更新后的设备使用情况数据
|
|
709
738
|
*/
|
|
710
|
-
update:
|
|
711
|
-
const axios =
|
|
739
|
+
update: (deviceId, usageData) => __awaiter(this, void 0, void 0, function* () {
|
|
740
|
+
const axios = yield this.context.ready;
|
|
712
741
|
return axios.put(`/api/v3/device/usage/${deviceId}`, usageData)
|
|
713
742
|
.then((res) => {
|
|
714
743
|
if (res.data.code !== 200) {
|
|
@@ -716,39 +745,39 @@ class DeviceGateway extends Object {
|
|
|
716
745
|
}
|
|
717
746
|
return res.data;
|
|
718
747
|
});
|
|
719
|
-
}
|
|
748
|
+
})
|
|
720
749
|
};
|
|
721
750
|
}
|
|
722
751
|
get disinfect() {
|
|
723
752
|
return {
|
|
724
|
-
openDoor:
|
|
725
|
-
var axios =
|
|
753
|
+
openDoor: (deviceId, door, open) => __awaiter(this, void 0, void 0, function* () {
|
|
754
|
+
var axios = yield this.context.ready;
|
|
726
755
|
return axios.post(`/api/v2/disinfect/${deviceId}`, { door, open });
|
|
727
|
-
},
|
|
728
|
-
action:
|
|
729
|
-
var axios =
|
|
756
|
+
}),
|
|
757
|
+
action: (deviceId, action) => __awaiter(this, void 0, void 0, function* () {
|
|
758
|
+
var axios = yield this.context.ready;
|
|
730
759
|
return axios.post(`/api/v2/disinfect/${deviceId}`, { action });
|
|
731
|
-
},
|
|
760
|
+
}),
|
|
732
761
|
config: {
|
|
733
|
-
set:
|
|
734
|
-
let axios =
|
|
762
|
+
set: (deviceId, config) => __awaiter(this, void 0, void 0, function* () {
|
|
763
|
+
let axios = yield this.context.ready;
|
|
735
764
|
return axios.post(`/api/v2/disinfect/${deviceId}/params`, config).then((res) => {
|
|
736
765
|
return res.data;
|
|
737
766
|
});
|
|
738
|
-
},
|
|
739
|
-
get:
|
|
740
|
-
let axios =
|
|
767
|
+
}),
|
|
768
|
+
get: (deviceId) => __awaiter(this, void 0, void 0, function* () {
|
|
769
|
+
let axios = yield this.context.ready;
|
|
741
770
|
return axios.get(`/api/v2/disinfect/${deviceId}/params`).then((res) => {
|
|
742
771
|
return res.data;
|
|
743
772
|
});
|
|
744
|
-
}
|
|
773
|
+
})
|
|
745
774
|
},
|
|
746
|
-
history:
|
|
747
|
-
let axios =
|
|
775
|
+
history: (deviceId, pageNum, pageSize) => __awaiter(this, void 0, void 0, function* () {
|
|
776
|
+
let axios = yield this.context.ready;
|
|
748
777
|
return axios.get(`/api/v2/disinfect/${deviceId}`, { params: { pageNum, pageSize } }).then((res) => {
|
|
749
778
|
return res.data;
|
|
750
779
|
});
|
|
751
|
-
}
|
|
780
|
+
})
|
|
752
781
|
};
|
|
753
782
|
}
|
|
754
783
|
}
|