@cpzxrobot/sdk 1.2.30 → 1.2.31

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,6 +10,7 @@ export class DeviceTypeGateway {
10
10
  this.context = context
11
11
  }
12
12
 
13
+ //需要返回.data
13
14
  list(): Promise<DeviceType[]> {
14
15
  if (this.deviceTypes) {
15
16
  return Promise.resolve(this.deviceTypes)
@@ -6,6 +6,7 @@ class DeviceTypeGateway {
6
6
  constructor(context) {
7
7
  this.context = context;
8
8
  }
9
+ //需要返回.data
9
10
  list() {
10
11
  if (this.deviceTypes) {
11
12
  return Promise.resolve(this.deviceTypes);
@@ -101,6 +101,12 @@ class FactoryGateway extends Object {
101
101
  return response.data;
102
102
  }
103
103
  //获得工厂的所有单元信息,以车间为单位树状结构
104
+ /**
105
+ * 异步获取指定工厂的单元信息
106
+ *
107
+ * @param id 工厂ID,可选参数。如果不提供,则默认获取当前用户选择的工厂ID
108
+ * @returns 返回包含单元信息的对象
109
+ */
104
110
  async units(id = undefined) {
105
111
  var axios = await this.context.ready;
106
112
  if (!id) {
@@ -7,6 +7,79 @@ class TransportGateway extends Object {
7
7
  this._selectedFarm = "";
8
8
  this.context = context;
9
9
  }
10
+ get pig() {
11
+ return {
12
+ // 根据栋舍获取车牌号列表信息
13
+ getCars: (factoryId) => {
14
+ return this.context.ready.then(() => {
15
+ return this.context.axios
16
+ .get("/api/v2/pigfarm/transport/cars", {
17
+ params: { factoryId }
18
+ })
19
+ .then((res) => {
20
+ if (res.data.code != 200) {
21
+ throw res.data.message;
22
+ }
23
+ return res.data.data;
24
+ });
25
+ });
26
+ },
27
+ // 获取运输批次信息(根据workshopId和truckCode)
28
+ getBatchByTruck: (workshopId, truckCode) => {
29
+ return this.context.ready.then(() => {
30
+ return this.context.axios
31
+ .get(`/api/v2/pigfarm/transport/bactch/${workshopId}/${truckCode}`)
32
+ .then((res) => {
33
+ if (res.data.code != 200) {
34
+ throw res.data.message;
35
+ }
36
+ return res.data.data;
37
+ });
38
+ });
39
+ },
40
+ // 获取运输批次信息(根据workshopId和时间范围)
41
+ getBatchByDateRange: (workshopId, startDate, endDate) => {
42
+ return this.context.ready.then(() => {
43
+ return this.context.axios
44
+ .get(`/api/v2/pigfarm/transport/bactch/${workshopId}`, {
45
+ params: { startDate, endDate }
46
+ })
47
+ .then((res) => {
48
+ if (res.data.code != 200) {
49
+ throw res.data.message;
50
+ }
51
+ return res.data.data;
52
+ });
53
+ });
54
+ },
55
+ // 创建猪运输单
56
+ createBatch: (data) => {
57
+ return this.context.ready.then(() => {
58
+ return this.context.axios
59
+ .post("/api/v2/pigfarm/transport/bactch", data)
60
+ .then((res) => {
61
+ if (res.data.code != 200) {
62
+ throw res.data.message;
63
+ }
64
+ return res.data.data;
65
+ });
66
+ });
67
+ },
68
+ // 获取运输单详情
69
+ getBatchDetail: (id) => {
70
+ return this.context.ready.then(() => {
71
+ return this.context.axios
72
+ .get(`/api/v2/pigfarm/transport/bactch/detail/${id}`)
73
+ .then((res) => {
74
+ if (res.data.code != 200) {
75
+ throw res.data.message;
76
+ }
77
+ return res.data.data;
78
+ });
79
+ });
80
+ }
81
+ };
82
+ }
10
83
  get fodder() {
11
84
  return {
12
85
  //获得打料列表
@@ -116,6 +116,12 @@ export class FactoryGateway extends Object {
116
116
  }
117
117
 
118
118
  //获得工厂的所有单元信息,以车间为单位树状结构
119
+ /**
120
+ * 异步获取指定工厂的单元信息
121
+ *
122
+ * @param id 工厂ID,可选参数。如果不提供,则默认获取当前用户选择的工厂ID
123
+ * @returns 返回包含单元信息的对象
124
+ */
119
125
  async units(id: number|undefined = undefined): Promise<any> {
120
126
  var axios = await this.context.ready;
121
127
  if (!id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.2.30",
3
+ "version": "1.2.31",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -957,6 +957,11 @@ baseURL: "/"
957
957
  | cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
958
958
  | cpzxrobot().transport.fodder.getRecentLoad | 获取料塔最近打料记录,传入towerId参数 |
959
959
  | cpzxrobot().transport.fodder.delete | 删除饲料信息,需要传入id参数 |
960
+ | cpzxrobot().transport.pig.getCars | 根据栋舍获取车牌号列表信息,传入factoryId参数 |
961
+ | cpzxrobot().transport.pig.getBatchByTruck | 获取运输批次信息,传入workshopId和truckCode参数 |
962
+ | cpzxrobot().transport.pig.getBatchByDateRange | 获取运输批次信息,传入workshopId、startDate和endDate参数 |
963
+ | cpzxrobot().transport.pig.createBatch | 创建猪运输单,传入运输单数据 |
964
+ | cpzxrobot().transport.pig.getBatchDetail | 获取运输单详情,传入运输单id |
960
965
  | cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
961
966
  | cpzxrobot().pigfarm.weightMeter.config.list | 获取称重计的配置信息 |
962
967
  | cpzxrobot().pigfarm.weightMeter.config.bind | 添加称重计的配置信息,绑定到料塔 |
@@ -9,6 +9,84 @@ export class TransportGateway extends Object {
9
9
  this.context = context;
10
10
  }
11
11
 
12
+ get pig() {
13
+ return {
14
+ // 根据栋舍获取车牌号列表信息
15
+ getCars: (factoryId: string): Promise<any> => {
16
+ return this.context.ready.then(() => {
17
+ return this.context.axios
18
+ .get("/api/v2/pigfarm/transport/cars", {
19
+ params: { factoryId }
20
+ })
21
+ .then((res) => {
22
+ if (res.data.code != 200) {
23
+ throw res.data.message;
24
+ }
25
+ return res.data.data;
26
+ });
27
+ });
28
+ },
29
+
30
+ // 获取运输批次信息(根据workshopId和truckCode)
31
+ getBatchByTruck: (workshopId: string, truckCode: string): Promise<any> => {
32
+ return this.context.ready.then(() => {
33
+ return this.context.axios
34
+ .get(`/api/v2/pigfarm/transport/bactch/${workshopId}/${truckCode}`)
35
+ .then((res) => {
36
+ if (res.data.code != 200) {
37
+ throw res.data.message;
38
+ }
39
+ return res.data.data;
40
+ });
41
+ });
42
+ },
43
+
44
+ // 获取运输批次信息(根据workshopId和时间范围)
45
+ getBatchByDateRange: (workshopId: string, startDate: string, endDate: string): Promise<any> => {
46
+ return this.context.ready.then(() => {
47
+ return this.context.axios
48
+ .get(`/api/v2/pigfarm/transport/bactch/${workshopId}`, {
49
+ params: { startDate, endDate }
50
+ })
51
+ .then((res) => {
52
+ if (res.data.code != 200) {
53
+ throw res.data.message;
54
+ }
55
+ return res.data.data;
56
+ });
57
+ });
58
+ },
59
+
60
+ // 创建猪运输单
61
+ createBatch: (data: any): Promise<any> => {
62
+ return this.context.ready.then(() => {
63
+ return this.context.axios
64
+ .post("/api/v2/pigfarm/transport/bactch", data)
65
+ .then((res) => {
66
+ if (res.data.code != 200) {
67
+ throw res.data.message;
68
+ }
69
+ return res.data.data;
70
+ });
71
+ });
72
+ },
73
+
74
+ // 获取运输单详情
75
+ getBatchDetail: (id: string): Promise<any> => {
76
+ return this.context.ready.then(() => {
77
+ return this.context.axios
78
+ .get(`/api/v2/pigfarm/transport/bactch/detail/${id}`)
79
+ .then((res) => {
80
+ if (res.data.code != 200) {
81
+ throw res.data.message;
82
+ }
83
+ return res.data.data;
84
+ });
85
+ });
86
+ }
87
+ }
88
+ }
89
+
12
90
  get fodder() {
13
91
  return {
14
92
  //获得打料列表