@cpzxrobot/sdk 1.3.38 → 1.3.39

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/car_gateway.ts CHANGED
@@ -21,6 +21,13 @@ export class CarGateway extends Object {
21
21
  .then((res) => res.data);
22
22
  }
23
23
 
24
+ async cars(factory: Factory, date: Date) {
25
+ var axios = await this.context.ready;
26
+ return axios
27
+ .get(`/api/v2/car/${factory.pid}/cars`)
28
+ .then((res) => res.data);
29
+ }
30
+
24
31
  //根据工厂pid获取订单列表,注意,该接口和
25
32
  async orders(factory: Factory, date: Date) {
26
33
  var axios = await this.context.ready;
package/device_gateway.ts CHANGED
@@ -895,33 +895,12 @@ export class DeviceGateway extends Object {
895
895
  };
896
896
  }
897
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() {
898
+ private generateFunctionsForDict(dictName: string): any {
920
899
  return {
921
900
  // 获取维护类型列表
922
901
  list: async (factoryId: number): Promise<any> => {
923
902
  const axios = await this.context.ready;
924
- return axios.get('/api/v3/device/maintenance-types', {
903
+ return axios.get(`/api/v3/device/${dictName}`, {
925
904
  params: { factoryId }
926
905
  });
927
906
  },
@@ -932,88 +911,29 @@ export class DeviceGateway extends Object {
932
911
  description?: string;
933
912
  }): Promise<any> => {
934
913
  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
- });
914
+ return axios.post(`/api/v3/device/${dictName}`, data);
948
915
  },
949
- create: async (data: {
950
- name: string;
951
- code?: string;
952
- color?: string;
953
- description?: string;
954
- }): Promise<any> => {
916
+ delete: async (id: number): Promise<any> => {
955
917
  var axios = await this.context.ready;
956
- return axios.post('/api/v3/device/maintenance-feedback-types', data);
918
+ return axios.delete(`/api/v3/device/${dictName}/${id}`);
957
919
  }
958
920
  }
959
921
  }
960
922
 
923
+ public maintenanceLevels = this.generateFunctionsForDict('maintenance-levels');
924
+
925
+ public maintenanceTypes = this.generateFunctionsForDict('maintenance-types');
926
+
927
+ public maintenanceFeedbackTypes = this.generateFunctionsForDict('maintenance-feedback-types');
928
+
961
929
  //维修中状态
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);
976
- }
977
- };
978
- }
930
+ public maintenanceStatus = this.generateFunctionsForDict('maintenance-status');
979
931
 
980
932
  //外委中状态列表
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
- }
933
+ public maintenanceOutsourceStatus =this.generateFunctionsForDict('maintenance-outsource-status');
998
934
 
999
935
  //故障来源
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
- }
936
+ public troubleDetectSource = this.generateFunctionsForDict('trouble-detect-source');
1017
937
 
1018
938
  get usage() {
1019
939
  return {
@@ -95,11 +95,11 @@ export class FeedTowerGateway extends DeviceFilter<FeedTower> {
95
95
  });
96
96
  return res.data;
97
97
  }
98
- async getCarList(): Promise<any> {
99
- var axios = await this.context.ready;
100
- const res = await axios.get("/api/v1/pigfarm/car/list");
101
- return res.data;
102
- }
98
+ // async getCarList(): Promise<any> {
99
+ // var axios = await this.context.ready;
100
+ // const res = await axios.get("/api/v1/pigfarm/car/list");
101
+ // return res.data;
102
+ // }
103
103
  async updateZeroTime(id: Number): Promise<any> {
104
104
  var axios = await this.context.ready;
105
105
  const res = await axios.post(
@@ -18,6 +18,12 @@ class CarGateway extends Object {
18
18
  .get(`/api/v2/car/${factory.pid}/detections?date=` + date.toISOString())
19
19
  .then((res) => res.data);
20
20
  }
21
+ async cars(factory, date) {
22
+ var axios = await this.context.ready;
23
+ return axios
24
+ .get(`/api/v2/car/${factory.pid}/cars`)
25
+ .then((res) => res.data);
26
+ }
21
27
  //根据工厂pid获取订单列表,注意,该接口和
22
28
  async orders(factory, date) {
23
29
  var axios = await this.context.ready;
@@ -140,6 +140,15 @@ class DeviceGateway extends Object {
140
140
  }
141
141
  constructor(context) {
142
142
  super();
143
+ this.maintenanceLevels = this.generateFunctionsForDict('maintenance-levels');
144
+ this.maintenanceTypes = this.generateFunctionsForDict('maintenance-types');
145
+ this.maintenanceFeedbackTypes = this.generateFunctionsForDict('maintenance-feedback-types');
146
+ //维修中状态
147
+ this.maintenanceStatus = this.generateFunctionsForDict('maintenance-status');
148
+ //外委中状态列表
149
+ this.maintenanceOutsourceStatus = this.generateFunctionsForDict('maintenance-outsource-status');
150
+ //故障来源
151
+ this.troubleDetectSource = this.generateFunctionsForDict('trouble-detect-source');
143
152
  this.context = context;
144
153
  // this.devices = []
145
154
  this.type = new device_type_gateway_1.DeviceTypeGateway(context);
@@ -677,87 +686,22 @@ class DeviceGateway extends Object {
677
686
  },
678
687
  };
679
688
  }
680
- get maintenanceLevels() {
681
- return {
682
- // 获取维护级别列表
683
- list: async (factoryId) => {
684
- const axios = await this.context.ready;
685
- return axios.get('/api/v3/device/maintenance-levels', {
686
- params: { factoryId }
687
- });
688
- },
689
- create: async (data) => {
690
- var axios = await this.context.ready;
691
- return axios.post('/api/v3/device/maintenance-levels', data);
692
- }
693
- };
694
- }
695
- get maintenanceTypes() {
689
+ generateFunctionsForDict(dictName) {
696
690
  return {
697
691
  // 获取维护类型列表
698
692
  list: async (factoryId) => {
699
693
  const axios = await this.context.ready;
700
- return axios.get('/api/v3/device/maintenance-types', {
694
+ return axios.get(`/api/v3/device/${dictName}`, {
701
695
  params: { factoryId }
702
696
  });
703
697
  },
704
698
  create: async (data) => {
705
699
  var axios = await this.context.ready;
706
- return axios.post('/api/v3/device/maintenance-levels', data);
707
- }
708
- };
709
- }
710
- get maintenanceFeedbackTypes() {
711
- return {
712
- // 获取维护类型列表
713
- list: async (factoryId) => {
714
- const axios = await this.context.ready;
715
- return axios.get('/api/v3/device/maintenance-feedback-types', {
716
- params: { factoryId }
717
- });
700
+ return axios.post(`/api/v3/device/${dictName}`, data);
718
701
  },
719
- create: async (data) => {
720
- var axios = await this.context.ready;
721
- return axios.post('/api/v3/device/maintenance-feedback-types', data);
722
- }
723
- };
724
- }
725
- //维修中状态
726
- get maintenanceStatus() {
727
- return {
728
- list: async () => {
729
- const axios = await this.context.ready;
730
- return axios.get('/api/v3/device/maintenance-status');
731
- },
732
- create: async (data) => {
733
- var axios = await this.context.ready;
734
- return axios.post('/api/v3/device/maintenance-status', data);
735
- }
736
- };
737
- }
738
- //外委中状态列表
739
- get maintenanceOutsourceStatus() {
740
- return {
741
- list: async () => {
742
- const axios = await this.context.ready;
743
- return axios.get('/api/v3/device/maintenance-outsource-status');
744
- },
745
- create: async (data) => {
746
- var axios = await this.context.ready;
747
- return axios.post('/api/v3/device/maintenance-outsource-status', data);
748
- }
749
- };
750
- }
751
- //故障来源
752
- get troubleDetectSource() {
753
- return {
754
- list: async () => {
755
- const axios = await this.context.ready;
756
- return axios.get('/api/v3/device/trouble-detect-source');
757
- },
758
- create: async (data) => {
702
+ delete: async (id) => {
759
703
  var axios = await this.context.ready;
760
- return axios.post('/api/v3/device/trouble-detect-source', data);
704
+ return axios.delete(`/api/v3/device/${dictName}/${id}`);
761
705
  }
762
706
  };
763
707
  }
@@ -81,11 +81,11 @@ class FeedTowerGateway extends device_filter_1.DeviceFilter {
81
81
  });
82
82
  return res.data;
83
83
  }
84
- async getCarList() {
85
- var axios = await this.context.ready;
86
- const res = await axios.get("/api/v1/pigfarm/car/list");
87
- return res.data;
88
- }
84
+ // async getCarList(): Promise<any> {
85
+ // var axios = await this.context.ready;
86
+ // const res = await axios.get("/api/v1/pigfarm/car/list");
87
+ // return res.data;
88
+ // }
89
89
  async updateZeroTime(id) {
90
90
  var axios = await this.context.ready;
91
91
  const res = await axios.post("/api/v1/pigfarm/device/status/updateZeroTime" + "?id=" + id);
@@ -37,9 +37,29 @@ class UserGateway extends Object {
37
37
  var axios = await this.context.ready;
38
38
  return axios.post('/api/v2/user', user);
39
39
  }
40
- async list(factory) {
41
- var axios = await this.context.ready;
42
- return axios.get('/api/v2/' + factory.id + '/users');
40
+ //根据组织机构id获得该组织机构下所有人员
41
+ listByGroup(groupId) {
42
+ return this.context.ready.then((axios) => {
43
+ return axios.get(`/api/v2/user/list/${groupId}`);
44
+ });
45
+ }
46
+ async list(factory = undefined) {
47
+ var factoryId = 0;
48
+ if (factory) {
49
+ if (typeof factory === 'number') {
50
+ factoryId = factory;
51
+ }
52
+ else {
53
+ factoryId = factory.id;
54
+ }
55
+ }
56
+ else {
57
+ var selectedFarm = await this.context.user.getSelectedFarm();
58
+ factoryId = selectedFarm.id;
59
+ }
60
+ return this.context.ready.then((axios) => {
61
+ return axios.get(`/api/v2/user/list/${factoryId}`);
62
+ });
43
63
  }
44
64
  listByProvince(area_code) {
45
65
  return this.context.ready.then((axios) => {
@@ -310,12 +330,6 @@ class UserGateway extends Object {
310
330
  },
311
331
  };
312
332
  }
313
- //根据组织机构id获得该组织机构下所有人员
314
- listByGroup(groupId) {
315
- return this.context.ready.then((axios) => {
316
- return axios.get(`/api/v2/user/list/${groupId}`);
317
- });
318
- }
319
333
  get position() {
320
334
  return {
321
335
  leader: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.38",
3
+ "version": "1.3.39",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/user_gateway.ts CHANGED
@@ -45,9 +45,28 @@ export class UserGateway extends Object {
45
45
  return axios.post('/api/v2/user', user)
46
46
  }
47
47
 
48
- async list(factory: Factory) {
49
- var axios = await this.context.ready
50
- return axios.get('/api/v2/' + factory.id + '/users')
48
+ //根据组织机构id获得该组织机构下所有人员
49
+ listByGroup(groupId: number) {
50
+ return this.context.ready.then((axios) => {
51
+ return axios.get(`/api/v2/user/list/${groupId}`)
52
+ })
53
+ }
54
+
55
+ async list(factory: Factory | number| undefined = undefined) {
56
+ var factoryId = 0
57
+ if (factory) {
58
+ if (typeof factory === 'number') {
59
+ factoryId = factory
60
+ } else {
61
+ factoryId = factory.id as number
62
+ }
63
+ }else{
64
+ var selectedFarm = await this.context.user.getSelectedFarm()
65
+ factoryId = selectedFarm.id
66
+ }
67
+ return this.context.ready.then((axios) => {
68
+ return axios.get(`/api/v2/user/list/${factoryId}`)
69
+ })
51
70
  }
52
71
 
53
72
  listByProvince(area_code: string) {
@@ -70,9 +89,9 @@ export class UserGateway extends Object {
70
89
  role:
71
90
  | string
72
91
  | {
73
- deptName: string
74
- roleCode: string
75
- }
92
+ deptName: string
93
+ roleCode: string
94
+ }
76
95
  ) {
77
96
  var args = {}
78
97
  if (typeof role === 'string') {
@@ -386,12 +405,7 @@ export class UserGateway extends Object {
386
405
  }
387
406
  }
388
407
 
389
- //根据组织机构id获得该组织机构下所有人员
390
- listByGroup(groupId: number) {
391
- return this.context.ready.then((axios) => {
392
- return axios.get(`/api/v2/user/list/${groupId}`)
393
- })
394
- }
408
+
395
409
 
396
410
  get position() {
397
411
  return {