nayota-show-sdk 0.0.9 → 0.1.0
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/api/devices.js +156 -0
- package/package.json +1 -1
package/api/devices.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { requestShow } from '../utils'
|
|
2
|
+
/**
|
|
3
|
+
* @file 设备api
|
|
4
|
+
* @module 设备接口
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 节点数据维度dataDimension
|
|
10
|
+
* @readonly
|
|
11
|
+
* @enum {string}
|
|
12
|
+
*/
|
|
13
|
+
var dataDimension = {
|
|
14
|
+
day: 'day',
|
|
15
|
+
year: 'year'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 节点类型propType
|
|
20
|
+
* @readonly
|
|
21
|
+
* @enum {string}
|
|
22
|
+
*/
|
|
23
|
+
var propType = {
|
|
24
|
+
check: 'check',
|
|
25
|
+
operate: 'operate'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 设备状态deviceStatus
|
|
30
|
+
* @readonly
|
|
31
|
+
* @enum {number}
|
|
32
|
+
*/
|
|
33
|
+
var deviceStatus = {
|
|
34
|
+
正常: 0,
|
|
35
|
+
告警: 1,
|
|
36
|
+
异常: 2,
|
|
37
|
+
故障: 3,
|
|
38
|
+
离线: 4
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {Object} device
|
|
43
|
+
* @property {string} _id - 设备id
|
|
44
|
+
* @property {string} name - 设备名称.
|
|
45
|
+
* @property {Array} hash - 根据参数PropId生成,用于判定设备是否已经导入(新版弃用)
|
|
46
|
+
* @property {Array} latLng - 设备在平面图上的经纬度
|
|
47
|
+
* @property {Array} mapLatLng - 设备在地图上的经纬度
|
|
48
|
+
* @property {string} shortAddress - 设备短地址
|
|
49
|
+
* @property {Array} attribute - 设备属性
|
|
50
|
+
* @property {string} attribute.key - 设备属性key
|
|
51
|
+
* @property {string} attribute.value - 设备属性value
|
|
52
|
+
* @property {string} attribute.note - 设备属性备注
|
|
53
|
+
* @property {Array} props - 设备节点
|
|
54
|
+
* @property {string} props._id - 节点id
|
|
55
|
+
* @property {string} props.name - 节点名称
|
|
56
|
+
* @property {string} props.key - 节点key
|
|
57
|
+
* @property {string} props.dataDimension - 节点数据维度,默认为day天,查看枚举dataDimension
|
|
58
|
+
* @property {string} props.type - 节点类型,查看枚举propType
|
|
59
|
+
* @property {string} props.propId - 节点propId,同IOT的check或者operate的_id
|
|
60
|
+
* @property {number} props.value - 节点最后值
|
|
61
|
+
* @property {string} props.valueStr - 节点最后值字符串
|
|
62
|
+
* @property {boolean} props.lineType - 节点在离线判定是否开启
|
|
63
|
+
* @property {string} props.lineTime - 节点在离线判定时间(单位小时)
|
|
64
|
+
* @property {boolean} props.statusType - 节点是否开启异常值判定
|
|
65
|
+
* @property {string} props.interval - 节点异常值判定的区间
|
|
66
|
+
* @property {string} props.company - 节点单位
|
|
67
|
+
* @property {array} props.enum - 节点枚举同IOT的区间
|
|
68
|
+
* @property {string} props.enum.label - 枚举字符串值
|
|
69
|
+
* @property {number} props.enum.value - 枚举值
|
|
70
|
+
* @property {number} props.enum.min - 枚举最小值
|
|
71
|
+
* @property {number} props.enum.max - 枚举最大值
|
|
72
|
+
* @property {string} n_device - 设备关联IOT展示设备的_id
|
|
73
|
+
* @property {string} depart - 设备层级id
|
|
74
|
+
* @property {number} order - 设备排序
|
|
75
|
+
* @property {string} deviceClass - 设备所属的设备类型
|
|
76
|
+
* @property {string} deviceStatus - 设备状态查看枚举deviceStatus
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param {*} query
|
|
82
|
+
* @param {number} query.page - 页码
|
|
83
|
+
* @param {number} query.limit - 每页数量
|
|
84
|
+
* @returns {number} code - 返回码,0表示成功
|
|
85
|
+
* @returns {number} total - 设备总数
|
|
86
|
+
* @returns {Array} rows - 设备数组查看设备数据定义
|
|
87
|
+
*/
|
|
88
|
+
export function list(query) {
|
|
89
|
+
return request({
|
|
90
|
+
url: '/devices',
|
|
91
|
+
method: 'get',
|
|
92
|
+
params: query
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 新增设备
|
|
98
|
+
* @param {Object} data - 包含设备的请求体 属性见list返回字段。
|
|
99
|
+
* @returns {number} code - 返回码,0表示成功
|
|
100
|
+
* @returns {string} data - 新增成功的数据 跟list返回字段一致
|
|
101
|
+
*/
|
|
102
|
+
export function create(data) {
|
|
103
|
+
return requestShow({
|
|
104
|
+
url: '/devices',
|
|
105
|
+
method: 'post',
|
|
106
|
+
data
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 修改设备
|
|
112
|
+
* @param {Object} data - 包含设备的请求体 属性见list返回字段。
|
|
113
|
+
* @returns {number} code - 返回码,0表示成功
|
|
114
|
+
* @returns {string} data - 修改成功的数据 跟list返回字段一致
|
|
115
|
+
*/
|
|
116
|
+
export function updateOne(data) {
|
|
117
|
+
return requestShow({
|
|
118
|
+
url: `/devices/${data._id}`,
|
|
119
|
+
method: 'put',
|
|
120
|
+
data
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 删除设备
|
|
125
|
+
* @param {string} id - 删除的设备id。
|
|
126
|
+
* @returns {number} code - 返回码,0表示成功
|
|
127
|
+
* @returns {string} data - 删除成功的数据 跟list返回字段一致
|
|
128
|
+
*/
|
|
129
|
+
export function deleteOne(id) {
|
|
130
|
+
return requestShow({
|
|
131
|
+
url: `/devices/${id}`,
|
|
132
|
+
method: 'delete'
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 批量删除设备
|
|
138
|
+
* @param {Array} ids - 删除的设备ids。
|
|
139
|
+
* @returns {number} code - 返回码,0表示成功
|
|
140
|
+
*/
|
|
141
|
+
export function deleteMany(ids) {
|
|
142
|
+
return requestShow({
|
|
143
|
+
url: '/devices',
|
|
144
|
+
method: 'delete',
|
|
145
|
+
data: ids // delete传递主体要包含在data里
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export default {
|
|
150
|
+
list,
|
|
151
|
+
create,
|
|
152
|
+
updateOne,
|
|
153
|
+
deleteOne,
|
|
154
|
+
deleteMany
|
|
155
|
+
}
|
|
156
|
+
|