@cpzxrobot/sdk 1.1.9 → 1.1.11

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_gateway.ts CHANGED
@@ -5,6 +5,7 @@ import type {
5
5
  Cpzxrobot,
6
6
  DataQueryArgs,
7
7
  DeviceV2,
8
+ Factory,
8
9
  } from ".";
9
10
  import { FeedTowerGateway } from "./device_types/feedtower";
10
11
  import { ElectricMeterGateway } from "./device_types/electricmeter";
@@ -64,6 +65,50 @@ export class DeviceGateway extends Object {
64
65
  };
65
66
  }
66
67
 
68
+ get thresholdConfig() {
69
+ return {
70
+ list: async (factory?: Factory) => {
71
+ let axios = await this.context.ready;
72
+ return axios.get(`/api/v2/threshold/config`, {
73
+ params: {
74
+ factoryType: factory?.kind
75
+ },
76
+ });
77
+ },
78
+ //新增或更新阈值配置,用于基础信息的更新或新增
79
+ post: async (data: any) => {
80
+ let axios = await this.context.ready;
81
+ return axios.post(`/api/v2/threshold/config`, data);
82
+ },
83
+ //向阈值配置中新增一条规则
84
+ addRule: async (configId: string, data: any) => {
85
+ let axios = await this.context.ready;
86
+ return axios.post(`/api/v2/threshold`, {
87
+ ...data,
88
+ configId: configId,
89
+ });
90
+ },
91
+ //删除阈值配置
92
+ deleteRule: async (id: string) => {
93
+ let axios = await this.context.ready;
94
+ return axios.post(`/api/v2/threshold/delete`, {
95
+ id: id,
96
+ });
97
+ },
98
+ //读取阈值配置,包括阈值规则列表
99
+ get: async (configId: string) => {
100
+ let axios = await this.context.ready;
101
+ return axios.get(`/api/v2/threshold/config/${configId}`);
102
+ },
103
+ delete: async (id: string) => {
104
+ let axios = await this.context.ready;
105
+ return axios.post(`/api/v2/threshold/config/delete`,{
106
+ id: id
107
+ });
108
+ },
109
+ };
110
+ }
111
+
67
112
  constructor(context: Cpzxrobot) {
68
113
  super();
69
114
  this.context = context;
@@ -38,6 +38,46 @@ class DeviceGateway extends Object {
38
38
  },
39
39
  };
40
40
  }
41
+ get thresholdConfig() {
42
+ return {
43
+ list: async (factory) => {
44
+ let axios = await this.context.ready;
45
+ return axios.get(`/api/v2/threshold/config`, {
46
+ params: {
47
+ factoryType: factory === null || factory === void 0 ? void 0 : factory.kind
48
+ },
49
+ });
50
+ },
51
+ //新增或更新阈值配置,用于基础信息的更新或新增
52
+ post: async (data) => {
53
+ let axios = await this.context.ready;
54
+ return axios.post(`/api/v2/threshold/config`, data);
55
+ },
56
+ //向阈值配置中新增一条规则
57
+ addRule: async (configId, data) => {
58
+ let axios = await this.context.ready;
59
+ return axios.post(`/api/v2/threshold`, Object.assign(Object.assign({}, data), { configId: configId }));
60
+ },
61
+ //删除阈值配置
62
+ deleteRule: async (id) => {
63
+ let axios = await this.context.ready;
64
+ return axios.post(`/api/v2/threshold/delete`, {
65
+ id: id,
66
+ });
67
+ },
68
+ //读取阈值配置,包括阈值规则列表
69
+ get: async (configId) => {
70
+ let axios = await this.context.ready;
71
+ return axios.get(`/api/v2/threshold/config/${configId}`);
72
+ },
73
+ delete: async (id) => {
74
+ let axios = await this.context.ready;
75
+ return axios.post(`/api/v2/threshold/config/delete`, {
76
+ id: id
77
+ });
78
+ },
79
+ };
80
+ }
41
81
  constructor(context) {
42
82
  super();
43
83
  this.context = context;
@@ -42,6 +42,10 @@ class FactoryGateway extends Object {
42
42
  var axios = await this.context.ready;
43
43
  return axios.post("/api/v2/factory/role", data);
44
44
  }
45
+ async deleteRole(id, roleId) {
46
+ var axios = await this.context.ready;
47
+ return axios.post("/api/v2/factory/role/delete?id=" + roleId);
48
+ }
45
49
  async users(id) {
46
50
  var axios = await this.context.ready;
47
51
  return axios.get("/api/v2/factory/" + id + "/users");
@@ -58,9 +62,9 @@ class FactoryGateway extends Object {
58
62
  var axios = await this.context.ready;
59
63
  return axios.post(`/api/v1/workshop/create`, data);
60
64
  },
61
- types: async (factoryType) => {
65
+ types: async (factory) => {
62
66
  var axios = await this.context.ready;
63
- return axios.get(`/api/v1/workshop/types/${factoryType}`);
67
+ return axios.get(`/api/v2/factory/${factory.kind}/workshop/type`);
64
68
  },
65
69
  list: async (factory) => {
66
70
  var axios = await this.context.ready;
@@ -50,6 +50,11 @@ export class FactoryGateway extends Object {
50
50
  return axios.post("/api/v2/factory/role", data);
51
51
  }
52
52
 
53
+ async deleteRole(id: number, roleId: number) {
54
+ var axios = await this.context.ready;
55
+ return axios.post("/api/v2/factory/role/delete?id=" + roleId);
56
+ }
57
+
53
58
  async users(id: number) {
54
59
  var axios = await this.context.ready;
55
60
  return axios.get("/api/v2/factory/" + id+"/users");
@@ -67,9 +72,9 @@ export class FactoryGateway extends Object {
67
72
  var axios = await this.context.ready;
68
73
  return axios.post(`/api/v1/workshop/create`, data);
69
74
  },
70
- types: async (factoryType: string) => {
75
+ types: async (factory: Factory) => {
71
76
  var axios = await this.context.ready;
72
- return axios.get(`/api/v1/workshop/types/${factoryType}`);
77
+ return axios.get(`/api/v2/factory/${factory.kind}/workshop/type`);
73
78
  },
74
79
  list: async (factory: Factory) => {
75
80
  var axios = await this.context.ready;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -90,13 +90,14 @@ baseURL: "/"
90
90
  | cpzxrobot().factory.apps | 获得工厂的应用列表,如果指定withRoles为true,则返回app和app的详细角色信息 |
91
91
  | cpzxrobot().factory.roles | 获得工厂的角色列表 |
92
92
  | cpzxrobot().factory.addRole | 添加工厂的角色 |
93
+ | cpzxrobot().factory.deleteRole | 删除工厂的角色 |
93
94
  | cpzxrobot().factory.info.get | 获得工厂的附加信息 |
94
95
  | cpzxrobot().factory.info.post | 更新或更新工厂的附加信息 |
95
96
  | cpzxrobot().factory.banner.add | 添加工厂的banner图片,提交formdata,需要传入file参数 |
96
97
  | cpzxrobot().factory.banner.delete | 删除工厂的banner图片,需要传入id参数 |
97
98
  | cpzxrobot().factory.workshop.get | 获得工厂的某个车间信息 |
98
- | cpzxrobot().factory.workshop.post | 添加料单信息 |
99
- | cpzxrobot().factory.workshop.types | 获得料单的类型列表 |
99
+ | cpzxrobot().factory.workshop.post | 添加车间信息 |
100
+ | cpzxrobot().factory.workshop.types | 获得车间的类型列表 |
100
101
  | cpzxrobot().transport.fodder.getDeviceByFodderld | 获得料单对应的设备 |
101
102
  | cpzxrobot().pigfarm.heatlamp.xxx | 操作保温灯 |
102
103
  | cpzxrobot().pigfarm.weightMeter.config.list | 获取称重计的配置信息 |
@@ -111,6 +112,12 @@ baseURL: "/"
111
112
  | cpzxrobot().device.feedTower.setAlarmParam | 设置料塔设备的报警参数 |
112
113
  | cpzxrobot().device.feedTower.updateAlarmParam | 更新料塔设备的报警参数 |
113
114
  | cpzxrobot().device.feedTower.getAlarmParam | 获得料塔设备的报警参数 |
115
+ | cpzxrobot().device.thresholdConfig.list | 获得设备报警阈值列表 |
116
+ | cpzxrobot().device.thresholdConfig.post | 添加或更新设备报警阈值(根据是否传入id) |
117
+ | cpzxrobot().device.thresholdConfig.delete | 删除设备报警阈值(根据id) |
118
+ | cpzxrobot().device.thresholdConfig.get | 获得设备报警阈值配置信息 |
119
+ | cpzxrobot().device.thresholdConfig.addRule | 获得设备报警阈值配置信息 |
120
+ | cpzxrobot().device.thresholdConfig.deleteRule | 删除设备报警阈值配置信息 |
114
121
  | cpzxrobot().pigfarm.unitStat | 获得单元的统计信息,包括每日料耗,饲料消耗,日龄,存栏量等 |
115
122
  | cpzxrobot().pigfarm.heatlamp.set | 设置保温灯的当前工作日龄,调用时,action传"dayage",argc传天数 |
116
123
  | cpzxrobot().pigfarm.heatlamp.switch | 设置保温灯的当前工作日龄,调用时,action"on"或"off" |
package/types.d.ts CHANGED
@@ -76,6 +76,7 @@ type Factory = {
76
76
  company_code: string;
77
77
  id?: number;
78
78
  type?: string;
79
+ kind?: string;
79
80
  pid?: number;
80
81
  };
81
82
  type Unit = {