@cpzxrobot/sdk 1.0.58 → 1.0.60

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DeviceTypeGateway } from "./device_type_gateway";
2
2
  import { DeviceFilter } from "./device_filter";
3
- import type { ElectricMeter, Cpzxrobot, DataQueryArgs } from ".";
3
+ import type { ElectricMeter, Cpzxrobot, DataQueryArgs, DeviceV2, Unit } from ".";
4
4
  import { FeedTowerGateway } from "./device_types/feedtower";
5
5
  import { ElectricMeterGateway } from "./device_types/electricmeter";
6
6
  import { NormalGateway } from "./device_types/normal_type";
@@ -16,6 +16,42 @@ export class DeviceGateway extends Object {
16
16
  public normalFilter: NormalGateway;
17
17
  context: Cpzxrobot;
18
18
 
19
+ get v2() {
20
+ return {
21
+ update: async (data: DeviceV2) => {
22
+ let axios = await this.context.ready;
23
+
24
+ return axios.post(`/api/v2/device/update`, data).then((res) => {
25
+ return res.data;
26
+ });
27
+ },
28
+
29
+ add: async (data: DeviceV2) => {
30
+ let axios = await this.context.ready;
31
+
32
+ return axios.post(`/api/v2/device/add`, data).then((res) => {
33
+ return res.data;
34
+ });
35
+ },
36
+
37
+ delete: async (id: number) => {
38
+ let axios = await this.context.ready;
39
+
40
+ return axios.post(`/api/v2/device/delete?id=${id}`).then((res) => {
41
+ return res.data;
42
+ });
43
+ },
44
+
45
+ list: async (unit:Unit) => {
46
+ let axios = await this.context.ready;
47
+
48
+ return axios.get(`/api/v2/device/list/${unit.id}`).then((res) => {
49
+ return res.data;
50
+ });
51
+ },
52
+ };
53
+ }
54
+
19
55
  constructor(context: Cpzxrobot) {
20
56
  super();
21
57
  this.context = context;
@@ -98,6 +134,6 @@ export class DeviceGateway extends Object {
98
134
  type: "diffPerDay", // diffPerDay, sumPerDay, latest
99
135
  }
100
136
  ) {
101
- return this.normalFilter.getData(id,args);
137
+ return this.normalFilter.getData(id, args);
102
138
  }
103
139
  }
@@ -10,6 +10,34 @@ const normal_type_1 = require("./device_types/normal_type");
10
10
  // shzx.device.feedTower: 料塔设备的数据获取网关
11
11
  // shzx.device.electricMeter:电表设备的数据获取网关
12
12
  class DeviceGateway extends Object {
13
+ get v2() {
14
+ return {
15
+ update: async (data) => {
16
+ let axios = await this.context.ready;
17
+ return axios.post(`/api/v2/device/update`, data).then((res) => {
18
+ return res.data;
19
+ });
20
+ },
21
+ add: async (data) => {
22
+ let axios = await this.context.ready;
23
+ return axios.post(`/api/v2/device/add`, data).then((res) => {
24
+ return res.data;
25
+ });
26
+ },
27
+ delete: async (id) => {
28
+ let axios = await this.context.ready;
29
+ return axios.post(`/api/v2/device/delete?id=${id}`).then((res) => {
30
+ return res.data;
31
+ });
32
+ },
33
+ list: async (unit) => {
34
+ let axios = await this.context.ready;
35
+ return axios.get(`/api/v2/device/list/${unit.id}`).then((res) => {
36
+ return res.data;
37
+ });
38
+ },
39
+ };
40
+ }
13
41
  constructor(context) {
14
42
  super();
15
43
  this.context = context;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.58",
3
+ "version": "1.0.60",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -78,6 +78,10 @@ baseURL: "/"
78
78
  | cpzxrobot().device.data | 获得设备的数据,该接口用于获取单个设备的详细数据 |
79
79
  | cpzxrobot().device.feedTower.list | 获得料塔设备的列表 |
80
80
  | cpzxrobot().device.xxx | 获得设备的相关信息 |
81
+ | cpzxrobot().device.v2.add | 新增设备(仅限v2设备) |
82
+ | cpzxrobot().device.v2.update | 更新设备(仅限v2设备) |
83
+ | cpzxrobot().device.v2.list | 删除设备(仅限v2设备) |
84
+ | cpzxrobot().device.v2.delete | 删除设备(仅限v2设备) |
81
85
  | cpzxrobot().camera.xxx | 获得摄像头的相关信息 |
82
86
  | cpzxrobot().factory.entry| 获得工厂的可显示动态信息 |
83
87
  | cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
package/types.d.ts CHANGED
@@ -168,6 +168,28 @@ type WeightMeterSensor = {
168
168
  deviceId: number;
169
169
  };
170
170
 
171
+ // {
172
+ //     "id":1,
173
+ //     "name":"qeq",
174
+ //     "category":"wqe",
175
+ //     "type":"111",
176
+ //     "unitId":123123,
177
+ //     "realDeviceId":123123,
178
+ //     "location":"222",
179
+ //     "supplier":"23132"
180
+ // }
181
+ //新版设备类型,后续可能还会添加新的属性
182
+ type DeviceV2 = {
183
+ id: number;
184
+ name: string;
185
+ category?: string;
186
+ type?: string;
187
+ unitId?: number;
188
+ realDeviceId?: number;
189
+ location?: string;
190
+ supplier?: string;
191
+ };
192
+
171
193
  export type FeedTower = {
172
194
  id: number;
173
195
  name: string;
@@ -287,5 +309,6 @@ declare module "@cpzxrobot/sdk" {
287
309
  DeviceConfig,
288
310
  DataQueryArgs,
289
311
  HeatLamp,
312
+ DeviceV2,
290
313
  };
291
314
  }