@cpzxrobot/sdk 1.0.27 → 1.0.28
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/device_filter.ts +21 -6
- package/dist/device_filter.js +21 -6
- package/dist/factory_gateway.js +6 -0
- package/factory_gateway.ts +7 -0
- package/package.json +1 -1
- package/readme.md +1 -0
package/device_filter.ts
CHANGED
|
@@ -112,13 +112,28 @@ export abstract class DeviceFilter<T extends { id: number }> {
|
|
|
112
112
|
type: "diffPerDay", // diffPerDay, sumPerDay, latest
|
|
113
113
|
}
|
|
114
114
|
) {
|
|
115
|
-
if
|
|
116
|
-
args.stop
|
|
115
|
+
if(!args.period || args.period.endsWith("d")) {
|
|
116
|
+
if (!args.stop) {
|
|
117
|
+
args.stop = this.formateDateToYYYYMMDD(new Date());
|
|
118
|
+
}
|
|
119
|
+
if (!args.start) {
|
|
120
|
+
const sevenDaysAgo = new Date();
|
|
121
|
+
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
|
|
122
|
+
args.start = this.formateDateToYYYYMMDD(sevenDaysAgo);
|
|
123
|
+
}
|
|
124
|
+
}else if(args.period.endsWith("h")) {
|
|
125
|
+
if (!args.stop) {
|
|
126
|
+
args.stop = new Date().toISOString();
|
|
127
|
+
}
|
|
128
|
+
if (!args.start) {
|
|
129
|
+
const oneDayAgo = new Date();
|
|
130
|
+
oneDayAgo.setDate(oneDayAgo.getDate() - 1);
|
|
131
|
+
args.start = oneDayAgo.toISOString();
|
|
132
|
+
}
|
|
117
133
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
args.start = this.formateDateToYYYYMMDD(sevenDaysAgo);
|
|
134
|
+
|
|
135
|
+
if(!args.type) {
|
|
136
|
+
args.type = "last";
|
|
122
137
|
}
|
|
123
138
|
|
|
124
139
|
return this.context.ready
|
package/dist/device_filter.js
CHANGED
|
@@ -91,13 +91,28 @@ class DeviceFilter {
|
|
|
91
91
|
stop: "",
|
|
92
92
|
type: "diffPerDay", // diffPerDay, sumPerDay, latest
|
|
93
93
|
}) {
|
|
94
|
-
if (!args.
|
|
95
|
-
args.stop
|
|
94
|
+
if (!args.period || args.period.endsWith("d")) {
|
|
95
|
+
if (!args.stop) {
|
|
96
|
+
args.stop = this.formateDateToYYYYMMDD(new Date());
|
|
97
|
+
}
|
|
98
|
+
if (!args.start) {
|
|
99
|
+
const sevenDaysAgo = new Date();
|
|
100
|
+
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
|
|
101
|
+
args.start = this.formateDateToYYYYMMDD(sevenDaysAgo);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else if (args.period.endsWith("h")) {
|
|
105
|
+
if (!args.stop) {
|
|
106
|
+
args.stop = new Date().toISOString();
|
|
107
|
+
}
|
|
108
|
+
if (!args.start) {
|
|
109
|
+
const oneDayAgo = new Date();
|
|
110
|
+
oneDayAgo.setDate(oneDayAgo.getDate() - 1);
|
|
111
|
+
args.start = oneDayAgo.toISOString();
|
|
112
|
+
}
|
|
96
113
|
}
|
|
97
|
-
if (!args.
|
|
98
|
-
|
|
99
|
-
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
|
|
100
|
-
args.start = this.formateDateToYYYYMMDD(sevenDaysAgo);
|
|
114
|
+
if (!args.type) {
|
|
115
|
+
args.type = "last";
|
|
101
116
|
}
|
|
102
117
|
return this.context.ready
|
|
103
118
|
.then(() => {
|
package/dist/factory_gateway.js
CHANGED
|
@@ -46,5 +46,11 @@ class FactoryGateway extends Object {
|
|
|
46
46
|
const response = await axios.get(`/api/v1/factory/${data.id}/organizaion`, data);
|
|
47
47
|
return response.data;
|
|
48
48
|
}
|
|
49
|
+
//支持以下三个name:'capacity'(规模),'used_capacity'(存栏量),'workshop_count'(栋舍/车间数量),'manager'(负责人)
|
|
50
|
+
async entry(factory, name) {
|
|
51
|
+
var axios = await this.context.ready;
|
|
52
|
+
const response = await axios.get(`/api/v1/factory/${factory.id}/entry/${name}`);
|
|
53
|
+
return response.data;
|
|
54
|
+
}
|
|
49
55
|
}
|
|
50
56
|
exports.FactoryGateway = FactoryGateway;
|
package/factory_gateway.ts
CHANGED
|
@@ -51,4 +51,11 @@ export class FactoryGateway extends Object {
|
|
|
51
51
|
const response = await axios.get(`/api/v1/factory/${data.id}/organizaion`, data);
|
|
52
52
|
return response.data;
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
//支持以下三个name:'capacity'(规模),'used_capacity'(存栏量),'workshop_count'(栋舍/车间数量),'manager'(负责人)
|
|
56
|
+
async entry(factory:Factory,name:string): Promise<any> {
|
|
57
|
+
var axios = await this.context.ready;
|
|
58
|
+
const response = await axios.get(`/api/v1/factory/${factory.id}/entry/${name}`);
|
|
59
|
+
return response.data;
|
|
60
|
+
}
|
|
54
61
|
}
|
package/package.json
CHANGED