@cpzxrobot/sdk 1.2.26 → 1.2.28

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,4 @@
1
- import { Cpzxrobot, Unit } from "."
1
+ import { Cpzxrobot, Unit, DeviceType } from "."
2
2
 
3
3
  //缓存设备类型数据
4
4
  export class DeviceTypeGateway {
@@ -10,7 +10,7 @@ export class DeviceTypeGateway {
10
10
  this.context = context
11
11
  }
12
12
 
13
- list(): Promise<[]> {
13
+ list(): Promise<DeviceType[]> {
14
14
  if (this.deviceTypes) {
15
15
  return Promise.resolve(this.deviceTypes)
16
16
  }
@@ -101,9 +101,9 @@ class FactoryGateway extends Object {
101
101
  return response.data;
102
102
  }
103
103
  //获得工厂的所有单元信息,以车间为单位树状结构
104
- async units(id) {
104
+ async units(id = undefined) {
105
105
  var axios = await this.context.ready;
106
- if (id === null) {
106
+ if (!id) {
107
107
  var farm = await this.context.user.getSelectedFarm();
108
108
  id = farm.id;
109
109
  }
@@ -116,9 +116,9 @@ export class FactoryGateway extends Object {
116
116
  }
117
117
 
118
118
  //获得工厂的所有单元信息,以车间为单位树状结构
119
- async units(id: number|null): Promise<any> {
119
+ async units(id: number|undefined = undefined): Promise<any> {
120
120
  var axios = await this.context.ready;
121
- if (id === null) {
121
+ if (!id) {
122
122
  var farm = await this.context.user.getSelectedFarm();
123
123
  id = farm.id;
124
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.26",
3
+ "version": "1.2.28",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -29,6 +29,7 @@ type Device = {
29
29
  supplier?: string;
30
30
  data?: number[];
31
31
  typeCode: string;
32
+ unitId: number;
32
33
  };
33
34
 
34
35
  type FeedTowerExtraInfo = {
@@ -97,6 +98,12 @@ type Unit = {
97
98
  workshopId?: number;
98
99
  factoryId?: number;
99
100
  };
101
+ type DeviceType = {
102
+ id: number;
103
+ code: string;
104
+ name: string;
105
+ location?: string;
106
+ };
100
107
  type HeatLamp = {
101
108
  id: number;
102
109
  unitId: number;
@@ -281,7 +288,7 @@ interface MyAxiosInstance {
281
288
  //option.title:上传文件选择框的标题
282
289
  //option.fileField:上传的文件字段名,默认为file
283
290
  //option.data:上传的数据,例如{id:123,name:"xxx"},文件会被附加到data中,作为文件字段上传
284
- upload: (url: string,option?: {}) => Promise<any>;
291
+ upload: (url: string, option?: {}) => Promise<any>;
285
292
  }
286
293
 
287
294
  interface Assistant {
@@ -299,17 +306,17 @@ interface DataQueryArgs {
299
306
  start?: string;
300
307
  stop?: string;
301
308
  type?:
302
- | "diffPerDay"
303
- | "sumPerDay"
304
- | "rangeOfDay"
305
- | "rangeToday"
306
- | "latest"
307
- | "latestInRangePerDay"
308
- | "last"
309
- | "max"
310
- | "raw"
311
- | "difference";
312
- period?: "1mo" | "1d" | "1h" |null; // 统计周期,默认为1d
309
+ | "diffPerDay"
310
+ | "sumPerDay"
311
+ | "rangeOfDay"
312
+ | "rangeToday"
313
+ | "latest"
314
+ | "latestInRangePerDay"
315
+ | "last"
316
+ | "max"
317
+ | "raw"
318
+ | "difference";
319
+ period?: "1mo" | "1d" | "1h" | null; // 统计周期,默认为1d
313
320
  offset?: string; // 可以设置统计偏移量,比如设置18h, 则统计从当天晚上6点开始
314
321
  [key: string]: any;
315
322
  aggerate?: string;
@@ -364,20 +371,20 @@ declare module "@cpzxrobot/sdk" {
364
371
  selectedFarm: Factory | null | undefined;
365
372
  selectedUnit: Unit | null | undefined;
366
373
  } = {
367
- devAuth: "",
368
- appCode: "",
369
- baseURL: "https://www.cpzxrobot.com/",
370
- selectedFarm: {
371
- id: 0,
372
- code: "",
373
- name: "",
374
- company_code: "",
375
- },
376
- selectedUnit: {
377
- id: 0,
378
- name: "",
379
- },
380
- }
374
+ devAuth: "",
375
+ appCode: "",
376
+ baseURL: "https://www.cpzxrobot.com/",
377
+ selectedFarm: {
378
+ id: 0,
379
+ code: "",
380
+ name: "",
381
+ company_code: "",
382
+ },
383
+ selectedUnit: {
384
+ id: 0,
385
+ name: "",
386
+ },
387
+ }
381
388
  ): Cpzxrobot;
382
389
  export {
383
390
  Cpzxrobot,