130 lines
4.1 KiB
TypeScript
130 lines
4.1 KiB
TypeScript
import request from '@/config/axios'
|
|
|
|
// 设备 VO
|
|
export interface DeviceVO {
|
|
id: number // 主键ID
|
|
devicename: string // 设备名称
|
|
devicecode: string // 设备ID/编号
|
|
devicetype: string // 设备类型
|
|
location: string // 设备位置
|
|
devicestatus: number // 设备状态(0:待激活 1 在线 2 离线 ,3 禁用 )
|
|
orgid: number // 机构ID
|
|
orgname: string // 机构名称
|
|
description: string // 设备描述
|
|
createtime: string // 创建时间
|
|
updatetime: string // 更新时间
|
|
createby: string // 创建人
|
|
updateby: string // 更新人
|
|
onlinetime: string // 最近上线时间
|
|
restart: number // 是否重启
|
|
vipstarttime: string // 会员开始时间
|
|
vipendtime: string // 会员结束时间
|
|
isvip: number // 是否会员
|
|
}
|
|
|
|
// 设备分布地图数据 VO
|
|
export interface DeviceMapVO {
|
|
totalCount: number // 总设备数
|
|
onlineCount: number // 在线设备数
|
|
offlineCount: number // 离线设备数
|
|
alertTotal: number // 预警总数
|
|
alertUnhandled: number // 未处理预警数
|
|
mapData: Array<{
|
|
name: string // 省份名称
|
|
value: number // 设备数量
|
|
}>
|
|
scatterData: Array<{
|
|
name: string // 省份名称
|
|
value: [number, number, number] // [经度, 纬度, 设备数量]
|
|
count: number // 设备数量
|
|
}>
|
|
}
|
|
|
|
// 设备统计数据 VO
|
|
export interface DeviceStatisticsVO {
|
|
totalCount: number // 总设备数
|
|
onlineCount: number // 在线设备数
|
|
offlineCount: number // 离线设备数
|
|
}
|
|
|
|
// 设备 API
|
|
export const DeviceApi = {
|
|
// 查询设备分页
|
|
getDevicePage: async (params: any) => {
|
|
return await request.get({ url: `/system/device/page`, params })
|
|
},
|
|
|
|
// 查询设备详情
|
|
getDevice: async (id: number) => {
|
|
return await request.get({ url: `/system/device/get?id=` + id })
|
|
},
|
|
// 查询设备详情
|
|
getDeviceId: async (devicecode: string) => {
|
|
return await request.get({ url: `/system/device/getDeviceId?devicecode=` + devicecode })
|
|
},
|
|
|
|
// 新增设备
|
|
createDevice: async (data: DeviceVO) => {
|
|
return await request.post({ url: `/system/device/create`, data })
|
|
},
|
|
|
|
// 修改设备
|
|
updateDevice: async (data: DeviceVO) => {
|
|
return await request.put({ url: `/system/device/update`, data })
|
|
},
|
|
|
|
// 删除设备
|
|
deleteDevice: async (id: number) => {
|
|
return await request.delete({ url: `/system/device/delete?id=` + id })
|
|
},
|
|
// 删除设备
|
|
deleteDeviceCode: async (devicecode: number) => {
|
|
return await request.delete({ url: `/system/device/deletecode?devicecode=` + devicecode })
|
|
},
|
|
|
|
// 导出设备 Excel
|
|
exportDevice: async (params) => {
|
|
return await request.download({ url: `/system/device/export-excel`, params })
|
|
},
|
|
|
|
//根据设备ID更新设备状态
|
|
updateDeviceStatus: async (devicecode: number, devicestatus: number) => {
|
|
return await request.put({ url: `/system/device/updateDeviceStatus?devicecode=` + devicecode + `&devicestatus=` + devicestatus })
|
|
},
|
|
|
|
//查询没有绑定过的设备
|
|
getDeviceNotBind: async (params: any) => {
|
|
return await request.get({ url: `/system/device/getDeviceNotBind`, params })
|
|
},
|
|
// 获取设备分布地图数据
|
|
getDeviceMapData: async (orgid: number) => {
|
|
return await request.get<DeviceMapVO>({
|
|
url: `/system/device/map-data`,
|
|
params: { orgid }
|
|
})
|
|
},
|
|
|
|
// 获取设备统计数据
|
|
getDeviceStatistics: async (orgid: number) => {
|
|
return await request.get<DeviceStatisticsVO>({
|
|
url: `/system/device/getDeviceidCount`,
|
|
params: { orgid }
|
|
})
|
|
},
|
|
|
|
//锁定和解锁设备
|
|
lockDevice: async (devicecode: number, devicestatus: number) => {
|
|
return await request.put({ url: `/system/device/lockDevice?devicecode=` + devicecode + `&devicestatus=` + devicestatus })
|
|
},
|
|
|
|
//重启设备
|
|
restartDevice: async (devicecode: number) => {
|
|
return await request.put({ url: `/system/device/restartDevice?devicecode=` + devicecode })
|
|
},
|
|
|
|
// 更新设备会员信息(开通/续费)
|
|
updateDeviceVip: async (data: { devicecode: string ; orgid: number; vipstarttime: number | string; vipendtime: number | string; isvip: number }) => {
|
|
return await request.put({ url: `/system/device/updateVip`, data })
|
|
}
|
|
}
|