@cpzxrobot/sdk 1.2.25 → 1.2.27

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/ai_gateway.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { Cpzxrobot } from "./types";
2
+
3
+ export class AiGateway extends Object {
4
+ context: Cpzxrobot;
5
+
6
+ constructor(context: Cpzxrobot) {
7
+ super();
8
+ this.context = context;
9
+ }
10
+
11
+ detechDeviceType(args:{
12
+ field: string;
13
+ }){
14
+ return this.context.ready.then(axios => {
15
+ return axios.post(" /api/chatai/deviceMatch", args);
16
+ })
17
+ }
18
+
19
+ }
@@ -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
  }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiGateway = void 0;
4
+ class AiGateway extends Object {
5
+ constructor(context) {
6
+ super();
7
+ this.context = context;
8
+ }
9
+ detechDeviceType(args) {
10
+ return this.context.ready.then(axios => {
11
+ return axios.post(" /api/chatai/deviceMatch", args);
12
+ });
13
+ }
14
+ }
15
+ exports.AiGateway = AiGateway;
@@ -103,6 +103,10 @@ class FactoryGateway extends Object {
103
103
  //获得工厂的所有单元信息,以车间为单位树状结构
104
104
  async units(id) {
105
105
  var axios = await this.context.ready;
106
+ if (id === null) {
107
+ var farm = await this.context.user.getSelectedFarm();
108
+ id = farm.id;
109
+ }
106
110
  const response = await axios.get(`/api/v2/factory/${id}/units`);
107
111
  return response.data;
108
112
  }
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ const news_gateway_1 = require("./news_gateway");
26
26
  const logs_gateway_1 = require("./logs_gateway");
27
27
  const robot_gateway_1 = require("./robot_gateway");
28
28
  const quotation_gateway_1 = require("./quotation_gateway");
29
+ const ai_gateway_1 = require("./ai_gateway");
29
30
  class Cpzxrobot {
30
31
  constructor(appCode) {
31
32
  this.pigfarm = new pigfarm_gateway_1.PigfarmGateway(this);
@@ -44,6 +45,7 @@ class Cpzxrobot {
44
45
  this.logs = new logs_gateway_1.LogsGateway(this);
45
46
  this.robot = new robot_gateway_1.RobotGateway(this);
46
47
  this.quotation = new quotation_gateway_1.QuotationGateway(this);
48
+ this.ai = new ai_gateway_1.AiGateway(this);
47
49
  //获取当前浏览器的域名
48
50
  this.ready = new Promise((resolve, reject) => {
49
51
  this.resolveReady = resolve;
@@ -116,8 +116,12 @@ export class FactoryGateway extends Object {
116
116
  }
117
117
 
118
118
  //获得工厂的所有单元信息,以车间为单位树状结构
119
- async units(id: number): Promise<any> {
119
+ async units(id: number|undefined): Promise<any> {
120
120
  var axios = await this.context.ready;
121
+ if (id === null) {
122
+ var farm = await this.context.user.getSelectedFarm();
123
+ id = farm.id;
124
+ }
121
125
  const response = await axios.get(`/api/v2/factory/${id}/units`);
122
126
  return response.data;
123
127
  }
package/index.ts CHANGED
@@ -21,6 +21,7 @@ import { NewsGateway } from "./news_gateway";
21
21
  import { LogsGateway } from "./logs_gateway";
22
22
  import { RobotGateway } from "./robot_gateway";
23
23
  import { QuotationGateway } from "./quotation_gateway";
24
+ import { AiGateway } from "./ai_gateway";
24
25
 
25
26
  export class Cpzxrobot {
26
27
  device: DeviceGateway;
@@ -72,6 +73,7 @@ export class Cpzxrobot {
72
73
  logs: LogsGateway = new LogsGateway(this);
73
74
  robot: RobotGateway = new RobotGateway(this);
74
75
  quotation: QuotationGateway = new QuotationGateway(this);
76
+ ai: AiGateway = new AiGateway(this);
75
77
 
76
78
 
77
79
  constructor(appCode: string) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.25",
3
+ "version": "1.2.27",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -79,6 +79,7 @@ server: {
79
79
  11. 车辆管理
80
80
  12. 新闻管理
81
81
  13. 日志管理
82
+ 14. AI网关管理
82
83
 
83
84
  ## 接口参考
84
85
  ### 工厂管理
@@ -183,7 +184,7 @@ await cpzxrobot().device.report(123, 4, "传感器读数异常");
183
184
  await cpzxrobot().device.report(456, 64, "设备已报废");
184
185
  ```
185
186
 
186
- ## faults函数说明
187
+ ### faults函数说明
187
188
 
188
189
  获取设备故障记录
189
190
 
@@ -918,7 +919,7 @@ baseURL: "/"
918
919
  * 调用对应的接口方法,例如`cpzxrobot().factory.workshops(factory_id)`
919
920
 
920
921
 
921
- ### 调用接口
922
+ ## 调用接口列表
922
923
 
923
924
  主要包入口:
924
925
 
@@ -1113,6 +1114,7 @@ baseURL: "/"
1113
1114
  | cpzxrobot().logs.operations | 获得操作日志列表,传入必要的参数 |
1114
1115
  | cpzxrobot().robot.cage | 获得栏位信息 |
1115
1116
  | cpzxrobot().robot.alarm | 获得报警信息,传入必要的参数 |
1117
+ | cpzxrobot().ai.detechDeviceType | 使用AI匹配设备类型 |
1116
1118
 
1117
1119
  ### 工厂信息接口
1118
1120
 
package/types.d.ts CHANGED
@@ -16,6 +16,7 @@ import { CompanyGateway } from "@cpzxrobot/sdk/company_gateway";
16
16
  import { LogsGateway } from "@cpzxrobot/sdk/logs_gateway";
17
17
  import { RobotGateway } from "@cpzxrobot/sdk/robot_gateway";
18
18
  import { QuotationGateway } from "./quotation_gateway";
19
+ import { AiGateway } from "./ai_gateway";
19
20
 
20
21
  type Device = {
21
22
  id: number;
@@ -28,6 +29,7 @@ type Device = {
28
29
  supplier?: string;
29
30
  data?: number[];
30
31
  typeCode: string;
32
+ unitId: number;
31
33
  };
32
34
 
33
35
  type FeedTowerExtraInfo = {
@@ -96,6 +98,12 @@ type Unit = {
96
98
  workshopId?: number;
97
99
  factoryId?: number;
98
100
  };
101
+ type DeviceType = {
102
+ id: number;
103
+ code: string;
104
+ name: string;
105
+ location?: string;
106
+ };
99
107
  type HeatLamp = {
100
108
  id: number;
101
109
  unitId: number;
@@ -280,7 +288,7 @@ interface MyAxiosInstance {
280
288
  //option.title:上传文件选择框的标题
281
289
  //option.fileField:上传的文件字段名,默认为file
282
290
  //option.data:上传的数据,例如{id:123,name:"xxx"},文件会被附加到data中,作为文件字段上传
283
- upload: (url: string,option?: {}) => Promise<any>;
291
+ upload: (url: string, option?: {}) => Promise<any>;
284
292
  }
285
293
 
286
294
  interface Assistant {
@@ -298,17 +306,17 @@ interface DataQueryArgs {
298
306
  start?: string;
299
307
  stop?: string;
300
308
  type?:
301
- | "diffPerDay"
302
- | "sumPerDay"
303
- | "rangeOfDay"
304
- | "rangeToday"
305
- | "latest"
306
- | "latestInRangePerDay"
307
- | "last"
308
- | "max"
309
- | "raw"
310
- | "difference";
311
- 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
312
320
  offset?: string; // 可以设置统计偏移量,比如设置18h, 则统计从当天晚上6点开始
313
321
  [key: string]: any;
314
322
  aggerate?: string;
@@ -335,6 +343,7 @@ class Cpzxrobot {
335
343
  logs: LogsGateway;
336
344
  robot: RobotGateway;
337
345
  quotation: QuotationGateway;
346
+ ai: AiGateway;
338
347
  dict: (key: string) => any;
339
348
  _getSelectedFarmFromMiniApp: () => Promise<Factory>;
340
349
  _getSelectedUnitFromMiniApp: () => Promise<Unit>;
@@ -362,20 +371,20 @@ declare module "@cpzxrobot/sdk" {
362
371
  selectedFarm: Factory | null | undefined;
363
372
  selectedUnit: Unit | null | undefined;
364
373
  } = {
365
- devAuth: "",
366
- appCode: "",
367
- baseURL: "https://www.cpzxrobot.com/",
368
- selectedFarm: {
369
- id: 0,
370
- code: "",
371
- name: "",
372
- company_code: "",
373
- },
374
- selectedUnit: {
375
- id: 0,
376
- name: "",
377
- },
378
- }
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
+ }
379
388
  ): Cpzxrobot;
380
389
  export {
381
390
  Cpzxrobot,