@cpzxrobot/sdk 1.3.4 → 1.3.5

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.
@@ -2,7 +2,7 @@ import {
2
2
  type FodderOrderList,
3
3
  type FeedTower,
4
4
  type FeedTowerExtraInfo,
5
- type DataQueryArgs,
5
+ type DataQueryArgs,
6
6
  type FeedTowerV2,
7
7
  } from "..";
8
8
  import { DeviceFilter } from "../device_filter";
@@ -14,8 +14,9 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
14
14
  return "FeedTower";
15
15
  }
16
16
 
17
- getDetail(info: FeedTower, id: number) {
18
- return this.context.axios
17
+ async getDetail(info: FeedTower, id: number) {
18
+ var axios = await this.context.ready;
19
+ return axios
19
20
  .post("/api/v1/pigfarm/device/status/detail?deviceId=" + id)
20
21
  .then((res: any) => {
21
22
  if (res.data.code != 200) {
@@ -26,11 +27,12 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
26
27
  });
27
28
  }
28
29
 
29
- wrapData(id: number, args: DataQueryArgs, p1: Promise<any>) {
30
+ async wrapData(id: number, args: DataQueryArgs, p1: Promise<any>) {
30
31
  const ps = [p1];
31
32
  if (!args.ingoreInput) {
33
+ var axios = await this.context.ready;
32
34
  ps.push(
33
- this.context.axios.post(`/api/v1/pigfarm/device/fodder`, {
35
+ axios.post(`/api/v1/pigfarm/device/fodder`, {
34
36
  device: id,
35
37
  times: [args.start, args.stop],
36
38
  })
@@ -54,10 +56,11 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
54
56
  });
55
57
  }
56
58
 
57
- wrapList(list: FeedTower[]): Promise<FeedTower[]> {
59
+ async wrapList(list: FeedTower[]): Promise<FeedTower[]> {
58
60
  const ids = list.map((device) => device.id);
61
+ var axios = await this.context.ready;
59
62
  //TODO 其他设备的详情需要支持,目前只有喂料塔
60
- return this.context.axios
63
+ return axios
61
64
  .post("/api/v1/pigfarm/device/status/list", ids)
62
65
  .then((res: any) => {
63
66
  if (res.data.code != 200) {
@@ -75,14 +78,16 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
75
78
  }
76
79
 
77
80
  async enter(data: FodderOrderList): Promise<any> {
78
- const res = await this.context.axios.post(
81
+ var axios = await this.context.ready;
82
+ const res = await axios.post(
79
83
  "/api/v1/pigfarm/device/fodder/import",
80
84
  data
81
85
  );
82
86
  return res;
83
87
  }
84
88
  async getCar(truck: string): Promise<any> {
85
- const res = await this.context.axios.get("/api/v1/pigfarm/car", {
89
+ var axios = await this.context.ready;
90
+ const res = await axios.get("/api/v1/pigfarm/car", {
86
91
  params: {
87
92
  truckCode: truck,
88
93
  random: 1,
@@ -91,11 +96,13 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
91
96
  return res.data;
92
97
  }
93
98
  async getCarList(): Promise<any> {
94
- const res = await this.context.axios.get("/api/v1/pigfarm/car/list");
99
+ var axios = await this.context.ready;
100
+ const res = await axios.get("/api/v1/pigfarm/car/list");
95
101
  return res.data;
96
102
  }
97
103
  async updateZeroTime(id: Number): Promise<any> {
98
- const res = await this.context.axios.post(
104
+ var axios = await this.context.ready;
105
+ const res = await axios.post(
99
106
  "/api/v1/pigfarm/device/status/updateZeroTime" + "?id=" + id
100
107
  );
101
108
  return res;
@@ -129,7 +136,8 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
129
136
  alertDays: number[];
130
137
  }
131
138
  ) {
132
- return this.context.axios.post(`/api/v2/device/config/feedTowerAlert/add`, {
139
+ var axios = await this.context.ready;
140
+ return axios.post(`/api/v2/device/config/feedTowerAlert/add`, {
133
141
  deviceId,
134
142
  config: param,
135
143
  });
@@ -143,7 +151,8 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
143
151
  alertDays: number[];
144
152
  }
145
153
  ) {
146
- return this.context.axios.post(
154
+ var axios = await this.context.ready;
155
+ return axios.post(
147
156
  `/api/v2/device/config/feedTowerAlert/update`,
148
157
  {
149
158
  deviceId,
@@ -154,7 +163,8 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
154
163
 
155
164
  //获取报警参数
156
165
  async getAlarmParam(deviceId: number) {
157
- return this.context.axios.get(
166
+ var axios = await this.context.ready;
167
+ return axios.get(
158
168
  `/api/v2/device/config/feedTowerAlert/${deviceId}`
159
169
  );
160
170
  }
@@ -183,24 +193,29 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
183
193
  supplier?: string; //供应商,可用于过滤设备
184
194
  } = undefined
185
195
  ) => {
186
- return this.context.axios.get(
196
+ var axios = await this.context.ready;
197
+ return axios.get(
187
198
  `/api/v2/device/feedTower/list/${options?.id}`
188
199
  );
189
200
  },
190
- add: (ft: FeedTowerV2) => {
191
- return this.context.axios.post("/api/v2/device/feedTower/add", ft);
201
+ add: async (ft: FeedTowerV2) => {
202
+ var axios = await this.context.ready;
203
+ return axios.post("/api/v2/device/feedTower/add", ft);
192
204
  },
193
- update: (ft: FeedTowerV2) => {
194
- return this.context.axios.post("/api/v2/device/feedTower/update", ft);
205
+ update: async (ft: FeedTowerV2) => {
206
+ var axios = await this.context.ready;
207
+ return axios.post("/api/v2/device/feedTower/update", ft);
195
208
  },
196
- adzero: (ft: FeedTowerV2, force = false) => {
197
- return this.context.axios.post(`/api/v2/device/feedTower/adzero`, {
209
+ adzero: async (ft: FeedTowerV2, force = false) => {
210
+ var axios = await this.context.ready;
211
+ return axios.post(`/api/v2/device/feedTower/adzero`, {
198
212
  id: ft.id,
199
213
  force: force
200
214
  });
201
215
  },
202
- correctWeight: (ft: FeedTowerV2, amount: Number,displayAmount: Number| undefined = undefined) => {
203
- return this.context.axios.post(`/api/v2/device/feedTower/correctWeight`, {
216
+ correctWeight: async (ft: FeedTowerV2, amount: Number, displayAmount: Number | undefined = undefined) => {
217
+ var axios = await this.context.ready;
218
+ return axios.post(`/api/v2/device/feedTower/correctWeight`, {
204
219
  id: ft.id,
205
220
  suttle: amount,
206
221
  displaySuttle: displayAmount
@@ -7,8 +7,9 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
7
7
  get deviceType() {
8
8
  return "FeedTower";
9
9
  }
10
- getDetail(info, id) {
11
- return this.context.axios
10
+ async getDetail(info, id) {
11
+ var axios = await this.context.ready;
12
+ return axios
12
13
  .post("/api/v1/pigfarm/device/status/detail?deviceId=" + id)
13
14
  .then((res) => {
14
15
  if (res.data.code != 200) {
@@ -18,10 +19,11 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
18
19
  return res.data.data;
19
20
  });
20
21
  }
21
- wrapData(id, args, p1) {
22
+ async wrapData(id, args, p1) {
22
23
  const ps = [p1];
23
24
  if (!args.ingoreInput) {
24
- ps.push(this.context.axios.post(`/api/v1/pigfarm/device/fodder`, {
25
+ var axios = await this.context.ready;
26
+ ps.push(axios.post(`/api/v1/pigfarm/device/fodder`, {
25
27
  device: id,
26
28
  times: [args.start, args.stop],
27
29
  }));
@@ -43,10 +45,11 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
43
45
  }
44
46
  });
45
47
  }
46
- wrapList(list) {
48
+ async wrapList(list) {
47
49
  const ids = list.map((device) => device.id);
50
+ var axios = await this.context.ready;
48
51
  //TODO 其他设备的详情需要支持,目前只有喂料塔
49
- return this.context.axios
52
+ return axios
50
53
  .post("/api/v1/pigfarm/device/status/list", ids)
51
54
  .then((res) => {
52
55
  if (res.data.code != 200) {
@@ -64,11 +67,13 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
64
67
  });
65
68
  }
66
69
  async enter(data) {
67
- const res = await this.context.axios.post("/api/v1/pigfarm/device/fodder/import", data);
70
+ var axios = await this.context.ready;
71
+ const res = await axios.post("/api/v1/pigfarm/device/fodder/import", data);
68
72
  return res;
69
73
  }
70
74
  async getCar(truck) {
71
- const res = await this.context.axios.get("/api/v1/pigfarm/car", {
75
+ var axios = await this.context.ready;
76
+ const res = await axios.get("/api/v1/pigfarm/car", {
72
77
  params: {
73
78
  truckCode: truck,
74
79
  random: 1,
@@ -77,11 +82,13 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
77
82
  return res.data;
78
83
  }
79
84
  async getCarList() {
80
- const res = await this.context.axios.get("/api/v1/pigfarm/car/list");
85
+ var axios = await this.context.ready;
86
+ const res = await axios.get("/api/v1/pigfarm/car/list");
81
87
  return res.data;
82
88
  }
83
89
  async updateZeroTime(id) {
84
- const res = await this.context.axios.post("/api/v1/pigfarm/device/status/updateZeroTime" + "?id=" + id);
90
+ var axios = await this.context.ready;
91
+ const res = await axios.post("/api/v1/pigfarm/device/status/updateZeroTime" + "?id=" + id);
85
92
  return res;
86
93
  }
87
94
  /**
@@ -104,41 +111,49 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
104
111
  }
105
112
  //设置报警参数
106
113
  async setAlarmParam(deviceId, param) {
107
- return this.context.axios.post(`/api/v2/device/config/feedTowerAlert/add`, {
114
+ var axios = await this.context.ready;
115
+ return axios.post(`/api/v2/device/config/feedTowerAlert/add`, {
108
116
  deviceId,
109
117
  config: param,
110
118
  });
111
119
  }
112
120
  async updateAlarmParam(deviceId, param) {
113
- return this.context.axios.post(`/api/v2/device/config/feedTowerAlert/update`, {
121
+ var axios = await this.context.ready;
122
+ return axios.post(`/api/v2/device/config/feedTowerAlert/update`, {
114
123
  deviceId,
115
124
  config: param,
116
125
  });
117
126
  }
118
127
  //获取报警参数
119
128
  async getAlarmParam(deviceId) {
120
- return this.context.axios.get(`/api/v2/device/config/feedTowerAlert/${deviceId}`);
129
+ var axios = await this.context.ready;
130
+ return axios.get(`/api/v2/device/config/feedTowerAlert/${deviceId}`);
121
131
  }
122
132
  //新版料塔列表功能,id为工厂id
123
133
  v2() {
124
134
  return {
125
135
  list: async (options = undefined) => {
126
- return this.context.axios.get(`/api/v2/device/feedTower/list/${options === null || options === void 0 ? void 0 : options.id}`);
136
+ var axios = await this.context.ready;
137
+ return axios.get(`/api/v2/device/feedTower/list/${options === null || options === void 0 ? void 0 : options.id}`);
127
138
  },
128
- add: (ft) => {
129
- return this.context.axios.post("/api/v2/device/feedTower/add", ft);
139
+ add: async (ft) => {
140
+ var axios = await this.context.ready;
141
+ return axios.post("/api/v2/device/feedTower/add", ft);
130
142
  },
131
- update: (ft) => {
132
- return this.context.axios.post("/api/v2/device/feedTower/update", ft);
143
+ update: async (ft) => {
144
+ var axios = await this.context.ready;
145
+ return axios.post("/api/v2/device/feedTower/update", ft);
133
146
  },
134
- adzero: (ft, force = false) => {
135
- return this.context.axios.post(`/api/v2/device/feedTower/adzero`, {
147
+ adzero: async (ft, force = false) => {
148
+ var axios = await this.context.ready;
149
+ return axios.post(`/api/v2/device/feedTower/adzero`, {
136
150
  id: ft.id,
137
151
  force: force
138
152
  });
139
153
  },
140
- correctWeight: (ft, amount, displayAmount = undefined) => {
141
- return this.context.axios.post(`/api/v2/device/feedTower/correctWeight`, {
154
+ correctWeight: async (ft, amount, displayAmount = undefined) => {
155
+ var axios = await this.context.ready;
156
+ return axios.post(`/api/v2/device/feedTower/correctWeight`, {
142
157
  id: ft.id,
143
158
  suttle: amount,
144
159
  displaySuttle: displayAmount
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {