@cpzxrobot/sdk 1.3.22 → 1.3.23
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/dist/production_gateway.js +24 -35
- package/package.json +1 -1
- package/production_gateway.ts +34 -43
|
@@ -11,7 +11,7 @@ class ProductionGateway extends Object {
|
|
|
11
11
|
* 添加产品类型
|
|
12
12
|
* @param productName 产品名称
|
|
13
13
|
*/
|
|
14
|
-
async
|
|
14
|
+
async add(productName) {
|
|
15
15
|
const axios = await this.context.ready;
|
|
16
16
|
const factory = await this.context.user.getSelectedFarm();
|
|
17
17
|
return axios.post('/api/v3/production/add', {
|
|
@@ -22,45 +22,34 @@ class ProductionGateway extends Object {
|
|
|
22
22
|
/**
|
|
23
23
|
* 获取所有产品类型列表
|
|
24
24
|
*/
|
|
25
|
-
async
|
|
25
|
+
async list() {
|
|
26
26
|
const axios = await this.context.ready;
|
|
27
27
|
const factory = await this.context.user.getSelectedFarm();
|
|
28
28
|
return axios.get(`/api/v3/production/list/${factory.id}`);
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*/
|
|
52
|
-
async getStats(period, factoryId) {
|
|
53
|
-
if (!factoryId) {
|
|
54
|
-
const factory = await this.context.user.getSelectedFarm();
|
|
55
|
-
factoryId = factory.id;
|
|
56
|
-
}
|
|
57
|
-
const axios = await this.context.ready;
|
|
58
|
-
return axios.get('/api/v3/production/stat', {
|
|
59
|
-
params: {
|
|
60
|
-
period,
|
|
61
|
-
factory_id: factoryId
|
|
30
|
+
get stat() {
|
|
31
|
+
return {
|
|
32
|
+
get: async (type, period, factoryId) => {
|
|
33
|
+
if (!factoryId) {
|
|
34
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
35
|
+
factoryId = factory.id;
|
|
36
|
+
}
|
|
37
|
+
const axios = await this.context.ready;
|
|
38
|
+
return axios.get(`/api/v3/production/stat/${type}/${period}`, {
|
|
39
|
+
params: {
|
|
40
|
+
factory_id: factoryId
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
create: async (request) => {
|
|
45
|
+
if (!request.factory_id) {
|
|
46
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
47
|
+
request.factory_id = factory.id;
|
|
48
|
+
}
|
|
49
|
+
const axios = await this.context.ready;
|
|
50
|
+
return axios.post('/api/v3/production/stat', request);
|
|
62
51
|
}
|
|
63
|
-
}
|
|
52
|
+
};
|
|
64
53
|
}
|
|
65
54
|
}
|
|
66
55
|
exports.ProductionGateway = ProductionGateway;
|
package/package.json
CHANGED
package/production_gateway.ts
CHANGED
|
@@ -13,7 +13,7 @@ export class ProductionGateway extends Object {
|
|
|
13
13
|
* 添加产品类型
|
|
14
14
|
* @param productName 产品名称
|
|
15
15
|
*/
|
|
16
|
-
async
|
|
16
|
+
async add(productName: string): Promise<{ code: number; message: string }> {
|
|
17
17
|
const axios = await this.context.ready;
|
|
18
18
|
const factory = await this.context.user.getSelectedFarm();
|
|
19
19
|
return axios.post('/api/v3/production/add', {
|
|
@@ -25,54 +25,45 @@ export class ProductionGateway extends Object {
|
|
|
25
25
|
/**
|
|
26
26
|
* 获取所有产品类型列表
|
|
27
27
|
*/
|
|
28
|
-
async
|
|
28
|
+
async list(): Promise<{ types: Production[] }> {
|
|
29
29
|
const axios = await this.context.ready;
|
|
30
30
|
const factory = await this.context.user.getSelectedFarm();
|
|
31
31
|
return axios.get(`/api/v3/production/list/${factory.id}`);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
get stat() {
|
|
35
|
+
return {
|
|
36
|
+
get: async (
|
|
37
|
+
type: 'sale' | 'order' | 'production',
|
|
38
|
+
period: 'month' | 'quater' | 'year', factoryId?: number): Promise<Array<{
|
|
39
|
+
time: string;
|
|
40
|
+
products: Record<number, number>;
|
|
41
|
+
}>> => {
|
|
42
|
+
if (!factoryId) {
|
|
43
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
44
|
+
factoryId = factory.id;
|
|
45
|
+
}
|
|
46
|
+
const axios = await this.context.ready;
|
|
47
|
+
return axios.get(`/api/v3/production/stat/${type}/${period}`, {
|
|
48
|
+
params: {
|
|
49
|
+
factory_id: factoryId
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
create: async (request: {
|
|
54
|
+
factory_id?: number;
|
|
55
|
+
time: Date;
|
|
56
|
+
period: number; // 1:月度, 2:季度, 3:年度
|
|
57
|
+
products: Record<number, number>; // 产品名称到产量的映射
|
|
58
|
+
}) => {
|
|
59
|
+
if (!request.factory_id) {
|
|
60
|
+
const factory = await this.context.user.getSelectedFarm();
|
|
61
|
+
request.factory_id = factory.id;
|
|
62
|
+
}
|
|
63
|
+
const axios = await this.context.ready;
|
|
64
|
+
return axios.post('/api/v3/production/stat', request);
|
|
65
|
+
}
|
|
47
66
|
}
|
|
48
|
-
const axios = await this.context.ready;
|
|
49
|
-
return axios.post('/api/v3/production/stat', {
|
|
50
|
-
factory_id: request.factory_id,
|
|
51
|
-
time: request.time.toISOString(),
|
|
52
|
-
period: request.period,
|
|
53
|
-
products: request.products
|
|
54
|
-
});
|
|
55
67
|
}
|
|
56
68
|
|
|
57
|
-
/**
|
|
58
|
-
* 查询产量统计数据
|
|
59
|
-
* @param period 统计周期(month|quater|year)
|
|
60
|
-
* @param factoryId 工厂ID
|
|
61
|
-
*/
|
|
62
|
-
async getStats(period: 'month' | 'quater' | 'year', factoryId?: number): Promise<Array<{
|
|
63
|
-
time: string;
|
|
64
|
-
products: Record<number, number>;
|
|
65
|
-
}>> {
|
|
66
|
-
if (!factoryId) {
|
|
67
|
-
const factory = await this.context.user.getSelectedFarm();
|
|
68
|
-
factoryId = factory.id;
|
|
69
|
-
}
|
|
70
|
-
const axios = await this.context.ready;
|
|
71
|
-
return axios.get('/api/v3/production/stat', {
|
|
72
|
-
params: {
|
|
73
|
-
period,
|
|
74
|
-
factory_id: factoryId
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
69
|
}
|