@cpzxrobot/sdk 1.3.105 → 1.3.106

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.
@@ -35,7 +35,12 @@ class MobilePlatform {
35
35
  setToken(_token) {
36
36
  }
37
37
  setSelectedFarm(_farm) {
38
- throw new Error("Method not implemented.");
38
+ if (typeof _farm === 'number') {
39
+ return this.platform.callHandler("setSelectedFarm", _farm);
40
+ }
41
+ else {
42
+ return this.platform.callHandler("setSelectedFarm", _farm.id);
43
+ }
39
44
  }
40
45
  setSelectedUnit(unit) {
41
46
  this.platform.callHandler("selectUnit", unit).then((_res) => {
@@ -111,6 +116,11 @@ class MobilePlatform {
111
116
  return this.platform.callHandler("getSelectedFarmFromMiniApp");
112
117
  });
113
118
  }
119
+ setSelectedFarmFromMiniApp(farmId) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ return this.platform.callHandler("setSelectedFarmFromMiniApp", farmId);
122
+ });
123
+ }
114
124
  getSelectedUnitFromMiniApp() {
115
125
  return __awaiter(this, void 0, void 0, function* () {
116
126
  return this.platform.callHandler("getSelectedUnitFromMiniApp");
@@ -21,6 +21,12 @@ class UserGateway extends Object {
21
21
  return this.context.platform.getSelectedFarmFromMiniApp();
22
22
  });
23
23
  }
24
+ //选择工厂
25
+ selectFarm(farm) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ return this.context.platform.setSelectedFarm(farm);
28
+ });
29
+ }
24
30
  selectUnit(unit) {
25
31
  return __awaiter(this, void 0, void 0, function* () {
26
32
  if (typeof unit === 'string' || typeof unit === 'number') {
@@ -42,9 +42,15 @@ class WebPlatform {
42
42
  this.token = token;
43
43
  }
44
44
  setSelectedFarm(farm) {
45
- this._selectedFarm = farm;
45
+ if (typeof farm === 'number') {
46
+ this._selectedFarm = { id: farm };
47
+ }
48
+ else {
49
+ this._selectedFarm = farm;
50
+ }
46
51
  //保存到本地缓存
47
52
  localStorage.setItem("selectedFarm", JSON.stringify(farm));
53
+ return Promise.resolve(true);
48
54
  }
49
55
  setSelectedUnit(unit) {
50
56
  this._selectedUnit = unit;
@@ -33,7 +33,15 @@ class WindwosMiniAppPlatform {
33
33
  setToken(_token) {
34
34
  }
35
35
  setSelectedFarm(_farm) {
36
- throw new Error("Method not implemented.");
36
+ var _a, _b, _c, _d;
37
+ if (typeof _farm === 'number') {
38
+ // @ts-ignore
39
+ return (_b = (_a = window.miniapp).selectFactoryById) === null || _b === void 0 ? void 0 : _b.call(_a, _farm);
40
+ }
41
+ else {
42
+ // @ts-ignore
43
+ return (_d = (_c = window.miniapp).selectFactoryById) === null || _d === void 0 ? void 0 : _d.call(_c, _farm.id);
44
+ }
37
45
  }
38
46
  setSelectedUnit(unit) {
39
47
  var _a, _b;
@@ -33,8 +33,12 @@ export class MobilePlatform implements PlatformInterface {
33
33
  setToken(_token: string): void {
34
34
  }
35
35
 
36
- setSelectedFarm(_farm: Factory): void {
37
- throw new Error("Method not implemented.");
36
+ setSelectedFarm(_farm: Factory|number): Promise<boolean> {
37
+ if (typeof _farm === 'number') {
38
+ return this.platform.callHandler("setSelectedFarm", _farm);
39
+ } else {
40
+ return this.platform.callHandler("setSelectedFarm", _farm.id);
41
+ }
38
42
  }
39
43
  setSelectedUnit(unit: Unit): void {
40
44
  this.platform.callHandler("selectUnit", unit).then((_res: any) => {
@@ -114,6 +118,10 @@ export class MobilePlatform implements PlatformInterface {
114
118
  return this.platform.callHandler("getSelectedFarmFromMiniApp");
115
119
  }
116
120
 
121
+ async setSelectedFarmFromMiniApp(farmId: number): Promise<boolean> {
122
+ return this.platform.callHandler("setSelectedFarmFromMiniApp", farmId);
123
+ }
124
+
117
125
  async getSelectedUnitFromMiniApp(): Promise<any> {
118
126
  return this.platform.callHandler("getSelectedUnitFromMiniApp");
119
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.105",
3
+ "version": "1.3.106",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -30,7 +30,7 @@ export abstract class PlatformInterface {
30
30
  abstract getAxiosFromMiniApp(): MyAxiosInstance;
31
31
  abstract ready(): Promise<boolean>;
32
32
  abstract setSelectedUnit(unit: Unit | String | Number): void;
33
- abstract setSelectedFarm(farm: Factory | String | Number): void;
33
+ abstract setSelectedFarm(farm: Factory | Number): Promise<boolean>;
34
34
  //change factory
35
35
  abstract openFactorySelector():void;
36
36
  abstract aiAssist(args:AiAssistRequest):void;
package/types.d.ts CHANGED
@@ -729,6 +729,10 @@ interface AlarmRuleDetail {
729
729
  thresholdConfigs?: AlarmRuleThresholdConfig[];
730
730
  /** 报警配置列表 */
731
731
  alarmConfigs?: AlarmRuleAlarmConfig[];
732
+ /** 继承自的报警规则id */
733
+ inheritedFrom?: number;
734
+ /** 激活规则的工厂数量 */
735
+ upperActiveSum?: number;
732
736
  }
733
737
 
734
738
  /**
package/user_gateway.ts CHANGED
@@ -13,6 +13,11 @@ export class UserGateway extends Object {
13
13
  return this.context.platform.getSelectedFarmFromMiniApp()
14
14
  }
15
15
 
16
+ //选择工厂
17
+ public async selectFarm(farm: Factory | number) {
18
+ return this.context.platform.setSelectedFarm(farm)
19
+ }
20
+
16
21
  public async selectUnit(unit: Unit | String | Number) {
17
22
  if (typeof unit === 'string' || typeof unit === 'number') {
18
23
  var resp = await this.context.unit.get(unit)
package/web_platform.ts CHANGED
@@ -37,10 +37,15 @@ export class WebPlatform implements PlatformInterface {
37
37
  setToken(token: string): void {
38
38
  this.token = token;
39
39
  }
40
- setSelectedFarm(farm: Factory): void {
41
- this._selectedFarm = farm;
40
+ setSelectedFarm(farm: Factory|number): Promise<boolean> {
41
+ if (typeof farm === 'number') {
42
+ this._selectedFarm = {id: farm} as Factory;
43
+ } else {
44
+ this._selectedFarm = farm;
45
+ }
42
46
  //保存到本地缓存
43
47
  localStorage.setItem("selectedFarm", JSON.stringify(farm));
48
+ return Promise.resolve(true);
44
49
  }
45
50
  setSelectedUnit(unit: Unit): void {
46
51
  this._selectedUnit = unit;
@@ -25,8 +25,14 @@ export class WindwosMiniAppPlatform implements PlatformInterface {
25
25
  }
26
26
  setToken(_token: string): void {
27
27
  }
28
- setSelectedFarm(_farm: Factory): void {
29
- throw new Error("Method not implemented.");
28
+ setSelectedFarm(_farm: Factory|number): Promise<boolean> {
29
+ if (typeof _farm === 'number') {
30
+ // @ts-ignore
31
+ return window.miniapp.selectFactoryById?.(_farm);
32
+ } else {
33
+ // @ts-ignore
34
+ return window.miniapp.selectFactoryById?.(_farm.id);
35
+ }
30
36
  }
31
37
  setSelectedUnit(unit: Unit): void {
32
38
  // @ts-ignore