@cpzxrobot/sdk 1.0.23 → 1.0.25

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/dist/index.js CHANGED
@@ -128,15 +128,25 @@ class Cpzxrobot {
128
128
  return platform.callHandler("axios_post", url, data);
129
129
  },
130
130
  };
131
- this.platformReady = new Promise((resolve, reject) => {
132
- window.addEventListener("flutterInAppWebViewPlatformReady", function () {
133
- console.log("flutter android/ios platform is ready");
134
- resolve(true);
131
+ if (
132
+ // @ts-ignore
133
+ window.flutter_inappwebview != null &&
134
+ // @ts-ignore
135
+ window.flutter_inappwebview.callHandler != null) {
136
+ this.platformReady = Promise.resolve(true);
137
+ }
138
+ else {
139
+ this.platformReady = new Promise((resolve, reject) => {
140
+ window.addEventListener("flutterInAppWebViewPlatformReady", function () {
141
+ console.log("flutter android/ios platform is ready");
142
+ resolve(true);
143
+ });
144
+ setTimeout(() => {
145
+ console.log("flutter android/ios platform is timeout");
146
+ reject("timeout");
147
+ }, 1500);
135
148
  });
136
- setTimeout(() => {
137
- reject("timeout");
138
- }, 1500);
139
- });
149
+ }
140
150
  }
141
151
  else if (this.isLocalDomain(domain)) {
142
152
  this.mode = "dev";
@@ -182,6 +192,10 @@ class Cpzxrobot {
182
192
  // @ts-ignore
183
193
  window._notifyUnitChanged = cb;
184
194
  break;
195
+ case "factoryChanged":
196
+ // @ts-ignore
197
+ window._notifyFactoryChanged = cb;
198
+ break;
185
199
  }
186
200
  }
187
201
  //打开其他小程序
@@ -22,16 +22,16 @@ class PigfarmGateway extends Object {
22
22
  dailyReportForUnit(unit, type) {
23
23
  return this.context.ready.then((axios) => {
24
24
  return axios.post(`/api/v1/pigfarm/today/${unit.id}`, {
25
- type
25
+ type,
26
26
  });
27
27
  });
28
28
  }
29
- //获得周/月/季度统计
29
+ //获得周/月/季度统计,如果出现跨批次的情况时,传回的数据的起始时间可能不是周/月/季度的开始时间,而是本批次的开始时间
30
30
  periodReportForUnit(unit, time, type) {
31
31
  return this.context.ready.then((axios) => {
32
32
  return axios.post(`/api/v1/pigfarm/statistics/${unit.id}`, {
33
33
  time: time,
34
- type: type
34
+ type: type,
35
35
  });
36
36
  });
37
37
  }
@@ -39,10 +39,8 @@ class PigfarmGateway extends Object {
39
39
  peakValleyForUnit(unit, start, end) {
40
40
  return this.context.ready.then((axios) => {
41
41
  return axios.post(`/api/v1/pigfarm/electric/${unit.id}`, {
42
- params: {
43
- start: start,
44
- end: end
45
- }
42
+ start: start,
43
+ end: end,
46
44
  });
47
45
  });
48
46
  }
@@ -28,7 +28,11 @@ class TransportGateway extends Object {
28
28
  });
29
29
  });
30
30
  },
31
- //获取设备打料数据
31
+ //获取打料详情
32
+ get inputs() {
33
+ return this.getDetail;
34
+ },
35
+ //获取设备打料数据 deperecated
32
36
  getDetail: (ids, date) => {
33
37
  return this.context.ready.then(() => {
34
38
  return this.context.axios
package/index.ts CHANGED
@@ -31,9 +31,9 @@ export class Cpzxrobot {
31
31
  _getSelectedFarmFromMiniApp!: () => any;
32
32
  _getSelectedUnitFromMiniApp!: () => any;
33
33
  _jumpToMiniApp!: (url: string) => any;
34
- setTitle!: (title: string) => void;
35
- saveBase64!: (base64: string, filename: string) => void;
36
- saveBlob!: (blob: Blob, filename: string) => void;
34
+ setTitle!: (title: string) => void;
35
+ saveBase64!: (base64: string, filename: string) => void;
36
+ saveBlob!: (blob: Blob, filename: string) => void;
37
37
  assistant: AssistantGateway;
38
38
  energy: EnergyGateway;
39
39
  camera: CameraGateway;
@@ -157,18 +157,28 @@ export class Cpzxrobot {
157
157
  return platform.callHandler("axios_post", url, data);
158
158
  },
159
159
  };
160
- this.platformReady = new Promise<boolean>((resolve, reject) => {
161
- window.addEventListener(
162
- "flutterInAppWebViewPlatformReady",
163
- function () {
164
- console.log("flutter android/ios platform is ready");
165
- resolve(true);
166
- }
167
- );
168
- setTimeout(() => {
169
- reject("timeout");
170
- }, 1500);
171
- });
160
+ if (
161
+ // @ts-ignore
162
+ window.flutter_inappwebview != null &&
163
+ // @ts-ignore
164
+ window.flutter_inappwebview.callHandler != null
165
+ ) {
166
+ this.platformReady = Promise.resolve(true);
167
+ } else {
168
+ this.platformReady = new Promise<boolean>((resolve, reject) => {
169
+ window.addEventListener(
170
+ "flutterInAppWebViewPlatformReady",
171
+ function () {
172
+ console.log("flutter android/ios platform is ready");
173
+ resolve(true);
174
+ }
175
+ );
176
+ setTimeout(() => {
177
+ console.log("flutter android/ios platform is timeout");
178
+ reject("timeout");
179
+ }, 1500);
180
+ });
181
+ }
172
182
  } else if (this.isLocalDomain(domain)) {
173
183
  this.mode = "dev";
174
184
  this.setTitle = function (title: string) {
@@ -216,6 +226,10 @@ export class Cpzxrobot {
216
226
  // @ts-ignore
217
227
  window._notifyUnitChanged = cb;
218
228
  break;
229
+ case "factoryChanged":
230
+ // @ts-ignore
231
+ window._notifyFactoryChanged = cb;
232
+ break;
219
233
  }
220
234
  }
221
235
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -21,49 +21,34 @@ export class PigfarmGateway extends Object {
21
21
  }
22
22
 
23
23
  //获得当日统计
24
- dailyReportForUnit(
25
- unit: Unit,
26
- type:
27
- | "feed"
28
- | "water"
29
- | "electric"
30
- ) {
24
+ dailyReportForUnit(unit: Unit, type: "feed" | "water" | "electric") {
31
25
  return this.context.ready.then((axios) => {
32
- return axios.post(`/api/v1/pigfarm/today/${unit.id}`,{
33
- type
26
+ return axios.post(`/api/v1/pigfarm/today/${unit.id}`, {
27
+ type,
34
28
  });
35
29
  });
36
30
  }
37
31
 
38
- //获得周/月/季度统计
32
+ //获得周/月/季度统计,如果出现跨批次的情况时,传回的数据的起始时间可能不是周/月/季度的开始时间,而是本批次的开始时间
39
33
  periodReportForUnit(
40
34
  unit: Unit,
41
35
  time: "week" | "month" | "season",
42
- type:
43
- | "feed"
44
- | "water"
45
- | "electric"
36
+ type: "feed" | "water" | "electric"
46
37
  ) {
47
38
  return this.context.ready.then((axios) => {
48
- return axios.post(`/api/v1/pigfarm/statistics/${unit.id}`,{
39
+ return axios.post(`/api/v1/pigfarm/statistics/${unit.id}`, {
49
40
  time: time,
50
- type: type
41
+ type: type,
51
42
  });
52
43
  });
53
44
  }
54
45
 
55
46
  //获得周期时间内的峰谷平能耗统计
56
- peakValleyForUnit(
57
- unit: Unit,
58
- start: string,
59
- end: string
60
- ) {
47
+ peakValleyForUnit(unit: Unit, start: string, end: string) {
61
48
  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
- }
49
+ return axios.post(`/api/v1/pigfarm/electric/${unit.id}`, {
50
+ start: start,
51
+ end: end,
67
52
  });
68
53
  });
69
54
  }
@@ -37,7 +37,11 @@ export class TransportGateway extends Object {
37
37
  });
38
38
  });
39
39
  },
40
- //获取设备打料数据
40
+ //获取打料详情
41
+ get inputs() {
42
+ return this.getDetail;
43
+ },
44
+ //获取设备打料数据 deperecated
41
45
  getDetail: (ids: Array<number>, date: string): Promise<any> => {
42
46
  return this.context.ready.then(() => {
43
47
  return this.context.axios