@cpzxrobot/sdk 1.0.4 → 1.0.5
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/assistant_gateway.ts +4 -2
- package/camera_gateway.ts +19 -15
- package/device_filter.ts +6 -4
- package/device_gateway.ts +12 -12
- package/device_type_gateway.ts +4 -2
- package/device_types/electricmeter.ts +2 -2
- package/device_types/feedtower.ts +5 -5
- package/device_types/normal_type.ts +3 -2
- package/dist/camera_gateway.js +2 -2
- package/dist/device_filter.js +3 -3
- package/dist/device_types/electricmeter.js +1 -1
- package/dist/device_types/feedtower.js +1 -1
- package/dist/device_types/normal_type.js +1 -1
- package/dist/energy_types/electric_meter_gateway.js +1 -5
- package/dist/index.js +187 -222
- package/dist/transport_gateway.js +22 -7
- package/energy_gateway.ts +3 -2
- package/energy_types/electric_meter_gateway.ts +4 -4
- package/factory_gateway.ts +4 -2
- package/index.ts +6 -29
- package/package.json +4 -2
- package/pigfarm_gateway.ts +4 -2
- package/transport_gateway.ts +52 -35
- package/types.d.ts +164 -84
- package/user_gateway.ts +5 -3
package/transport_gateway.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { Cpzxrobot, FodderOrder } from ".";
|
|
2
|
+
|
|
1
3
|
export class TransportGateway extends Object {
|
|
2
|
-
_selectedFarm: string =
|
|
3
|
-
context:
|
|
4
|
+
_selectedFarm: string = "";
|
|
5
|
+
context: Cpzxrobot;
|
|
4
6
|
|
|
5
|
-
constructor(context:
|
|
6
|
-
super()
|
|
7
|
-
this.context = context
|
|
7
|
+
constructor(context: Cpzxrobot) {
|
|
8
|
+
super();
|
|
9
|
+
this.context = context;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
get fodder() {
|
|
@@ -13,55 +15,70 @@ export class TransportGateway extends Object {
|
|
|
13
15
|
getData: (
|
|
14
16
|
id: number | undefined = undefined,
|
|
15
17
|
page: {
|
|
16
|
-
current: number
|
|
17
|
-
pageSize: number
|
|
18
|
-
deviceId: number | undefined
|
|
18
|
+
current: number;
|
|
19
|
+
pageSize: number;
|
|
20
|
+
deviceId: number | undefined;
|
|
19
21
|
} = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
current: 1,
|
|
23
|
+
pageSize: 10,
|
|
24
|
+
deviceId: id,
|
|
25
|
+
}
|
|
24
26
|
): Promise<FodderOrder[]> => {
|
|
25
27
|
return this.context.ready.then(() => {
|
|
26
28
|
return this.context.axios
|
|
27
|
-
.get(
|
|
28
|
-
params: page
|
|
29
|
+
.get("/api/v1/pigfarm/device/fodder", {
|
|
30
|
+
params: page,
|
|
29
31
|
})
|
|
30
32
|
.then((res) => {
|
|
31
33
|
if (res.data.code != 200) {
|
|
32
|
-
throw res.data.message
|
|
34
|
+
throw res.data.message;
|
|
33
35
|
}
|
|
34
|
-
return res.data.data.list
|
|
36
|
+
return res.data.data.list;
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
//获取设备打料数据
|
|
41
|
+
getDetail: (ids: Array<number>, date: string): Promise<any> => {
|
|
42
|
+
return this.context.ready.then(() => {
|
|
43
|
+
return this.context.axios
|
|
44
|
+
.post("/api/v1/pigfarm/device/fodderTower/detailDeviceLoad", {
|
|
45
|
+
ids,
|
|
46
|
+
date,
|
|
35
47
|
})
|
|
36
|
-
|
|
48
|
+
.then((res) => {
|
|
49
|
+
return res.data;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
37
52
|
},
|
|
38
53
|
create: (data: FodderOrder) => {
|
|
39
54
|
return this.context.ready.then(() => {
|
|
40
|
-
return this.context.axios
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
return this.context.axios
|
|
56
|
+
.post("/api/v1/pigfarm/device/fodder/add", data)
|
|
57
|
+
.then((res) => {
|
|
58
|
+
if (res.data.code != 200) {
|
|
59
|
+
throw res.data.message;
|
|
60
|
+
}
|
|
61
|
+
return res.data.data;
|
|
62
|
+
});
|
|
63
|
+
});
|
|
47
64
|
},
|
|
48
65
|
bind: (data: {
|
|
49
|
-
deviceIds: number[]
|
|
50
|
-
fodderType: string //料塔类型
|
|
51
|
-
fodderAmount: number //料塔容量
|
|
52
|
-
fodderId: number //料塔id,类 ZC2023 用于绑定料塔
|
|
66
|
+
deviceIds: number[];
|
|
67
|
+
fodderType: string; //料塔类型
|
|
68
|
+
fodderAmount: number; //料塔容量
|
|
69
|
+
fodderId: number; //料塔id,类 ZC2023 用于绑定料塔
|
|
53
70
|
}) => {
|
|
54
71
|
return this.context.ready.then(() => {
|
|
55
72
|
return this.context.axios
|
|
56
|
-
.post(
|
|
73
|
+
.post("/api/v1/pigfarm/device/fodderTower/addList", data)
|
|
57
74
|
.then((res) => {
|
|
58
75
|
if (res.data.code != 200) {
|
|
59
|
-
throw res.data.message
|
|
76
|
+
throw res.data.message;
|
|
60
77
|
}
|
|
61
|
-
return res.data.data
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
}
|
|
78
|
+
return res.data.data;
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
};
|
|
66
83
|
}
|
|
67
84
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,102 +1,182 @@
|
|
|
1
|
-
|
|
1
|
+
import { DeviceGateway } from "@cpzxrobot/sdk/device_gateway";
|
|
2
|
+
import { FactoryGateway } from "@cpzxrobot/sdk/factory_gateway";
|
|
3
|
+
import { TransportGateway } from "@cpzxrobot/sdk/transport_gateway";
|
|
4
|
+
import { UserGateway } from "@cpzxrobot/sdk/user_gateway";
|
|
2
5
|
|
|
3
6
|
type Device = {
|
|
4
|
-
id: number
|
|
5
|
-
deviceId: string
|
|
6
|
-
name: string
|
|
7
|
-
type: number
|
|
8
|
-
typeCode:string
|
|
9
|
-
currentAmount: number
|
|
10
|
-
location: string
|
|
11
|
-
supplier?: string
|
|
12
|
-
data?: number[]
|
|
13
|
-
typeCode: string
|
|
14
|
-
}
|
|
7
|
+
id: number;
|
|
8
|
+
deviceId: string;
|
|
9
|
+
name: string;
|
|
10
|
+
type: number;
|
|
11
|
+
typeCode: string;
|
|
12
|
+
currentAmount: number;
|
|
13
|
+
location: string;
|
|
14
|
+
supplier?: string;
|
|
15
|
+
data?: number[];
|
|
16
|
+
typeCode: string;
|
|
17
|
+
};
|
|
15
18
|
|
|
16
|
-
type FeedTowerExtraInfo = {
|
|
17
|
-
currentAmount: number
|
|
18
|
-
loadAmount: number
|
|
19
|
-
feedTowerAmount: number
|
|
20
|
-
feedTowerCode: string
|
|
21
|
-
id: number
|
|
22
|
-
surplus_amount: number
|
|
23
|
-
}
|
|
19
|
+
export type FeedTowerExtraInfo = {
|
|
20
|
+
currentAmount: number;
|
|
21
|
+
loadAmount: number;
|
|
22
|
+
feedTowerAmount: number;
|
|
23
|
+
feedTowerCode: string;
|
|
24
|
+
id: number;
|
|
25
|
+
surplus_amount: number;
|
|
26
|
+
};
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
//FodderOrder 料单信息
|
|
29
|
+
export type FodderOrder = {
|
|
30
|
+
id?: number;
|
|
31
|
+
fodderId?: string;
|
|
32
|
+
fodderAmount: number;
|
|
33
|
+
fodderCode: string;
|
|
34
|
+
createTime: string;
|
|
35
|
+
status: string;
|
|
36
|
+
fodderUnit: string;
|
|
37
|
+
truckCode?: string;
|
|
38
|
+
date?: string;
|
|
39
|
+
type?: string;
|
|
40
|
+
};
|
|
41
|
+
//
|
|
42
|
+
export type FodderOrderList = {
|
|
43
|
+
car: string; //车牌号
|
|
44
|
+
date: string; //日期
|
|
45
|
+
source: string; //来源
|
|
46
|
+
factoryCode: string; //当前工厂编号
|
|
47
|
+
results: FodderOrderInFactory[];
|
|
48
|
+
};
|
|
49
|
+
type FodderOrderInFactory = {
|
|
50
|
+
farm: string; //工厂名称
|
|
51
|
+
fodderCode: string; //料号
|
|
52
|
+
towers: FodderOrderInTower[];
|
|
53
|
+
};
|
|
50
54
|
|
|
51
|
-
type
|
|
52
|
-
name: string //料塔名称
|
|
53
|
-
unit: string //单位
|
|
54
|
-
weight: number //重量
|
|
55
|
-
}
|
|
55
|
+
export type FodderOrderInTower = {
|
|
56
|
+
name: string; //料塔名称
|
|
57
|
+
unit: string; //单位
|
|
58
|
+
weight: number; //重量
|
|
59
|
+
};
|
|
56
60
|
|
|
57
|
-
type Shzx = {
|
|
58
|
-
user: UserGateway
|
|
59
|
-
ready: Promise<MyAxiosInstance>
|
|
60
|
-
axios: MyAxiosInstance
|
|
61
|
-
_getSelectedFarmFromMiniApp: () => Promise<Factory>
|
|
62
|
-
_getSelectedUnitFromMiniApp: () => Promise<Unit>
|
|
63
|
-
mode: string
|
|
64
|
-
}
|
|
65
61
|
type Assistant = {
|
|
66
|
-
info: String
|
|
67
|
-
status: String
|
|
68
|
-
name: String
|
|
69
|
-
id: Number
|
|
70
|
-
}
|
|
71
|
-
type Factory = {
|
|
72
|
-
code: string
|
|
73
|
-
name?: string
|
|
74
|
-
company_code: string
|
|
75
|
-
id?: number
|
|
76
|
-
}
|
|
62
|
+
info: String;
|
|
63
|
+
status: String;
|
|
64
|
+
name: String;
|
|
65
|
+
id: Number;
|
|
66
|
+
};
|
|
67
|
+
export type Factory = {
|
|
68
|
+
code: string;
|
|
69
|
+
name?: string;
|
|
70
|
+
company_code: string;
|
|
71
|
+
id?: number;
|
|
72
|
+
};
|
|
77
73
|
type Unit = {
|
|
78
|
-
name?: string
|
|
79
|
-
id?: number
|
|
80
|
-
type?: string
|
|
81
|
-
workshopName?:string
|
|
82
|
-
}
|
|
74
|
+
name?: string;
|
|
75
|
+
id?: number;
|
|
76
|
+
type?: string;
|
|
77
|
+
workshopName?: string;
|
|
78
|
+
};
|
|
83
79
|
|
|
84
80
|
type Electricity = {
|
|
85
|
-
deviceId: string
|
|
86
|
-
nextDeviceList: number[] | []
|
|
87
|
-
power: number
|
|
88
|
-
}
|
|
81
|
+
deviceId: string;
|
|
82
|
+
nextDeviceList: number[] | [];
|
|
83
|
+
power: number;
|
|
84
|
+
};
|
|
89
85
|
|
|
90
86
|
type Camera = {
|
|
91
|
-
id: number
|
|
92
|
-
name: string
|
|
87
|
+
id: number;
|
|
88
|
+
name: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type FeedTower = {
|
|
92
|
+
id: number;
|
|
93
|
+
name: string;
|
|
94
|
+
currentAmount: number;
|
|
95
|
+
lastZeroTime: string;
|
|
96
|
+
cycle?: number;
|
|
97
|
+
"pg.feedtower.status"?: string;
|
|
98
|
+
"pg.feedtower.near-zero"?: string;
|
|
99
|
+
deviation: number;
|
|
100
|
+
towerVolume: number;
|
|
101
|
+
unit: string;
|
|
102
|
+
unitId: number;
|
|
103
|
+
deviceId: number;
|
|
104
|
+
fodderUnit: string;
|
|
105
|
+
fodderCode: string;
|
|
106
|
+
diff: number;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export interface MyAxiosInstance {
|
|
110
|
+
get: (url: string, config?: any) => Promise<any>;
|
|
111
|
+
post: (url: string, data?: any, config?: any) => Promise<any>;
|
|
93
112
|
}
|
|
94
113
|
|
|
95
|
-
interface
|
|
96
|
-
|
|
97
|
-
|
|
114
|
+
export interface Assistant {
|
|
115
|
+
info: String;
|
|
116
|
+
status: Number;
|
|
117
|
+
name: String;
|
|
118
|
+
id: Number;
|
|
119
|
+
}
|
|
120
|
+
export interface ElectricMeter extends Device {
|
|
121
|
+
coefficient: number;
|
|
122
|
+
status: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export class Cpzxrobot {
|
|
126
|
+
transport: TransportGateway;
|
|
127
|
+
ready: Promise<MyAxiosInstance>;
|
|
128
|
+
factory: FactoryGateway;
|
|
129
|
+
user: UserGateway;
|
|
130
|
+
device: DeviceGateway;
|
|
131
|
+
mode: string;
|
|
132
|
+
axios: MyAxiosInstance;
|
|
133
|
+
_getSelectedFarmFromMiniApp: () => Promise<Factory>;
|
|
134
|
+
_getSelectedUnitFromMiniApp: () => Promise<Unit>;
|
|
98
135
|
}
|
|
99
136
|
|
|
100
137
|
declare global {
|
|
101
|
-
let getAuth: () => string
|
|
138
|
+
let getAuth: () => string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare module "@cpzxrobot/sdk" {
|
|
142
|
+
export default function (
|
|
143
|
+
args: {
|
|
144
|
+
devAuth: string;
|
|
145
|
+
baseURL: string;
|
|
146
|
+
appCode: string;
|
|
147
|
+
selectedFarm: Factory;
|
|
148
|
+
selectedUnit: Unit;
|
|
149
|
+
} = {
|
|
150
|
+
devAuth: "",
|
|
151
|
+
appCode: "",
|
|
152
|
+
baseURL: "https://www.cpzxrobot.com/",
|
|
153
|
+
selectedFarm: {
|
|
154
|
+
id: 0,
|
|
155
|
+
code: "",
|
|
156
|
+
name: "",
|
|
157
|
+
company_code: "",
|
|
158
|
+
},
|
|
159
|
+
selectedUnit: {
|
|
160
|
+
id: 0,
|
|
161
|
+
name: "",
|
|
162
|
+
},
|
|
163
|
+
}
|
|
164
|
+
): Cpzxrobot;
|
|
165
|
+
export {
|
|
166
|
+
Cpzxrobot,
|
|
167
|
+
Factory,
|
|
168
|
+
Unit,
|
|
169
|
+
Device,
|
|
170
|
+
FeedTower,
|
|
171
|
+
FodderOrder,
|
|
172
|
+
FodderOrderList,
|
|
173
|
+
FodderOrderInFactory,
|
|
174
|
+
FodderOrderInTower,
|
|
175
|
+
MyAxiosInstance,
|
|
176
|
+
Assistant,
|
|
177
|
+
ElectricMeter,
|
|
178
|
+
Camera,
|
|
179
|
+
FeedTowerExtraInfo,
|
|
180
|
+
Electricity,
|
|
181
|
+
};
|
|
102
182
|
}
|
package/user_gateway.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Cpzxrobot, Factory, Unit } from "./types";
|
|
2
|
+
|
|
1
3
|
export class UserGateway extends Object {
|
|
2
4
|
_selectedFarm: Factory = {
|
|
3
5
|
code: "",
|
|
@@ -5,19 +7,19 @@ export class UserGateway extends Object {
|
|
|
5
7
|
company_code: "",
|
|
6
8
|
id: 0,
|
|
7
9
|
};
|
|
8
|
-
context:
|
|
10
|
+
context: Cpzxrobot;
|
|
9
11
|
_selectedUnit: Unit = {
|
|
10
12
|
name: "",
|
|
11
13
|
id: 0,
|
|
12
14
|
};
|
|
13
15
|
|
|
14
|
-
constructor(context:
|
|
16
|
+
constructor(context: Cpzxrobot) {
|
|
15
17
|
super();
|
|
16
18
|
this.context = context;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
//获得当前用户选择的工厂
|
|
20
|
-
getSelectedFarm() {
|
|
22
|
+
public getSelectedFarm(): Promise<Factory> {
|
|
21
23
|
return new Promise<Factory>((resolve, reject) => {
|
|
22
24
|
switch (this.context.mode) {
|
|
23
25
|
case "dev":
|