@cpzxrobot/sdk 1.3.113 → 1.3.114

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.
@@ -0,0 +1,69 @@
1
+ import type {
2
+ Cpzxrobot,
3
+ AiformTemplateListResponse,
4
+ AiformTemplateSaveRequest,
5
+ AiformTemplateSaveResponse,
6
+ } from ".";
7
+
8
+ export class AiformGateway extends Object {
9
+ context: Cpzxrobot
10
+
11
+ constructor(context: Cpzxrobot) {
12
+ super()
13
+ this.context = context
14
+ }
15
+
16
+ get template() {
17
+ return {
18
+ /**
19
+ * 按工厂ID查询模板列表
20
+ * @param factoryId 工厂ID
21
+ * @returns Promise 包含模板列表
22
+ */
23
+ list: async (factoryId?: number): Promise<AiformTemplateListResponse> => {
24
+ const axios = await this.context.ready;
25
+
26
+ // 参数验证
27
+ if (!factoryId) {
28
+ var selectedFarm = await this.context.user.getSelectedFarm();
29
+ factoryId = selectedFarm.id;
30
+ }
31
+
32
+ return axios.get(`/api/v2/aiform/template/list/${factoryId}`).then((res) => {
33
+ if (res.data.code !== 200) {
34
+ throw new Error(res.data.message || '获取模板列表失败');
35
+ }
36
+ return res.data;
37
+ });
38
+ },
39
+
40
+ /**
41
+ * 新增或修改模板
42
+ * @param request 模板保存请求参数
43
+ * @returns Promise 包含保存结果
44
+ */
45
+ save: async (request: AiformTemplateSaveRequest): Promise<AiformTemplateSaveResponse> => {
46
+ const axios = await this.context.ready;
47
+
48
+ // 参数验证
49
+ if (!request.factoryId) {
50
+ var selectedFarm = await this.context.user.getSelectedFarm();
51
+ request.factoryId = selectedFarm.id;
52
+ }
53
+ if (!request.name) {
54
+ throw new Error('模板名称不能为空');
55
+ }
56
+ if (!request.content) {
57
+ throw new Error('模板内容不能为空');
58
+ }
59
+
60
+ return axios.post(`/api/v2/aiform/template/save`, request).then((res) => {
61
+ if (res.data.code !== 200) {
62
+ throw new Error(res.data.message || '保存模板失败');
63
+ }
64
+ return res.data;
65
+ });
66
+ },
67
+ };
68
+ }
69
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AiformGateway = void 0;
13
+ class AiformGateway extends Object {
14
+ constructor(context) {
15
+ super();
16
+ this.context = context;
17
+ }
18
+ get template() {
19
+ return {
20
+ /**
21
+ * 按工厂ID查询模板列表
22
+ * @param factoryId 工厂ID
23
+ * @returns Promise 包含模板列表
24
+ */
25
+ list: (factoryId) => __awaiter(this, void 0, void 0, function* () {
26
+ const axios = yield this.context.ready;
27
+ // 参数验证
28
+ if (!factoryId) {
29
+ var selectedFarm = yield this.context.user.getSelectedFarm();
30
+ factoryId = selectedFarm.id;
31
+ }
32
+ return axios.get(`/api/v2/aiform/template/list/${factoryId}`).then((res) => {
33
+ if (res.data.code !== 200) {
34
+ throw new Error(res.data.message || '获取模板列表失败');
35
+ }
36
+ return res.data;
37
+ });
38
+ }),
39
+ /**
40
+ * 新增或修改模板
41
+ * @param request 模板保存请求参数
42
+ * @returns Promise 包含保存结果
43
+ */
44
+ save: (request) => __awaiter(this, void 0, void 0, function* () {
45
+ const axios = yield this.context.ready;
46
+ // 参数验证
47
+ if (!request.factoryId) {
48
+ var selectedFarm = yield this.context.user.getSelectedFarm();
49
+ request.factoryId = selectedFarm.id;
50
+ }
51
+ if (!request.name) {
52
+ throw new Error('模板名称不能为空');
53
+ }
54
+ if (!request.content) {
55
+ throw new Error('模板内容不能为空');
56
+ }
57
+ return axios.post(`/api/v2/aiform/template/save`, request).then((res) => {
58
+ if (res.data.code !== 200) {
59
+ throw new Error(res.data.message || '保存模板失败');
60
+ }
61
+ return res.data;
62
+ });
63
+ }),
64
+ };
65
+ }
66
+ }
67
+ exports.AiformGateway = AiformGateway;
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ const production_gateway_1 = require("./production_gateway");
55
55
  const purchase_gateway_1 = require("./purchase_gateway");
56
56
  const warehouse_gateway_1 = require("./warehouse_gateway");
57
57
  const sparepart_gateway_1 = require("./sparepart_gateway");
58
+ const aiform_gateway_1 = require("./aiform_gateway");
58
59
  class Cpzxrobot {
59
60
  constructor(appCode, baseUrl, initSelectedFactory, initSelectedUnit) {
60
61
  this.pigfarm = new pigfarm_gateway_1.PigfarmGateway(this);
@@ -76,6 +77,7 @@ class Cpzxrobot {
76
77
  this.construction = new construction_gateway_1.ConstructionGateway(this);
77
78
  this.system = new system_gateway_1.SystemGateway(this);
78
79
  this.production = new production_gateway_1.ProductionGateway(this);
80
+ this.aiform = new aiform_gateway_1.AiformGateway(this);
79
81
  this.sseCallbacks = {};
80
82
  //获取当前浏览器的域名
81
83
  this.ready = new Promise((resolve, reject) => {
package/index.ts CHANGED
@@ -30,6 +30,7 @@ import { ProductionGateway } from "./production_gateway";
30
30
  import { PurchaseGateway } from "./purchase_gateway";
31
31
  import { WarehouseGateway } from "./warehouse_gateway";
32
32
  import { SparePartGateway } from "./sparepart_gateway";
33
+ import { AiformGateway } from "./aiform_gateway";
33
34
 
34
35
  export class Cpzxrobot {
35
36
  private static factorySelectorLoaded = false;
@@ -74,6 +75,7 @@ export class Cpzxrobot {
74
75
  purchase!: PurchaseGateway;
75
76
  warehouse!: WarehouseGateway;
76
77
  sparepart!: SparePartGateway;
78
+ aiform: AiformGateway = new AiformGateway(this);
77
79
  sseCallbacks: {
78
80
  [key: string]: (data: any) => void;
79
81
  } = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.113",
3
+ "version": "1.3.114",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -805,6 +805,60 @@ interface ActivatedFactoriesResponse {
805
805
  message: string;
806
806
  }
807
807
 
808
+ /**
809
+ * AI报表模板接口
810
+ */
811
+ interface AiformTemplate {
812
+ /** 模板ID */
813
+ id: number;
814
+ /** 工厂ID */
815
+ factoryId: number;
816
+ /** 模板名称 */
817
+ name: string;
818
+ /** 模板内容 */
819
+ content: string;
820
+ /** 注意事项 */
821
+ attention?: string;
822
+ }
823
+
824
+ /**
825
+ * AI报表模板列表响应接口
826
+ */
827
+ interface AiformTemplateListResponse {
828
+ /** 响应码 */
829
+ code: number;
830
+ /** 提示信息 */
831
+ message: string;
832
+ /** 模板列表 */
833
+ data: AiformTemplate[];
834
+ }
835
+
836
+ /**
837
+ * AI报表模板保存请求接口
838
+ */
839
+ interface AiformTemplateSaveRequest {
840
+ /** 模板ID(传则修改,不传则新增) */
841
+ id?: number;
842
+ /** 工厂ID */
843
+ factoryId: number;
844
+ /** 模板名称 */
845
+ name: string;
846
+ /** 模板内容 */
847
+ content: string;
848
+ /** 注意事项 */
849
+ attention?: string;
850
+ }
851
+
852
+ /**
853
+ * AI报表模板保存响应接口
854
+ */
855
+ interface AiformTemplateSaveResponse {
856
+ /** 响应码 */
857
+ code: number;
858
+ /** 提示信息 */
859
+ message: string;
860
+ }
861
+
808
862
  declare class Cpzxrobot {
809
863
  transport: TransportGateway;
810
864
  ready: Promise<MyAxiosInstance>;
@@ -908,6 +962,10 @@ declare module "@cpzxrobot/sdk" {
908
962
  ActiveAlarmRuleRequest,
909
963
  ActiveAlarmRuleResponse,
910
964
  ActivatedFactoriesResponse,
965
+ AiformTemplate,
966
+ AiformTemplateListResponse,
967
+ AiformTemplateSaveRequest,
968
+ AiformTemplateSaveResponse,
911
969
  AlarmRuleDetail,
912
970
  AlarmRuleListResponse,
913
971
  AlarmRuleDetailResponse,