@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.
@@ -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].split(",");
164
- if (arr[i].startsWith("#")) {
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], 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].split(",");
359
- if (arr[i].startsWith("#")) {
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.ingoreInput) {
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.ingoreInput) {
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 其他设备的详情需要支持,目前只有喂料塔
@@ -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
- async search(data) {
11
- var axios = await this.context.ready;
12
- var params = {};
13
- if (!("id" in data)) {
14
- //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
15
- params = data;
16
- }
17
- else {
18
- params = { unit_id: data.id };
19
- }
20
- const response = await axios.post("/api/v1/camera/search", params);
21
- return response.data;
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
- async getUrl(data) {
25
- var axios = await this.context.ready;
26
- const response = await axios.get(`/api/v1/camera/${data.id}/url/wss`);
27
- return response.data;
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
- async weather(id) {
31
- var axios = await this.context.ready;
32
- const response = await axios.get(`/api/v1/weather?factoryId=${id}`);
33
- return response.data;
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
- async control(data, action, start, stop) {
36
- var axios = await this.context.ready;
37
- var url = `/api/v1/camera/${data.id}/control/${action}`;
38
- if (start) {
39
- url += `?start=${start}`;
40
- }
41
- else if (stop) {
42
- url += `?stop=${stop}`;
43
- }
44
- const response = await axios.get(url);
45
- return response.data;
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
- async playback(data) {
49
- var axios = await this.context.ready;
50
- var url = `/api/v1/camera/${data.id}/playback`;
51
- if (data.start) {
52
- url += `?start=${encodeURIComponent(data.start)}`;
53
- }
54
- if (data.end) {
55
- url += `${data.start ? '&' : '?'}end=${encodeURIComponent(data.end)}`;
56
- }
57
- const response = await axios.get(url);
58
- return response.data;
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;
@@ -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
- async weightRecords(factory, date) {
10
- var axios = await this.context.ready;
11
- return axios
12
- .get(`/api/v2/car/${factory.pid}/weightRecords?date=` + date.toISOString())
13
- .then((res) => res.data);
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
- async detections(factory, date) {
16
- var axios = await this.context.ready;
17
- return axios
18
- .get(`/api/v2/car/${factory.pid}/detections?date=` + date.toISOString())
19
- .then((res) => res.data);
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
- async cars(factory) {
22
- var axios = await this.context.ready;
23
- return axios
24
- .get(`/api/v2/car/${factory.pid}/cars`)
25
- .then((res) => res.data);
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
- async orders(factory, date) {
29
- var axios = await this.context.ready;
30
- return axios
31
- .get(`/api/v2/car/${factory.pid}/orders?date=` + date.toISOString());
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
- async ordersByFactory(factory, date) {
34
- var axios = await this.context.ready;
35
- //filter=未分配的
36
- return axios
37
- .get(`/api/v2/car/${factory.id}/order?date=` + date.toISOString() + "&filter=unallocated")
38
- .then((res) => res.data);
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
- async updateRecord(factory, record) {
69
- var axios = await this.context.ready;
70
- return axios.post(`/api/v2/car/${factory.pid}/weightRecord`, record);
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
- async addRecord(factory, record) {
73
- var axios = await this.context.ready;
74
- return axios.post(`/api/v2/car/${factory.pid}/weightRecord`, record);
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: async (factory, status = "running") => {
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}`, {