@cpzxrobot/sdk 1.0.45 → 1.0.47

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.
@@ -69,10 +69,42 @@ class PigfarmGateway extends Object {
69
69
  return axios.post(`/api/v1/pigfarm/heatLamp/config/add`, Object.assign(Object.assign({}, data), { unitId: unit.id }));
70
70
  });
71
71
  },
72
- list: async (unit) => {
72
+ configList: async (unit) => {
73
73
  var axios = await this.context.ready;
74
74
  return axios.post(`/api/v1/pigfarm/heatLamp/config/list?unitId=${unit.id}`);
75
75
  },
76
+ list: async (unit) => {
77
+ var axios = await this.context.ready;
78
+ return axios.post(`/api/v1/pigfarm/heatLamp/list/${unit.id}`);
79
+ },
80
+ //返回物联网相关的字段
81
+ iotFields: async (lamp) => {
82
+ var axios = await this.context.ready;
83
+ return axios.post(`/api/v1/pigfarm/heatLamp/iotFields/${lamp.id}`);
84
+ },
85
+ //开关,传入id或对象,action为on或off
86
+ switch: async (lamp, action) => {
87
+ var axios = await this.context.ready;
88
+ var id = typeof lamp === "number" ? lamp : lamp.id;
89
+ return axios.post(`/api/v1/pigfarm/heatLamp/switch`, {
90
+ id,
91
+ action,
92
+ });
93
+ },
94
+ //设置,传入id或对象,action为dayage时需要传回设置的天数
95
+ set: async (lamp, action, arg) => {
96
+ var axios = await this.context.ready;
97
+ var url = action === "dayage" ? "/api/v1/pigfarm/heatLamp/syncDayage" : "";
98
+ var id = typeof lamp === "number" ? lamp : lamp.id;
99
+ var body = {
100
+ id
101
+ };
102
+ switch (action) {
103
+ case "dayage":
104
+ body["days"] = arg;
105
+ }
106
+ return axios.post(`/api/v1/pigfarm/heatLamp/config/set`, lamp);
107
+ },
76
108
  get: async (id) => {
77
109
  var axios = await this.context.ready;
78
110
  return axios.get(`/api/v1/pigfarm/heatLamp/config/${id}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.45",
3
+ "version": "1.0.47",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -81,12 +81,51 @@ export class PigfarmGateway extends Object {
81
81
  });
82
82
  });
83
83
  },
84
- list: async (unit: Unit): Promise<any> => {
84
+ configList: async (unit: Unit): Promise<any> => {
85
85
  var axios = await this.context.ready;
86
86
  return axios.post(
87
87
  `/api/v1/pigfarm/heatLamp/config/list?unitId=${unit.id}`
88
88
  );
89
89
  },
90
+ list: async (unit: Unit): Promise<any> => {
91
+ var axios = await this.context.ready;
92
+ return axios.post(
93
+ `/api/v1/pigfarm/heatLamp/list/${unit.id}`
94
+ );
95
+ },
96
+ //返回物联网相关的字段
97
+ iotFields: async (lamp: HeatLamp): Promise<any> => {
98
+ var axios = await this.context.ready;
99
+ return axios.post(
100
+ `/api/v1/pigfarm/heatLamp/iotFields/${lamp.id}`
101
+ );
102
+ },
103
+ //开关,传入id或对象,action为on或off
104
+ switch: async (lamp: HeatLamp | number, action: "on" | "off") => {
105
+ var axios = await this.context.ready;
106
+ var id = typeof lamp === "number" ? lamp : lamp.id;
107
+ return axios.post(`/api/v1/pigfarm/heatLamp/switch`, {
108
+ id,
109
+ action,
110
+ });
111
+ },
112
+ //设置,传入id或对象,action为dayage时需要传回设置的天数
113
+ set: async (lamp: HeatLamp, action: "dayage",arg: any): Promise<any> => {
114
+ var axios = await this.context.ready;
115
+ var url = action === "dayage" ? "/api/v1/pigfarm/heatLamp/syncDayage" : "";
116
+ var id = typeof lamp === "number" ? lamp : lamp.id;
117
+ var body:{
118
+ id: number,
119
+ days?: number,
120
+ } = {
121
+ id
122
+ };
123
+ switch (action) {
124
+ case "dayage":
125
+ body["days"] = arg;
126
+ }
127
+ return axios.post(`/api/v1/pigfarm/heatLamp/config/set`, lamp);
128
+ },
90
129
  get: async (id: number): Promise<any> => {
91
130
  var axios = await this.context.ready;
92
131
  return axios.get(`/api/v1/pigfarm/heatLamp/config/${id}`);
package/readme.md CHANGED
@@ -84,6 +84,9 @@ baseURL: "/"
84
84
  | cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
85
85
  | cpzxrobot().device.feedTower.stat | 获得料塔设备的料耗,饲料重量 |
86
86
  | cpzxrobot().pigfarm.unitStat | 获得单元的统计信息,包括每日料耗,饲料消耗,日龄,存栏量等 |
87
+ | cpzxrobot().pigfarm.heatlamp.set | 设置保温灯的当前工作日龄,调用时,action传"dayage",argc传天数 |
88
+ | cpzxrobot().pigfarm.heatlamp.switch | 设置保温灯的当前工作日龄,调用时,action"on"或"off" |
89
+ | cpzxrobot().pigfarm.heatlamp.iotFields | 获取保温灯用于获取iot的字段列表 |
87
90
 
88
91
 
89
92
  ### 工厂信息接口