@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
package/company_gateway.ts
CHANGED
|
@@ -39,13 +39,14 @@ export class CompanyGateway extends Object {
|
|
|
39
39
|
|
|
40
40
|
get data() {
|
|
41
41
|
return {
|
|
42
|
-
export: async (companyId: string, supplier?: string, startDate?: string, endDate?: string) => {
|
|
42
|
+
export: async (companyId: string, supplier?: string,modelId?: string, startDate?: string, endDate?: string) => {
|
|
43
43
|
var axios = await this.context.ready;
|
|
44
44
|
return axios.getAndSave(`/api/v2/company/${companyId}/data/export`, {
|
|
45
45
|
params: {
|
|
46
46
|
supplier,
|
|
47
47
|
startDate,
|
|
48
|
-
endDate
|
|
48
|
+
endDate,
|
|
49
|
+
model: modelId,
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
}
|
package/device_filter.ts
CHANGED
|
@@ -160,8 +160,8 @@ export abstract class DeviceFilter<T extends { id: number }> {
|
|
|
160
160
|
var dataGroups = new SensorDatas();
|
|
161
161
|
var field: FieldDatas | null = null;
|
|
162
162
|
for (var i = 0; i < arr.length; i++) {
|
|
163
|
-
var values = arr[i]
|
|
164
|
-
if (arr[i]
|
|
163
|
+
var values = arr[i]!.split(",");
|
|
164
|
+
if (arr[i]!.startsWith("#")) {
|
|
165
165
|
if (!inAnnotation) {
|
|
166
166
|
inAnnotation = true;
|
|
167
167
|
if (field) {
|
|
@@ -188,7 +188,7 @@ export abstract class DeviceFilter<T extends { id: number }> {
|
|
|
188
188
|
if (inAnnotation) {
|
|
189
189
|
inAnnotation = false;
|
|
190
190
|
for (var j = 0; j < values.length; j++) {
|
|
191
|
-
field!.columns.set(values[j]
|
|
191
|
+
field!.columns.set(values[j]!, j);
|
|
192
192
|
}
|
|
193
193
|
} else {
|
|
194
194
|
field!.values.push(values);
|
|
@@ -240,7 +240,7 @@ export abstract class DeviceFilter<T extends { id: number }> {
|
|
|
240
240
|
const matcher = args.start.match(/-(\d+)(\w+)/);
|
|
241
241
|
if (matcher) {
|
|
242
242
|
d = new Date();
|
|
243
|
-
const num = parseInt(matcher[1]);
|
|
243
|
+
const num = parseInt(matcher[1]!);
|
|
244
244
|
const unit = matcher[2];
|
|
245
245
|
if (unit == "y") {
|
|
246
246
|
d.setFullYear(d.getFullYear() - num);
|
package/device_gateway.ts
CHANGED
|
@@ -75,6 +75,16 @@ export class DeviceGateway extends Object {
|
|
|
75
75
|
filters: Map<string, DeviceFilter<any>>;
|
|
76
76
|
public normalFilter: NormalGateway;
|
|
77
77
|
context: Cpzxrobot;
|
|
78
|
+
public categories = [
|
|
79
|
+
{ id: 0, name: '网关',order: 4 }, //排序时网关优先级不高
|
|
80
|
+
{ id: 1, name: '传感器',order: 1 },
|
|
81
|
+
{ id: 2, name: '执行器',order: 2 },
|
|
82
|
+
{ id: 3, name: 'AI设备',order: 3 },
|
|
83
|
+
{ id: 4, name: '业务数据',order: 5 },
|
|
84
|
+
{ id: 5, name: '设备参数',order: 6 },
|
|
85
|
+
{ id: 8, name: '生产设备',order: 7 },
|
|
86
|
+
{ id: 9, name: '设备部件',order: 8 },
|
|
87
|
+
];
|
|
78
88
|
|
|
79
89
|
get v2() {
|
|
80
90
|
return {
|
|
@@ -355,8 +365,8 @@ export class DeviceGateway extends Object {
|
|
|
355
365
|
var columns: string[] = [];
|
|
356
366
|
var faults: DeviceFault[] = [];
|
|
357
367
|
for (var i = 0; i < arr.length; i++) {
|
|
358
|
-
var values = arr[i]
|
|
359
|
-
if (arr[i]
|
|
368
|
+
var values = arr[i]!.split(",");
|
|
369
|
+
if (arr[i]!.startsWith("#")) {
|
|
360
370
|
} else if (arr[i] != "") {
|
|
361
371
|
if (inAnnotation) {
|
|
362
372
|
inAnnotation = false;
|
|
@@ -14,7 +14,7 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
|
|
|
14
14
|
return "FeedTower";
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
async getDetail(info: FeedTower, id: number) {
|
|
17
|
+
override async getDetail(info: FeedTower, id: number) {
|
|
18
18
|
var axios = await this.context.ready;
|
|
19
19
|
return axios
|
|
20
20
|
.post("/api/v1/pigfarm/device/status/detail?deviceId=" + id)
|
|
@@ -27,9 +27,9 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
async wrapData(id: number, args: DataQueryArgs, p1: Promise<any>) {
|
|
30
|
+
override async wrapData(id: number, args: DataQueryArgs, p1: Promise<any>) {
|
|
31
31
|
const ps = [p1];
|
|
32
|
-
if (!args
|
|
32
|
+
if (!args["ingoreInput"]) {
|
|
33
33
|
var axios = await this.context.ready;
|
|
34
34
|
ps.push(
|
|
35
35
|
axios.post(`/api/v1/pigfarm/device/fodder`, {
|
|
@@ -43,7 +43,7 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
|
|
|
43
43
|
if (res[0].data.Error) {
|
|
44
44
|
throw res[0].data.Error;
|
|
45
45
|
} else {
|
|
46
|
-
if (!args
|
|
46
|
+
if (!args["ingoreInput"]) {
|
|
47
47
|
if (res[1].data.data.list == undefined) {
|
|
48
48
|
throw "未查询到饲料下料数据,请联系管理员";
|
|
49
49
|
}
|
|
@@ -56,7 +56,7 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
async wrapList(list: FeedTower[]): Promise<FeedTower[]> {
|
|
59
|
+
override async wrapList(list: FeedTower[]): Promise<FeedTower[]> {
|
|
60
60
|
const ids = list.map((device) => device.id);
|
|
61
61
|
var axios = await this.context.ready;
|
|
62
62
|
//TODO 其他设备的详情需要支持,目前只有喂料塔
|
package/dist/camera_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.CameraGateway = void 0;
|
|
4
13
|
class CameraGateway extends Object {
|
|
@@ -7,55 +16,65 @@ class CameraGateway extends Object {
|
|
|
7
16
|
this.context = context;
|
|
8
17
|
}
|
|
9
18
|
//查询摄像头,如果传unit,按单元搜索,或者有unit_id,优先使用unit_id,然后使用workshop_id,最后使用factory_id,查询对应的摄像头
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
search(data) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
var axios = yield this.context.ready;
|
|
22
|
+
var params = {};
|
|
23
|
+
if (!("id" in data)) {
|
|
24
|
+
//should has unit_id or factory_id or workshop_id at least one, if has more than one, use unit_id first,then workshop_id, then factory_id
|
|
25
|
+
params = data;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
params = { unit_id: data.id };
|
|
29
|
+
}
|
|
30
|
+
const response = yield axios.post("/api/v1/camera/search", params);
|
|
31
|
+
return response.data;
|
|
32
|
+
});
|
|
22
33
|
}
|
|
23
34
|
//获得摄像头的播放地址
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
getUrl(data) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
var axios = yield this.context.ready;
|
|
38
|
+
const response = yield axios.get(`/api/v1/camera/${data.id}/url/wss`);
|
|
39
|
+
return response.data;
|
|
40
|
+
});
|
|
28
41
|
}
|
|
29
42
|
//获取工厂天气
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
weather(id) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
var axios = yield this.context.ready;
|
|
46
|
+
const response = yield axios.get(`/api/v1/weather?factoryId=${id}`);
|
|
47
|
+
return response.data;
|
|
48
|
+
});
|
|
34
49
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
control(data, action, start, stop) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
var axios = yield this.context.ready;
|
|
53
|
+
var url = `/api/v1/camera/${data.id}/control/${action}`;
|
|
54
|
+
if (start) {
|
|
55
|
+
url += `?start=${start}`;
|
|
56
|
+
}
|
|
57
|
+
else if (stop) {
|
|
58
|
+
url += `?stop=${stop}`;
|
|
59
|
+
}
|
|
60
|
+
const response = yield axios.get(url);
|
|
61
|
+
return response.data;
|
|
62
|
+
});
|
|
46
63
|
}
|
|
47
64
|
// 获取摄像头历史视频回放地址
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
playback(data) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
var axios = yield this.context.ready;
|
|
68
|
+
var url = `/api/v1/camera/${data.id}/playback`;
|
|
69
|
+
if (data.start) {
|
|
70
|
+
url += `?start=${encodeURIComponent(data.start)}`;
|
|
71
|
+
}
|
|
72
|
+
if (data.end) {
|
|
73
|
+
url += `${data.start ? '&' : '?'}end=${encodeURIComponent(data.end)}`;
|
|
74
|
+
}
|
|
75
|
+
const response = yield axios.get(url);
|
|
76
|
+
return response.data;
|
|
77
|
+
});
|
|
59
78
|
}
|
|
60
79
|
}
|
|
61
80
|
exports.CameraGateway = CameraGateway;
|
package/dist/car_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.CarGateway = void 0;
|
|
4
13
|
class CarGateway extends Object {
|
|
@@ -6,36 +15,46 @@ class CarGateway extends Object {
|
|
|
6
15
|
super();
|
|
7
16
|
this.context = context;
|
|
8
17
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
weightRecords(factory, date) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var axios = yield this.context.ready;
|
|
21
|
+
return axios
|
|
22
|
+
.get(`/api/v2/car/${factory.pid}/weightRecords?date=` + date.toISOString())
|
|
23
|
+
.then((res) => res.data);
|
|
24
|
+
});
|
|
14
25
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
detections(factory, date) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
var axios = yield this.context.ready;
|
|
29
|
+
return axios
|
|
30
|
+
.get(`/api/v2/car/${factory.pid}/detections?date=` + date.toISOString())
|
|
31
|
+
.then((res) => res.data);
|
|
32
|
+
});
|
|
20
33
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
cars(factory) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
var axios = yield this.context.ready;
|
|
37
|
+
return axios
|
|
38
|
+
.get(`/api/v2/car/${factory.pid}/cars`)
|
|
39
|
+
.then((res) => res.data);
|
|
40
|
+
});
|
|
26
41
|
}
|
|
27
42
|
//根据工厂pid获取订单列表,注意,该接口和
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
orders(factory, date) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
var axios = yield this.context.ready;
|
|
46
|
+
return axios
|
|
47
|
+
.get(`/api/v2/car/${factory.pid}/orders?date=` + date.toISOString());
|
|
48
|
+
});
|
|
32
49
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
50
|
+
ordersByFactory(factory, date) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
var axios = yield this.context.ready;
|
|
53
|
+
//filter=未分配的
|
|
54
|
+
return axios
|
|
55
|
+
.get(`/api/v2/car/${factory.id}/order?date=` + date.toISOString() + "&filter=unallocated")
|
|
56
|
+
.then((res) => res.data);
|
|
57
|
+
});
|
|
39
58
|
}
|
|
40
59
|
listByProvince(area_code) {
|
|
41
60
|
return this.context.ready.then((axios) => {
|
|
@@ -65,13 +84,17 @@ class CarGateway extends Object {
|
|
|
65
84
|
// "manualCarWeightTime":"2025-05-08 08:20:49"
|
|
66
85
|
// }
|
|
67
86
|
// 增加手动重量记录或者增加称重记录
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
87
|
+
updateRecord(factory, record) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
var axios = yield this.context.ready;
|
|
90
|
+
return axios.post(`/api/v2/car/${factory.pid}/weightRecord`, record);
|
|
91
|
+
});
|
|
71
92
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
93
|
+
addRecord(factory, record) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
var axios = yield this.context.ready;
|
|
96
|
+
return axios.post(`/api/v2/car/${factory.pid}/weightRecord`, record);
|
|
97
|
+
});
|
|
75
98
|
}
|
|
76
99
|
}
|
|
77
100
|
exports.CarGateway = CarGateway;
|
|
@@ -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.ChickenFarmGateway = void 0;
|
|
4
13
|
class ChickenFarmGateway extends Object {
|
|
@@ -9,11 +18,11 @@ class ChickenFarmGateway extends Object {
|
|
|
9
18
|
//获得日龄
|
|
10
19
|
get deadDetection() {
|
|
11
20
|
return {
|
|
12
|
-
by_factory:
|
|
21
|
+
by_factory: (factory_1, ...args_1) => __awaiter(this, [factory_1, ...args_1], void 0, function* (factory, status = "running") {
|
|
13
22
|
return this.context.ready.then((axios) => {
|
|
14
23
|
return axios.get(`api/v2/diedchicken/task/factory=${factory.id}/status=${status}`);
|
|
15
24
|
});
|
|
16
|
-
},
|
|
25
|
+
}),
|
|
17
26
|
detail: (taskId, offset = 0, size = 10) => {
|
|
18
27
|
return this.context.ready.then((axios) => {
|
|
19
28
|
return axios.get(`api/v2/diedchicken/task/${taskId}`, {
|