@cpzxrobot/sdk 1.2.16 → 1.2.18

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_gateway.ts CHANGED
@@ -319,4 +319,51 @@ export class DeviceGateway extends Object {
319
319
  return faults;
320
320
 
321
321
  }
322
+
323
+
324
+ // 报告设备问题
325
+ report(id: number, status: number, description: string): Promise<any> {
326
+ return this.context.ready.then(() => {
327
+ return this.context.axios.post("/api/v3/device/report", {
328
+ id,
329
+ status,
330
+ description
331
+ }).then((res) => {
332
+ if (res.data.code != 200) {
333
+ throw res.data.message;
334
+ }
335
+ return res.data;
336
+ });
337
+ });
338
+ }
339
+
340
+ get ctrl() {
341
+ return {
342
+ // 获取设备控制参数
343
+ get: (deviceId: number,type: string, no: any ): Promise<any> => {
344
+ return this.context.ready.then(() => {
345
+ return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/${type}/${no}`)
346
+ .then((res) => {
347
+ if (res.data.code != 200) {
348
+ throw res.data.message;
349
+ }
350
+ return res.data;
351
+ });
352
+ });
353
+ },
354
+
355
+ // 配置设备控制参数
356
+ set: (deviceId: number,type: string, no: any,params: any): Promise<any> => {
357
+ return this.context.ready.then(() => {
358
+ return this.context.axios.post(`/api/v2/device/ctrl/${deviceId}/${type}/${no}`, params)
359
+ .then((res) => {
360
+ if (res.data.code != 200) {
361
+ throw res.data.message;
362
+ }
363
+ return res.data;
364
+ });
365
+ });
366
+ }
367
+ };
368
+ }
322
369
  }
@@ -233,5 +233,48 @@ class DeviceGateway extends Object {
233
233
  }
234
234
  return faults;
235
235
  }
236
+ // 报告设备问题
237
+ report(id, status, description) {
238
+ return this.context.ready.then(() => {
239
+ return this.context.axios.post("/api/v3/device/report", {
240
+ id,
241
+ status,
242
+ description
243
+ }).then((res) => {
244
+ if (res.data.code != 200) {
245
+ throw res.data.message;
246
+ }
247
+ return res.data;
248
+ });
249
+ });
250
+ }
251
+ get ctrl() {
252
+ return {
253
+ // 获取设备控制参数
254
+ get: (deviceId, type, no) => {
255
+ return this.context.ready.then(() => {
256
+ return this.context.axios.get(`/api/v2/device/ctrl/${deviceId}/${type}/${no}`)
257
+ .then((res) => {
258
+ if (res.data.code != 200) {
259
+ throw res.data.message;
260
+ }
261
+ return res.data;
262
+ });
263
+ });
264
+ },
265
+ // 配置设备控制参数
266
+ set: (deviceId, type, no, params) => {
267
+ return this.context.ready.then(() => {
268
+ return this.context.axios.post(`/api/v2/device/ctrl/${deviceId}/${type}/${no}`, params)
269
+ .then((res) => {
270
+ if (res.data.code != 200) {
271
+ throw res.data.message;
272
+ }
273
+ return res.data;
274
+ });
275
+ });
276
+ }
277
+ };
278
+ }
236
279
  }
237
280
  exports.DeviceGateway = DeviceGateway;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.16",
3
+ "version": "1.2.18",
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
  获取设备故障记录