@cpzxrobot/sdk 1.0.60 → 1.0.62

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.
@@ -1,103 +1,110 @@
1
- import { type FodderOrderList, type FeedTower,type FeedTowerExtraInfo, DataQueryArgs } from '..'
2
- import { DeviceFilter } from '../device_filter'
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 'FeedTower'
13
+ return "FeedTower";
9
14
  }
10
15
 
11
16
  getDetail(info: FeedTower, id: number) {
12
17
  return this.context.axios
13
- .post('/api/v1/pigfarm/device/status/detail?deviceId=' + id)
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('/api/v1/pigfarm/device/status/list', ids)
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('/api/v1/pigfarm/device/fodder/import', data)
71
- return res
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('/api/v1/pigfarm/car', {
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('/api/v1/pigfarm/car/list')
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
- '/api/v1/pigfarm/device/status/updateZeroTime' + '?id=' + id
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
- * @param deviceIds 设备ID数组
97
- * @param start 开始时间,格式为yyyy-MM-dd
98
- * @param end 结束时间,格式为yyyy-MM-dd
99
- * @returns 饲料统计信息
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,24 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
108
115
  });
109
116
  });
110
117
  }
118
+
119
+ //设置报警参数
120
+ async setAlarmParam(
121
+ deviceId: number,
122
+ param: {
123
+ zeroPeriod: number;
124
+ zeroValue: number;
125
+ alertDays: number[];
126
+ }
127
+ ) {
128
+ return this.context.axios.post(`/api/v2/device/config/feedTowerAlert/add`, {
129
+ deviceId,
130
+ config: param,
131
+ });
132
+ }
133
+
134
+ //获取报警参数
135
+ async getAlarmParam(deviceId: number) {
136
+ return this.context.axios.get(`/api/v2/device/config/feedTowerAlert/${deviceId}`);
137
+ }
111
138
  }
@@ -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 'FeedTower';
8
+ return "FeedTower";
9
9
  }
10
10
  getDetail(info, id) {
11
11
  return this.context.axios
12
- .post('/api/v1/pigfarm/device/status/detail?deviceId=' + id)
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('/api/v1/pigfarm/device/status/list', ids)
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('/api/v1/pigfarm/device/fodder/import', data);
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('/api/v1/pigfarm/car', {
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('/api/v1/pigfarm/car/list');
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('/api/v1/pigfarm/device/status/updateZeroTime' + '?id=' + id);
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
- * @param deviceIds 设备ID数组
88
- * @param start 开始时间,格式为yyyy-MM-dd
89
- * @param end 结束时间,格式为yyyy-MM-dd
90
- * @returns 饲料统计信息
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,16 @@ 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
+ }
109
+ //获取报警参数
110
+ async getAlarmParam(deviceId) {
111
+ return this.context.axios.get(`/api/v2/device/config/feedTowerAlert/${deviceId}`);
112
+ }
102
113
  }
103
114
  exports.FeedTowerGateway = FeedTowerGateway;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -87,6 +87,7 @@ baseURL: "/"
87
87
  | cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
88
88
  | cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
89
89
  | cpzxrobot().device.feedTower.stat | 获得料塔设备的料耗,饲料重量 |
90
+ | cpzxrobot().device.feedTower.setAlarmParam | 设置料塔设备的报警参数 |
90
91
  | cpzxrobot().pigfarm.unitStat | 获得单元的统计信息,包括每日料耗,饲料消耗,日龄,存栏量等 |
91
92
  | cpzxrobot().pigfarm.heatlamp.set | 设置保温灯的当前工作日龄,调用时,action传"dayage",argc传天数 |
92
93
  | cpzxrobot().pigfarm.heatlamp.switch | 设置保温灯的当前工作日龄,调用时,action"on"或"off" |
package/types.d.ts CHANGED
@@ -157,6 +157,7 @@ type WeightMeter = {
157
157
  type WeightMeterSensor = {
158
158
  id: number;
159
159
  weightMeterId: number; //仪表id
160
+ weightMeterNum: number; //仪表路数
160
161
  scaleDivision: number; //分度值
161
162
  fullScale: number; //满量程
162
163
  slopeRate: number; //斜率值
package/unit_gateway.ts CHANGED
@@ -10,7 +10,7 @@ export class UnitGateway extends Object {
10
10
  return {
11
11
  add: (
12
12
  unit: Unit,
13
- type: "heatLamp",
13
+ type: "HeatLamp",
14
14
  config: {
15
15
  [key: string]: any;
16
16
  }