index.ts
1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { DeviceProfileModel } from '../../device/model/deviceModel';
import { HistoryData } from './model';
import { defHttp } from '/@/utils/http/axios';
import { isString } from '/@/utils/is';
import { OrderByEnum } from '/@/views/device/localtion/cpns/TimePeriodForm/config';
// 获取设备配置
export const getDeviceProfile = (deviceType?: string) => {
return defHttp.get<DeviceProfileModel[]>({
url: '/device_profile/me/list',
params: { deviceType: isString(deviceType) ? deviceType : undefined },
});
};
// 获取历史数据
export const getDeviceHistoryInfo = (params: Recordable, orderBy = OrderByEnum.DESC) => {
return defHttp.get<HistoryData>(
{
url: `/plugins/telemetry/DEVICE/${params.entityId}/values/timeseries`,
params: { orderBy, ...params, entityId: null },
},
{
joinPrefix: false,
}
);
};
// 获取设备数据的keys
export const getDeviceDataKeys = (id: string) => {
return defHttp.get<string[]>(
{
url: `/plugins/telemetry/DEVICE/${id}/keys/timeseries`,
},
{
joinPrefix: false,
}
);
};
// 获取设备状态,在线 or 离线时间
export const getDeviceActiveTime = (entityId: string) => {
return defHttp.get(
{
url: `/plugins/telemetry/DEVICE/${entityId}/values/attributes?keys=active`,
},
{
joinPrefix: false,
}
);
};
// 获取设备属性
export const getDeviceAttribute = (entityId: string) => {
return defHttp.get(
{
url: `/plugins/telemetry/DEVICE/${entityId}/values/attributes?keys`,
},
{
joinPrefix: false,
}
);
};