@cpzxrobot/sdk 1.0.21 → 1.0.23

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);
@@ -18,5 +18,33 @@ class PigfarmGateway extends Object {
18
18
  return axios.get(`/api/v1/pigfarm/pigcount/${unit.id}`);
19
19
  });
20
20
  }
21
+ //获得当日统计
22
+ dailyReportForUnit(unit, type) {
23
+ return this.context.ready.then((axios) => {
24
+ return axios.post(`/api/v1/pigfarm/today/${unit.id}`, {
25
+ type
26
+ });
27
+ });
28
+ }
29
+ //获得周/月/季度统计
30
+ periodReportForUnit(unit, time, type) {
31
+ return this.context.ready.then((axios) => {
32
+ return axios.post(`/api/v1/pigfarm/statistics/${unit.id}`, {
33
+ time: time,
34
+ type: type
35
+ });
36
+ });
37
+ }
38
+ //获得周期时间内的峰谷平能耗统计
39
+ peakValleyForUnit(unit, start, end) {
40
+ return this.context.ready.then((axios) => {
41
+ return axios.post(`/api/v1/pigfarm/electric/${unit.id}`, {
42
+ params: {
43
+ start: start,
44
+ end: end
45
+ }
46
+ });
47
+ });
48
+ }
21
49
  }
22
50
  exports.PigfarmGateway = PigfarmGateway;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -19,4 +19,52 @@ export class PigfarmGateway extends Object {
19
19
  return axios.get(`/api/v1/pigfarm/pigcount/${unit.id}`);
20
20
  });
21
21
  }
22
+
23
+ //获得当日统计
24
+ dailyReportForUnit(
25
+ unit: Unit,
26
+ type:
27
+ | "feed"
28
+ | "water"
29
+ | "electric"
30
+ ) {
31
+ return this.context.ready.then((axios) => {
32
+ return axios.post(`/api/v1/pigfarm/today/${unit.id}`,{
33
+ type
34
+ });
35
+ });
36
+ }
37
+
38
+ //获得周/月/季度统计
39
+ periodReportForUnit(
40
+ unit: Unit,
41
+ time: "week" | "month" | "season",
42
+ type:
43
+ | "feed"
44
+ | "water"
45
+ | "electric"
46
+ ) {
47
+ return this.context.ready.then((axios) => {
48
+ return axios.post(`/api/v1/pigfarm/statistics/${unit.id}`,{
49
+ time: time,
50
+ type: type
51
+ });
52
+ });
53
+ }
54
+
55
+ //获得周期时间内的峰谷平能耗统计
56
+ peakValleyForUnit(
57
+ unit: Unit,
58
+ start: string,
59
+ end: string
60
+ ) {
61
+ return this.context.ready.then((axios) => {
62
+ return axios.post(`/api/v1/pigfarm/electric/${unit.id}`,{
63
+ params: {
64
+ start: start,
65
+ end: end
66
+ }
67
+ });
68
+ });
69
+ }
22
70
  }