@cpzxrobot/sdk 1.0.66 → 1.0.69

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/camera_gateway.ts CHANGED
@@ -60,11 +60,12 @@ export class CameraGateway extends Object {
60
60
  | "up"
61
61
  | "down"
62
62
  | "zoom_in"
63
- | "zoom_out"
63
+ | "zoom_out",
64
+ start: boolean = true
64
65
  ): Promise<any> {
65
66
  var axios = await this.context.ready;
66
67
  const response = await axios.get(
67
- `/api/v1/camera/${data.id}/control/${action}`
68
+ `/api/v1/camera/${data.id}/control/${action}?start=${start}`
68
69
  );
69
70
  return response.data;
70
71
  }
@@ -139,14 +139,50 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
139
139
  alertDays: number[];
140
140
  }
141
141
  ) {
142
- return this.context.axios.post(`/api/v2/device/config/feedTowerAlert/update`, {
143
- deviceId,
144
- config: param,
145
- });
142
+ return this.context.axios.post(
143
+ `/api/v2/device/config/feedTowerAlert/update`,
144
+ {
145
+ deviceId,
146
+ config: param,
147
+ }
148
+ );
146
149
  }
147
150
 
148
151
  //获取报警参数
149
152
  async getAlarmParam(deviceId: number) {
150
- return this.context.axios.get(`/api/v2/device/config/feedTowerAlert/${deviceId}`);
153
+ return this.context.axios.get(
154
+ `/api/v2/device/config/feedTowerAlert/${deviceId}`
155
+ );
156
+ }
157
+
158
+ //新版料塔列表功能,id为工厂id
159
+ v2() {
160
+ return {
161
+ list: async (
162
+ options:
163
+ | undefined
164
+ | {
165
+ id?: Number | null | undefined; //工厂id
166
+ data?:
167
+ | "diffPerDay"
168
+ | "sumPerDay"
169
+ | "latest"
170
+ | "weekoverweek"
171
+ | "last"
172
+ | "rangeOfDay"
173
+ | "rangeToday"
174
+ | null; //如果data为null,则不获取数据,只获取设备列表,否则获取设备列表和数据
175
+ status?: string;
176
+ unit?: Number;
177
+ detail?: boolean;
178
+ type?: string;
179
+ supplier?: string; //供应商,可用于过滤设备
180
+ } = undefined
181
+ ) => {
182
+ return this.context.axios.get(
183
+ `/api/v2/device/feedTower/list/${options?.id}`
184
+ );
185
+ },
186
+ };
151
187
  }
152
188
  }
@@ -32,9 +32,9 @@ class CameraGateway extends Object {
32
32
  const response = await axios.get(`/api/v1/weather?code=${id}`);
33
33
  return response.data;
34
34
  }
35
- async control(data, action) {
35
+ async control(data, action, start = true) {
36
36
  var axios = await this.context.ready;
37
- const response = await axios.get(`/api/v1/camera/${data.id}/control/${action}`);
37
+ const response = await axios.get(`/api/v1/camera/${data.id}/control/${action}?start=${start}`);
38
38
  return response.data;
39
39
  }
40
40
  }
@@ -116,5 +116,13 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
116
116
  async getAlarmParam(deviceId) {
117
117
  return this.context.axios.get(`/api/v2/device/config/feedTowerAlert/${deviceId}`);
118
118
  }
119
+ //新版料塔列表功能,id为工厂id
120
+ v2() {
121
+ return {
122
+ list: async (options = undefined) => {
123
+ return this.context.axios.get(`/api/v2/device/feedTower/list/${options === null || options === void 0 ? void 0 : options.id}`);
124
+ },
125
+ };
126
+ }
119
127
  }
120
128
  exports.FeedTowerGateway = FeedTowerGateway;
@@ -89,22 +89,77 @@ class PigfarmGateway extends Object {
89
89
  return axios.get(`/api/v2/pigfarm/weightMeter/list/${factory.id}`);
90
90
  });
91
91
  },
92
- //获取仪表下的所有传感器,这里获得的都是已绑定的
93
- sensors: (weightMeterId) => {
94
- return this.context.ready.then((axios) => {
95
- return axios.get(`/api/v2/pigfarm/weightMeterSensor/config/list/${weightMeterId}`);
96
- });
97
- },
98
92
  add: (data) => {
99
93
  return this.context.ready.then((axios) => {
100
94
  return axios.post(`/api/v2/pigfarm/weightMeter/add`, data);
101
95
  });
102
96
  },
103
- //按料塔获取仪表信息
104
- getByFt: (deviceId) => {
105
- return this.context.ready.then((axios) => {
106
- return axios.get(`/api/v2/pigfarm/weightMeterSensor/config/by-ft/${deviceId}`);
107
- });
97
+ config: () => {
98
+ return {
99
+ //获取仪表下的所有通道配置,这里获得的都是已绑定的
100
+ list: (weightMeterId) => {
101
+ return this.context.ready.then((axios) => {
102
+ return axios.get(`/api/v2/pigfarm/weightMeter/config/list/${weightMeterId}`);
103
+ });
104
+ },
105
+ //按料塔获取仪表信息
106
+ getByFt: (deviceId) => {
107
+ return this.context.ready.then((axios) => {
108
+ return axios.get(`/api/v2/pigfarm/weightMeter/config/by-ft/${deviceId}`);
109
+ });
110
+ },
111
+ updateSensor: (data) => {
112
+ return this.context.ready.then((axios) => {
113
+ return axios.post(`/api/v2/pigfarm/weightMeter/config/update`, data);
114
+ });
115
+ },
116
+ //首先创建料塔,然后绑定传感器,绑定时需要传入料塔设备id和仪表id
117
+ bind: (deviceId, meterId, args) => {
118
+ //检查endValue1和endValue2的长度是否为2
119
+ if (args.endValue1.length !== 2 || args.endValue2.length !== 2) {
120
+ throw new Error("endValue1和endValue2的长度必须为2");
121
+ }
122
+ //检查endValue1的第二个值是否等于endValue2的第一个值
123
+ if (args.endValue1[1] !== args.endValue2[0]) {
124
+ throw new Error("endValue1的第二个值必须等于endValue2的第一个值");
125
+ }
126
+ //检查endValue1的第一个值是否是0,最好界面就限制只能是0
127
+ if (args.endValue1[0] !== 0) {
128
+ throw new Error("endValue1的第一个值必须为0");
129
+ }
130
+ args.deviceId = deviceId;
131
+ args.weightMeterId = meterId;
132
+ return this.context.ready.then((axios) => {
133
+ return axios.post(`/api/v2/pigfarm/weightMeter/config/add`, args);
134
+ });
135
+ },
136
+ };
137
+ },
138
+ sensor: () => {
139
+ return {
140
+ //获取配置对应的传感器列表(这里的传感器不是平台的传感器,而是绑定的实际传感器)
141
+ list: (weightMeterConfigId) => {
142
+ return this.context.ready.then((axios) => {
143
+ return axios.get(`/api/v2/pigfarm/weightSensor/sensor/list/${weightMeterConfigId}`);
144
+ });
145
+ },
146
+ update: (data) => {
147
+ if (!data.weightMeterConfigId) {
148
+ throw new Error("weightMeterConfigId不能为空");
149
+ }
150
+ return this.context.ready.then((axios) => {
151
+ return axios.post(`/api/v2/pigfarm/weightSensor/sensor/saveOrUpdate`, data);
152
+ });
153
+ },
154
+ add: (data) => {
155
+ if (data.weightMeterConfigId) {
156
+ throw new Error("weightMeterConfigId不为空");
157
+ }
158
+ return this.context.ready.then((axios) => {
159
+ return axios.post(`/api/v2/pigfarm/weightSensor/sensor/saveOrUpdate`, data);
160
+ });
161
+ },
162
+ };
108
163
  },
109
164
  //更新仪表信息
110
165
  update: (data) => {
@@ -112,31 +167,6 @@ class PigfarmGateway extends Object {
112
167
  return axios.post(`/api/v2/pigfarm/weightMeter/update`, data);
113
168
  });
114
169
  },
115
- updateSensor: (data) => {
116
- return this.context.ready.then((axios) => {
117
- return axios.post(`/api/v2/pigfarm/weightMeterSensor/config/update`, data);
118
- });
119
- },
120
- //首先创建料塔,然后绑定传感器,绑定时需要传入料塔设备id和仪表id
121
- bind: (deviceId, meterId, args) => {
122
- //检查endValue1和endValue2的长度是否为2
123
- if (args.endValue1.length !== 2 || args.endValue2.length !== 2) {
124
- throw new Error("endValue1和endValue2的长度必须为2");
125
- }
126
- //检查endValue1的第二个值是否等于endValue2的第一个值
127
- if (args.endValue1[1] !== args.endValue2[0]) {
128
- throw new Error("endValue1的第二个值必须等于endValue2的第一个值");
129
- }
130
- //检查endValue1的第一个值是否是0,最好界面就限制只能是0
131
- if (args.endValue1[0] !== 0) {
132
- throw new Error("endValue1的第一个值必须为0");
133
- }
134
- args.deviceId = deviceId;
135
- args.weightMeterId = meterId;
136
- return this.context.ready.then((axios) => {
137
- return axios.post(`/api/v2/pigfarm/weightMeterSensor/config/add`, args);
138
- });
139
- },
140
170
  };
141
171
  }
142
172
  get heatlamp() {
@@ -38,5 +38,26 @@ class UnitGateway extends Object {
38
38
  },
39
39
  };
40
40
  }
41
+ v2() {
42
+ return {
43
+ //新增时必传factoryId, 当上层是workshop时,需要传workshopId
44
+ add: (unit) => {
45
+ return this.context.ready.then((axios) => {
46
+ return axios.post(`/api/v2/unit/add`, unit);
47
+ });
48
+ },
49
+ //新增时必传factoryId, 当上层是workshop时,需要传workshopId
50
+ update: (unit) => {
51
+ return this.context.ready.then((axios) => {
52
+ return axios.post(`/api/v2/unit/update`, unit);
53
+ });
54
+ },
55
+ delete: (unit) => {
56
+ return this.context.ready.then((axios) => {
57
+ return axios.get(`/api/v2/unit/delete?id=${unit.id}`);
58
+ });
59
+ },
60
+ };
61
+ }
41
62
  }
42
63
  exports.UnitGateway = UnitGateway;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.66",
3
+ "version": "1.0.69",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -6,6 +6,7 @@ import {
6
6
  Unit,
7
7
  WeightMeter,
8
8
  WeightMeterSensor,
9
+ weightMeterSensorsConfig,
9
10
  } from ".";
10
11
 
11
12
  export class PigfarmGateway extends Object {
@@ -105,31 +106,100 @@ export class PigfarmGateway extends Object {
105
106
  //获取仪表列表,
106
107
  list: (factory: Factory) => {
107
108
  return this.context.ready.then((axios) => {
108
- return axios.get(
109
- `/api/v2/pigfarm/weightMeter/list/${factory.id}`
110
- );
111
- });
112
- },
113
- //获取仪表下的所有传感器,这里获得的都是已绑定的
114
- sensors: (weightMeterId: number) => {
115
- return this.context.ready.then((axios) => {
116
- return axios.get(
117
- `/api/v2/pigfarm/weightMeterSensor/config/list/${weightMeterId}`
118
- );
109
+ return axios.get(`/api/v2/pigfarm/weightMeter/list/${factory.id}`);
119
110
  });
120
111
  },
112
+
121
113
  add: (data: WeightMeter) => {
122
114
  return this.context.ready.then((axios) => {
123
115
  return axios.post(`/api/v2/pigfarm/weightMeter/add`, data);
124
116
  });
125
117
  },
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
- );
132
- });
118
+ config: () => {
119
+ return {
120
+ //获取仪表下的所有通道配置,这里获得的都是已绑定的
121
+ list: (weightMeterId: number) => {
122
+ return this.context.ready.then((axios) => {
123
+ return axios.get(
124
+ `/api/v2/pigfarm/weightMeter/config/list/${weightMeterId}`
125
+ );
126
+ });
127
+ },
128
+ //按料塔获取仪表信息
129
+ getByFt: (deviceId: number) => {
130
+ return this.context.ready.then((axios) => {
131
+ return axios.get(
132
+ `/api/v2/pigfarm/weightMeter/config/by-ft/${deviceId}`
133
+ );
134
+ });
135
+ },
136
+ updateSensor: (data: any) => {
137
+ return this.context.ready.then((axios) => {
138
+ return axios.post(
139
+ `/api/v2/pigfarm/weightMeter/config/update`,
140
+ data
141
+ );
142
+ });
143
+ },
144
+ //首先创建料塔,然后绑定传感器,绑定时需要传入料塔设备id和仪表id
145
+ bind: (
146
+ deviceId: number,
147
+ meterId: number,
148
+ args: WeightMeterSensor
149
+ ) => {
150
+ //检查endValue1和endValue2的长度是否为2
151
+ if (args.endValue1.length !== 2 || args.endValue2.length !== 2) {
152
+ throw new Error("endValue1和endValue2的长度必须为2");
153
+ }
154
+ //检查endValue1的第二个值是否等于endValue2的第一个值
155
+ if (args.endValue1[1] !== args.endValue2[0]) {
156
+ throw new Error("endValue1的第二个值必须等于endValue2的第一个值");
157
+ }
158
+ //检查endValue1的第一个值是否是0,最好界面就限制只能是0
159
+ if (args.endValue1[0] !== 0) {
160
+ throw new Error("endValue1的第一个值必须为0");
161
+ }
162
+ args.deviceId = deviceId;
163
+ args.weightMeterId = meterId;
164
+ return this.context.ready.then((axios) => {
165
+ return axios.post(`/api/v2/pigfarm/weightMeter/config/add`, args);
166
+ });
167
+ },
168
+ };
169
+ },
170
+ sensor: () => {
171
+ return {
172
+ //获取配置对应的传感器列表(这里的传感器不是平台的传感器,而是绑定的实际传感器)
173
+ list: (weightMeterConfigId: number) => {
174
+ return this.context.ready.then((axios) => {
175
+ return axios.get(
176
+ `/api/v2/pigfarm/weightSensor/sensor/list/${weightMeterConfigId}`
177
+ );
178
+ });
179
+ },
180
+ update: (data: weightMeterSensorsConfig) => {
181
+ if(!data.weightMeterConfigId){
182
+ throw new Error("weightMeterConfigId不能为空");
183
+ }
184
+ return this.context.ready.then((axios) => {
185
+ return axios.post(
186
+ `/api/v2/pigfarm/weightSensor/sensor/saveOrUpdate`,
187
+ data
188
+ );
189
+ });
190
+ },
191
+ add: (data: weightMeterSensorsConfig) => {
192
+ if(data.weightMeterConfigId){
193
+ throw new Error("weightMeterConfigId不为空");
194
+ }
195
+ return this.context.ready.then((axios) => {
196
+ return axios.post(
197
+ `/api/v2/pigfarm/weightSensor/sensor/saveOrUpdate`,
198
+ data
199
+ );
200
+ });
201
+ },
202
+ };
133
203
  },
134
204
  //更新仪表信息
135
205
  update: (data: any) => {
@@ -137,38 +207,6 @@ export class PigfarmGateway extends Object {
137
207
  return axios.post(`/api/v2/pigfarm/weightMeter/update`, data);
138
208
  });
139
209
  },
140
- updateSensor: (data: any) => {
141
- return this.context.ready.then((axios) => {
142
- return axios.post(
143
- `/api/v2/pigfarm/weightMeterSensor/config/update`,
144
- data
145
- );
146
- });
147
- },
148
- //首先创建料塔,然后绑定传感器,绑定时需要传入料塔设备id和仪表id
149
- bind: (
150
- deviceId: number,
151
- meterId: number,
152
- args: WeightMeterSensor
153
- ) => {
154
- //检查endValue1和endValue2的长度是否为2
155
- if (args.endValue1.length !== 2 || args.endValue2.length !== 2) {
156
- throw new Error("endValue1和endValue2的长度必须为2");
157
- }
158
- //检查endValue1的第二个值是否等于endValue2的第一个值
159
- if (args.endValue1[1] !== args.endValue2[0]) {
160
- throw new Error("endValue1的第二个值必须等于endValue2的第一个值");
161
- }
162
- //检查endValue1的第一个值是否是0,最好界面就限制只能是0
163
- if (args.endValue1[0] !== 0) {
164
- throw new Error("endValue1的第一个值必须为0");
165
- }
166
- args.deviceId = deviceId;
167
- args.weightMeterId = meterId;
168
- return this.context.ready.then((axios) => {
169
- return axios.post(`/api/v2/pigfarm/weightMeterSensor/config/add`, args);
170
- });
171
- },
172
210
  };
173
211
  }
174
212
 
package/readme.md CHANGED
@@ -77,6 +77,7 @@ baseURL: "/"
77
77
  | cpzxrobot().device.list | 获得常见设备的列表(当没有特殊类型需求时调用),列表接口提供data参数,可以同步获得多个设备的数据,尽量使用该接口获得设备数据 |
78
78
  | cpzxrobot().device.data | 获得设备的数据,该接口用于获取单个设备的详细数据 |
79
79
  | cpzxrobot().device.feedTower.list | 获得料塔设备的列表 |
80
+ | cpzxrobot().device.feedTower.v2.list | 获得料塔设备的列表(新版),暂不支持v1版本的data等附加参数,只支持按工厂获取 |
80
81
  | cpzxrobot().device.xxx | 获得设备的相关信息 |
81
82
  | cpzxrobot().device.v2.add | 新增设备(仅限v2设备) |
82
83
  | cpzxrobot().device.v2.update | 更新设备(仅限v2设备) |
@@ -86,6 +87,12 @@ baseURL: "/"
86
87
  | cpzxrobot().factory.entry| 获得工厂的可显示动态信息 |
87
88
  | cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
88
89
  | cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
90
+ | cpzxrobot().pigfarm.weightMeter.config.list | 获取称重计的配置信息 |
91
+ | cpzxrobot().pigfarm.weightMeter.config.bind | 添加称重计的配置信息,绑定到料塔 |
92
+ | cpzxrobot().pigfarm.weightMeter.config.update | 更新称重计的配置信息 |
93
+ | cpzxrobot().pigfarm.weightMeter.sensor.list | 获取称重计的传感器列表 |
94
+ | cpzxrobot().pigfarm.weightMeter.sensor.add | 添加称重计的传感器信息 |
95
+ | cpzxrobot().pigfarm.weightMeter.sensor.update | 更新称重计的传感器信息 |
89
96
  | cpzxrobot().device.feedTower.stat | 获得料塔设备的料耗,饲料重量 |
90
97
  | cpzxrobot().device.feedTower.setAlarmParam | 设置料塔设备的报警参数 |
91
98
  | cpzxrobot().device.feedTower.updateAlarmParam | 更新料塔设备的报警参数 |
@@ -95,6 +102,10 @@ baseURL: "/"
95
102
  | cpzxrobot().pigfarm.heatlamp.switch | 设置保温灯的当前工作日龄,调用时,action"on"或"off" |
96
103
  | cpzxrobot().pigfarm.heatlamp.iotFields | 获取保温灯用于获取iot的字段列表 |
97
104
  | cpzxrobot().scanQrcode | 调用扫码功能,获得扫码文字 |
105
+ | cpzxrobot().unit.v2.list | 获得单元列表,v2版本 |
106
+ | cpzxrobot().unit.v2.add | 添加单元,v2版本 |
107
+ | cpzxrobot().unit.v2.update | 更新单元,v2版本 |
108
+ | cpzxrobot().unit.v2.delete | 删除单元,v2版本 |
98
109
 
99
110
 
100
111
  ### 工厂信息接口
package/types.d.ts CHANGED
@@ -78,8 +78,9 @@ type Unit = {
78
78
  id?: number;
79
79
  type?: string;
80
80
  workshopName?: string;
81
+ workshopId?: number;
82
+ factoryId?: number;
81
83
  };
82
-
83
84
  type HeatLamp = {
84
85
  id: number;
85
86
  unitId: number;
@@ -169,6 +170,17 @@ type WeightMeterSensor = {
169
170
  deviceId: number;
170
171
  };
171
172
 
173
+ type weightMeterSensorsConfig = {
174
+ weightMeterConfigId: number;
175
+ sensors: WeightMeterSensor[];
176
+ };
177
+
178
+ type WeightMeterSensor = {
179
+ address: number,
180
+ adzero: number,
181
+ hornScale: number,
182
+ }
183
+
172
184
  // {
173
185
  //     "id":1,
174
186
  //     "name":"qeq",
package/unit_gateway.ts CHANGED
@@ -50,4 +50,28 @@ export class UnitGateway extends Object {
50
50
  },
51
51
  };
52
52
  }
53
+
54
+ v2() {
55
+ return {
56
+ //新增时必传factoryId, 当上层是workshop时,需要传workshopId
57
+ add: (unit: Unit) => {
58
+ return this.context.ready.then((axios) => {
59
+ return axios.post(`/api/v2/unit/add`, unit);
60
+ });
61
+ },
62
+
63
+ //新增时必传factoryId, 当上层是workshop时,需要传workshopId
64
+ update: (unit: Unit) => {
65
+ return this.context.ready.then((axios) => {
66
+ return axios.post(`/api/v2/unit/update`, unit);
67
+ });
68
+ },
69
+
70
+ delete: (unit: Unit) => {
71
+ return this.context.ready.then((axios) => {
72
+ return axios.get(`/api/v2/unit/delete?id=${unit.id}`);
73
+ });
74
+ },
75
+ };
76
+ }
53
77
  }