@cpzxrobot/sdk 1.2.15 → 1.2.17

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.
@@ -25,11 +25,6 @@ export class ContractGateway extends Object {
25
25
  });
26
26
  }
27
27
 
28
- postGet(id: number) {
29
- return this.context.ready.then((axios) => {
30
- return axios.post(`/api/v2/coremde-sale/contract/get`, {id});
31
- });
32
- }
33
28
 
34
29
  addForProject(args: any) {
35
30
  return this.context.ready.then((axios) => {
package/device_filter.ts CHANGED
@@ -329,6 +329,52 @@ export abstract class DeviceFilter<T extends { id: number }> {
329
329
  return `${year}-${String(month).padStart(2, "0")}`;
330
330
  }
331
331
 
332
+ // 报告设备问题
333
+ report(id: number, status: number, description: string): Promise<any> {
334
+ return this.context.ready.then(() => {
335
+ return this.context.axios.post("/api/v3/device/report", {
336
+ id,
337
+ status,
338
+ description
339
+ }).then((res) => {
340
+ if (res.data.code != 200) {
341
+ throw res.data.message;
342
+ }
343
+ return res.data;
344
+ });
345
+ });
346
+ }
347
+
348
+ get ctrl() {
349
+ return {
350
+ // 获取设备控制参数
351
+ get: (deviceId: number,type: string, no: any ): Promise<any> => {
352
+ return this.context.ready.then(() => {
353
+ return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/${type}/${no}`)
354
+ .then((res) => {
355
+ if (res.data.code != 200) {
356
+ throw res.data.message;
357
+ }
358
+ return res.data;
359
+ });
360
+ });
361
+ },
362
+
363
+ // 配置设备控制参数
364
+ set: (deviceId: number,type: string, no: any,params: any): Promise<any> => {
365
+ return this.context.ready.then(() => {
366
+ return this.context.axios.post(`/api/v2/device/ctrl/${deviceId}/${type}/${no}`, params)
367
+ .then((res) => {
368
+ if (res.data.code != 200) {
369
+ throw res.data.message;
370
+ }
371
+ return res.data;
372
+ });
373
+ });
374
+ }
375
+ };
376
+ }
377
+
332
378
  //获取设备列表,如果options.id为空,则获取用户选中工厂的设备列表,否则获取指定id的工厂的设备
333
379
  //last:获取最新数据
334
380
  // rangeToday:获取今天的第一个数据和最后一个数据
@@ -16,11 +16,6 @@ class ContractGateway extends Object {
16
16
  return axios.get(`/api/v2/coremde-sale/contract/get?id=${id}`);
17
17
  });
18
18
  }
19
- postGet(id) {
20
- return this.context.ready.then((axios) => {
21
- return axios.post(`/api/v2/coremde-sale/contract/get`, { id });
22
- });
23
- }
24
19
  addForProject(args) {
25
20
  return this.context.ready.then((axios) => {
26
21
  return axios.post(`/api/v2/coremde-sale/contract/project/add`, args);
@@ -293,6 +293,49 @@ class DeviceFilter {
293
293
  // 使用 `padStart` 方法来确保月份和日期总是两位数
294
294
  return `${year}-${String(month).padStart(2, "0")}`;
295
295
  }
296
+ // 报告设备问题
297
+ report(id, status, description) {
298
+ return this.context.ready.then(() => {
299
+ return this.context.axios.post("/api/v3/device/report", {
300
+ id,
301
+ status,
302
+ description
303
+ }).then((res) => {
304
+ if (res.data.code != 200) {
305
+ throw res.data.message;
306
+ }
307
+ return res.data;
308
+ });
309
+ });
310
+ }
311
+ get ctrl() {
312
+ return {
313
+ // 获取设备控制参数
314
+ get: (deviceId, type, no) => {
315
+ return this.context.ready.then(() => {
316
+ return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/${type}/${no}`)
317
+ .then((res) => {
318
+ if (res.data.code != 200) {
319
+ throw res.data.message;
320
+ }
321
+ return res.data;
322
+ });
323
+ });
324
+ },
325
+ // 配置设备控制参数
326
+ set: (deviceId, type, no, params) => {
327
+ return this.context.ready.then(() => {
328
+ return this.context.axios.post(`/api/v2/device/ctrl/${deviceId}/${type}/${no}`, params)
329
+ .then((res) => {
330
+ if (res.data.code != 200) {
331
+ throw res.data.message;
332
+ }
333
+ return res.data;
334
+ });
335
+ });
336
+ }
337
+ };
338
+ }
296
339
  //获取设备列表,如果options.id为空,则获取用户选中工厂的设备列表,否则获取指定id的工厂的设备
297
340
  //last:获取最新数据
298
341
  // rangeToday:获取今天的第一个数据和最后一个数据
package/dist/index.js CHANGED
@@ -164,6 +164,14 @@ class Cpzxrobot {
164
164
  this.saveBlob = this._saveBlobAsBase64;
165
165
  // @ts-ignore
166
166
  this.getGeo = window.miniapp.getGeo;
167
+ // @ts-ignore
168
+ this.setResult = window.miniapp.setResult;
169
+ // @ts-ignore
170
+ this.setResultAs = window.miniapp.setResultAs;
171
+ // @ts-ignore
172
+ this.setError = window.miniapp.setError;
173
+ // @ts-ignore
174
+ this.setProgress = window.miniapp.setProgress;
167
175
  }
168
176
  else if (domain == "appassets.androidplatform.net" ||
169
177
  this.isIosMiniApp(window.location)) {
@@ -206,6 +214,18 @@ class Cpzxrobot {
206
214
  this.reloadGroup = function (group) {
207
215
  return platform.callHandler("app.reloadGroup", group);
208
216
  };
217
+ this.setResult = function (name, value) {
218
+ return platform.callHandler("app.setResult", name, value);
219
+ };
220
+ this.setResultAs = function (name, value, type) {
221
+ return platform.callHandler("app.setResultAs", name, value, type);
222
+ };
223
+ this.setError = function (message) {
224
+ return platform.callHandler("app.setError", message);
225
+ };
226
+ this.setProgress = function (precentage) {
227
+ return platform.callHandler("app.setProgress", precentage);
228
+ };
209
229
  this.axios = {
210
230
  get: function (url, data) {
211
231
  return platform.callHandler("axios_get", url, data);
package/index.ts CHANGED
@@ -53,6 +53,10 @@ export class Cpzxrobot {
53
53
  lat: number;
54
54
  lng: number;
55
55
  }>;
56
+ setResult!: (name: string, value: any) => void;
57
+ setResultAs!: (name: string, value: any, type: string) => void;
58
+ setError!: (message: string) => void;
59
+ setProgress!: (precentage: number) => void;
56
60
  assistant: AssistantGateway;
57
61
  energy: EnergyGateway;
58
62
  camera: CameraGateway;
@@ -201,6 +205,14 @@ export class Cpzxrobot {
201
205
  this.saveBlob = this._saveBlobAsBase64;
202
206
  // @ts-ignore
203
207
  this.getGeo = window.miniapp.getGeo;
208
+ // @ts-ignore
209
+ this.setResult = window.miniapp.setResult;
210
+ // @ts-ignore
211
+ this.setResultAs = window.miniapp.setResultAs;
212
+ // @ts-ignore
213
+ this.setError = window.miniapp.setError;
214
+ // @ts-ignore
215
+ this.setProgress = window.miniapp.setProgress;
204
216
  } else if (
205
217
  domain == "appassets.androidplatform.net" ||
206
218
  this.isIosMiniApp(window.location)
@@ -246,6 +258,18 @@ export class Cpzxrobot {
246
258
  this.reloadGroup = function (group: string) {
247
259
  return platform.callHandler("app.reloadGroup", group);
248
260
  };
261
+ this.setResult = function (name: string, value: any) {
262
+ return platform.callHandler("app.setResult", name, value);
263
+ };
264
+ this.setResultAs = function (name: string, value: any, type: string) {
265
+ return platform.callHandler("app.setResultAs", name, value, type);
266
+ };
267
+ this.setError = function (message: string) {
268
+ return platform.callHandler("app.setError", message);
269
+ };
270
+ this.setProgress = function (precentage: number) {
271
+ return platform.callHandler("app.setProgress", precentage);
272
+ };
249
273
  this.axios = {
250
274
  get: function (url, data) {
251
275
  return platform.callHandler("axios_get", url, data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.15",
3
+ "version": "1.2.17",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -113,6 +113,43 @@ cpzxrobot().device.thresholdConfig.list()
113
113
 
114
114
  // 获取设备报警列表
115
115
 
116
+ // 报告设备问题
117
+ cpzxrobot().device.report(deviceId, status, description)
118
+ ```
119
+
120
+ ### report函数说明
121
+
122
+ 报告设备问题状态
123
+
124
+ #### 参数
125
+ - `deviceId`: number - 设备ID
126
+ - `status`: number - 设备状态码,可选值如下:
127
+ - 0: 正常状态
128
+ - 1: 待确认错误
129
+ - 2: 需要检查的错误
130
+ - 3: 维护中
131
+ - 4: 需要自行修复的错误
132
+ - 5: 需要更换的错误
133
+ - 8: 等待修复
134
+ - 9: 等待更换
135
+ - 16: 正在修复
136
+ - 17: 正在更换
137
+ - 33: 已更换
138
+ - 64: 已废弃
139
+ - `description`: string - 问题描述
140
+
141
+ #### 返回值
142
+ Promise<any> - 返回操作结果
143
+
144
+ #### 使用示例
145
+ ```typescript
146
+ // 报告设备需要修复
147
+ await cpzxrobot().device.report(123, 4, "传感器读数异常");
148
+
149
+ // 报告设备已废弃
150
+ await cpzxrobot().device.report(456, 64, "设备已报废");
151
+ ```
152
+
116
153
  ## faults函数说明
117
154
 
118
155
  获取设备故障记录