@cpzxrobot/sdk 1.0.38 → 1.0.40

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/camera_gateway.ts CHANGED
@@ -6,32 +6,38 @@ export class CameraGateway extends Object {
6
6
  super();
7
7
  this.context = context;
8
8
  }
9
- //搜索摄像头,传入unit对象或者unit的id
10
- async search(data: Unit): Promise<any> {
9
+
10
+ async search(
11
+ data:
12
+ | Unit
13
+ | {
14
+ workshop_id?: number;
15
+ factory_id?: number;
16
+ unit_id?: number;
17
+ }
18
+ ): Promise<any> {
11
19
  var axios = await this.context.ready;
12
- var id = data.id;
20
+ var params = {};
13
21
 
14
- if (!id) {
15
- //if data is string
16
- if (typeof data === "string") {
17
- id = data;
18
- }else{
19
- throw new Error("请传入正确的Unit对象");
20
- }
22
+ if (!("id" in data)) {
23
+ //should has unit_id or factory_id or workshop_id at least one, if has more than one, use unit_id first,then workshop_id, then factory_id
24
+ params = data as {
25
+ workshop_id?: number;
26
+ factory_id?: number;
27
+ unit_id?: number;
28
+ };
29
+ }else{
30
+ params = {unit_id:data.id}
21
31
  }
22
32
 
23
- const response = await axios.post("/api/v1/camera/search", {
24
- unit_id: id,
25
- });
33
+ const response = await axios.post("/api/v1/camera/search", params);
26
34
  return response.data;
27
35
  }
28
36
 
29
37
  //获得摄像头的播放地址
30
38
  async getUrl(data: Camera): Promise<any> {
31
39
  var axios = await this.context.ready;
32
- const response = await axios.get(
33
- `/api/v1/camera/${data.id}/url/wss`
34
- );
40
+ const response = await axios.get(`/api/v1/camera/${data.id}/url/wss`);
35
41
  return response.data;
36
42
  }
37
43
  //获取工厂天气
@@ -6,22 +6,17 @@ class CameraGateway extends Object {
6
6
  super();
7
7
  this.context = context;
8
8
  }
9
- //搜索摄像头,传入unit对象或者unit的id
10
9
  async search(data) {
11
10
  var axios = await this.context.ready;
12
- var id = data.id;
13
- if (!id) {
14
- //if data is string
15
- if (typeof data === "string") {
16
- id = data;
17
- }
18
- else {
19
- throw new Error("请传入正确的Unit对象");
20
- }
11
+ var params = {};
12
+ if (!("id" in data)) {
13
+ //should has unit_id or factory_id or workshop_id at least one, if has more than one, use unit_id first,then workshop_id, then factory_id
14
+ params = data;
21
15
  }
22
- const response = await axios.post("/api/v1/camera/search", {
23
- unit_id: id,
24
- });
16
+ else {
17
+ params = { unit_id: data.id };
18
+ }
19
+ const response = await axios.post("/api/v1/camera/search", params);
25
20
  return response.data;
26
21
  }
27
22
  //获得摄像头的播放地址
@@ -39,7 +39,7 @@ class TransportGateway extends Object {
39
39
  return this.context.axios
40
40
  .get("/api/v1/pigfarm/device/fodderTower/getDeviceByFodderId", {
41
41
  params: {
42
- fodderld: id,
42
+ fodderId: id,
43
43
  },
44
44
  })
45
45
  .then((res) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -116,6 +116,10 @@ factory_id: 工厂id
116
116
 
117
117
  如果入参为:{factory_id:xxx}则按工厂搜索
118
118
 
119
+ 如果入参为:{workshop_id:xxx}则按车间搜索
120
+
121
+ 如果入参为Unit对象,则按Unit对象的id进行搜索
122
+
119
123
  ### app功能相关
120
124
 
121
125
  `cpzxrobot().saveBlob(blob,filname)`
@@ -134,4 +138,5 @@ heatlamp 属性提供了一组方法,用于管理猪场的热灯配置。它
134
138
  **cpzxrobot().pigfarm.heatlamp.add(unit, data)**:添加新的热灯配置。
135
139
  **cpzxrobot().pigfarm.heatlamp.list(unit)**:列出指定单元的所有热灯配置。
136
140
  **cpzxrobot().pigfarm.heatlamp.get(id)**:获取指定 ID 的热灯配置。
137
- **cpzxrobot().pigfarm.heatlamp.update(lamp)**:更新热灯配置。
141
+ **cpzxrobot().pigfarm.heatlamp.update(lamp)**:更新热灯配置。
142
+
@@ -49,7 +49,7 @@ export class TransportGateway extends Object {
49
49
  return this.context.axios
50
50
  .get("/api/v1/pigfarm/device/fodderTower/getDeviceByFodderId", {
51
51
  params: {
52
- fodderld: id,
52
+ fodderId: id,
53
53
  },
54
54
  })
55
55
  .then((res) => {