@cpzxrobot/sdk 1.0.20 → 1.0.22

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_filter.ts CHANGED
@@ -98,6 +98,12 @@ export abstract class DeviceFilter<T extends { id: number }> {
98
98
  });
99
99
  }
100
100
 
101
+ //获取设备数据,和getData相同作用,为统一接口进行了重命名
102
+ get data() {
103
+ return this.getData;
104
+ }
105
+
106
+ //deprecated,请使用data进行调用
101
107
  getData(
102
108
  id: number,
103
109
  args: DataQueryArgs = {
@@ -106,10 +112,10 @@ export abstract class DeviceFilter<T extends { id: number }> {
106
112
  type: "diffPerDay", // diffPerDay, sumPerDay, latest
107
113
  }
108
114
  ) {
109
- if (args.stop == "") {
115
+ if (!args.stop) {
110
116
  args.stop = this.formateDateToYYYYMMDD(new Date());
111
117
  }
112
- if (args.start == "") {
118
+ if (!args.start) {
113
119
  const sevenDaysAgo = new Date();
114
120
  sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
115
121
  args.start = this.formateDateToYYYYMMDD(sevenDaysAgo);
@@ -81,15 +81,20 @@ class DeviceFilter {
81
81
  });
82
82
  });
83
83
  }
84
+ //获取设备数据,和getData相同作用,为统一接口进行了重命名
85
+ get data() {
86
+ return this.getData;
87
+ }
88
+ //deprecated,请使用data进行调用
84
89
  getData(id, args = {
85
90
  start: "",
86
91
  stop: "",
87
92
  type: "diffPerDay", // diffPerDay, sumPerDay, latest
88
93
  }) {
89
- if (args.stop == "") {
94
+ if (!args.stop) {
90
95
  args.stop = this.formateDateToYYYYMMDD(new Date());
91
96
  }
92
- if (args.start == "") {
97
+ if (!args.start) {
93
98
  const sevenDaysAgo = new Date();
94
99
  sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
95
100
  args.start = this.formateDateToYYYYMMDD(sevenDaysAgo);
@@ -9,7 +9,7 @@ class PigfarmGateway extends Object {
9
9
  //获得日龄
10
10
  dayageForUnit(unit) {
11
11
  return this.context.ready.then((axios) => {
12
- return axios.get(`/api/v1/pigfarm/${unit.id}/dayage`);
12
+ return axios.get(`/api/v1/pigfarm/dayage/${unit.id}`);
13
13
  });
14
14
  }
15
15
  //获得存栏量
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -9,7 +9,7 @@ export class PigfarmGateway extends Object {
9
9
  //获得日龄
10
10
  dayageForUnit(unit: Unit) {
11
11
  return this.context.ready.then((axios) => {
12
- return axios.get(`/api/v1/pigfarm/${unit.id}/dayage`);
12
+ return axios.get(`/api/v1/pigfarm/dayage/${unit.id}`);
13
13
  });
14
14
  }
15
15
 
package/readme.md CHANGED
@@ -74,8 +74,8 @@ baseURL: "/"
74
74
  | 调用入口 | 功能说明 |
75
75
  | ----------------------- | -------------------- |
76
76
  | cpzxrobot().factory.xxx | 获得工厂的相关信息 |
77
- | cpzxrobot().device.list | 获得常见设备的列表(当没有特殊类型需求时调用) |
78
- | cpzxrobot().device.data | 获得设备的数据 |
77
+ | cpzxrobot().device.list | 获得常见设备的列表(当没有特殊类型需求时调用),列表接口提供data参数,可以同步获得多个设备的数据,尽量使用该接口获得设备数据 |
78
+ | cpzxrobot().device.data | 获得设备的数据,该接口用于获取单个设备的详细数据 |
79
79
  | cpzxrobot().device.feedTower.list | 获得料塔设备的列表 |
80
80
  | cpzxrobot().device.xxx | 获得设备的相关信息 |
81
81
  | cpzxrobot().camera.xxx | 获得摄像头的相关信息 |