@cpzxrobot/sdk 1.0.26 → 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 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 (!args.stop) {
116
- args.stop = this.formateDateToYYYYMMDD(new Date());
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
- if (!args.start) {
119
- const sevenDaysAgo = new Date();
120
- sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
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/device_gateway.ts CHANGED
@@ -78,6 +78,7 @@ export class DeviceGateway extends Object {
78
78
  | null; //如果data为null,则不获取数据,只获取设备列表,否则获取设备列表和数据
79
79
  status?: string;
80
80
  unit?: Number;
81
+ type?: string;
81
82
  detail?: boolean;
82
83
  supplier?: string; //供应商,可用于过滤设备
83
84
  } = undefined
@@ -91,13 +91,28 @@ class DeviceFilter {
91
91
  stop: "",
92
92
  type: "diffPerDay", // diffPerDay, sumPerDay, latest
93
93
  }) {
94
- if (!args.stop) {
95
- args.stop = this.formateDateToYYYYMMDD(new Date());
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.start) {
98
- const sevenDaysAgo = new Date();
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(() => {
@@ -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;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -79,6 +79,7 @@ baseURL: "/"
79
79
  | cpzxrobot().device.feedTower.list | 获得料塔设备的列表 |
80
80
  | cpzxrobot().device.xxx | 获得设备的相关信息 |
81
81
  | cpzxrobot().camera.xxx | 获得摄像头的相关信息 |
82
+ | cpzxrobot().factory.entry| 获得工厂的可显示动态信息 |
82
83
 
83
84
  ### 工厂信息接口
84
85