@cpzxrobot/sdk 1.3.31 → 1.3.33

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.
@@ -10,7 +10,7 @@ export class CompanyGateway extends Object {
10
10
  this.warzone = new WarzoneGateway(context);
11
11
  }
12
12
 
13
- async list(pageNo: number, pageSize: number,pid:number, companyName:string) {
13
+ async list(pageNo: number, pageSize: number, pid: number, companyName: string) {
14
14
  var axios = await this.context.ready;
15
15
  return axios
16
16
  .get(`/api/v2/company/list?current=${pageNo}&size=${pageSize}&pid=${pid}&companyName=${companyName}`)
@@ -54,19 +54,36 @@ export class CompanyGateway extends Object {
54
54
  }
55
55
  }
56
56
 
57
+ async attribute(key: string, companyId: number | undefined = undefined) {
58
+ let axios = await this.context.ready;
59
+ if (!companyId) {
60
+ var selectedFarm = await this.context.user.getSelectedFarm();
61
+ companyId = selectedFarm.id;
62
+ }
63
+ return axios.get(`/api/v2/company/${companyId}/attribute/${key}`);
64
+ }
65
+
57
66
  get department() {
58
67
  return {
59
68
  list: async (pid: string) => {
60
69
  var axios = await this.context.ready;
61
70
  return axios.get(`/api/v3/enterprise/department/${pid}`);
62
71
  },
63
- detail: async (id: string) => {
72
+ detail: async (id: string|number) => {
64
73
  var axios = await this.context.ready;
65
74
  return axios.get(`/api/v3/enterprise/department/${id}/detail`);
66
75
  },
67
76
  create: async (data: any) => {
68
77
  var axios = await this.context.ready;
69
78
  return axios.post(`/api/v3/enterprise/department`, data);
79
+ },
80
+ mark: async (factoryId: string, departmentId: string, kind: "maintenance") => {
81
+ var axios = await this.context.ready;
82
+ return axios.post(`/api/v3/enterprise/department/${factoryId}/mark`, { departmentId, kind });
83
+ },
84
+ users: async (id: number) => {
85
+ var axios = await this.context.ready;
86
+ return axios.get("/api/v2/factory/" + id + "/users");
70
87
  }
71
88
  }
72
89
  }
@@ -163,7 +180,7 @@ export class CompanyGateway extends Object {
163
180
  }
164
181
 
165
182
  //用于获得父节点的子节点列表,用于树形结构展示
166
- async treenode(pid: number|undefined) {
183
+ async treenode(pid: number | undefined) {
167
184
  var axios = await this.context.ready;
168
185
  if (pid == undefined) {
169
186
  return axios.get(`/api/tenant/groups`);
package/device_filter.ts CHANGED
@@ -341,6 +341,7 @@ export abstract class DeviceFilter<T extends { id: number }> {
341
341
  | "sumPerDay"
342
342
  | "latest"
343
343
  | "weekoverweek"
344
+ | "lastWithTime"
344
345
  | "last"
345
346
  | "rangeOfDay"
346
347
  | "rangeToday"
package/device_gateway.ts CHANGED
@@ -6,6 +6,7 @@ import type {
6
6
  DataQueryArgs,
7
7
  DeviceV2,
8
8
  Factory,
9
+ Supplier,
9
10
  } from ".";
10
11
 
11
12
  class DeviceFault {
@@ -263,6 +264,7 @@ export class DeviceGateway extends Object {
263
264
  | "latest"
264
265
  | "weekoverweek"
265
266
  | "last"
267
+ | "lastWithTime"
266
268
  | "rangeToday"
267
269
  | null; //如果data为null,则不获取数据,只获取设备列表,否则获取设备列表和数据
268
270
  status?: string;
@@ -530,7 +532,7 @@ export class DeviceGateway extends Object {
530
532
  * @param data 更新数据
531
533
  * @returns Promise
532
534
  */
533
- edit: (configId: string, data: {
535
+ edit: (configId: number, data: {
534
536
  name: string;
535
537
  manufacturer_id: number;
536
538
  model_id: number;
@@ -564,7 +566,7 @@ export class DeviceGateway extends Object {
564
566
  * @param keyword 搜索关键词(可选)
565
567
  * @returns Promise
566
568
  */
567
- list: (keyword?: string): Promise<any> => {
569
+ list: (keyword?: any): Promise<any> => {
568
570
  return this.context.ready.then(() => {
569
571
  return this.context.axios.get(`/api/v3/device/suppliers`, {
570
572
  params: {
@@ -578,14 +580,7 @@ export class DeviceGateway extends Object {
578
580
  * @param data 供应商数据
579
581
  * @returns Promise
580
582
  */
581
- create: (data: {
582
- name: string;
583
- code?: string;
584
- contact?: string;
585
- phone?: string;
586
- address?: string;
587
- remark?: string;
588
- }): Promise<any> => {
583
+ create: (data: Supplier): Promise<any> => {
589
584
  return this.context.ready.then(() => {
590
585
  return this.context.axios.post(`/api/v3/device/suppliers`, data);
591
586
  });
@@ -596,14 +591,7 @@ export class DeviceGateway extends Object {
596
591
  * @param data 更新数据
597
592
  * @returns Promise
598
593
  */
599
- update: (id: number, data: {
600
- name?: string;
601
- code?: string;
602
- contact?: string;
603
- phone?: string;
604
- address?: string;
605
- remark?: string;
606
- }): Promise<any> => {
594
+ update: (id: number, data: Supplier): Promise<any> => {
607
595
  return this.context.ready.then(() => {
608
596
  return this.context.axios.put(`/api/v3/device/suppliers/${id}`, data);
609
597
  });
@@ -628,7 +616,7 @@ export class DeviceGateway extends Object {
628
616
  if (parentId == undefined) {
629
617
  return this.context.axios.get(`/api/v3/device/purpose`);
630
618
  } else {
631
- return this.context.axios.get(`/api/v3/device/purpose/${parentId}`);
619
+ return this.context.axios.get(`/api/v3/device/purpose/${parentId}/children`);
632
620
  }
633
621
  });
634
622
  },
@@ -652,22 +640,30 @@ export class DeviceGateway extends Object {
652
640
  return this.context.ready.then(() => {
653
641
  return this.context.axios.delete(`/api/v3/device/purpose/${id}`);
654
642
  });
655
- }
643
+ },
644
+
645
+ detail: (id: number): Promise<any> => {
646
+ return this.context.ready.then(() => {
647
+ return this.context.axios.get(`/api/v3/device/purpose/${id}`);
648
+ });
649
+ },
656
650
  }
657
651
  }
658
652
 
659
653
  get trouble() {
660
654
  return {
661
- list: async (
662
- pageNum: number = 1,
663
- pageSize: number = 10
664
- ): Promise<any> => {
655
+ list: async (args: {
656
+ sourceType: "device" | "comprehensive" | undefined,
657
+ pageNum: number,
658
+ pageSize: number,
659
+ } = {
660
+ sourceType: "device",
661
+ pageNum: 1,
662
+ pageSize: 10,
663
+ }): Promise<any> => {
665
664
  const axios = await this.context.ready;
666
665
  return axios.get('/api/v3/device/trouble/list', {
667
- params: {
668
- pageNum,
669
- pageSize
670
- }
666
+ params: args
671
667
  });
672
668
  },
673
669
 
@@ -696,7 +692,29 @@ export class DeviceGateway extends Object {
696
692
  }
697
693
  return res.data;
698
694
  });
699
- }
695
+ },
696
+
697
+ history: async (troubleId: string): Promise<any> => {
698
+ const axios = await this.context.ready;
699
+ return axios.get(`/api/v3/device/trouble/${troubleId}/handle-records`)
700
+ .then((res) => {
701
+ if (res.data.code !== 200) {
702
+ throw new Error(res.data.message || '获取处理记录失败');
703
+ }
704
+ return res.data;
705
+ });
706
+ },
707
+
708
+ delete: async (troubleIds: number[]): Promise<any> => {
709
+ const axios = await this.context.ready;
710
+ return axios.delete('/api/v3/device/trouble/delete', troubleIds)
711
+ .then((res) => {
712
+ if (res.data.code !== 200) {
713
+ throw new Error(res.data.message || '删除故障失败');
714
+ }
715
+ return res.data;
716
+ });
717
+ },
700
718
  };
701
719
  }
702
720
 
@@ -719,6 +737,44 @@ export class DeviceGateway extends Object {
719
737
  }
720
738
  }
721
739
 
740
+ get troubleReason() {
741
+ return {
742
+ list: async (): Promise<any> => {
743
+ var axios = await this.context.ready;
744
+ return axios.get('/api/v3/device/trouble-reason');
745
+ },
746
+
747
+ create: async (data: {
748
+ name: string;
749
+ code?: string;
750
+ color?: string;
751
+ description?: string;
752
+ }): Promise<any> => {
753
+ var axios = await this.context.ready;
754
+ return axios.post('/api/v3/device/trouble-reason', data);
755
+ }
756
+ }
757
+ }
758
+
759
+ get troubleEmergency() {
760
+ return {
761
+ list: async (): Promise<any> => {
762
+ var axios = await this.context.ready;
763
+ return axios.get('/api/v3/device/trouble-emergency');
764
+ },
765
+
766
+ create: async (data: {
767
+ name: string;
768
+ code?: string;
769
+ color?: string;
770
+ description?: string;
771
+ }): Promise<any> => {
772
+ var axios = await this.context.ready;
773
+ return axios.post('/api/v3/device/trouble-emergency', data);
774
+ }
775
+ }
776
+ }
777
+
722
778
  get troubleType() {
723
779
  return {
724
780
  // 获取根节点(原list方法)
@@ -799,6 +855,11 @@ export class DeviceGateway extends Object {
799
855
  delete: async (id: number): Promise<any> => {
800
856
  var axios = await this.context.ready;
801
857
  return axios.delete(`/api/v3/device/model/${id}`);
858
+ },
859
+
860
+ detail: async (id: number): Promise<any> => {
861
+ var axios = await this.context.ready;
862
+ return axios.get(`/api/v3/device/model/${id}`);
802
863
  }
803
864
  }
804
865
  }
@@ -821,9 +882,7 @@ export class DeviceGateway extends Object {
821
882
  members?: number[];
822
883
  }): Promise<any> => {
823
884
  const axios = await this.context.ready;
824
- return axios.post('/api/v3/device/maintenance-groups', group, {
825
- params: { factoryId }
826
- });
885
+ return axios.post(`/api/v3/device/maintenance-groups?factoryId=${factoryId}`, group);
827
886
  },
828
887
 
829
888
  // 删除维护组
@@ -832,7 +891,165 @@ export class DeviceGateway extends Object {
832
891
  return axios.delete(`/api/v3/device/maintenance-groups/${groupId}`, {
833
892
  params: { factoryId }
834
893
  });
894
+ },
895
+ };
896
+ }
897
+
898
+ get maintenanceLevels() {
899
+ return {
900
+ // 获取维护级别列表
901
+ list: async (factoryId: number): Promise<any> => {
902
+ const axios = await this.context.ready;
903
+ return axios.get('/api/v3/device/maintenance-levels', {
904
+ params: { factoryId }
905
+ });
906
+ },
907
+ create: async (data: {
908
+ name: string;
909
+ code?: string;
910
+ color?: string;
911
+ description?: string;
912
+ }): Promise<any> => {
913
+ var axios = await this.context.ready;
914
+ return axios.post('/api/v3/device/maintenance-levels', data);
915
+ }
916
+ }
917
+ }
918
+
919
+ get maintenanceTypes() {
920
+ return {
921
+ // 获取维护类型列表
922
+ list: async (factoryId: number): Promise<any> => {
923
+ const axios = await this.context.ready;
924
+ return axios.get('/api/v3/device/maintenance-types', {
925
+ params: { factoryId }
926
+ });
927
+ },
928
+ create: async (data: {
929
+ name: string;
930
+ code?: string;
931
+ color?: string;
932
+ description?: string;
933
+ }): Promise<any> => {
934
+ var axios = await this.context.ready;
935
+ return axios.post('/api/v3/device/maintenance-levels', data);
936
+ }
937
+ }
938
+ }
939
+
940
+ get maintenanceFeedbackTypes() {
941
+ return {
942
+ // 获取维护类型列表
943
+ list: async (factoryId: number): Promise<any> => {
944
+ const axios = await this.context.ready;
945
+ return axios.get('/api/v3/device/maintenance-feedback-types', {
946
+ params: { factoryId }
947
+ });
948
+ },
949
+ create: async (data: {
950
+ name: string;
951
+ code?: string;
952
+ color?: string;
953
+ description?: string;
954
+ }): Promise<any> => {
955
+ var axios = await this.context.ready;
956
+ return axios.post('/api/v3/device/maintenance-feedback-types', data);
957
+ }
958
+ }
959
+ }
960
+
961
+ //维修中状态
962
+ get maintenanceStatus() {
963
+ return {
964
+ list: async (): Promise<any> => {
965
+ const axios = await this.context.ready;
966
+ return axios.get('/api/v3/device/maintenance-status');
967
+ },
968
+ create: async (data: {
969
+ name: string;
970
+ code?: string;
971
+ color?: string;
972
+ description?: string;
973
+ }): Promise<any> => {
974
+ var axios = await this.context.ready;
975
+ return axios.post('/api/v3/device/maintenance-status', data);
835
976
  }
836
977
  };
837
978
  }
979
+
980
+ //外委中状态列表
981
+ get maintenanceOutsourceStatus() {
982
+ return {
983
+ list: async (): Promise<any> => {
984
+ const axios = await this.context.ready;
985
+ return axios.get('/api/v3/device/maintenance-outsource-status');
986
+ },
987
+ create: async (data: {
988
+ name: string;
989
+ code?: string;
990
+ color?: string;
991
+ description?: string;
992
+ }): Promise<any> => {
993
+ var axios = await this.context.ready;
994
+ return axios.post('/api/v3/device/maintenance-outsource-status', data);
995
+ }
996
+ };
997
+ }
998
+
999
+ //故障来源
1000
+ get troubleDetectSource() {
1001
+ return {
1002
+ list: async (): Promise<any> => {
1003
+ const axios = await this.context.ready;
1004
+ return axios.get('/api/v3/device/trouble-detect-source');
1005
+ },
1006
+ create: async (data: {
1007
+ name: string;
1008
+ code?: string;
1009
+ color?: string;
1010
+ description?: string;
1011
+ }): Promise<any> => {
1012
+ var axios = await this.context.ready;
1013
+ return axios.post('/api/v3/device/trouble-detect-source', data);
1014
+ }
1015
+ };
1016
+ }
1017
+
1018
+ get usage() {
1019
+ return {
1020
+ /**
1021
+ * 获取设备使用情况
1022
+ * @param deviceId 设备ID
1023
+ * @returns Promise 包含设备使用情况的数据
1024
+ */
1025
+ get: async (deviceId: number): Promise<any> => {
1026
+ const axios = await this.context.ready;
1027
+ return axios.get(`/api/v3/device/usage/${deviceId}`)
1028
+ .then((res) => {
1029
+ if (res.data.code !== 200) {
1030
+ throw new Error(res.data.message || '获取设备使用情况失败');
1031
+ }
1032
+ return res.data;
1033
+ });
1034
+ },
1035
+
1036
+ /**
1037
+ * 更新设备使用情况
1038
+ * @param deviceId 设备ID
1039
+ * @param usageData 使用情况数据
1040
+ * @returns Promise 包含更新后的设备使用情况数据
1041
+ */
1042
+ update: async (deviceId: number, usageData: any): Promise<any> => {
1043
+ const axios = await this.context.ready;
1044
+ return axios.put(`/api/v3/device/usage/${deviceId}`, usageData)
1045
+ .then((res) => {
1046
+ if (res.data.code !== 200) {
1047
+ throw new Error(res.data.message || '更新设备使用情况失败');
1048
+ }
1049
+ return res.data;
1050
+ });
1051
+ }
1052
+ };
1053
+ }
1054
+
838
1055
  }
@@ -46,6 +46,14 @@ class CompanyGateway extends Object {
46
46
  },
47
47
  };
48
48
  }
49
+ async attribute(key, companyId = undefined) {
50
+ let axios = await this.context.ready;
51
+ if (!companyId) {
52
+ var selectedFarm = await this.context.user.getSelectedFarm();
53
+ companyId = selectedFarm.id;
54
+ }
55
+ return axios.get(`/api/v2/company/${companyId}/attribute/${key}`);
56
+ }
49
57
  get department() {
50
58
  return {
51
59
  list: async (pid) => {
@@ -59,6 +67,14 @@ class CompanyGateway extends Object {
59
67
  create: async (data) => {
60
68
  var axios = await this.context.ready;
61
69
  return axios.post(`/api/v3/enterprise/department`, data);
70
+ },
71
+ mark: async (factoryId, departmentId, kind) => {
72
+ var axios = await this.context.ready;
73
+ return axios.post(`/api/v3/enterprise/department/${factoryId}/mark`, { departmentId, kind });
74
+ },
75
+ users: async (id) => {
76
+ var axios = await this.context.ready;
77
+ return axios.get("/api/v2/factory/" + id + "/users");
62
78
  }
63
79
  };
64
80
  }