@cpzxrobot/sdk 1.3.109 → 1.3.112
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 +23 -0
- package/dist/device_gateway.js +21 -0
- package/dist/factory_gateway.js +16 -3
- package/dist/mobile_platform.js +0 -5
- package/dist/web_platform.js +7 -2
- package/factory_gateway.ts +13 -2
- package/mobile_platform.ts +0 -4
- package/package.json +1 -1
- package/types.d.ts +14 -12
- package/web_platform.ts +7 -2
package/device_gateway.ts
CHANGED
|
@@ -154,6 +154,29 @@ export class DeviceGateway extends Object {
|
|
|
154
154
|
});
|
|
155
155
|
},
|
|
156
156
|
|
|
157
|
+
export: async (params: any = undefined) => {
|
|
158
|
+
let axios = await this.context.ready;
|
|
159
|
+
var url = `/api/v2/device/list/export`;
|
|
160
|
+
if (params) {
|
|
161
|
+
//if params is string
|
|
162
|
+
if (typeof params === "string") {
|
|
163
|
+
url = `/api/v2/device/list/export?${params}`;
|
|
164
|
+
}
|
|
165
|
+
// if params is object
|
|
166
|
+
else {
|
|
167
|
+
url = `/api/v2/device/list/export?${Object.keys(params)
|
|
168
|
+
.map((key) => `${key}=${params[key]}`)
|
|
169
|
+
.join("&")}`;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return axios.getAndSave(url, {
|
|
174
|
+
params: params,
|
|
175
|
+
}).then((res) => {
|
|
176
|
+
return res.data;
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
|
|
157
180
|
preview: async (type: String, sn: any) => {
|
|
158
181
|
let axios = await this.context.ready;
|
|
159
182
|
|
package/dist/device_gateway.js
CHANGED
|
@@ -99,6 +99,27 @@ class DeviceGateway extends Object {
|
|
|
99
99
|
return res.data;
|
|
100
100
|
});
|
|
101
101
|
}),
|
|
102
|
+
export: (...args_1) => __awaiter(this, [...args_1], void 0, function* (params = undefined) {
|
|
103
|
+
let axios = yield this.context.ready;
|
|
104
|
+
var url = `/api/v2/device/list/export`;
|
|
105
|
+
if (params) {
|
|
106
|
+
//if params is string
|
|
107
|
+
if (typeof params === "string") {
|
|
108
|
+
url = `/api/v2/device/list/export?${params}`;
|
|
109
|
+
}
|
|
110
|
+
// if params is object
|
|
111
|
+
else {
|
|
112
|
+
url = `/api/v2/device/list/export?${Object.keys(params)
|
|
113
|
+
.map((key) => `${key}=${params[key]}`)
|
|
114
|
+
.join("&")}`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return axios.getAndSave(url, {
|
|
118
|
+
params: params,
|
|
119
|
+
}).then((res) => {
|
|
120
|
+
return res.data;
|
|
121
|
+
});
|
|
122
|
+
}),
|
|
102
123
|
preview: (type, sn) => __awaiter(this, void 0, void 0, function* () {
|
|
103
124
|
let axios = yield this.context.ready;
|
|
104
125
|
return axios.get(`/api/v2/device/iotValue/${type}/${sn}`).then((res) => {
|
package/dist/factory_gateway.js
CHANGED
|
@@ -85,10 +85,10 @@ class FactoryGateway extends Object {
|
|
|
85
85
|
return axios.post("/api/v2/factory/role/delete?id=" + roleId);
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
users(
|
|
89
|
-
return __awaiter(this,
|
|
88
|
+
users(id_1) {
|
|
89
|
+
return __awaiter(this, arguments, void 0, function* (id, scope = "current") {
|
|
90
90
|
var axios = yield this.context.ready;
|
|
91
|
-
return axios.get("/api/v2/factory/" + id + "/users");
|
|
91
|
+
return axios.get("/api/v2/factory/" + id + "/users?scope=" + scope);
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
//获得工厂的车间信息
|
|
@@ -117,6 +117,19 @@ class FactoryGateway extends Object {
|
|
|
117
117
|
}),
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
+
get(id) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
var axios = yield this.context.ready;
|
|
123
|
+
const response = yield axios.get(`/api/v1/factory/${id}`);
|
|
124
|
+
const body = response.data;
|
|
125
|
+
if (body.Error) {
|
|
126
|
+
throw new Error(body.Error);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return body;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
120
133
|
//获得工厂的基础信息,城市,省份,建造信息等
|
|
121
134
|
get info() {
|
|
122
135
|
return {
|
package/dist/mobile_platform.js
CHANGED
|
@@ -116,11 +116,6 @@ class MobilePlatform {
|
|
|
116
116
|
return this.platform.callHandler("getSelectedFarmFromMiniApp");
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
setSelectedFarmFromMiniApp(farmId) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
return this.platform.callHandler("setSelectedFarmFromMiniApp", farmId);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
119
|
getSelectedUnitFromMiniApp() {
|
|
125
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
121
|
return this.platform.callHandler("getSelectedUnitFromMiniApp");
|
package/dist/web_platform.js
CHANGED
|
@@ -43,13 +43,18 @@ class WebPlatform {
|
|
|
43
43
|
}
|
|
44
44
|
setSelectedFarm(farm) {
|
|
45
45
|
if (typeof farm === 'number') {
|
|
46
|
-
this.
|
|
46
|
+
return this.context.factory.get(farm).then((f) => {
|
|
47
|
+
this._selectedFarm = f;
|
|
48
|
+
//保存到本地缓存
|
|
49
|
+
localStorage.setItem("selectedFarm", JSON.stringify(this._selectedFarm));
|
|
50
|
+
return Promise.resolve(true);
|
|
51
|
+
});
|
|
47
52
|
}
|
|
48
53
|
else {
|
|
49
54
|
this._selectedFarm = farm;
|
|
50
55
|
}
|
|
51
56
|
//保存到本地缓存
|
|
52
|
-
localStorage.setItem("selectedFarm", JSON.stringify(
|
|
57
|
+
localStorage.setItem("selectedFarm", JSON.stringify(this._selectedFarm));
|
|
53
58
|
return Promise.resolve(true);
|
|
54
59
|
}
|
|
55
60
|
setSelectedUnit(unit) {
|
package/factory_gateway.ts
CHANGED
|
@@ -70,9 +70,9 @@ export class FactoryGateway extends Object {
|
|
|
70
70
|
return axios.post("/api/v2/factory/role/delete?id=" + roleId);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
async users(id: number) {
|
|
73
|
+
async users(id: number, scope: "current" | "parents" | "children" = "current") {
|
|
74
74
|
var axios = await this.context.ready;
|
|
75
|
-
return axios.get("/api/v2/factory/" + id+"/users");
|
|
75
|
+
return axios.get("/api/v2/factory/" + id+"/users?scope=" + scope);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
//获得工厂的车间信息
|
|
@@ -102,6 +102,17 @@ export class FactoryGateway extends Object {
|
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
async get(id: number): Promise<Factory> {
|
|
106
|
+
var axios = await this.context.ready;
|
|
107
|
+
const response = await axios.get(`/api/v1/factory/${id}`);
|
|
108
|
+
const body = response.data;
|
|
109
|
+
if (body.Error) {
|
|
110
|
+
throw new Error(body.Error);
|
|
111
|
+
}else{
|
|
112
|
+
return body as Factory;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
105
116
|
//获得工厂的基础信息,城市,省份,建造信息等
|
|
106
117
|
get info() {
|
|
107
118
|
return {
|
package/mobile_platform.ts
CHANGED
|
@@ -118,10 +118,6 @@ export class MobilePlatform implements PlatformInterface {
|
|
|
118
118
|
return this.platform.callHandler("getSelectedFarmFromMiniApp");
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
async setSelectedFarmFromMiniApp(farmId: number): Promise<boolean> {
|
|
122
|
-
return this.platform.callHandler("setSelectedFarmFromMiniApp", farmId);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
121
|
async getSelectedUnitFromMiniApp(): Promise<any> {
|
|
126
122
|
return this.platform.callHandler("getSelectedUnitFromMiniApp");
|
|
127
123
|
}
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -371,6 +371,20 @@ interface DataQueryArgs {
|
|
|
371
371
|
aggerate?: string;
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* 设备告警统计响应接口
|
|
378
|
+
*/
|
|
379
|
+
interface DeviceAlarmStatsResponse {
|
|
380
|
+
/** 响应码 */
|
|
381
|
+
code: number;
|
|
382
|
+
/** 告警统计数据 */
|
|
383
|
+
data: DeviceAlarmStats;
|
|
384
|
+
/** 响应消息 */
|
|
385
|
+
message: string;
|
|
386
|
+
}
|
|
387
|
+
|
|
374
388
|
/**
|
|
375
389
|
* 设备告警统计数据接口
|
|
376
390
|
*/
|
|
@@ -389,18 +403,6 @@ interface DeviceAlarmStats {
|
|
|
389
403
|
maxResolveId: number;
|
|
390
404
|
}
|
|
391
405
|
|
|
392
|
-
/**
|
|
393
|
-
* 设备告警统计响应接口
|
|
394
|
-
*/
|
|
395
|
-
interface DeviceAlarmStatsResponse {
|
|
396
|
-
/** 响应码 */
|
|
397
|
-
code: number;
|
|
398
|
-
/** 告警统计数据 */
|
|
399
|
-
data: DeviceAlarmStats;
|
|
400
|
-
/** 响应消息 */
|
|
401
|
-
message: string;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
406
|
/**
|
|
405
407
|
* 设备报警统计列表项接口
|
|
406
408
|
*/
|
package/web_platform.ts
CHANGED
|
@@ -39,12 +39,17 @@ export class WebPlatform implements PlatformInterface {
|
|
|
39
39
|
}
|
|
40
40
|
setSelectedFarm(farm: Factory|number): Promise<boolean> {
|
|
41
41
|
if (typeof farm === 'number') {
|
|
42
|
-
this.
|
|
42
|
+
return this.context.factory.get(farm).then((f:Factory) => {
|
|
43
|
+
this._selectedFarm = f;
|
|
44
|
+
//保存到本地缓存
|
|
45
|
+
localStorage.setItem("selectedFarm", JSON.stringify(this._selectedFarm));
|
|
46
|
+
return Promise.resolve(true);
|
|
47
|
+
});
|
|
43
48
|
} else {
|
|
44
49
|
this._selectedFarm = farm;
|
|
45
50
|
}
|
|
46
51
|
//保存到本地缓存
|
|
47
|
-
localStorage.setItem("selectedFarm", JSON.stringify(
|
|
52
|
+
localStorage.setItem("selectedFarm", JSON.stringify(this._selectedFarm));
|
|
48
53
|
return Promise.resolve(true);
|
|
49
54
|
}
|
|
50
55
|
setSelectedUnit(unit: Unit): void {
|