@cpzxrobot/sdk 1.0.81 → 1.0.83
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/factory_gateway.js +35 -8
- package/factory_gateway.ts +79 -32
- package/package.json +1 -1
- package/readme.md +5 -1
- package/types.d.ts +1 -0
- package/unit_gateway.ts +2 -2
package/dist/factory_gateway.js
CHANGED
|
@@ -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(
|
|
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;
|
|
@@ -38,7 +48,13 @@ class FactoryGateway extends Object {
|
|
|
38
48
|
//获得工厂的所有单元信息,以车间为单位树状结构
|
|
39
49
|
async units(id) {
|
|
40
50
|
var axios = await this.context.ready;
|
|
41
|
-
const response = await axios.get(`/api/
|
|
51
|
+
const response = await axios.get(`/api/v2/factory/${id}/units`);
|
|
52
|
+
return response.data;
|
|
53
|
+
}
|
|
54
|
+
//获得工厂的业务类型
|
|
55
|
+
async businessType(data) {
|
|
56
|
+
var axios = await this.context.ready;
|
|
57
|
+
const response = await axios.get(`/api/v2/factory/businessType/${data.type}`);
|
|
42
58
|
return response.data;
|
|
43
59
|
}
|
|
44
60
|
async company(data) {
|
|
@@ -49,14 +65,25 @@ class FactoryGateway extends Object {
|
|
|
49
65
|
//支持以下三个name:'capacity'(规模),'used_capacity'(存栏量),'workshop_count'(栋舍/车间数量),'manager'(负责人),'electric'/'water'/'feed' (电耗/水耗/饲料耗)
|
|
50
66
|
async entry(factory, name) {
|
|
51
67
|
var axios = await this.context.ready;
|
|
52
|
-
if ([
|
|
68
|
+
if (["electric", "water", "feed"].includes(name)) {
|
|
53
69
|
const response = await axios.post(`/api/v1/pigfarm/consumption/${factory.id}`, {
|
|
54
|
-
type: name
|
|
70
|
+
type: name,
|
|
55
71
|
});
|
|
56
72
|
return response.data;
|
|
57
73
|
}
|
|
58
74
|
const response = await axios.get(`/api/v1/factory/${factory.id}/entry/${name}`);
|
|
59
75
|
return response.data;
|
|
60
76
|
}
|
|
77
|
+
get banner() {
|
|
78
|
+
return {
|
|
79
|
+
//上传banner,formData中包含key为file的文件,返回code
|
|
80
|
+
add: (factory, form) => {
|
|
81
|
+
return this.context.axios.get(`/api/v1/factory/${factory.id}/banner/add`);
|
|
82
|
+
},
|
|
83
|
+
del: (code) => {
|
|
84
|
+
return this.context.axios.get(`/api/v1/factory/banner/delete?id=${code}`);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
61
88
|
}
|
|
62
89
|
exports.FactoryGateway = FactoryGateway;
|
package/factory_gateway.ts
CHANGED
|
@@ -1,67 +1,114 @@
|
|
|
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(
|
|
18
|
-
|
|
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/
|
|
46
|
-
return response.data
|
|
58
|
+
var axios = await this.context.ready;
|
|
59
|
+
const response = await axios.get(`/api/v2/factory/${id}/units`);
|
|
60
|
+
return response.data;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//获得工厂的业务类型
|
|
64
|
+
async businessType(data: Factory): Promise<any> {
|
|
65
|
+
var axios = await this.context.ready;
|
|
66
|
+
const response = await axios.get(
|
|
67
|
+
`/api/v2/factory/businessType/${data.type}`
|
|
68
|
+
);
|
|
69
|
+
return response.data;
|
|
47
70
|
}
|
|
48
71
|
|
|
49
72
|
async company(data: Factory): Promise<any> {
|
|
50
73
|
var axios = await this.context.ready;
|
|
51
|
-
const response = await axios.get(
|
|
74
|
+
const response = await axios.get(
|
|
75
|
+
`/api/v1/factory/${data.id}/organizaion`,
|
|
76
|
+
data
|
|
77
|
+
);
|
|
52
78
|
return response.data;
|
|
53
79
|
}
|
|
54
80
|
|
|
55
81
|
//支持以下三个name:'capacity'(规模),'used_capacity'(存栏量),'workshop_count'(栋舍/车间数量),'manager'(负责人),'electric'/'water'/'feed' (电耗/水耗/饲料耗)
|
|
56
|
-
async entry(factory:Factory,name:string): Promise<any> {
|
|
82
|
+
async entry(factory: Factory, name: string): Promise<any> {
|
|
57
83
|
var axios = await this.context.ready;
|
|
58
|
-
if ([
|
|
59
|
-
const response = await axios.post(
|
|
60
|
-
|
|
61
|
-
|
|
84
|
+
if (["electric", "water", "feed"].includes(name)) {
|
|
85
|
+
const response = await axios.post(
|
|
86
|
+
`/api/v1/pigfarm/consumption/${factory.id}`,
|
|
87
|
+
{
|
|
88
|
+
type: name,
|
|
89
|
+
}
|
|
90
|
+
);
|
|
62
91
|
return response.data;
|
|
63
92
|
}
|
|
64
|
-
const response = await axios.get(
|
|
93
|
+
const response = await axios.get(
|
|
94
|
+
`/api/v1/factory/${factory.id}/entry/${name}`
|
|
95
|
+
);
|
|
65
96
|
return response.data;
|
|
66
|
-
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
get banner() {
|
|
100
|
+
return {
|
|
101
|
+
//上传banner,formData中包含key为file的文件,返回code
|
|
102
|
+
add: (factory: Factory, form: FormData) => {
|
|
103
|
+
return this.context.axios.get(
|
|
104
|
+
`/api/v1/factory/${factory.id}/banner/add`
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
del: (code: String) => {
|
|
108
|
+
return this.context.axios.get(
|
|
109
|
+
`/api/v1/factory/banner/delete?id=${code}`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
67
114
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -86,7 +86,11 @@ 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 | 更新或更新工厂的附加信息 |
|
|
92
|
+
| cpzxrobot().factory.banner.add | 添加工厂的banner图片,提交formdata,需要传入file参数 |
|
|
93
|
+
| cpzxrobot().factory.banner.delete | 删除工厂的banner图片,需要传入id参数 |
|
|
90
94
|
| cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
|
|
91
95
|
| cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
|
|
92
96
|
| cpzxrobot().pigfarm.weightMeter.config.list | 获取称重计的配置信息 |
|
package/types.d.ts
CHANGED
package/unit_gateway.ts
CHANGED
|
@@ -10,7 +10,7 @@ export class UnitGateway extends Object {
|
|
|
10
10
|
return {
|
|
11
11
|
add: (
|
|
12
12
|
unit: Unit,
|
|
13
|
-
type: "HeatLamp",
|
|
13
|
+
type: "HeatLamp" | "DeviceFilter",
|
|
14
14
|
config: {
|
|
15
15
|
[key: string]: any;
|
|
16
16
|
}
|
|
@@ -38,7 +38,7 @@ export class UnitGateway extends Object {
|
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
},
|
|
41
|
-
get: (unit: Unit, type: "
|
|
41
|
+
get: (unit: Unit, type: "HeatLamp"| "") => {
|
|
42
42
|
return this.context.ready.then((axios) => {
|
|
43
43
|
return axios.get(`/api/v2/unit/config`, {
|
|
44
44
|
params: {
|