@cpzxrobot/sdk 1.3.20 → 1.3.22
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 +124 -5
- package/dist/device_gateway.js +84 -0
- package/dist/index.js +2 -0
- package/dist/mobile_platform.js +6 -0
- package/dist/production_gateway.js +66 -0
- package/dist/web_platform.js +15 -0
- package/index.ts +2 -0
- package/mobile_platform.ts +6 -0
- package/package.json +1 -1
- package/production_gateway.ts +78 -0
- package/types.d.ts +23 -1
- package/web_platform.ts +18 -0
package/device_gateway.ts
CHANGED
|
@@ -204,8 +204,8 @@ export class DeviceGateway extends Object {
|
|
|
204
204
|
|
|
205
205
|
//获取设备详情
|
|
206
206
|
//ID:点位ID,设备UUID,当type是device时,为设备ID(UUID);当type是datapoint时,为点位ID(number)
|
|
207
|
-
show(id: any, type: "device"|"datapoint" = "datapoint"){
|
|
208
|
-
this.context.platform.showInDeviceManager(id,type);
|
|
207
|
+
show(id: any, type: "device" | "datapoint" = "datapoint") {
|
|
208
|
+
this.context.platform.showInDeviceManager(id, type);
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
async watch(
|
|
@@ -367,9 +367,9 @@ export class DeviceGateway extends Object {
|
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
// 设备生产商 GET /api/v2/device/manufacturers
|
|
370
|
-
manufacturers(category: string|undefined = undefined): Promise<any> {
|
|
370
|
+
manufacturers(category: string | undefined = undefined): Promise<any> {
|
|
371
371
|
return this.context.ready.then(() => {
|
|
372
|
-
return this.context.axios.get("/api/v2/device/manufacturers",{
|
|
372
|
+
return this.context.axios.get("/api/v2/device/manufacturers", {
|
|
373
373
|
params: {
|
|
374
374
|
category
|
|
375
375
|
}
|
|
@@ -382,7 +382,7 @@ export class DeviceGateway extends Object {
|
|
|
382
382
|
});
|
|
383
383
|
});
|
|
384
384
|
}
|
|
385
|
-
|
|
385
|
+
|
|
386
386
|
|
|
387
387
|
get ctrl() {
|
|
388
388
|
return {
|
|
@@ -426,4 +426,123 @@ export class DeviceGateway extends Object {
|
|
|
426
426
|
}
|
|
427
427
|
};
|
|
428
428
|
}
|
|
429
|
+
|
|
430
|
+
get v3() {
|
|
431
|
+
//v1的设备实际是点位,v3的设备才是真正的设备
|
|
432
|
+
return {
|
|
433
|
+
list: (args: {
|
|
434
|
+
limit?: number;
|
|
435
|
+
offset?: number;
|
|
436
|
+
factoryId?: number;
|
|
437
|
+
} = {}): Promise<any> => {
|
|
438
|
+
return this.context.ready.then(async () => {
|
|
439
|
+
|
|
440
|
+
if (args.factoryId == undefined) {
|
|
441
|
+
var farm = await this.context.user.getSelectedFarm();
|
|
442
|
+
args.factoryId = farm.id;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return this.context.axios.get(`/api/v3/device/list`, {
|
|
446
|
+
params: {
|
|
447
|
+
limit: args.limit,
|
|
448
|
+
offset: args.offset,
|
|
449
|
+
factory_id: args.factoryId
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
},
|
|
454
|
+
detail: (id: number): Promise<any> => {
|
|
455
|
+
return this.context.ready.then(() => {
|
|
456
|
+
return this.context.axios.get(`/api/v3/device/detail/${id}`);
|
|
457
|
+
});
|
|
458
|
+
},
|
|
459
|
+
manufacturer: (id: number): Promise<any> => {
|
|
460
|
+
return this.context.ready.then(() => {
|
|
461
|
+
return this.context.axios.get(`/api/v3/device/manufacturer/${id}`);
|
|
462
|
+
});
|
|
463
|
+
},
|
|
464
|
+
manufacturers: (): Promise<any> => {
|
|
465
|
+
return this.context.ready.then(() => {
|
|
466
|
+
return this.context.axios.get(`/api/v3/device/manufacturer/list`);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
get purpose() {
|
|
473
|
+
return {
|
|
474
|
+
list: (parentId: number | undefined): Promise<any> => {
|
|
475
|
+
return this.context.ready.then(() => {
|
|
476
|
+
if (parentId == undefined) {
|
|
477
|
+
return this.context.axios.get(`/api/v3/device/purpose`);
|
|
478
|
+
} else {
|
|
479
|
+
return this.context.axios.get(`/api/v3/device/purpose/${parentId}`);
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
},
|
|
483
|
+
|
|
484
|
+
create: (data: {
|
|
485
|
+
name: string;
|
|
486
|
+
code: string;
|
|
487
|
+
parts?: string[];
|
|
488
|
+
faultCategories?: string[];
|
|
489
|
+
isImportant?: boolean;
|
|
490
|
+
importantParams?: string;
|
|
491
|
+
parentId?: number;
|
|
492
|
+
path?: string;
|
|
493
|
+
}): Promise<any> => {
|
|
494
|
+
return this.context.ready.then(() => {
|
|
495
|
+
return this.context.axios.post(`/api/v3/device/purpose`, data);
|
|
496
|
+
});
|
|
497
|
+
},
|
|
498
|
+
|
|
499
|
+
delete: (id: number): Promise<any> => {
|
|
500
|
+
return this.context.ready.then(() => {
|
|
501
|
+
return this.context.axios.delete(`/api/v3/device/purpose/${id}`);
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
get model() {
|
|
508
|
+
return {
|
|
509
|
+
list: async (manufacturerId: Number | undefined): Promise<any> => {
|
|
510
|
+
var axios = await this.context.ready;
|
|
511
|
+
if (manufacturerId === undefined) {
|
|
512
|
+
return axios.get('/api/v3/device/model');
|
|
513
|
+
} else {
|
|
514
|
+
return axios.get('/api/v3/device/model', { params: { manufacturerId } });
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
|
|
518
|
+
create: async (data: {
|
|
519
|
+
name: string;
|
|
520
|
+
code: string;
|
|
521
|
+
category?: string;
|
|
522
|
+
manufacturerId?: number;
|
|
523
|
+
connectionCategory?: number;
|
|
524
|
+
connectionType?: number;
|
|
525
|
+
}): Promise<any> => {
|
|
526
|
+
var axios = await this.context.ready;
|
|
527
|
+
return axios.post('/api/v3/device/model', data);
|
|
528
|
+
},
|
|
529
|
+
|
|
530
|
+
update: async (id: number, data: {
|
|
531
|
+
name?: string;
|
|
532
|
+
code?: string;
|
|
533
|
+
category?: string;
|
|
534
|
+
manufacturerId?: number;
|
|
535
|
+
connectionCategory?: number;
|
|
536
|
+
connectionType?: number;
|
|
537
|
+
}): Promise<any> => {
|
|
538
|
+
var axios = await this.context.ready;
|
|
539
|
+
return axios.put(`/api/v3/device/model/${id}`, data);
|
|
540
|
+
},
|
|
541
|
+
|
|
542
|
+
delete: async (id: number): Promise<any> => {
|
|
543
|
+
var axios = await this.context.ready;
|
|
544
|
+
return axios.delete(`/api/v3/device/model/${id}`);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
429
548
|
}
|
package/dist/device_gateway.js
CHANGED
|
@@ -322,5 +322,89 @@ class DeviceGateway extends Object {
|
|
|
322
322
|
}
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
|
+
get v3() {
|
|
326
|
+
//v1的设备实际是点位,v3的设备才是真正的设备
|
|
327
|
+
return {
|
|
328
|
+
list: (args = {}) => {
|
|
329
|
+
return this.context.ready.then(async () => {
|
|
330
|
+
if (args.factoryId == undefined) {
|
|
331
|
+
var farm = await this.context.user.getSelectedFarm();
|
|
332
|
+
args.factoryId = farm.id;
|
|
333
|
+
}
|
|
334
|
+
return this.context.axios.get(`/api/v3/device/list`, {
|
|
335
|
+
params: {
|
|
336
|
+
limit: args.limit,
|
|
337
|
+
offset: args.offset,
|
|
338
|
+
factory_id: args.factoryId
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
},
|
|
343
|
+
detail: (id) => {
|
|
344
|
+
return this.context.ready.then(() => {
|
|
345
|
+
return this.context.axios.get(`/api/v3/device/detail/${id}`);
|
|
346
|
+
});
|
|
347
|
+
},
|
|
348
|
+
manufacturer: (id) => {
|
|
349
|
+
return this.context.ready.then(() => {
|
|
350
|
+
return this.context.axios.get(`/api/v3/device/manufacturer/${id}`);
|
|
351
|
+
});
|
|
352
|
+
},
|
|
353
|
+
manufacturers: () => {
|
|
354
|
+
return this.context.ready.then(() => {
|
|
355
|
+
return this.context.axios.get(`/api/v3/device/manufacturer/list`);
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
get purpose() {
|
|
361
|
+
return {
|
|
362
|
+
list: (parentId) => {
|
|
363
|
+
return this.context.ready.then(() => {
|
|
364
|
+
if (parentId == undefined) {
|
|
365
|
+
return this.context.axios.get(`/api/v3/device/purpose`);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
return this.context.axios.get(`/api/v3/device/purpose/${parentId}`);
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
create: (data) => {
|
|
373
|
+
return this.context.ready.then(() => {
|
|
374
|
+
return this.context.axios.post(`/api/v3/device/purpose`, data);
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
delete: (id) => {
|
|
378
|
+
return this.context.ready.then(() => {
|
|
379
|
+
return this.context.axios.delete(`/api/v3/device/purpose/${id}`);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
get model() {
|
|
385
|
+
return {
|
|
386
|
+
list: async (manufacturerId) => {
|
|
387
|
+
var axios = await this.context.ready;
|
|
388
|
+
if (manufacturerId === undefined) {
|
|
389
|
+
return axios.get('/api/v3/device/model');
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
return axios.get('/api/v3/device/model', { params: { manufacturerId } });
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
create: async (data) => {
|
|
396
|
+
var axios = await this.context.ready;
|
|
397
|
+
return axios.post('/api/v3/device/model', data);
|
|
398
|
+
},
|
|
399
|
+
update: async (id, data) => {
|
|
400
|
+
var axios = await this.context.ready;
|
|
401
|
+
return axios.put(`/api/v3/device/model/${id}`, data);
|
|
402
|
+
},
|
|
403
|
+
delete: async (id) => {
|
|
404
|
+
var axios = await this.context.ready;
|
|
405
|
+
return axios.delete(`/api/v3/device/model/${id}`);
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
}
|
|
325
409
|
}
|
|
326
410
|
exports.DeviceGateway = DeviceGateway;
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ const construction_gateway_1 = require("./construction_gateway");
|
|
|
51
51
|
const system_gateway_1 = require("./system_gateway");
|
|
52
52
|
const mobile_platform_1 = require("./mobile_platform");
|
|
53
53
|
const web_platform_1 = require("./web_platform");
|
|
54
|
+
const production_gateway_1 = require("./production_gateway");
|
|
54
55
|
class Cpzxrobot {
|
|
55
56
|
constructor(appCode, baseUrl, initSelectedFactory, initSelectedUnit) {
|
|
56
57
|
this.pigfarm = new pigfarm_gateway_1.PigfarmGateway(this);
|
|
@@ -71,6 +72,7 @@ class Cpzxrobot {
|
|
|
71
72
|
this.ai = new ai_gateway_1.AiGateway(this);
|
|
72
73
|
this.construction = new construction_gateway_1.ConstructionGateway(this);
|
|
73
74
|
this.system = new system_gateway_1.SystemGateway(this);
|
|
75
|
+
this.production = new production_gateway_1.ProductionGateway(this);
|
|
74
76
|
this.sseCallbacks = {};
|
|
75
77
|
//获取当前浏览器的域名
|
|
76
78
|
this.ready = new Promise((resolve, reject) => {
|
package/dist/mobile_platform.js
CHANGED
|
@@ -65,6 +65,12 @@ class MobilePlatform {
|
|
|
65
65
|
getAndSave: function (url, config) {
|
|
66
66
|
return that.platform.callHandler("axios_getAndSave", url, config);
|
|
67
67
|
},
|
|
68
|
+
delete: function (url, data) {
|
|
69
|
+
return that.platform.callHandler("axios_exec", "DELETE", url, data);
|
|
70
|
+
},
|
|
71
|
+
put: function (url, data) {
|
|
72
|
+
return that.platform.callHandler("axios_exec", "PUT", url, data);
|
|
73
|
+
},
|
|
68
74
|
getAndPreview: function (url, config) {
|
|
69
75
|
if (config == undefined) {
|
|
70
76
|
config = {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProductionGateway = void 0;
|
|
4
|
+
// 产量统计网关,管理工厂产量数据
|
|
5
|
+
class ProductionGateway extends Object {
|
|
6
|
+
constructor(context) {
|
|
7
|
+
super();
|
|
8
|
+
this.context = context;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 添加产品类型
|
|
12
|
+
* @param productName 产品名称
|
|
13
|
+
*/
|
|
14
|
+
async addType(productName) {
|
|
15
|
+
const axios = await this.context.ready;
|
|
16
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
17
|
+
return axios.post('/api/v3/production/add', {
|
|
18
|
+
product_name: productName,
|
|
19
|
+
factory_id: factory.id
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 获取所有产品类型列表
|
|
24
|
+
*/
|
|
25
|
+
async listTypes() {
|
|
26
|
+
const axios = await this.context.ready;
|
|
27
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
28
|
+
return axios.get(`/api/v3/production/list/${factory.id}`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 录入产量统计数据
|
|
32
|
+
* @param request 统计请求参数
|
|
33
|
+
*/
|
|
34
|
+
async createStat(request) {
|
|
35
|
+
if (!request.factory_id) {
|
|
36
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
37
|
+
request.factory_id = factory.id;
|
|
38
|
+
}
|
|
39
|
+
const axios = await this.context.ready;
|
|
40
|
+
return axios.post('/api/v3/production/stat', {
|
|
41
|
+
factory_id: request.factory_id,
|
|
42
|
+
time: request.time.toISOString(),
|
|
43
|
+
period: request.period,
|
|
44
|
+
products: request.products
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 查询产量统计数据
|
|
49
|
+
* @param period 统计周期(month|quater|year)
|
|
50
|
+
* @param factoryId 工厂ID
|
|
51
|
+
*/
|
|
52
|
+
async getStats(period, factoryId) {
|
|
53
|
+
if (!factoryId) {
|
|
54
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
55
|
+
factoryId = factory.id;
|
|
56
|
+
}
|
|
57
|
+
const axios = await this.context.ready;
|
|
58
|
+
return axios.get('/api/v3/production/stat', {
|
|
59
|
+
params: {
|
|
60
|
+
period,
|
|
61
|
+
factory_id: factoryId
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ProductionGateway = ProductionGateway;
|
package/dist/web_platform.js
CHANGED
|
@@ -126,6 +126,21 @@ class WebPlatform {
|
|
|
126
126
|
return response.blob();
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
|
+
delete: async (url, data, config) => {
|
|
130
|
+
const response = await this.fetchWithAuth(url, {
|
|
131
|
+
method: 'DELETE',
|
|
132
|
+
headers: config === null || config === void 0 ? void 0 : config.headers
|
|
133
|
+
});
|
|
134
|
+
return { data: await response.json() };
|
|
135
|
+
},
|
|
136
|
+
put: async (url, data, config) => {
|
|
137
|
+
const response = await this.fetchWithAuth(url, {
|
|
138
|
+
method: 'PUT',
|
|
139
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, config === null || config === void 0 ? void 0 : config.headers),
|
|
140
|
+
body: JSON.stringify(data)
|
|
141
|
+
});
|
|
142
|
+
return { data: await response.json() };
|
|
143
|
+
},
|
|
129
144
|
post: async (url, data, config) => {
|
|
130
145
|
const response = await this.fetchWithAuth(url, {
|
|
131
146
|
method: 'POST',
|
package/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { ConstructionGateway } from "./construction_gateway";
|
|
|
26
26
|
import { SystemGateway } from "./system_gateway";
|
|
27
27
|
import { MobilePlatform } from "./mobile_platform";
|
|
28
28
|
import { WebPlatform } from "./web_platform";
|
|
29
|
+
import { ProductionGateway } from "./production_gateway";
|
|
29
30
|
|
|
30
31
|
export class Cpzxrobot {
|
|
31
32
|
private static factorySelectorLoaded = false;
|
|
@@ -66,6 +67,7 @@ export class Cpzxrobot {
|
|
|
66
67
|
ai: AiGateway = new AiGateway(this);
|
|
67
68
|
construction: ConstructionGateway = new ConstructionGateway(this);
|
|
68
69
|
system: SystemGateway = new SystemGateway(this);
|
|
70
|
+
production: ProductionGateway = new ProductionGateway(this);
|
|
69
71
|
sseCallbacks: {
|
|
70
72
|
[key: string]: (data: any) => void;
|
|
71
73
|
} = {};
|
package/mobile_platform.ts
CHANGED
|
@@ -77,6 +77,12 @@ export class MobilePlatform implements PlatformInterface {
|
|
|
77
77
|
getAndSave: function (url, config) {
|
|
78
78
|
return that.platform.callHandler("axios_getAndSave", url, config);
|
|
79
79
|
},
|
|
80
|
+
delete: function (url, data) {
|
|
81
|
+
return that.platform.callHandler("axios_exec", "DELETE", url, data);
|
|
82
|
+
},
|
|
83
|
+
put: function (url, data) {
|
|
84
|
+
return that.platform.callHandler("axios_exec", "PUT", url, data);
|
|
85
|
+
},
|
|
80
86
|
getAndPreview: function (url, config) {
|
|
81
87
|
if (config == undefined) {
|
|
82
88
|
config = {};
|
package/package.json
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Cpzxrobot, Production } from ".";
|
|
2
|
+
|
|
3
|
+
// 产量统计网关,管理工厂产量数据
|
|
4
|
+
export class ProductionGateway extends Object {
|
|
5
|
+
context: Cpzxrobot;
|
|
6
|
+
|
|
7
|
+
constructor(context: Cpzxrobot) {
|
|
8
|
+
super();
|
|
9
|
+
this.context = context;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 添加产品类型
|
|
14
|
+
* @param productName 产品名称
|
|
15
|
+
*/
|
|
16
|
+
async addType(productName: string): Promise<{ code: number; message: string }> {
|
|
17
|
+
const axios = await this.context.ready;
|
|
18
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
19
|
+
return axios.post('/api/v3/production/add', {
|
|
20
|
+
product_name: productName,
|
|
21
|
+
factory_id: factory.id
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 获取所有产品类型列表
|
|
27
|
+
*/
|
|
28
|
+
async listTypes(): Promise<{ types: Production[] }> {
|
|
29
|
+
const axios = await this.context.ready;
|
|
30
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
31
|
+
return axios.get(`/api/v3/production/list/${factory.id}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 录入产量统计数据
|
|
36
|
+
* @param request 统计请求参数
|
|
37
|
+
*/
|
|
38
|
+
async createStat(request: {
|
|
39
|
+
factory_id?: number;
|
|
40
|
+
time: Date;
|
|
41
|
+
period: number; // 1:月度, 2:季度, 3:年度
|
|
42
|
+
products: Record<number, number>; // 产品名称到产量的映射
|
|
43
|
+
}): Promise<void> {
|
|
44
|
+
if (!request.factory_id) {
|
|
45
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
46
|
+
request.factory_id = factory.id;
|
|
47
|
+
}
|
|
48
|
+
const axios = await this.context.ready;
|
|
49
|
+
return axios.post('/api/v3/production/stat', {
|
|
50
|
+
factory_id: request.factory_id,
|
|
51
|
+
time: request.time.toISOString(),
|
|
52
|
+
period: request.period,
|
|
53
|
+
products: request.products
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 查询产量统计数据
|
|
59
|
+
* @param period 统计周期(month|quater|year)
|
|
60
|
+
* @param factoryId 工厂ID
|
|
61
|
+
*/
|
|
62
|
+
async getStats(period: 'month' | 'quater' | 'year', factoryId?: number): Promise<Array<{
|
|
63
|
+
time: string;
|
|
64
|
+
products: Record<number, number>;
|
|
65
|
+
}>> {
|
|
66
|
+
if (!factoryId) {
|
|
67
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
68
|
+
factoryId = factory.id;
|
|
69
|
+
}
|
|
70
|
+
const axios = await this.context.ready;
|
|
71
|
+
return axios.get('/api/v3/production/stat', {
|
|
72
|
+
params: {
|
|
73
|
+
period,
|
|
74
|
+
factory_id: factoryId
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
package/types.d.ts
CHANGED
|
@@ -263,6 +263,11 @@ type FeedTowerV2 = {
|
|
|
263
263
|
buildTime: string;
|
|
264
264
|
};
|
|
265
265
|
|
|
266
|
+
type Production = {
|
|
267
|
+
id: number;
|
|
268
|
+
name: string;
|
|
269
|
+
};
|
|
270
|
+
|
|
266
271
|
type FeedTower = {
|
|
267
272
|
id: number;
|
|
268
273
|
name: string;
|
|
@@ -284,6 +289,7 @@ type FeedTower = {
|
|
|
284
289
|
interface MyAxiosInstance {
|
|
285
290
|
get: (url: string, config?: any) => Promise<any>;
|
|
286
291
|
post: (url: string, data?: any, config?: any) => Promise<any>;
|
|
292
|
+
put: (url: string, data?: any, config?: any) => Promise<any>;
|
|
287
293
|
getAndSave: (url: string, data?: {
|
|
288
294
|
fileName?: string;
|
|
289
295
|
params?: any;
|
|
@@ -302,6 +308,7 @@ interface MyAxiosInstance {
|
|
|
302
308
|
//option.data:上传的数据,例如{id:123,name:"xxx"},文件会被附加到data中,作为文件字段上传
|
|
303
309
|
upload: (url: string, option?: {}) => Promise<any>;
|
|
304
310
|
getAsSse: (url: string, fn: any, config?: any) => Promise<any>;
|
|
311
|
+
delete: (url: string, data?: any, config?: any) => Promise<any>;
|
|
305
312
|
}
|
|
306
313
|
|
|
307
314
|
interface Assistant {
|
|
@@ -315,6 +322,19 @@ interface ElectricMeter extends Device {
|
|
|
315
322
|
status: string;
|
|
316
323
|
}
|
|
317
324
|
|
|
325
|
+
interface DevicePurpose {
|
|
326
|
+
id?: number;
|
|
327
|
+
name: string;
|
|
328
|
+
code: string;
|
|
329
|
+
parts?: string[];
|
|
330
|
+
faultCategories?: string[];
|
|
331
|
+
isImportant?: boolean;
|
|
332
|
+
importantParams?: string;
|
|
333
|
+
parentId?: number;
|
|
334
|
+
path?: string;
|
|
335
|
+
children?: DevicePurpose[];
|
|
336
|
+
}
|
|
337
|
+
|
|
318
338
|
interface DataQueryArgs {
|
|
319
339
|
start?: string;
|
|
320
340
|
stop?: string;
|
|
@@ -362,6 +382,7 @@ class Cpzxrobot {
|
|
|
362
382
|
system: SystemGateway;
|
|
363
383
|
dict: (key: string) => any;
|
|
364
384
|
platform: PlatformInterface;
|
|
385
|
+
production: ProductionGateway;
|
|
365
386
|
// _getSelectedFarmFromMiniApp: () => Promise<Factory>;
|
|
366
387
|
// _getSelectedUnitFromMiniApp: () => Promise<Unit>;
|
|
367
388
|
openMiniApp: (url: string) => void;
|
|
@@ -431,6 +452,7 @@ declare module "@cpzxrobot/sdk" {
|
|
|
431
452
|
DeviceV2,
|
|
432
453
|
FieldDatas,
|
|
433
454
|
SensorDatas,
|
|
434
|
-
ElectricMeterRate
|
|
455
|
+
ElectricMeterRate,
|
|
456
|
+
DevicePurpose,
|
|
435
457
|
};
|
|
436
458
|
}
|
package/web_platform.ts
CHANGED
|
@@ -132,6 +132,24 @@ export class WebPlatform implements PlatformInterface {
|
|
|
132
132
|
return response.blob();
|
|
133
133
|
}
|
|
134
134
|
},
|
|
135
|
+
delete: async (url: string, data?: any, config?: any) => {
|
|
136
|
+
const response = await this.fetchWithAuth(url, {
|
|
137
|
+
method: 'DELETE',
|
|
138
|
+
headers: config?.headers
|
|
139
|
+
});
|
|
140
|
+
return { data: await response.json() };
|
|
141
|
+
},
|
|
142
|
+
put: async (url: string, data?: any, config?: any) => {
|
|
143
|
+
const response = await this.fetchWithAuth(url, {
|
|
144
|
+
method: 'PUT',
|
|
145
|
+
headers: {
|
|
146
|
+
'Content-Type': 'application/json',
|
|
147
|
+
...config?.headers
|
|
148
|
+
},
|
|
149
|
+
body: JSON.stringify(data)
|
|
150
|
+
});
|
|
151
|
+
return { data: await response.json() };
|
|
152
|
+
},
|
|
135
153
|
post: async (url: string, data?: any, config?: any) => {
|
|
136
154
|
const response = await this.fetchWithAuth(url, {
|
|
137
155
|
method: 'POST',
|