@cpzxrobot/sdk 1.3.69 → 1.3.71
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/company_gateway.ts +3 -2
- package/device_filter.ts +4 -4
- package/device_gateway.ts +12 -2
- package/device_types/feedtower.ts +5 -5
- package/dist/camera_gateway.js +61 -42
- package/dist/car_gateway.js +54 -31
- package/dist/chickenfarm_gateway.js +11 -2
- package/dist/company_gateway.js +120 -94
- package/dist/device_gateway.js +210 -181
- package/dist/device_types/feedtower.js +130 -101
- package/dist/energy_gateway.js +33 -20
- package/dist/factory_gateway.js +129 -90
- package/dist/index.js +1 -1
- package/dist/mobile_platform.js +70 -43
- package/dist/pigfarm_gateway.js +51 -42
- package/dist/production_gateway.js +31 -18
- package/dist/project_gateway.js +12 -3
- package/dist/purchase_gateway.js +73 -38
- package/dist/sensor_datas.js +23 -11
- package/dist/sparepart_gateway.js +27 -18
- package/dist/test_strict.js +18 -0
- package/dist/user_gateway.js +131 -100
- package/dist/warehouse_gateway.js +34 -15
- package/dist/web_platform.js +213 -194
- package/dist/windows_platform.js +15 -5
- package/factory_gateway.ts +2 -2
- package/index.ts +3 -3
- package/mobile_platform.ts +3 -3
- package/news_gateway.ts +1 -1
- package/package.json +1 -1
- package/sensor_datas.ts +27 -16
- package/test_strict.ts +22 -0
- package/tsconfig.json +19 -19
- package/types.d.ts +12 -49
- package/web_platform.ts +15 -15
- package/windows_platform.ts +3 -3
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.FeedTowerGateway = void 0;
|
|
4
13
|
const device_filter_1 = require("../device_filter");
|
|
@@ -7,89 +16,101 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
|
|
|
7
16
|
get deviceType() {
|
|
8
17
|
return "FeedTower";
|
|
9
18
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
getDetail(info, id) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
var axios = yield this.context.ready;
|
|
22
|
+
return axios
|
|
23
|
+
.post("/api/v1/pigfarm/device/status/detail?deviceId=" + id)
|
|
24
|
+
.then((res) => {
|
|
25
|
+
if (res.data.code != 200) {
|
|
26
|
+
throw res.data.message;
|
|
27
|
+
}
|
|
28
|
+
res.data.data.unit = info.unit;
|
|
29
|
+
return res.data.data;
|
|
30
|
+
});
|
|
20
31
|
});
|
|
21
32
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
device
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return Promise.all(ps).then((res) => {
|
|
32
|
-
if (res[0].data.Error) {
|
|
33
|
-
throw res[0].data.Error;
|
|
33
|
+
wrapData(id, args, p1) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const ps = [p1];
|
|
36
|
+
if (!args["ingoreInput"]) {
|
|
37
|
+
var axios = yield this.context.ready;
|
|
38
|
+
ps.push(axios.post(`/api/v1/pigfarm/device/fodder`, {
|
|
39
|
+
device: id,
|
|
40
|
+
times: [args.start, args.stop],
|
|
41
|
+
}));
|
|
34
42
|
}
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
return Promise.all(ps).then((res) => {
|
|
44
|
+
if (res[0].data.Error) {
|
|
45
|
+
throw res[0].data.Error;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
if (!args["ingoreInput"]) {
|
|
49
|
+
if (res[1].data.data.list == undefined) {
|
|
50
|
+
throw "未查询到饲料下料数据,请联系管理员";
|
|
51
|
+
}
|
|
52
|
+
res[1].data.data.list.forEach((item) => {
|
|
53
|
+
res[0].data[item.date] += item.data;
|
|
54
|
+
});
|
|
39
55
|
}
|
|
40
|
-
res[
|
|
41
|
-
res[0].data[item.date] += item.data;
|
|
42
|
-
});
|
|
56
|
+
return res[0].data;
|
|
43
57
|
}
|
|
44
|
-
|
|
45
|
-
}
|
|
58
|
+
});
|
|
46
59
|
});
|
|
47
60
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
wrapList(list) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const ids = list.map((device) => device.id);
|
|
64
|
+
var axios = yield this.context.ready;
|
|
65
|
+
//TODO 其他设备的详情需要支持,目前只有喂料塔
|
|
66
|
+
return axios
|
|
67
|
+
.post("/api/v1/pigfarm/device/status/list", ids)
|
|
68
|
+
.then((res) => {
|
|
69
|
+
if (res.data.code != 200) {
|
|
70
|
+
throw res.data.message;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
res.data.data.forEach((device) => {
|
|
74
|
+
const found = list.find((d) => d.id === device.id);
|
|
75
|
+
if (found) {
|
|
76
|
+
Object.assign(found, device);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return list;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
67
82
|
});
|
|
68
83
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
84
|
+
enter(data) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
var axios = yield this.context.ready;
|
|
87
|
+
const res = yield axios.post("/api/v1/pigfarm/device/fodder/import", data);
|
|
88
|
+
return res;
|
|
89
|
+
});
|
|
73
90
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
getCar(truck) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
var axios = yield this.context.ready;
|
|
94
|
+
const res = yield axios.get("/api/v1/pigfarm/car", {
|
|
95
|
+
params: {
|
|
96
|
+
truckCode: truck,
|
|
97
|
+
random: 1,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
return res.data;
|
|
81
101
|
});
|
|
82
|
-
return res.data;
|
|
83
102
|
}
|
|
84
103
|
// async getCarList(): Promise<any> {
|
|
85
104
|
// var axios = await this.context.ready;
|
|
86
105
|
// const res = await axios.get("/api/v1/pigfarm/car/list");
|
|
87
106
|
// return res.data;
|
|
88
107
|
// }
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
108
|
+
updateZeroTime(id) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
var axios = yield this.context.ready;
|
|
111
|
+
const res = yield axios.post("/api/v1/pigfarm/device/status/updateZeroTime" + "?id=" + id);
|
|
112
|
+
return res;
|
|
113
|
+
});
|
|
93
114
|
}
|
|
94
115
|
/**
|
|
95
116
|
* 查询指定设备的饲料统计信息
|
|
@@ -99,66 +120,74 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
|
|
|
99
120
|
* @param end 结束时间,格式为yyyy-MM-dd
|
|
100
121
|
* @returns 饲料统计信息
|
|
101
122
|
*/
|
|
102
|
-
|
|
103
|
-
return this
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
123
|
+
stat(deviceIds, start, end) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
return this.context.ready.then((axios) => {
|
|
126
|
+
return axios.post(`/api/v1/pigfarm/feedStatics`, {
|
|
127
|
+
ids: deviceIds,
|
|
128
|
+
type: "device",
|
|
129
|
+
start: start,
|
|
130
|
+
end: end,
|
|
131
|
+
});
|
|
109
132
|
});
|
|
110
133
|
});
|
|
111
134
|
}
|
|
112
135
|
//设置报警参数
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
136
|
+
setAlarmParam(deviceId, param) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
var axios = yield this.context.ready;
|
|
139
|
+
return axios.post(`/api/v2/device/config/feedTowerAlert/add`, {
|
|
140
|
+
deviceId,
|
|
141
|
+
config: param,
|
|
142
|
+
});
|
|
118
143
|
});
|
|
119
144
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
145
|
+
updateAlarmParam(deviceId, param) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
var axios = yield this.context.ready;
|
|
148
|
+
return axios.post(`/api/v2/device/config/feedTowerAlert/update`, {
|
|
149
|
+
deviceId,
|
|
150
|
+
config: param,
|
|
151
|
+
});
|
|
125
152
|
});
|
|
126
153
|
}
|
|
127
154
|
//获取报警参数
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
155
|
+
getAlarmParam(deviceId) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
var axios = yield this.context.ready;
|
|
158
|
+
return axios.get(`/api/v2/device/config/feedTowerAlert/${deviceId}`);
|
|
159
|
+
});
|
|
131
160
|
}
|
|
132
161
|
//新版料塔列表功能,id为工厂id
|
|
133
162
|
v2() {
|
|
134
163
|
return {
|
|
135
|
-
list:
|
|
136
|
-
var axios =
|
|
164
|
+
list: (...args_1) => __awaiter(this, [...args_1], void 0, function* (options = undefined) {
|
|
165
|
+
var axios = yield this.context.ready;
|
|
137
166
|
return axios.get(`/api/v2/device/feedTower/list/${options === null || options === void 0 ? void 0 : options.id}`);
|
|
138
|
-
},
|
|
139
|
-
add:
|
|
140
|
-
var axios =
|
|
167
|
+
}),
|
|
168
|
+
add: (ft) => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
var axios = yield this.context.ready;
|
|
141
170
|
return axios.post("/api/v2/device/feedTower/add", ft);
|
|
142
|
-
},
|
|
143
|
-
update:
|
|
144
|
-
var axios =
|
|
171
|
+
}),
|
|
172
|
+
update: (ft) => __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
var axios = yield this.context.ready;
|
|
145
174
|
return axios.post("/api/v2/device/feedTower/update", ft);
|
|
146
|
-
},
|
|
147
|
-
adzero:
|
|
148
|
-
var axios =
|
|
175
|
+
}),
|
|
176
|
+
adzero: (ft_1, ...args_1) => __awaiter(this, [ft_1, ...args_1], void 0, function* (ft, force = false) {
|
|
177
|
+
var axios = yield this.context.ready;
|
|
149
178
|
return axios.post(`/api/v2/device/feedTower/adzero`, {
|
|
150
179
|
id: ft.id,
|
|
151
180
|
force: force
|
|
152
181
|
});
|
|
153
|
-
},
|
|
154
|
-
correctWeight:
|
|
155
|
-
var axios =
|
|
182
|
+
}),
|
|
183
|
+
correctWeight: (ft_1, amount_1, ...args_1) => __awaiter(this, [ft_1, amount_1, ...args_1], void 0, function* (ft, amount, displayAmount = undefined) {
|
|
184
|
+
var axios = yield this.context.ready;
|
|
156
185
|
return axios.post(`/api/v2/device/feedTower/correctWeight`, {
|
|
157
186
|
id: ft.id,
|
|
158
187
|
suttle: amount,
|
|
159
188
|
displaySuttle: displayAmount
|
|
160
189
|
});
|
|
161
|
-
}
|
|
190
|
+
})
|
|
162
191
|
};
|
|
163
192
|
}
|
|
164
193
|
}
|
package/dist/energy_gateway.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.EnergyGateway = void 0;
|
|
4
13
|
const electric_meter_gateway_1 = require("./energy_types/electric_meter_gateway");
|
|
@@ -20,31 +29,35 @@ class EnergyGateway extends Object {
|
|
|
20
29
|
* @param type 统计类型
|
|
21
30
|
* @param factoryId 工厂ID
|
|
22
31
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
stat(type_1) {
|
|
33
|
+
return __awaiter(this, arguments, void 0, function* (type, factoryId = undefined) {
|
|
34
|
+
if (!factoryId) {
|
|
35
|
+
var factory = yield this.context.user.getSelectedFarm();
|
|
36
|
+
factoryId = factory.id;
|
|
37
|
+
}
|
|
38
|
+
var axios = yield this.context.ready;
|
|
39
|
+
return axios.get(`/api/v3/energy/stat/${type}`, { params: { factory_id: factoryId } });
|
|
40
|
+
});
|
|
30
41
|
}
|
|
31
42
|
/**
|
|
32
43
|
* 创建能源统计记录
|
|
33
44
|
* @param request 创建统计请求参数
|
|
34
45
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
createStat(request) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
if (!request.factory_id) {
|
|
49
|
+
const factory = yield this.context.user.getSelectedFarm();
|
|
50
|
+
request.factory_id = factory.id;
|
|
51
|
+
}
|
|
52
|
+
const axios = yield this.context.ready;
|
|
53
|
+
return axios.post('/api/v3/energy/createstat', {
|
|
54
|
+
factory_id: request.factory_id,
|
|
55
|
+
time: request.time.toISOString(),
|
|
56
|
+
period: request.period,
|
|
57
|
+
electric: request.electric,
|
|
58
|
+
gas: request.gas,
|
|
59
|
+
cpv: request.cpv
|
|
60
|
+
});
|
|
48
61
|
});
|
|
49
62
|
}
|
|
50
63
|
}
|
package/dist/factory_gateway.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.FactoryGateway = void 0;
|
|
4
13
|
class FactoryGateway extends Object {
|
|
@@ -12,76 +21,94 @@ class FactoryGateway extends Object {
|
|
|
12
21
|
};
|
|
13
22
|
this.context = context;
|
|
14
23
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
search(data) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
yield this.context.ready;
|
|
27
|
+
const response = yield this.context.axios.post("/api/v1/factory/search", data);
|
|
28
|
+
return response.data;
|
|
29
|
+
});
|
|
19
30
|
}
|
|
20
31
|
//获得工厂的单元信息
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
unit(id) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
var axios = yield this.context.ready;
|
|
35
|
+
const response = yield axios.get(`/api/v1/unit/${id}`);
|
|
36
|
+
return response.data;
|
|
37
|
+
});
|
|
25
38
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
add(factory) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
var axios = yield this.context.ready;
|
|
42
|
+
return axios.post("/api/v2/company/factory", factory);
|
|
43
|
+
});
|
|
29
44
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
listByCompany(companyId) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
var axios = yield this.context.ready;
|
|
48
|
+
return axios.get(`/api/v2/company/${companyId}/factory`);
|
|
49
|
+
});
|
|
33
50
|
}
|
|
34
51
|
//获得工厂的应用信息, 如果指定withRoles为true,则返回app和app的详细角色信息
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
apps(id_1) {
|
|
53
|
+
return __awaiter(this, arguments, void 0, function* (id, withRoles = false) {
|
|
54
|
+
var axios = yield this.context.ready;
|
|
55
|
+
var url = `/api/v1/factory/${id}/apps`;
|
|
56
|
+
if (withRoles) {
|
|
57
|
+
url += "/roles";
|
|
58
|
+
}
|
|
59
|
+
const response = yield axios.get(url);
|
|
60
|
+
return response.data;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
roles(id) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
var axios = yield this.context.ready;
|
|
66
|
+
return axios.get("/api/v2/factory/" + id + "/roles");
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
addRole(id, data) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
data.factoryId = id;
|
|
72
|
+
var axios = yield this.context.ready;
|
|
73
|
+
return axios.post("/api/v2/factory/role", data);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
deleteRole(roleId) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
var axios = yield this.context.ready;
|
|
79
|
+
return axios.post("/api/v2/factory/role/delete?id=" + roleId);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
users(id) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
var axios = yield this.context.ready;
|
|
85
|
+
return axios.get("/api/v2/factory/" + id + "/users");
|
|
86
|
+
});
|
|
60
87
|
}
|
|
61
88
|
//获得工厂的车间信息
|
|
62
89
|
get workshop() {
|
|
63
90
|
return {
|
|
64
|
-
get:
|
|
65
|
-
var axios =
|
|
66
|
-
const response =
|
|
91
|
+
get: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
var axios = yield this.context.ready;
|
|
93
|
+
const response = yield axios.get(`/api/v1/workshop/${id}`);
|
|
67
94
|
return response.data;
|
|
68
|
-
},
|
|
69
|
-
post:
|
|
70
|
-
var axios =
|
|
95
|
+
}),
|
|
96
|
+
post: (data) => __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
var axios = yield this.context.ready;
|
|
71
98
|
return axios.post(`/api/v1/workshop/create`, data);
|
|
72
|
-
},
|
|
73
|
-
types:
|
|
74
|
-
var axios =
|
|
99
|
+
}),
|
|
100
|
+
types: (factory) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
var axios = yield this.context.ready;
|
|
75
102
|
return axios.get(`/api/v2/factory/${factory.business_kind}/workshop/type`);
|
|
76
|
-
},
|
|
77
|
-
list:
|
|
78
|
-
var axios =
|
|
103
|
+
}),
|
|
104
|
+
list: (factory) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
var axios = yield this.context.ready;
|
|
79
106
|
return axios.get(`/api/v1/factory/${factory.id}/workshops`);
|
|
80
|
-
},
|
|
81
|
-
delete:
|
|
82
|
-
var axios =
|
|
107
|
+
}),
|
|
108
|
+
delete: (id) => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
var axios = yield this.context.ready;
|
|
83
110
|
return axios.post(`/api/v2/workshop/delete?id=${id}`);
|
|
84
|
-
},
|
|
111
|
+
}),
|
|
85
112
|
};
|
|
86
113
|
}
|
|
87
114
|
//获得工厂的基础信息,城市,省份,建造信息等
|
|
@@ -96,10 +123,12 @@ class FactoryGateway extends Object {
|
|
|
96
123
|
};
|
|
97
124
|
}
|
|
98
125
|
//获得工厂的所有车间信息
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
126
|
+
workshops(id) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
var axios = yield this.context.ready;
|
|
129
|
+
const response = yield axios.get(`/api/v1/factory/${id}/workshops`);
|
|
130
|
+
return response.data;
|
|
131
|
+
});
|
|
103
132
|
}
|
|
104
133
|
//获得工厂的所有单元信息,以车间为单位树状结构
|
|
105
134
|
/**
|
|
@@ -108,37 +137,45 @@ class FactoryGateway extends Object {
|
|
|
108
137
|
* @param id 工厂ID,可选参数。如果不提供,则默认获取当前用户选择的工厂ID
|
|
109
138
|
* @returns 返回包含单元信息的对象
|
|
110
139
|
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
140
|
+
units() {
|
|
141
|
+
return __awaiter(this, arguments, void 0, function* (id = undefined) {
|
|
142
|
+
var axios = yield this.context.ready;
|
|
143
|
+
if (!id) {
|
|
144
|
+
var farm = yield this.context.user.getSelectedFarm();
|
|
145
|
+
id = farm.id;
|
|
146
|
+
}
|
|
147
|
+
const response = yield axios.get(`/api/v2/factory/${id}/units`);
|
|
148
|
+
return response.data;
|
|
149
|
+
});
|
|
119
150
|
}
|
|
120
151
|
//获得工厂的业务类型
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
152
|
+
businessType(data) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
var axios = yield this.context.ready;
|
|
155
|
+
const response = yield axios.get(`/api/v2/factory/businessType/${data.type}`);
|
|
156
|
+
return response.data;
|
|
157
|
+
});
|
|
125
158
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
159
|
+
company(data) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
var axios = yield this.context.ready;
|
|
162
|
+
const response = yield axios.get(`/api/v1/factory/${data.id}/organizaion`, data);
|
|
163
|
+
return response.data;
|
|
164
|
+
});
|
|
130
165
|
}
|
|
131
166
|
//支持以下三个name:'capacity'(规模),'used_capacity'(存栏量),'workshop_count'(栋舍/车间数量),'manager'(负责人),'electric'/'water'/'feed' (电耗/水耗/饲料耗)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
167
|
+
entry(factory, name) {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
var axios = yield this.context.ready;
|
|
170
|
+
if (["electric", "water", "feed"].indexOf(name) !== -1) {
|
|
171
|
+
const response = yield axios.post(`/api/v1/pigfarm/consumption/${factory.id}`, {
|
|
172
|
+
type: name,
|
|
173
|
+
});
|
|
174
|
+
return response.data;
|
|
175
|
+
}
|
|
176
|
+
const response = yield axios.get(`/api/v1/factory/${factory.id}/entry/${name}`);
|
|
138
177
|
return response.data;
|
|
139
|
-
}
|
|
140
|
-
const response = await axios.get(`/api/v1/factory/${factory.id}/entry/${name}`);
|
|
141
|
-
return response.data;
|
|
178
|
+
});
|
|
142
179
|
}
|
|
143
180
|
get banner() {
|
|
144
181
|
return {
|
|
@@ -159,13 +196,15 @@ class FactoryGateway extends Object {
|
|
|
159
196
|
};
|
|
160
197
|
}
|
|
161
198
|
//获得工厂的设备报警信息
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
199
|
+
alert(params) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
let axios = yield this.context.ready;
|
|
202
|
+
const response = yield axios.get(`/api/v1/device/alert`, {
|
|
203
|
+
params: params,
|
|
204
|
+
});
|
|
205
|
+
const json = response.data;
|
|
206
|
+
return json;
|
|
166
207
|
});
|
|
167
|
-
const json = response.data;
|
|
168
|
-
return json;
|
|
169
208
|
}
|
|
170
209
|
}
|
|
171
210
|
exports.FactoryGateway = FactoryGateway;
|
package/dist/index.js
CHANGED
|
@@ -311,7 +311,7 @@ class Cpzxrobot {
|
|
|
311
311
|
// 列出所有的本地开发域名
|
|
312
312
|
const localDomains = ["localhost", "127.0.0.1", "0.0.0.0"];
|
|
313
313
|
// 检查当前域名是否在本地开发域名列表中
|
|
314
|
-
return localDomains.
|
|
314
|
+
return localDomains.indexOf(domain) !== -1;
|
|
315
315
|
}
|
|
316
316
|
setTitle(title) {
|
|
317
317
|
if (this.platform) {
|