@cpzxrobot/sdk 1.0.43 → 1.0.45

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.
@@ -89,4 +89,23 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
89
89
  )
90
90
  return res
91
91
  }
92
+
93
+ /**
94
+ * 查询指定设备的饲料统计信息
95
+ *
96
+ * @param deviceIds 设备ID数组
97
+ * @param start 开始时间,格式为yyyy-MM-dd
98
+ * @param end 结束时间,格式为yyyy-MM-dd
99
+ * @returns 饲料统计信息
100
+ */
101
+ async stat(deviceIds: Number[], start: string, end: string) {
102
+ return this.context.ready.then((axios) => {
103
+ return axios.post(`/api/v1/pigfarm/feedStatics`, {
104
+ ids: deviceIds,
105
+ type: "device",
106
+ start: start,
107
+ end: end,
108
+ });
109
+ });
110
+ }
92
111
  }
@@ -81,5 +81,23 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
81
81
  const res = await this.context.axios.post('/api/v1/pigfarm/device/status/updateZeroTime' + '?id=' + id);
82
82
  return res;
83
83
  }
84
+ /**
85
+ * 查询指定设备的饲料统计信息
86
+ *
87
+ * @param deviceIds 设备ID数组
88
+ * @param start 开始时间,格式为yyyy-MM-dd
89
+ * @param end 结束时间,格式为yyyy-MM-dd
90
+ * @returns 饲料统计信息
91
+ */
92
+ async stat(deviceIds, start, end) {
93
+ return this.context.ready.then((axios) => {
94
+ return axios.post(`/api/v1/pigfarm/feedStatics`, {
95
+ ids: deviceIds,
96
+ type: "device",
97
+ start: start,
98
+ end: end,
99
+ });
100
+ });
101
+ }
84
102
  }
85
103
  exports.FeedTowerGateway = FeedTowerGateway;
@@ -17,6 +17,24 @@ class PigfarmGateway extends Object {
17
17
  return this.context.ready.then((axios) => {
18
18
  return axios.get(`/api/v1/pigfarm/pigcount/${unit.id}`);
19
19
  });
20
+ /**
21
+ * 获取单元统计信息
22
+ *
23
+ * @param unitIds 单元ID数组
24
+ * @param start 开始时间,格式为"yyyy-MM-dd"
25
+ * @param end 结束时间,格式为"yyyy-MM-dd"
26
+ * @returns 返回Promise对象,解析后得到axios响应结果
27
+ */
28
+ }
29
+ unitStat(unitIds, start, end) {
30
+ return this.context.ready.then((axios) => {
31
+ return axios.post(`/api/v1/pigfarm/feedStatics`, {
32
+ ids: unitIds,
33
+ type: "unit",
34
+ start: start,
35
+ end: end,
36
+ });
37
+ });
20
38
  }
21
39
  //获得当日统计
22
40
  dailyReportForUnit(unit, type) {
@@ -63,6 +81,14 @@ class PigfarmGateway extends Object {
63
81
  var axios = await this.context.ready;
64
82
  return axios.post(`/api/v1/pigfarm/heatLamp/config/update`, lamp);
65
83
  },
84
+ control: async (lamp, action) => {
85
+ var axios = await this.context.ready;
86
+ var id = typeof lamp === "number" ? lamp : lamp.id;
87
+ return axios.post(`/api/v1/pigfarm/heatLamp/control`, {
88
+ id,
89
+ action,
90
+ });
91
+ },
66
92
  };
67
93
  }
68
94
  }
@@ -15,6 +15,7 @@ class TransportGateway extends Object {
15
15
  pageSize: 10,
16
16
  deviceId: id,
17
17
  unitId: undefined,
18
+ factoryId: undefined,
18
19
  }) => {
19
20
  return this.context.ready.then(() => {
20
21
  return this.context.axios
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -18,6 +18,24 @@ export class PigfarmGateway extends Object {
18
18
  return this.context.ready.then((axios) => {
19
19
  return axios.get(`/api/v1/pigfarm/pigcount/${unit.id}`);
20
20
  });
21
+
22
+ /**
23
+ * 获取单元统计信息
24
+ *
25
+ * @param unitIds 单元ID数组
26
+ * @param start 开始时间,格式为"yyyy-MM-dd"
27
+ * @param end 结束时间,格式为"yyyy-MM-dd"
28
+ * @returns 返回Promise对象,解析后得到axios响应结果
29
+ */ }
30
+ unitStat(unitIds: Number[], start: string, end: string) {
31
+ return this.context.ready.then((axios) => {
32
+ return axios.post(`/api/v1/pigfarm/feedStatics`, {
33
+ ids: unitIds,
34
+ type: "unit",
35
+ start: start,
36
+ end: end,
37
+ });
38
+ });
21
39
  }
22
40
 
23
41
  //获得当日统计
@@ -55,7 +73,7 @@ export class PigfarmGateway extends Object {
55
73
 
56
74
  get heatlamp() {
57
75
  return {
58
- add: (unit:Unit, data: HeatLamp) => {
76
+ add: (unit: Unit, data: HeatLamp) => {
59
77
  return this.context.ready.then((axios) => {
60
78
  return axios.post(`/api/v1/pigfarm/heatLamp/config/add`, {
61
79
  ...data,
@@ -63,17 +81,27 @@ export class PigfarmGateway extends Object {
63
81
  });
64
82
  });
65
83
  },
66
- list: async (unit:Unit):Promise<any>=> {
84
+ list: async (unit: Unit): Promise<any> => {
85
+ var axios = await this.context.ready;
86
+ return axios.post(
87
+ `/api/v1/pigfarm/heatLamp/config/list?unitId=${unit.id}`
88
+ );
89
+ },
90
+ get: async (id: number): Promise<any> => {
67
91
  var axios = await this.context.ready;
68
- return axios.post(`/api/v1/pigfarm/heatLamp/config/list?unitId=${unit.id}`)
92
+ return axios.get(`/api/v1/pigfarm/heatLamp/config/${id}`);
69
93
  },
70
- get: async (id: number):Promise<any>=> {
94
+ update: async (lamp: HeatLamp): Promise<any> => {
71
95
  var axios = await this.context.ready;
72
- return axios.get(`/api/v1/pigfarm/heatLamp/config/${id}`)
96
+ return axios.post(`/api/v1/pigfarm/heatLamp/config/update`, lamp);
73
97
  },
74
- update:async (lamp: HeatLamp):Promise<any>=> {
98
+ control: async (lamp: HeatLamp | number, action: "on" | "off") => {
75
99
  var axios = await this.context.ready;
76
- return axios.post(`/api/v1/pigfarm/heatLamp/config/update`,lamp)
100
+ var id = typeof lamp === "number" ? lamp : lamp.id;
101
+ return axios.post(`/api/v1/pigfarm/heatLamp/control`, {
102
+ id,
103
+ action,
104
+ });
77
105
  },
78
106
  };
79
107
  }
package/readme.md CHANGED
@@ -82,6 +82,8 @@ baseURL: "/"
82
82
  | cpzxrobot().factory.entry| 获得工厂的可显示动态信息 |
83
83
  | cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
84
84
  | cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
85
+ | cpzxrobot().device.feedTower.stat | 获得料塔设备的料耗,饲料重量 |
86
+ | cpzxrobot().pigfarm.unitStat | 获得单元的统计信息,包括每日料耗,饲料消耗,日龄,存栏量等 |
85
87
 
86
88
 
87
89
  ### 工厂信息接口
@@ -19,11 +19,13 @@ export class TransportGateway extends Object {
19
19
  pageSize: number;
20
20
  deviceId: number | undefined;
21
21
  unitId: number | undefined;
22
+ factoryId: number | undefined;
22
23
  } = {
23
24
  current: 1,
24
25
  pageSize: 10,
25
26
  deviceId: id,
26
27
  unitId: undefined,
28
+ factoryId: undefined,
27
29
  }
28
30
  ): Promise<FodderOrder[]> => {
29
31
  return this.context.ready.then(() => {