@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.
@@ -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
- async getDetail(info, id) {
11
- var axios = await this.context.ready;
12
- return axios
13
- .post("/api/v1/pigfarm/device/status/detail?deviceId=" + id)
14
- .then((res) => {
15
- if (res.data.code != 200) {
16
- throw res.data.message;
17
- }
18
- res.data.data.unit = info.unit;
19
- return res.data.data;
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
- async wrapData(id, args, p1) {
23
- const ps = [p1];
24
- if (!args.ingoreInput) {
25
- var axios = await this.context.ready;
26
- ps.push(axios.post(`/api/v1/pigfarm/device/fodder`, {
27
- device: id,
28
- times: [args.start, args.stop],
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
- else {
36
- if (!args.ingoreInput) {
37
- if (res[1].data.data.list == undefined) {
38
- throw "未查询到饲料下料数据,请联系管理员";
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[1].data.data.list.forEach((item) => {
41
- res[0].data[item.date] += item.data;
42
- });
56
+ return res[0].data;
43
57
  }
44
- return res[0].data;
45
- }
58
+ });
46
59
  });
47
60
  }
48
- async wrapList(list) {
49
- const ids = list.map((device) => device.id);
50
- var axios = await this.context.ready;
51
- //TODO 其他设备的详情需要支持,目前只有喂料塔
52
- return axios
53
- .post("/api/v1/pigfarm/device/status/list", ids)
54
- .then((res) => {
55
- if (res.data.code != 200) {
56
- throw res.data.message;
57
- }
58
- else {
59
- res.data.data.forEach((device) => {
60
- const found = list.find((d) => d.id === device.id);
61
- if (found) {
62
- Object.assign(found, device);
63
- }
64
- });
65
- return list;
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
- async enter(data) {
70
- var axios = await this.context.ready;
71
- const res = await axios.post("/api/v1/pigfarm/device/fodder/import", data);
72
- return res;
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
- async getCar(truck) {
75
- var axios = await this.context.ready;
76
- const res = await axios.get("/api/v1/pigfarm/car", {
77
- params: {
78
- truckCode: truck,
79
- random: 1,
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
- async updateZeroTime(id) {
90
- var axios = await this.context.ready;
91
- const res = await axios.post("/api/v1/pigfarm/device/status/updateZeroTime" + "?id=" + id);
92
- return res;
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
- async stat(deviceIds, start, end) {
103
- return this.context.ready.then((axios) => {
104
- return axios.post(`/api/v1/pigfarm/feedStatics`, {
105
- ids: deviceIds,
106
- type: "device",
107
- start: start,
108
- end: end,
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
- async setAlarmParam(deviceId, param) {
114
- var axios = await this.context.ready;
115
- return axios.post(`/api/v2/device/config/feedTowerAlert/add`, {
116
- deviceId,
117
- config: param,
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
- async updateAlarmParam(deviceId, param) {
121
- var axios = await this.context.ready;
122
- return axios.post(`/api/v2/device/config/feedTowerAlert/update`, {
123
- deviceId,
124
- config: param,
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
- async getAlarmParam(deviceId) {
129
- var axios = await this.context.ready;
130
- return axios.get(`/api/v2/device/config/feedTowerAlert/${deviceId}`);
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: async (options = undefined) => {
136
- var axios = await this.context.ready;
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: async (ft) => {
140
- var axios = await this.context.ready;
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: async (ft) => {
144
- var axios = await this.context.ready;
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: async (ft, force = false) => {
148
- var axios = await this.context.ready;
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: async (ft, amount, displayAmount = undefined) => {
155
- var axios = await this.context.ready;
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
  }
@@ -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
- async stat(type, factoryId = undefined) {
24
- if (!factoryId) {
25
- var factory = await this.context.user.getSelectedFarm();
26
- factoryId = factory.id;
27
- }
28
- var axios = await this.context.ready;
29
- return axios.get(`/api/v3/energy/stat/${type}`, { params: { factory_id: factoryId } });
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
- async createStat(request) {
36
- if (!request.factory_id) {
37
- const factory = await this.context.user.getSelectedFarm();
38
- request.factory_id = factory.id;
39
- }
40
- const axios = await this.context.ready;
41
- return axios.post('/api/v3/energy/createstat', {
42
- factory_id: request.factory_id,
43
- time: request.time.toISOString(),
44
- period: request.period,
45
- electric: request.electric,
46
- gas: request.gas,
47
- cpv: request.cpv
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
  }
@@ -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
- async search(data) {
16
- await this.context.ready;
17
- const response = await this.context.axios.post("/api/v1/factory/search", data);
18
- return response.data;
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
- async unit(id) {
22
- var axios = await this.context.ready;
23
- const response = await axios.get(`/api/v1/workshop/unit/${id}`);
24
- return response.data;
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
- async add(factory) {
27
- var axios = await this.context.ready;
28
- return axios.post("/api/v2/company/factory", factory);
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
- async listByCompany(companyId) {
31
- var axios = await this.context.ready;
32
- return axios.get(`/api/v2/company/${companyId}/factory`);
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
- async apps(id, withRoles = false) {
36
- var axios = await this.context.ready;
37
- var url = `/api/v1/factory/${id}/apps`;
38
- if (withRoles) {
39
- url += "/roles";
40
- }
41
- const response = await axios.get(url);
42
- return response.data;
43
- }
44
- async roles(id) {
45
- var axios = await this.context.ready;
46
- return axios.get("/api/v2/factory/" + id + "/roles");
47
- }
48
- async addRole(id, data) {
49
- data.factoryId = id;
50
- var axios = await this.context.ready;
51
- return axios.post("/api/v2/factory/role", data);
52
- }
53
- async deleteRole(roleId) {
54
- var axios = await this.context.ready;
55
- return axios.post("/api/v2/factory/role/delete?id=" + roleId);
56
- }
57
- async users(id) {
58
- var axios = await this.context.ready;
59
- return axios.get("/api/v2/factory/" + id + "/users");
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: async (id) => {
65
- var axios = await this.context.ready;
66
- const response = await axios.get(`/api/v1/workshop/${id}`);
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: async (data) => {
70
- var axios = await this.context.ready;
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: async (factory) => {
74
- var axios = await this.context.ready;
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: async (factory) => {
78
- var axios = await this.context.ready;
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: async (id) => {
82
- var axios = await this.context.ready;
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
- async workshops(id) {
100
- var axios = await this.context.ready;
101
- const response = await axios.get(`/api/v1/factory/${id}/workshops`);
102
- return response.data;
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
- async units(id = undefined) {
112
- var axios = await this.context.ready;
113
- if (!id) {
114
- var farm = await this.context.user.getSelectedFarm();
115
- id = farm.id;
116
- }
117
- const response = await axios.get(`/api/v2/factory/${id}/units`);
118
- return response.data;
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
- async businessType(data) {
122
- var axios = await this.context.ready;
123
- const response = await axios.get(`/api/v2/factory/businessType/${data.type}`);
124
- return response.data;
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
- async company(data) {
127
- var axios = await this.context.ready;
128
- const response = await axios.get(`/api/v1/factory/${data.id}/organizaion`, data);
129
- return response.data;
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
- async entry(factory, name) {
133
- var axios = await this.context.ready;
134
- if (["electric", "water", "feed"].includes(name)) {
135
- const response = await axios.post(`/api/v1/pigfarm/consumption/${factory.id}`, {
136
- type: name,
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
- async alert(params) {
163
- let axios = await this.context.ready;
164
- const response = await axios.get(`/api/v1/device/alert`, {
165
- params: params,
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.includes(domain);
314
+ return localDomains.indexOf(domain) !== -1;
315
315
  }
316
316
  setTitle(title) {
317
317
  if (this.platform) {