@cpzxrobot/sdk 1.0.81 → 1.0.82

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.
@@ -5,16 +5,16 @@ class FactoryGateway extends Object {
5
5
  constructor(context) {
6
6
  super();
7
7
  this._selectedFarm = {
8
- code: '',
9
- name: '',
10
- company_code: '',
11
- id: 0
8
+ code: "",
9
+ name: "",
10
+ company_code: "",
11
+ id: 0,
12
12
  };
13
13
  this.context = context;
14
14
  }
15
15
  async search(data) {
16
16
  await this.context.ready;
17
- const response = await this.context.axios.post('/api/v1/factory/search', data);
17
+ const response = await this.context.axios.post("/api/v1/factory/search", data);
18
18
  return response.data;
19
19
  }
20
20
  //获得工厂的单元信息
@@ -29,6 +29,16 @@ class FactoryGateway extends Object {
29
29
  const response = await axios.get(`/api/v1/workshop/${id}`);
30
30
  return response.data;
31
31
  }
32
+ get info() {
33
+ return {
34
+ get: (factory) => {
35
+ return this.context.axios.get(`/api/v2/factory/${factory.id}/info`);
36
+ },
37
+ post: (info) => {
38
+ return this.context.axios.post(`/api/v2/factory/${info.id}/info`, info);
39
+ },
40
+ };
41
+ }
32
42
  //获得工厂的所有车间信息
33
43
  async workshops(id) {
34
44
  var axios = await this.context.ready;
@@ -49,9 +59,9 @@ class FactoryGateway extends Object {
49
59
  //支持以下三个name:'capacity'(规模),'used_capacity'(存栏量),'workshop_count'(栋舍/车间数量),'manager'(负责人),'electric'/'water'/'feed' (电耗/水耗/饲料耗)
50
60
  async entry(factory, name) {
51
61
  var axios = await this.context.ready;
52
- if (['electric', 'water', 'feed'].includes(name)) {
62
+ if (["electric", "water", "feed"].includes(name)) {
53
63
  const response = await axios.post(`/api/v1/pigfarm/consumption/${factory.id}`, {
54
- type: name
64
+ type: name,
55
65
  });
56
66
  return response.data;
57
67
  }
@@ -1,67 +1,89 @@
1
- import { Cpzxrobot, Factory } from "./types"
1
+ import { Cpzxrobot, Factory } from "./types";
2
2
 
3
3
  export class FactoryGateway extends Object {
4
4
  _selectedFarm: Factory = {
5
- code: '',
6
- name: '',
7
- company_code: '',
8
- id: 0
9
- }
10
- context: Cpzxrobot
5
+ code: "",
6
+ name: "",
7
+ company_code: "",
8
+ id: 0,
9
+ };
10
+ context: Cpzxrobot;
11
11
  constructor(context: Cpzxrobot) {
12
- super()
13
- this.context = context
12
+ super();
13
+ this.context = context;
14
14
  }
15
15
  async search(data: Factory): Promise<any> {
16
- await this.context.ready
17
- const response = await this.context.axios.post('/api/v1/factory/search', data)
18
- return response.data
16
+ await this.context.ready;
17
+ const response = await this.context.axios.post(
18
+ "/api/v1/factory/search",
19
+ data
20
+ );
21
+ return response.data;
19
22
  }
20
23
 
21
24
  //获得工厂的单元信息
22
25
  async unit(id: number): Promise<any> {
23
- var axios = await this.context.ready
24
- const response = await axios.get(`/api/v1/workshop/unit/${id}`)
25
- return response.data
26
+ var axios = await this.context.ready;
27
+ const response = await axios.get(`/api/v1/workshop/unit/${id}`);
28
+ return response.data;
26
29
  }
27
30
 
28
31
  //获得工厂的车间信息
29
32
  async workshop(id: number): Promise<any> {
30
- var axios = await this.context.ready
31
- const response = await axios.get(`/api/v1/workshop/${id}`)
32
- return response.data
33
+ var axios = await this.context.ready;
34
+ const response = await axios.get(`/api/v1/workshop/${id}`);
35
+ return response.data;
36
+ }
37
+
38
+ get info() {
39
+ return {
40
+ get: (factory: Factory) => {
41
+ return this.context.axios.get(`/api/v2/factory/${factory.id}/info`);
42
+ },
43
+ post: (info: any) => {
44
+ return this.context.axios.post(`/api/v2/factory/${info.id}/info`, info);
45
+ },
46
+ };
33
47
  }
34
48
 
35
49
  //获得工厂的所有车间信息
36
50
  async workshops(id: number): Promise<any> {
37
- var axios = await this.context.ready
38
- const response = await axios.get(`/api/v1/factory/${id}/workshops`)
39
- return response.data
51
+ var axios = await this.context.ready;
52
+ const response = await axios.get(`/api/v1/factory/${id}/workshops`);
53
+ return response.data;
40
54
  }
41
55
 
42
56
  //获得工厂的所有单元信息,以车间为单位树状结构
43
57
  async units(id: number): Promise<any> {
44
- var axios = await this.context.ready
45
- const response = await axios.get(`/api/v1/factory/${id}/units`)
46
- return response.data
58
+ var axios = await this.context.ready;
59
+ const response = await axios.get(`/api/v1/factory/${id}/units`);
60
+ return response.data;
47
61
  }
48
62
 
49
63
  async company(data: Factory): Promise<any> {
50
64
  var axios = await this.context.ready;
51
- const response = await axios.get(`/api/v1/factory/${data.id}/organizaion`, data);
65
+ const response = await axios.get(
66
+ `/api/v1/factory/${data.id}/organizaion`,
67
+ data
68
+ );
52
69
  return response.data;
53
70
  }
54
71
 
55
72
  //支持以下三个name:'capacity'(规模),'used_capacity'(存栏量),'workshop_count'(栋舍/车间数量),'manager'(负责人),'electric'/'water'/'feed' (电耗/水耗/饲料耗)
56
- async entry(factory:Factory,name:string): Promise<any> {
73
+ async entry(factory: Factory, name: string): Promise<any> {
57
74
  var axios = await this.context.ready;
58
- if (['electric','water','feed'].includes(name)) {
59
- const response = await axios.post(`/api/v1/pigfarm/consumption/${factory.id}`,{
60
- type:name
61
- });
75
+ if (["electric", "water", "feed"].includes(name)) {
76
+ const response = await axios.post(
77
+ `/api/v1/pigfarm/consumption/${factory.id}`,
78
+ {
79
+ type: name,
80
+ }
81
+ );
62
82
  return response.data;
63
83
  }
64
- const response = await axios.get(`/api/v1/factory/${factory.id}/entry/${name}`);
84
+ const response = await axios.get(
85
+ `/api/v1/factory/${factory.id}/entry/${name}`
86
+ );
65
87
  return response.data;
66
- }
88
+ }
67
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.81",
3
+ "version": "1.0.82",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -86,7 +86,9 @@ baseURL: "/"
86
86
  | cpzxrobot().device.v2.delete | 删除设备(仅限v2设备) |
87
87
  | cpzxrobot().camera.xxx | 获得摄像头的相关信息 |
88
88
  | cpzxrobot().camera.control | 控制摄像头,例如:左移,右移,上移,下移等,如果传输start为true,则开始控制,如果传输stop为true,则停止控制,如果都没传输,则执行3秒后自动停止,传输start为true时,前端必须在需要停止时自行发送stop为true的消息 |
89
- | cpzxrobot().factory.entry| 获得工厂的可显示动态信息 |
89
+ | cpzxrobot().factory.entry | 获得工厂的可显示动态信息 |
90
+ | cpzxrobot().factory.info.get | 获得工厂的附加信息 |
91
+ | cpzxrobot().factory.info.post | 更新或更新工厂的附加信息 |
90
92
  | cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
91
93
  | cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
92
94
  | cpzxrobot().pigfarm.weightMeter.config.list | 获取称重计的配置信息 |