@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.
@@ -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: async (data) => {
57
- let axios = await this.context.ready;
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: async (data) => {
63
- let axios = await this.context.ready;
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: async (id) => {
69
- let axios = await this.context.ready;
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: async (condition, params = undefined) => {
75
- let axios = await this.context.ready;
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: async (type, sn) => {
94
- let axios = await this.context.ready;
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: async (factory) => {
104
- let axios = await this.context.ready;
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: async (data) => {
113
- let axios = await this.context.ready;
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: async (configId, data) => {
118
- let axios = await this.context.ready;
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: async (id) => {
123
- let axios = await this.context.ready;
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: async (configId) => {
130
- let axios = await this.context.ready;
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: async (id) => {
134
- let axios = await this.context.ready;
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
- async watch(ids, fn, showLast = true) {
177
- var axios = await this.context.ready;
178
- var idQuery = "";
179
- if (Array.isArray(ids)) {
180
- idQuery = ids.map(x => `ids=${x}`).join("&");
181
- }
182
- else {
183
- idQuery = `ids=${ids}`;
184
- }
185
- if (showLast) {
186
- idQuery += "&show-last=true";
187
- }
188
- return axios.getAsSse(`/api/v1/device/watch?` + idQuery, fn);
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
- async info(id) {
230
- let axios = await this.context.ready;
231
- return axios.get(`/api/v1/device/info/${id}`);
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
- async validate(serialNumbers, type = "pywl") {
234
- let axios = await this.context.ready;
235
- return axios.post(`/api/v2/device/validateSerialNumber`, {
236
- serialNumbers,
237
- type,
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
- async batchValidate(serialNumbers, type = "pywl") {
241
- let axios = await this.context.ready;
242
- return axios.upload(`/api/v2/device/batchValidate`, {
243
- serialNumbers,
244
- type,
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
- async faults(deviceId, startTime, endTime) {
248
- let axios = await this.context.ready;
249
- const startTimeRfc3339 = startTime.toISOString();
250
- const endTimeRfc3339 = endTime.toISOString();
251
- const response = await axios.get(`/api/v1/device/${deviceId}/faults?start=${startTimeRfc3339}&stop=${endTimeRfc3339}`);
252
- const json = response.data;
253
- var faultsData = json.faults;
254
- // #group,false,false,true,true,false,false,true,true,true,true,true,true
255
- // #datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,boolean,string,string,string,string,string,string
256
- // #default,last,,,,,,,,,,,
257
- // ,result,table,_start,_stop,_time,_value,DeviceId,_field,_measurement,category,field,status
258
- // ,,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
259
- // ,,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
260
- // ,,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
261
- // ,,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
262
- // ,,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
263
- // ,,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
264
- faultsData = faultsData.replace(/\r/g, "");
265
- var arr = faultsData.split("\n");
266
- var inAnnotation = false;
267
- var columns = [];
268
- var faults = [];
269
- for (var i = 0; i < arr.length; i++) {
270
- var values = arr[i].split(",");
271
- if (arr[i].startsWith("#")) {
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
- faults.push(new DeviceFault(values, columns));
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
- return faults;
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(async () => {
437
+ return this.context.ready.then(() => __awaiter(this, void 0, void 0, function* () {
409
438
  if (args.factoryId == undefined) {
410
- var farm = await this.context.user.getSelectedFarm();
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: async (args = {
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 = await this.context.ready;
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: async (data) => {
551
- const axios = await this.context.ready;
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: async (troubleId) => {
561
- const axios = await this.context.ready;
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: async (troubleIds) => {
571
- const axios = await this.context.ready;
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: async () => {
586
- var axios = await this.context.ready;
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: async (id) => {
591
- var axios = await this.context.ready;
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: async (id) => {
596
- var axios = await this.context.ready;
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: async () => {
601
- var axios = await this.context.ready;
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: async (data) => {
606
- var axios = await this.context.ready;
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: async (id) => {
611
- var axios = await this.context.ready;
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: async (manufacturerId) => {
619
- var axios = await this.context.ready;
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: async (data) => {
628
- var axios = await this.context.ready;
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: async (id, data) => {
632
- var axios = await this.context.ready;
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: async (id) => {
636
- var axios = await this.context.ready;
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: async (id) => {
640
- var axios = await this.context.ready;
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: async (factoryId) => {
649
- const axios = await this.context.ready;
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: async (factoryId, group) => {
656
- const axios = await this.context.ready;
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: async (factoryId, groupId) => {
661
- const axios = await this.context.ready;
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: async (factoryId) => {
672
- const axios = await this.context.ready;
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: async (data) => {
678
- var axios = await this.context.ready;
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: async (id) => {
682
- var axios = await this.context.ready;
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: async (deviceId) => {
695
- const axios = await this.context.ready;
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: async (deviceId, usageData) => {
711
- const axios = await this.context.ready;
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: async (deviceId, door, open) => {
725
- var axios = await this.context.ready;
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: async (deviceId, action) => {
729
- var axios = await this.context.ready;
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: async (deviceId, config) => {
734
- let axios = await this.context.ready;
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: async (deviceId) => {
740
- let axios = await this.context.ready;
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: async (deviceId, pageNum, pageSize) => {
747
- let axios = await this.context.ready;
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
  }