@cpzxrobot/sdk 1.3.42 → 1.3.44
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 +11 -5
- package/dist/device_gateway.js +12 -5
- package/package.json +1 -1
- package/types.d.ts +3 -3
package/device_gateway.ts
CHANGED
|
@@ -211,11 +211,17 @@ export class DeviceGateway extends Object {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
async watch(
|
|
214
|
-
|
|
214
|
+
ids: number|number[],
|
|
215
215
|
fn: any,
|
|
216
216
|
) {
|
|
217
217
|
var axios = await this.context.ready;
|
|
218
|
-
|
|
218
|
+
var idQuery = "";
|
|
219
|
+
if (Array.isArray(ids)) {
|
|
220
|
+
idQuery = ids.map(x => `ids=${x}`).join("&");
|
|
221
|
+
}else{
|
|
222
|
+
idQuery = `ids=${ids}`;
|
|
223
|
+
}
|
|
224
|
+
return axios.getAsSse(`/api/v1/device/watch?`+idQuery, fn)
|
|
219
225
|
}
|
|
220
226
|
|
|
221
227
|
private getFilter<T extends { id: number }>(
|
|
@@ -977,7 +983,7 @@ export class DeviceGateway extends Object {
|
|
|
977
983
|
return {
|
|
978
984
|
openDoor: async (deviceId: number,door: "doora" | "doorb", open: boolean) => {
|
|
979
985
|
var axios = await this.context.ready;
|
|
980
|
-
return axios.post(`/api/v2/
|
|
986
|
+
return axios.post(`/api/v2/disinfect/${deviceId}`, { door, open })
|
|
981
987
|
},
|
|
982
988
|
config: async (deviceId: number, config: {
|
|
983
989
|
mode?: number; // 0:没有消毒 1:高温消毒 2:臭氧消毒 3:高温+臭氧
|
|
@@ -986,13 +992,13 @@ export class DeviceGateway extends Object {
|
|
|
986
992
|
targetOzone?: number; // 目标臭氧浓度
|
|
987
993
|
}) => {
|
|
988
994
|
let axios = await this.context.ready;
|
|
989
|
-
return axios.post(`/api/v2/
|
|
995
|
+
return axios.post(`/api/v2/disinfect/${deviceId}`, config).then((res) => {
|
|
990
996
|
return res.data;
|
|
991
997
|
});
|
|
992
998
|
},
|
|
993
999
|
history: async (deviceId: number, pageNum:number,pageSize:number) => {
|
|
994
1000
|
let axios = await this.context.ready;
|
|
995
|
-
return axios.get(`/api/v2/
|
|
1001
|
+
return axios.get(`/api/v2/disinfect/${deviceId}`, { params: { pageNum, pageSize } }).then((res) => {
|
|
996
1002
|
return res.data;
|
|
997
1003
|
});
|
|
998
1004
|
}
|
package/dist/device_gateway.js
CHANGED
|
@@ -168,9 +168,16 @@ class DeviceGateway extends Object {
|
|
|
168
168
|
show(id, type = "datapoint") {
|
|
169
169
|
this.context.platform.showInDeviceManager(id, type);
|
|
170
170
|
}
|
|
171
|
-
async watch(
|
|
171
|
+
async watch(ids, fn) {
|
|
172
172
|
var axios = await this.context.ready;
|
|
173
|
-
|
|
173
|
+
var idQuery = "";
|
|
174
|
+
if (Array.isArray(ids)) {
|
|
175
|
+
idQuery = ids.map(x => `ids=${x}`).join("&");
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
idQuery = `ids=${ids}`;
|
|
179
|
+
}
|
|
180
|
+
return axios.getAsSse(`/api/v1/device/watch?` + idQuery, fn);
|
|
174
181
|
}
|
|
175
182
|
getFilter(type, cls) {
|
|
176
183
|
// 如果filters中已经有对应type的过滤器,则直接返回该过滤器
|
|
@@ -744,17 +751,17 @@ class DeviceGateway extends Object {
|
|
|
744
751
|
return {
|
|
745
752
|
openDoor: async (deviceId, door, open) => {
|
|
746
753
|
var axios = await this.context.ready;
|
|
747
|
-
return axios.post(`/api/v2/
|
|
754
|
+
return axios.post(`/api/v2/disinfect/${deviceId}`, { door, open });
|
|
748
755
|
},
|
|
749
756
|
config: async (deviceId, config) => {
|
|
750
757
|
let axios = await this.context.ready;
|
|
751
|
-
return axios.post(`/api/v2/
|
|
758
|
+
return axios.post(`/api/v2/disinfect/${deviceId}`, config).then((res) => {
|
|
752
759
|
return res.data;
|
|
753
760
|
});
|
|
754
761
|
},
|
|
755
762
|
history: async (deviceId, pageNum, pageSize) => {
|
|
756
763
|
let axios = await this.context.ready;
|
|
757
|
-
return axios.get(`/api/v2/
|
|
764
|
+
return axios.get(`/api/v2/disinfect/${deviceId}`, { params: { pageNum, pageSize } }).then((res) => {
|
|
758
765
|
return res.data;
|
|
759
766
|
});
|
|
760
767
|
}
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ type Device = {
|
|
|
33
33
|
currentAmount: number;
|
|
34
34
|
location: string;
|
|
35
35
|
supplier?: string;
|
|
36
|
-
data?:
|
|
36
|
+
data?: any;
|
|
37
37
|
typeCode: string;
|
|
38
38
|
unitId: number;
|
|
39
39
|
};
|
|
@@ -87,9 +87,9 @@ type Assistant = {
|
|
|
87
87
|
id: Number;
|
|
88
88
|
};
|
|
89
89
|
type Factory = {
|
|
90
|
-
code
|
|
90
|
+
code?: string;
|
|
91
91
|
name?: string;
|
|
92
|
-
company_code
|
|
92
|
+
company_code?: string;
|
|
93
93
|
id?: number;
|
|
94
94
|
type?: string;
|
|
95
95
|
kind?: string;
|