@cpzxrobot/sdk 1.2.56 → 1.2.57

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.
@@ -15,5 +15,37 @@ class EnergyGateway extends Object {
15
15
  }
16
16
  return new electric_meter_gateway_1.ElectricMeterGateway(this.context);
17
17
  }
18
+ /**
19
+ * 获取工厂能源统计信息
20
+ * @param type 统计类型
21
+ * @param factoryId 工厂ID
22
+ */
23
+ async stat(type, factoryId = null) {
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 } });
30
+ }
31
+ /**
32
+ * 创建能源统计记录
33
+ * @param request 创建统计请求参数
34
+ */
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/stat', {
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
48
+ });
49
+ }
18
50
  }
19
51
  exports.EnergyGateway = EnergyGateway;
package/energy_gateway.ts CHANGED
@@ -17,4 +17,44 @@ export class EnergyGateway extends Object {
17
17
  return new ElectricMeterGateway(this.context);
18
18
  }
19
19
 
20
+ /**
21
+ * 获取工厂能源统计信息
22
+ * @param type 统计类型
23
+ * @param factoryId 工厂ID
24
+ */
25
+ async stat(type: string, factoryId: number | null = null): Promise<any> {
26
+ if (!factoryId) {
27
+ var factory = await this.context.user.getSelectedFarm();
28
+ factoryId = factory.id;
29
+ }
30
+ var axios = await this.context.ready;
31
+ return axios.get(`/api/v3/energy/stat/${type}`, { params: { factory_id: factoryId } });
32
+ }
33
+
34
+ /**
35
+ * 创建能源统计记录
36
+ * @param request 创建统计请求参数
37
+ */
38
+ async createStat(request: {
39
+ factory_id?: number;
40
+ time: Date;
41
+ period: number;
42
+ electric?: number;
43
+ gas?: number;
44
+ cpv?: number;
45
+ }): Promise<void> {
46
+ if (!request.factory_id) {
47
+ const factory = await this.context.user.getSelectedFarm();
48
+ request.factory_id = factory.id;
49
+ }
50
+ const axios = await this.context.ready;
51
+ return axios.post('/api/v3/energy/stat', {
52
+ factory_id: request.factory_id,
53
+ time: request.time.toISOString(),
54
+ period: request.period,
55
+ electric: request.electric,
56
+ gas: request.gas,
57
+ cpv: request.cpv
58
+ });
59
+ }
20
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.56",
3
+ "version": "1.2.57",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -17,6 +17,7 @@ import { LogsGateway } from "@cpzxrobot/sdk/logs_gateway";
17
17
  import { RobotGateway } from "@cpzxrobot/sdk/robot_gateway";
18
18
  import { QuotationGateway } from "./quotation_gateway";
19
19
  import { AiGateway } from "./ai_gateway";
20
+ import { EnergyGateway } from "./energy_gateway";
20
21
 
21
22
  type Device = {
22
23
  id: number;
@@ -344,6 +345,7 @@ class Cpzxrobot {
344
345
  robot: RobotGateway;
345
346
  quotation: QuotationGateway;
346
347
  ai: AiGateway;
348
+ energy: EnergyGateway;
347
349
  dict: (key: string) => any;
348
350
  _getSelectedFarmFromMiniApp: () => Promise<Factory>;
349
351
  _getSelectedUnitFromMiniApp: () => Promise<Unit>;