@cpzxrobot/sdk 1.0.4 → 1.0.6
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/assistant_gateway.ts +4 -2
- package/camera_gateway.ts +19 -15
- package/device_filter.ts +6 -4
- package/device_gateway.ts +12 -12
- package/device_type_gateway.ts +4 -2
- package/device_types/electricmeter.ts +2 -2
- package/device_types/feedtower.ts +5 -5
- package/device_types/normal_type.ts +3 -2
- package/dist/camera_gateway.js +2 -2
- package/dist/device_filter.js +3 -3
- package/dist/device_types/electricmeter.js +1 -1
- package/dist/device_types/feedtower.js +1 -1
- package/dist/device_types/normal_type.js +1 -1
- package/dist/energy_types/electric_meter_gateway.js +1 -5
- package/dist/index.js +187 -222
- package/dist/transport_gateway.js +22 -7
- package/energy_gateway.ts +3 -2
- package/energy_types/electric_meter_gateway.ts +4 -4
- package/factory_gateway.ts +4 -2
- package/index.ts +52 -34
- package/package.json +4 -2
- package/pigfarm_gateway.ts +4 -2
- package/transport_gateway.ts +52 -35
- package/types.d.ts +166 -84
- package/user_gateway.ts +5 -3
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
-
};
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
7
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Cpzxrobot = void 0;
|
|
8
7
|
exports.default = default_1;
|
|
9
8
|
const device_gateway_1 = require("./device_gateway");
|
|
10
9
|
const user_gateway_1 = require("./user_gateway");
|
|
@@ -15,239 +14,205 @@ const assistant_gateway_1 = require("./assistant_gateway");
|
|
|
15
14
|
const energy_gateway_1 = require("./energy_gateway");
|
|
16
15
|
const camera_gateway_1 = require("./camera_gateway");
|
|
17
16
|
const pigfarm_gateway_1 = require("./pigfarm_gateway");
|
|
18
|
-
class
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
exit() {
|
|
42
|
-
if (this.mode === "miniapp_in_app") {
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
window.exitMiniapp();
|
|
45
|
-
} else {
|
|
46
|
-
window.close();
|
|
17
|
+
class Cpzxrobot {
|
|
18
|
+
constructor(appCode) {
|
|
19
|
+
this.pigfarm = new pigfarm_gateway_1.PigfarmGateway(this);
|
|
20
|
+
this.hash = "shzx";
|
|
21
|
+
this.mode = "dev";
|
|
22
|
+
this.auth = "";
|
|
23
|
+
this.token = "";
|
|
24
|
+
this.setTitle = () => { };
|
|
25
|
+
//获取当前浏览器的域名
|
|
26
|
+
this.ready = new Promise((resolve, reject) => {
|
|
27
|
+
this.resolveReady = resolve;
|
|
28
|
+
this.rejectReady = reject;
|
|
29
|
+
});
|
|
30
|
+
this.getDomain();
|
|
31
|
+
this.appCode = appCode;
|
|
32
|
+
this.user = new user_gateway_1.UserGateway(this);
|
|
33
|
+
this.factory = new factory_gateway_1.FactoryGateway(this);
|
|
34
|
+
this.device = new device_gateway_1.DeviceGateway(this);
|
|
35
|
+
this.transport = new transport_gateway_1.TransportGateway(this);
|
|
36
|
+
this.assistant = new assistant_gateway_1.AssistantGateway(this);
|
|
37
|
+
this.energy = new energy_gateway_1.EnergyGateway(this);
|
|
38
|
+
this.camera = new camera_gateway_1.CameraGateway(this);
|
|
47
39
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
baseURL,
|
|
56
|
-
});
|
|
57
|
-
instance.interceptors.request.use(
|
|
58
|
-
(config) => {
|
|
59
|
-
// 在发送请求之前在头部添加token
|
|
60
|
-
config.headers.Authorization = this.token;
|
|
61
|
-
// 解析和验证Token
|
|
62
|
-
return config;
|
|
63
|
-
},
|
|
64
|
-
function (error) {
|
|
65
|
-
// 对请求错误做些什么
|
|
66
|
-
return Promise.reject(error);
|
|
40
|
+
exit() {
|
|
41
|
+
if (this.mode === "miniapp_in_app") {
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
window.exitMiniapp();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
window.close();
|
|
67
47
|
}
|
|
68
|
-
);
|
|
69
|
-
this.axios = instance;
|
|
70
48
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
getDomain() {
|
|
74
|
-
const domain = window.location.hostname;
|
|
75
|
-
console.log("load domain ", domain);
|
|
76
|
-
if (domain == "miniapp") {
|
|
77
|
-
this.mode = "miniapp_in_app";
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
this.axios = getAxiosFromMiniApp();
|
|
80
|
-
this.platformReady = Promise.resolve(true);
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
this._getSelectedFarmFromMiniApp = window.getSelectedFarmFromMiniApp;
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
this._getSelectedUnitFromMiniApp = window.getSelectedUnitFromMiniApp;
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
this._jumpToMiniApp = window.miniapp.open;
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
this.setTitle = window.miniapp.setTitle;
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
this.saveBase64 = window.miniapp.saveBase64;
|
|
91
|
-
} else if (
|
|
92
|
-
domain == "appassets.androidplatform.net" ||
|
|
93
|
-
this.isIosMiniApp(window.location)
|
|
94
|
-
) {
|
|
95
|
-
this.mode = "miniapp_in_app";
|
|
96
|
-
const platform =
|
|
97
|
-
// @ts-ignore
|
|
98
|
-
window.flutter_inappwebview;
|
|
99
|
-
this._getSelectedFarmFromMiniApp = function () {
|
|
100
|
-
return platform.callHandler("getSelectedFarmFromMiniApp");
|
|
101
|
-
};
|
|
102
|
-
this._getSelectedUnitFromMiniApp = function () {
|
|
103
|
-
return platform.callHandler("getSelectedUnitFromMiniApp");
|
|
104
|
-
};
|
|
105
|
-
this._jumpToMiniApp = function (url) {
|
|
106
|
-
return platform.callHandler("app.openMiniapp", url);
|
|
107
|
-
};
|
|
108
|
-
this.setTitle = function (title) {
|
|
109
|
-
return platform.callHandler("app.setTitle", title);
|
|
110
|
-
};
|
|
111
|
-
this.saveBase64 = function (base64, filename) {
|
|
112
|
-
return platform.callHandler("app.saveBase64", base64, filename);
|
|
113
|
-
};
|
|
114
|
-
this.axios = {
|
|
115
|
-
get: function (url, data) {
|
|
116
|
-
console.log(url, data);
|
|
117
|
-
return platform.callHandler("axios_get", url, data);
|
|
118
|
-
},
|
|
119
|
-
post: function (url, data) {
|
|
120
|
-
console.log(url, data);
|
|
121
|
-
return platform.callHandler("axios_post", url, data);
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
this.platformReady = new Promise((resolve, reject) => {
|
|
125
|
-
window.addEventListener(
|
|
126
|
-
"flutterInAppWebViewPlatformReady",
|
|
127
|
-
function () {
|
|
128
|
-
console.log("flutter android/ios platform is ready");
|
|
129
|
-
resolve(true);
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
setTimeout(() => {
|
|
133
|
-
reject("timeout");
|
|
134
|
-
}, 1500);
|
|
135
|
-
});
|
|
136
|
-
} else if (this.isLocalDomain(domain)) {
|
|
137
|
-
this.mode = "dev";
|
|
138
|
-
this.setTitle = function (title) {
|
|
139
|
-
document.title = title;
|
|
140
|
-
};
|
|
141
|
-
console.log(
|
|
142
|
-
"欢迎使用上海正诚物联网IOT系统,您当前是开发环境,请在平台获取开发用jwt key,并传入devAuth设置"
|
|
143
|
-
);
|
|
144
|
-
} else {
|
|
145
|
-
this.mode = "miniapp_in_web";
|
|
49
|
+
inApp() {
|
|
50
|
+
return this.mode === "miniapp_in_app";
|
|
146
51
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
52
|
+
initAxios(baseURL) {
|
|
53
|
+
if (this.mode !== "miniapp_in_app") {
|
|
54
|
+
const instance = axios_1.default.create({
|
|
55
|
+
baseURL,
|
|
56
|
+
});
|
|
57
|
+
instance.interceptors.request.use((config) => {
|
|
58
|
+
// 在发送请求之前在头部添加token
|
|
59
|
+
config.headers.Authorization = this.token;
|
|
60
|
+
// 解析和验证Token
|
|
61
|
+
return config;
|
|
62
|
+
}, function (error) {
|
|
63
|
+
// 对请求错误做些什么
|
|
64
|
+
return Promise.reject(error);
|
|
65
|
+
});
|
|
66
|
+
this.axios = instance;
|
|
67
|
+
}
|
|
161
68
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
69
|
+
//获取当前浏览器的域名
|
|
70
|
+
getDomain() {
|
|
71
|
+
const domain = window.location.hostname;
|
|
72
|
+
console.log("load domain ", domain);
|
|
73
|
+
if (domain == "miniapp") {
|
|
74
|
+
this.mode = "miniapp_in_app";
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
this.axios = getAxiosFromMiniApp();
|
|
77
|
+
this.platformReady = Promise.resolve(true);
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
this._getSelectedFarmFromMiniApp = window.getSelectedFarmFromMiniApp;
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
this._getSelectedUnitFromMiniApp = window.getSelectedUnitFromMiniApp;
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
this._jumpToMiniApp = window.miniapp.open;
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
this.setTitle = window.miniapp.setTitle;
|
|
86
|
+
}
|
|
87
|
+
else if (domain == "appassets.androidplatform.net" ||
|
|
88
|
+
this.isIosMiniApp(window.location)) {
|
|
89
|
+
this.mode = "miniapp_in_app";
|
|
90
|
+
const platform =
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
window.flutter_inappwebview;
|
|
93
|
+
this._getSelectedFarmFromMiniApp = function () {
|
|
94
|
+
return platform.callHandler("getSelectedFarmFromMiniApp");
|
|
95
|
+
};
|
|
96
|
+
this._getSelectedUnitFromMiniApp = function () {
|
|
97
|
+
return platform.callHandler("getSelectedUnitFromMiniApp");
|
|
98
|
+
};
|
|
99
|
+
this._jumpToMiniApp = function (url) {
|
|
100
|
+
return platform.callHandler("app.openMiniapp", url);
|
|
101
|
+
};
|
|
102
|
+
this.setTitle = function (title) {
|
|
103
|
+
return platform.callHandler("app.setTitle", title);
|
|
104
|
+
};
|
|
105
|
+
this.axios = {
|
|
106
|
+
get: function (url, data) {
|
|
107
|
+
console.log(url, data);
|
|
108
|
+
return platform.callHandler("axios_get", url, data);
|
|
109
|
+
},
|
|
110
|
+
post: function (url, data) {
|
|
111
|
+
console.log(url, data);
|
|
112
|
+
return platform.callHandler("axios_post", url, data);
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
this.platformReady = new Promise((resolve, reject) => {
|
|
116
|
+
window.addEventListener("flutterInAppWebViewPlatformReady", function () {
|
|
117
|
+
console.log("flutter android/ios platform is ready");
|
|
118
|
+
resolve(true);
|
|
119
|
+
});
|
|
120
|
+
setTimeout(() => {
|
|
121
|
+
reject("timeout");
|
|
122
|
+
}, 1500);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else if (this.isLocalDomain(domain)) {
|
|
126
|
+
this.mode = "dev";
|
|
127
|
+
this.setTitle = function (title) {
|
|
128
|
+
document.title = title;
|
|
129
|
+
};
|
|
130
|
+
console.log("欢迎使用上海正诚物联网IOT系统,您当前是开发环境,请在平台获取开发用jwt key,并传入devAuth设置");
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
this.mode = "miniapp_in_web";
|
|
134
|
+
}
|
|
186
135
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
this.initAxios(baseURL);
|
|
192
|
-
console.log("shzx is ready");
|
|
193
|
-
this.resolveReady(this.axios);
|
|
194
|
-
});
|
|
195
|
-
return;
|
|
136
|
+
isIosMiniApp(location) {
|
|
137
|
+
//hostname is 'localhost' and has search params starting with 'mode=ios'
|
|
138
|
+
return (location.hostname === "localhost" &&
|
|
139
|
+
location.search.startsWith("?mode=ios"));
|
|
196
140
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
})
|
|
204
|
-
.then((res) => {
|
|
205
|
-
if (res.data.Error) {
|
|
206
|
-
throw res.data.Error;
|
|
207
|
-
} else {
|
|
208
|
-
this.token = "Bearer " + res.data.token;
|
|
141
|
+
on(event, cb) {
|
|
142
|
+
switch (event) {
|
|
143
|
+
case "unitChanged":
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
window._notifyUnitChanged = cb;
|
|
146
|
+
break;
|
|
209
147
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
148
|
+
}
|
|
149
|
+
//打开其他小程序
|
|
150
|
+
openMiniApp(url) {
|
|
151
|
+
this._jumpToMiniApp(url);
|
|
152
|
+
}
|
|
153
|
+
setAuth(auth, baseURL) {
|
|
154
|
+
if (this.mode === "miniapp_in_app") {
|
|
155
|
+
this.platformReady.then(() => {
|
|
156
|
+
this.initAxios(baseURL);
|
|
157
|
+
console.log("shzx is ready");
|
|
158
|
+
this.resolveReady(this.axios);
|
|
159
|
+
});
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
this.initAxios(baseURL);
|
|
163
|
+
this.auth = auth;
|
|
164
|
+
this.axios
|
|
165
|
+
.post("/api/v1/user/auth", {
|
|
166
|
+
appCode: this.appCode,
|
|
167
|
+
auth: auth,
|
|
168
|
+
})
|
|
169
|
+
.then((res) => {
|
|
170
|
+
if (res.data.Error) {
|
|
171
|
+
throw res.data.Error;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
this.token = "Bearer " + res.data.token;
|
|
175
|
+
}
|
|
176
|
+
this.resolveReady(this.axios);
|
|
177
|
+
})
|
|
178
|
+
.catch((err) => {
|
|
179
|
+
console.log("shzx ready caller reject", err);
|
|
180
|
+
this.rejectReady(err);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
isLocalDomain(domain) {
|
|
184
|
+
// 列出所有的本地开发域名
|
|
185
|
+
const localDomains = ["localhost", "127.0.0.1", "0.0.0.0"];
|
|
186
|
+
// 检查当前域名是否在本地开发域名列表中
|
|
187
|
+
return localDomains.includes(domain);
|
|
188
|
+
}
|
|
223
189
|
}
|
|
190
|
+
exports.Cpzxrobot = Cpzxrobot;
|
|
224
191
|
let _instance;
|
|
225
|
-
function default_1(
|
|
226
|
-
args = {
|
|
192
|
+
function default_1(args = {
|
|
227
193
|
devAuth: "",
|
|
228
194
|
appCode: "",
|
|
229
195
|
baseURL: "https://www.cpzxrobot.com/",
|
|
230
196
|
selectedFarm: {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
197
|
+
id: 0,
|
|
198
|
+
code: "",
|
|
199
|
+
name: "",
|
|
200
|
+
company_code: "",
|
|
235
201
|
},
|
|
236
202
|
selectedUnit: {
|
|
237
|
-
|
|
238
|
-
|
|
203
|
+
id: 0,
|
|
204
|
+
name: "",
|
|
239
205
|
},
|
|
240
|
-
|
|
241
|
-
) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
206
|
+
}) {
|
|
207
|
+
if (!_instance) {
|
|
208
|
+
_instance = new Cpzxrobot(args.appCode);
|
|
209
|
+
_instance.setAuth(args.devAuth, args.baseURL);
|
|
210
|
+
if (args.selectedFarm) {
|
|
211
|
+
_instance.user.selectedFarm = args.selectedFarm;
|
|
212
|
+
}
|
|
213
|
+
if (args.selectedUnit) {
|
|
214
|
+
_instance.user.selectedUnit = args.selectedUnit;
|
|
215
|
+
}
|
|
250
216
|
}
|
|
251
|
-
|
|
252
|
-
return _instance;
|
|
217
|
+
return _instance;
|
|
253
218
|
}
|
|
@@ -4,7 +4,7 @@ exports.TransportGateway = void 0;
|
|
|
4
4
|
class TransportGateway extends Object {
|
|
5
5
|
constructor(context) {
|
|
6
6
|
super();
|
|
7
|
-
this._selectedFarm =
|
|
7
|
+
this._selectedFarm = "";
|
|
8
8
|
this.context = context;
|
|
9
9
|
}
|
|
10
10
|
get fodder() {
|
|
@@ -13,12 +13,12 @@ class TransportGateway extends Object {
|
|
|
13
13
|
getData: (id = undefined, page = {
|
|
14
14
|
current: 1,
|
|
15
15
|
pageSize: 10,
|
|
16
|
-
deviceId: id
|
|
16
|
+
deviceId: id,
|
|
17
17
|
}) => {
|
|
18
18
|
return this.context.ready.then(() => {
|
|
19
19
|
return this.context.axios
|
|
20
|
-
.get(
|
|
21
|
-
params: page
|
|
20
|
+
.get("/api/v1/pigfarm/device/fodder", {
|
|
21
|
+
params: page,
|
|
22
22
|
})
|
|
23
23
|
.then((res) => {
|
|
24
24
|
if (res.data.code != 200) {
|
|
@@ -28,9 +28,24 @@ class TransportGateway extends Object {
|
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
},
|
|
31
|
+
//获取设备打料数据
|
|
32
|
+
getDetail: (ids, date) => {
|
|
33
|
+
return this.context.ready.then(() => {
|
|
34
|
+
return this.context.axios
|
|
35
|
+
.post("/api/v1/pigfarm/device/fodderTower/detailDeviceLoad", {
|
|
36
|
+
ids,
|
|
37
|
+
date,
|
|
38
|
+
})
|
|
39
|
+
.then((res) => {
|
|
40
|
+
return res.data;
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
},
|
|
31
44
|
create: (data) => {
|
|
32
45
|
return this.context.ready.then(() => {
|
|
33
|
-
return this.context.axios
|
|
46
|
+
return this.context.axios
|
|
47
|
+
.post("/api/v1/pigfarm/device/fodder/add", data)
|
|
48
|
+
.then((res) => {
|
|
34
49
|
if (res.data.code != 200) {
|
|
35
50
|
throw res.data.message;
|
|
36
51
|
}
|
|
@@ -41,7 +56,7 @@ class TransportGateway extends Object {
|
|
|
41
56
|
bind: (data) => {
|
|
42
57
|
return this.context.ready.then(() => {
|
|
43
58
|
return this.context.axios
|
|
44
|
-
.post(
|
|
59
|
+
.post("/api/v1/pigfarm/device/fodderTower/addList", data)
|
|
45
60
|
.then((res) => {
|
|
46
61
|
if (res.data.code != 200) {
|
|
47
62
|
throw res.data.message;
|
|
@@ -49,7 +64,7 @@ class TransportGateway extends Object {
|
|
|
49
64
|
return res.data.data;
|
|
50
65
|
});
|
|
51
66
|
});
|
|
52
|
-
}
|
|
67
|
+
},
|
|
53
68
|
};
|
|
54
69
|
}
|
|
55
70
|
}
|
package/energy_gateway.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Cpzxrobot } from ".";
|
|
1
2
|
import { ElectricMeterGateway } from "./energy_types/electric_meter_gateway";
|
|
2
3
|
//消息助手网关,获取消息助手的信息
|
|
3
4
|
export class EnergyGateway extends Object {
|
|
4
|
-
context:
|
|
5
|
+
context: Cpzxrobot;
|
|
5
6
|
_electric: ElectricMeterGateway | null = null;
|
|
6
7
|
|
|
7
|
-
constructor(context:
|
|
8
|
+
constructor(context: Cpzxrobot) {
|
|
8
9
|
super();
|
|
9
10
|
this.context = context;
|
|
10
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Cpzxrobot } from "..";
|
|
2
2
|
|
|
3
3
|
export interface ElectricMeterRate {
|
|
4
4
|
endHour: number;
|
|
@@ -12,16 +12,16 @@ export interface ElectricMeterRate {
|
|
|
12
12
|
|
|
13
13
|
//消息助手网关,获取消息助手的信息
|
|
14
14
|
export class ElectricMeterGateway extends Object {
|
|
15
|
-
context:
|
|
15
|
+
context: Cpzxrobot
|
|
16
16
|
|
|
17
|
-
constructor(context:
|
|
17
|
+
constructor(context: Cpzxrobot) {
|
|
18
18
|
super()
|
|
19
19
|
this.context = context
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
//返回峰谷平电表的阶梯区间
|
|
23
23
|
getRates() {
|
|
24
|
-
return
|
|
24
|
+
return this.context.ready.then((axios) => {
|
|
25
25
|
return axios.get('/api/v1/energy/electricRange').then((res) => {
|
|
26
26
|
if (res.data.code !== 200) {
|
|
27
27
|
throw res.data.message
|
package/factory_gateway.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Cpzxrobot, Factory } from "./types"
|
|
2
|
+
|
|
1
3
|
export class FactoryGateway extends Object {
|
|
2
4
|
_selectedFarm: Factory = {
|
|
3
5
|
code: '',
|
|
@@ -5,8 +7,8 @@ export class FactoryGateway extends Object {
|
|
|
5
7
|
company_code: '',
|
|
6
8
|
id: 0
|
|
7
9
|
}
|
|
8
|
-
context:
|
|
9
|
-
constructor(context:
|
|
10
|
+
context: Cpzxrobot
|
|
11
|
+
constructor(context: Cpzxrobot) {
|
|
10
12
|
super()
|
|
11
13
|
this.context = context
|
|
12
14
|
}
|