@cpzxrobot/sdk 1.0.60 → 1.0.61
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_types/feedtower.ts +64 -45
- package/dist/device_types/feedtower.js +24 -17
- package/package.json +1 -1
|
@@ -1,103 +1,110 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type FodderOrderList,
|
|
3
|
+
type FeedTower,
|
|
4
|
+
type FeedTowerExtraInfo,
|
|
5
|
+
DataQueryArgs,
|
|
6
|
+
} from "..";
|
|
7
|
+
import { DeviceFilter } from "../device_filter";
|
|
3
8
|
|
|
4
9
|
export class FeedTowerGateway extends DeviceFilter<FeedTower> {
|
|
5
10
|
// Add properties and methods specific to the FeedTower type here
|
|
6
11
|
|
|
7
12
|
get deviceType() {
|
|
8
|
-
return
|
|
13
|
+
return "FeedTower";
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
getDetail(info: FeedTower, id: number) {
|
|
12
17
|
return this.context.axios
|
|
13
|
-
.post(
|
|
18
|
+
.post("/api/v1/pigfarm/device/status/detail?deviceId=" + id)
|
|
14
19
|
.then((res: any) => {
|
|
15
20
|
if (res.data.code != 200) {
|
|
16
|
-
throw res.data.message
|
|
21
|
+
throw res.data.message;
|
|
17
22
|
}
|
|
18
|
-
res.data.data.unit = info.unit
|
|
19
|
-
return res.data.data
|
|
20
|
-
})
|
|
23
|
+
res.data.data.unit = info.unit;
|
|
24
|
+
return res.data.data;
|
|
25
|
+
});
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
wrapData(id: number, args: DataQueryArgs, p1: Promise<any>) {
|
|
24
|
-
const ps = [p1]
|
|
29
|
+
const ps = [p1];
|
|
25
30
|
if (!args.ingoreInput) {
|
|
26
31
|
ps.push(
|
|
27
32
|
this.context.axios.post(`/api/v1/pigfarm/device/fodder`, {
|
|
28
33
|
device: id,
|
|
29
|
-
times: [args.start, args.stop]
|
|
34
|
+
times: [args.start, args.stop],
|
|
30
35
|
})
|
|
31
|
-
)
|
|
36
|
+
);
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
return Promise.all(ps).then((res) => {
|
|
35
40
|
if (res[0].data.Error) {
|
|
36
|
-
throw res[0].data.Error
|
|
41
|
+
throw res[0].data.Error;
|
|
37
42
|
} else {
|
|
38
43
|
if (!args.ingoreInput) {
|
|
39
44
|
res[1].data.data.list.forEach((item: any) => {
|
|
40
|
-
res[0].data[item.date] += item.data
|
|
41
|
-
})
|
|
45
|
+
res[0].data[item.date] += item.data;
|
|
46
|
+
});
|
|
42
47
|
}
|
|
43
|
-
return res[0].data
|
|
48
|
+
return res[0].data;
|
|
44
49
|
}
|
|
45
|
-
})
|
|
50
|
+
});
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
wrapList(list: FeedTower[]): Promise<FeedTower[]> {
|
|
49
|
-
const ids = list.map((device) => device.id)
|
|
54
|
+
const ids = list.map((device) => device.id);
|
|
50
55
|
//TODO 其他设备的详情需要支持,目前只有喂料塔
|
|
51
56
|
return this.context.axios
|
|
52
|
-
.post(
|
|
53
|
-
.then((res:any) => {
|
|
57
|
+
.post("/api/v1/pigfarm/device/status/list", ids)
|
|
58
|
+
.then((res: any) => {
|
|
54
59
|
if (res.data.code != 200) {
|
|
55
|
-
throw res.data.message
|
|
60
|
+
throw res.data.message;
|
|
56
61
|
} else {
|
|
57
62
|
res.data.data.forEach((device: FeedTowerExtraInfo) => {
|
|
58
|
-
const found = list.find((d) => d.id === device.id)
|
|
63
|
+
const found = list.find((d) => d.id === device.id);
|
|
59
64
|
if (found) {
|
|
60
|
-
Object.assign(found, device)
|
|
65
|
+
Object.assign(found, device);
|
|
61
66
|
}
|
|
62
|
-
})
|
|
63
|
-
return list
|
|
67
|
+
});
|
|
68
|
+
return list;
|
|
64
69
|
}
|
|
65
|
-
})
|
|
70
|
+
});
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
|
|
69
73
|
async enter(data: FodderOrderList): Promise<any> {
|
|
70
|
-
const res = await this.context.axios.post(
|
|
71
|
-
|
|
74
|
+
const res = await this.context.axios.post(
|
|
75
|
+
"/api/v1/pigfarm/device/fodder/import",
|
|
76
|
+
data
|
|
77
|
+
);
|
|
78
|
+
return res;
|
|
72
79
|
}
|
|
73
80
|
async getCar(truck: string): Promise<any> {
|
|
74
|
-
const res = await this.context.axios.get(
|
|
81
|
+
const res = await this.context.axios.get("/api/v1/pigfarm/car", {
|
|
75
82
|
params: {
|
|
76
83
|
truckCode: truck,
|
|
77
|
-
random: 1
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
return res.data
|
|
84
|
+
random: 1,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
return res.data;
|
|
81
88
|
}
|
|
82
89
|
async getCarList(): Promise<any> {
|
|
83
|
-
const res = await this.context.axios.get(
|
|
84
|
-
return res.data
|
|
90
|
+
const res = await this.context.axios.get("/api/v1/pigfarm/car/list");
|
|
91
|
+
return res.data;
|
|
85
92
|
}
|
|
86
93
|
async updateZeroTime(id: Number): Promise<any> {
|
|
87
94
|
const res = await this.context.axios.post(
|
|
88
|
-
|
|
89
|
-
)
|
|
90
|
-
return res
|
|
95
|
+
"/api/v1/pigfarm/device/status/updateZeroTime" + "?id=" + id
|
|
96
|
+
);
|
|
97
|
+
return res;
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
* 查询指定设备的饲料统计信息
|
|
102
|
+
*
|
|
103
|
+
* @param deviceIds 设备ID数组
|
|
104
|
+
* @param start 开始时间,格式为yyyy-MM-dd
|
|
105
|
+
* @param end 结束时间,格式为yyyy-MM-dd
|
|
106
|
+
* @returns 饲料统计信息
|
|
107
|
+
*/
|
|
101
108
|
async stat(deviceIds: Number[], start: string, end: string) {
|
|
102
109
|
return this.context.ready.then((axios) => {
|
|
103
110
|
return axios.post(`/api/v1/pigfarm/feedStatics`, {
|
|
@@ -108,4 +115,16 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
|
|
|
108
115
|
});
|
|
109
116
|
});
|
|
110
117
|
}
|
|
118
|
+
|
|
119
|
+
//设置报警参数
|
|
120
|
+
async setAlarmParam(deviceId:number, param:{
|
|
121
|
+
"zeroPeriod":number,
|
|
122
|
+
"zeroValue":number,
|
|
123
|
+
"alertDays":number[]
|
|
124
|
+
}) {
|
|
125
|
+
return this.context.axios.post(`/api/v2/device/config/feedTowerAlert/add`, {
|
|
126
|
+
deviceId,
|
|
127
|
+
config:param,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
111
130
|
}
|
|
@@ -5,11 +5,11 @@ const device_filter_1 = require("../device_filter");
|
|
|
5
5
|
class FeedTowerGateway extends device_filter_1.DeviceFilter {
|
|
6
6
|
// Add properties and methods specific to the FeedTower type here
|
|
7
7
|
get deviceType() {
|
|
8
|
-
return
|
|
8
|
+
return "FeedTower";
|
|
9
9
|
}
|
|
10
10
|
getDetail(info, id) {
|
|
11
11
|
return this.context.axios
|
|
12
|
-
.post(
|
|
12
|
+
.post("/api/v1/pigfarm/device/status/detail?deviceId=" + id)
|
|
13
13
|
.then((res) => {
|
|
14
14
|
if (res.data.code != 200) {
|
|
15
15
|
throw res.data.message;
|
|
@@ -23,7 +23,7 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
|
|
|
23
23
|
if (!args.ingoreInput) {
|
|
24
24
|
ps.push(this.context.axios.post(`/api/v1/pigfarm/device/fodder`, {
|
|
25
25
|
device: id,
|
|
26
|
-
times: [args.start, args.stop]
|
|
26
|
+
times: [args.start, args.stop],
|
|
27
27
|
}));
|
|
28
28
|
}
|
|
29
29
|
return Promise.all(ps).then((res) => {
|
|
@@ -44,7 +44,7 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
|
|
|
44
44
|
const ids = list.map((device) => device.id);
|
|
45
45
|
//TODO 其他设备的详情需要支持,目前只有喂料塔
|
|
46
46
|
return this.context.axios
|
|
47
|
-
.post(
|
|
47
|
+
.post("/api/v1/pigfarm/device/status/list", ids)
|
|
48
48
|
.then((res) => {
|
|
49
49
|
if (res.data.code != 200) {
|
|
50
50
|
throw res.data.message;
|
|
@@ -61,34 +61,34 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
async enter(data) {
|
|
64
|
-
const res = await this.context.axios.post(
|
|
64
|
+
const res = await this.context.axios.post("/api/v1/pigfarm/device/fodder/import", data);
|
|
65
65
|
return res;
|
|
66
66
|
}
|
|
67
67
|
async getCar(truck) {
|
|
68
|
-
const res = await this.context.axios.get(
|
|
68
|
+
const res = await this.context.axios.get("/api/v1/pigfarm/car", {
|
|
69
69
|
params: {
|
|
70
70
|
truckCode: truck,
|
|
71
|
-
random: 1
|
|
72
|
-
}
|
|
71
|
+
random: 1,
|
|
72
|
+
},
|
|
73
73
|
});
|
|
74
74
|
return res.data;
|
|
75
75
|
}
|
|
76
76
|
async getCarList() {
|
|
77
|
-
const res = await this.context.axios.get(
|
|
77
|
+
const res = await this.context.axios.get("/api/v1/pigfarm/car/list");
|
|
78
78
|
return res.data;
|
|
79
79
|
}
|
|
80
80
|
async updateZeroTime(id) {
|
|
81
|
-
const res = await this.context.axios.post(
|
|
81
|
+
const res = await this.context.axios.post("/api/v1/pigfarm/device/status/updateZeroTime" + "?id=" + id);
|
|
82
82
|
return res;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
* 查询指定设备的饲料统计信息
|
|
86
|
+
*
|
|
87
|
+
* @param deviceIds 设备ID数组
|
|
88
|
+
* @param start 开始时间,格式为yyyy-MM-dd
|
|
89
|
+
* @param end 结束时间,格式为yyyy-MM-dd
|
|
90
|
+
* @returns 饲料统计信息
|
|
91
|
+
*/
|
|
92
92
|
async stat(deviceIds, start, end) {
|
|
93
93
|
return this.context.ready.then((axios) => {
|
|
94
94
|
return axios.post(`/api/v1/pigfarm/feedStatics`, {
|
|
@@ -99,5 +99,12 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
|
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
+
//设置报警参数
|
|
103
|
+
async setAlarmParam(deviceId, param) {
|
|
104
|
+
return this.context.axios.post(`/api/v2/device/config/feedTowerAlert/add`, {
|
|
105
|
+
deviceId,
|
|
106
|
+
config: param,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
102
109
|
}
|
|
103
110
|
exports.FeedTowerGateway = FeedTowerGateway;
|