@cpzxrobot/sdk 1.0.57 → 1.0.59

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;
@@ -86,7 +86,7 @@ class PigfarmGateway extends Object {
86
86
  //获取仪表列表,
87
87
  list: (factory) => {
88
88
  return this.context.ready.then((axios) => {
89
- return axios.get(`/api/v2/pigfarm/relay/weightMeter/list/${factory.id}`);
89
+ return axios.get(`/api/v2/pigfarm/weightMeter/list/${factory.id}`);
90
90
  });
91
91
  },
92
92
  //获取仪表下的所有传感器,这里获得的都是已绑定的
@@ -97,13 +97,19 @@ class PigfarmGateway extends Object {
97
97
  },
98
98
  add: (data) => {
99
99
  return this.context.ready.then((axios) => {
100
- return axios.post(`/api/v2/pigfarm/relay/weightMeter/add`, data);
100
+ return axios.post(`/api/v2/pigfarm/weightMeter/add`, data);
101
+ });
102
+ },
103
+ //按料塔获取仪表信息
104
+ getByFt: (deviceId) => {
105
+ return this.context.ready.then((axios) => {
106
+ return axios.get(`/api/v2/pigfarm/weightMeterSensor/config/by-ft/${deviceId}`);
101
107
  });
102
108
  },
103
109
  //更新仪表信息
104
110
  update: (data) => {
105
111
  return this.context.ready.then((axios) => {
106
- return axios.post(`/api/v2/pigfarm/relay/weightMeter/update`, data);
112
+ return axios.post(`/api/v2/pigfarm/weightMeter/update`, data);
107
113
  });
108
114
  },
109
115
  updateSensor: (data) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.57",
3
+ "version": "1.0.59",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -106,7 +106,7 @@ export class PigfarmGateway extends Object {
106
106
  list: (factory: Factory) => {
107
107
  return this.context.ready.then((axios) => {
108
108
  return axios.get(
109
- `/api/v2/pigfarm/relay/weightMeter/list/${factory.id}`
109
+ `/api/v2/pigfarm/weightMeter/list/${factory.id}`
110
110
  );
111
111
  });
112
112
  },
@@ -120,13 +120,21 @@ export class PigfarmGateway extends Object {
120
120
  },
121
121
  add: (data: WeightMeter) => {
122
122
  return this.context.ready.then((axios) => {
123
- return axios.post(`/api/v2/pigfarm/relay/weightMeter/add`, data);
123
+ return axios.post(`/api/v2/pigfarm/weightMeter/add`, data);
124
+ });
125
+ },
126
+ //按料塔获取仪表信息
127
+ getByFt: (deviceId: number) => {
128
+ return this.context.ready.then((axios) => {
129
+ return axios.get(
130
+ `/api/v2/pigfarm/weightMeterSensor/config/by-ft/${deviceId}`
131
+ );
124
132
  });
125
133
  },
126
134
  //更新仪表信息
127
135
  update: (data: any) => {
128
136
  return this.context.ready.then((axios) => {
129
- return axios.post(`/api/v2/pigfarm/relay/weightMeter/update`, data);
137
+ return axios.post(`/api/v2/pigfarm/weightMeter/update`, data);
130
138
  });
131
139
  },
132
140
  updateSensor: (data: any) => {
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
  }