Vue3 + Element Plus版本iot前端迁移到vben版本
This commit is contained in:
95
apps/web-antd/src/api/iot/alert/config/index.ts
Normal file
95
apps/web-antd/src/api/iot/alert/config/index.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace AlertConfigApi {
|
||||
/** IoT 告警配置 VO */
|
||||
export interface AlertConfig {
|
||||
id?: number;
|
||||
name: string;
|
||||
description?: string;
|
||||
level?: number;
|
||||
status?: number;
|
||||
sceneRuleIds?: number[];
|
||||
receiveUserIds?: number[];
|
||||
receiveUserNames?: string;
|
||||
receiveTypes?: number[];
|
||||
createTime?: Date;
|
||||
updateTime?: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** IoT 告警配置 */
|
||||
export interface AlertConfig {
|
||||
id?: number;
|
||||
name?: string;
|
||||
description?: string;
|
||||
level?: number;
|
||||
status?: number;
|
||||
sceneRuleIds?: number[];
|
||||
receiveUserIds?: number[];
|
||||
receiveUserNames?: string;
|
||||
receiveTypes?: number[];
|
||||
createTime?: Date;
|
||||
updateTime?: Date;
|
||||
}
|
||||
|
||||
/** 查询告警配置分页 */
|
||||
export function getAlertConfigPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<AlertConfigApi.AlertConfig>>(
|
||||
'/iot/alert-config/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询告警配置详情 */
|
||||
export function getAlertConfig(id: number) {
|
||||
return requestClient.get<AlertConfigApi.AlertConfig>(
|
||||
`/iot/alert-config/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询所有告警配置列表 */
|
||||
export function getAlertConfigList() {
|
||||
return requestClient.get<AlertConfigApi.AlertConfig[]>('/iot/alert-config/list');
|
||||
}
|
||||
|
||||
/** 新增告警配置 */
|
||||
export function createAlertConfig(data: AlertConfig) {
|
||||
return requestClient.post('/iot/alert-config/create', data);
|
||||
}
|
||||
|
||||
/** 修改告警配置 */
|
||||
export function updateAlertConfig(data: AlertConfig) {
|
||||
return requestClient.put('/iot/alert-config/update', data);
|
||||
}
|
||||
|
||||
/** 删除告警配置 */
|
||||
export function deleteAlertConfig(id: number) {
|
||||
return requestClient.delete(`/iot/alert-config/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除告警配置 */
|
||||
export function deleteAlertConfigList(ids: number[]) {
|
||||
return requestClient.delete('/iot/alert-config/delete-list', {
|
||||
params: { ids: ids.join(',') },
|
||||
});
|
||||
}
|
||||
|
||||
/** 启用/禁用告警配置 */
|
||||
export function toggleAlertConfig(id: number, enabled: boolean) {
|
||||
return requestClient.put(`/iot/alert-config/toggle`, {
|
||||
id,
|
||||
enabled,
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取告警配置简单列表 */
|
||||
export function getSimpleAlertConfigList() {
|
||||
return requestClient.get<AlertConfigApi.AlertConfig[]>(
|
||||
'/iot/alert-config/simple-list',
|
||||
);
|
||||
}
|
||||
|
||||
export { AlertConfigApi };
|
||||
|
||||
85
apps/web-antd/src/api/iot/alert/record/index.ts
Normal file
85
apps/web-antd/src/api/iot/alert/record/index.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace AlertRecordApi {
|
||||
/** IoT 告警记录 VO */
|
||||
export interface AlertRecord {
|
||||
id?: number;
|
||||
configId?: number;
|
||||
configName?: string;
|
||||
configLevel?: number;
|
||||
deviceId?: number;
|
||||
deviceName?: string;
|
||||
productId?: number;
|
||||
productName?: string;
|
||||
deviceMessage?: string;
|
||||
processStatus?: boolean;
|
||||
processRemark?: string;
|
||||
processTime?: Date;
|
||||
createTime?: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** IoT 告警记录 */
|
||||
export interface AlertRecord {
|
||||
id?: number;
|
||||
configId?: number;
|
||||
configName?: string;
|
||||
configLevel?: number;
|
||||
deviceId?: number;
|
||||
deviceName?: string;
|
||||
productId?: number;
|
||||
productName?: string;
|
||||
deviceMessage?: string;
|
||||
processStatus?: boolean;
|
||||
processRemark?: string;
|
||||
processTime?: Date;
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** 查询告警记录分页 */
|
||||
export function getAlertRecordPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<AlertRecordApi.AlertRecord>>(
|
||||
'/iot/alert-record/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询告警记录详情 */
|
||||
export function getAlertRecord(id: number) {
|
||||
return requestClient.get<AlertRecordApi.AlertRecord>(
|
||||
`/iot/alert-record/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 处理告警记录 */
|
||||
export function processAlertRecord(id: number, remark?: string) {
|
||||
return requestClient.put('/iot/alert-record/process', {
|
||||
id,
|
||||
remark,
|
||||
});
|
||||
}
|
||||
|
||||
/** 批量处理告警记录 */
|
||||
export function batchProcessAlertRecord(ids: number[], remark?: string) {
|
||||
return requestClient.put('/iot/alert-record/batch-process', {
|
||||
ids,
|
||||
remark,
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除告警记录 */
|
||||
export function deleteAlertRecord(id: number) {
|
||||
return requestClient.delete(`/iot/alert-record/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除告警记录 */
|
||||
export function deleteAlertRecordList(ids: number[]) {
|
||||
return requestClient.delete('/iot/alert-record/delete-list', {
|
||||
params: { ids: ids.join(',') },
|
||||
});
|
||||
}
|
||||
|
||||
export { AlertRecordApi };
|
||||
|
||||
224
apps/web-antd/src/api/iot/device/device/index.ts
Normal file
224
apps/web-antd/src/api/iot/device/device/index.ts
Normal file
@@ -0,0 +1,224 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace IotDeviceApi {
|
||||
/** IoT 设备 VO */
|
||||
export interface Device {
|
||||
id?: number; // 设备 ID,主键,自增
|
||||
deviceName: string; // 设备名称
|
||||
productId: number; // 产品编号
|
||||
productKey?: string; // 产品标识
|
||||
deviceType?: number; // 设备类型
|
||||
nickname?: string; // 设备备注名称
|
||||
gatewayId?: number; // 网关设备 ID
|
||||
state?: number; // 设备状态
|
||||
status?: number; // 设备状态(兼容字段)
|
||||
onlineTime?: Date; // 最后上线时间
|
||||
offlineTime?: Date; // 最后离线时间
|
||||
activeTime?: Date; // 设备激活时间
|
||||
createTime?: Date; // 创建时间
|
||||
ip?: string; // 设备的 IP 地址
|
||||
firmwareVersion?: string; // 设备的固件版本
|
||||
deviceSecret?: string; // 设备密钥,用于设备认证,需安全存储
|
||||
mqttClientId?: string; // MQTT 客户端 ID
|
||||
mqttUsername?: string; // MQTT 用户名
|
||||
mqttPassword?: string; // MQTT 密码
|
||||
authType?: string; // 认证类型
|
||||
locationType?: number; // 定位类型
|
||||
latitude?: number; // 设备位置的纬度
|
||||
longitude?: number; // 设备位置的经度
|
||||
areaId?: number; // 地区编码
|
||||
address?: string; // 设备详细地址
|
||||
serialNumber?: string; // 设备序列号
|
||||
config?: string; // 设备配置
|
||||
groupIds?: number[]; // 添加分组 ID
|
||||
picUrl?: string; // 设备图片
|
||||
location?: string; // 位置信息(格式:经度,纬度)
|
||||
}
|
||||
|
||||
/** IoT 设备属性详细 VO */
|
||||
export interface DevicePropertyDetail {
|
||||
identifier: string; // 属性标识符
|
||||
value: string; // 最新值
|
||||
updateTime: Date; // 更新时间
|
||||
name: string; // 属性名称
|
||||
dataType: string; // 数据类型
|
||||
dataSpecs: any; // 数据定义
|
||||
dataSpecsList: any[]; // 数据定义列表
|
||||
}
|
||||
|
||||
/** IoT 设备属性 VO */
|
||||
export interface DeviceProperty {
|
||||
identifier: string; // 属性标识符
|
||||
value: string; // 最新值
|
||||
updateTime: Date; // 更新时间
|
||||
}
|
||||
|
||||
/** 设备认证参数 VO */
|
||||
export interface DeviceAuthInfo {
|
||||
clientId: string; // 客户端 ID
|
||||
username: string; // 用户名
|
||||
password: string; // 密码
|
||||
}
|
||||
|
||||
/** IoT 设备发送消息 Request VO */
|
||||
export interface DeviceMessageSendReq {
|
||||
deviceId: number; // 设备编号
|
||||
method: string; // 请求方法
|
||||
params?: any; // 请求参数
|
||||
}
|
||||
|
||||
/** 设备分组更新请求 */
|
||||
export interface DeviceGroupUpdateReq {
|
||||
ids: number[]; // 设备 ID 列表
|
||||
groupIds: number[]; // 分组 ID 列表
|
||||
}
|
||||
}
|
||||
|
||||
/** IoT 设备状态枚举 */
|
||||
export enum DeviceStateEnum {
|
||||
INACTIVE = 0, // 未激活
|
||||
ONLINE = 1, // 在线
|
||||
OFFLINE = 2, // 离线
|
||||
}
|
||||
|
||||
/** 查询设备分页 */
|
||||
export function getDevicePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<IotDeviceApi.Device>>(
|
||||
'/iot/device/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询设备详情 */
|
||||
export function getDevice(id: number) {
|
||||
return requestClient.get<IotDeviceApi.Device>(`/iot/device/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 新增设备 */
|
||||
export function createDevice(data: IotDeviceApi.Device) {
|
||||
return requestClient.post('/iot/device/create', data);
|
||||
}
|
||||
|
||||
/** 修改设备 */
|
||||
export function updateDevice(data: IotDeviceApi.Device) {
|
||||
return requestClient.put('/iot/device/update', data);
|
||||
}
|
||||
|
||||
/** 修改设备分组 */
|
||||
export function updateDeviceGroup(data: IotDeviceApi.DeviceGroupUpdateReq) {
|
||||
return requestClient.put('/iot/device/update-group', data);
|
||||
}
|
||||
|
||||
/** 删除单个设备 */
|
||||
export function deleteDevice(id: number) {
|
||||
return requestClient.delete(`/iot/device/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 删除多个设备 */
|
||||
export function deleteDeviceList(ids: number[]) {
|
||||
return requestClient.delete('/iot/device/delete-list', {
|
||||
params: { ids: ids.join(',') },
|
||||
});
|
||||
}
|
||||
|
||||
/** 导出设备 */
|
||||
export function exportDeviceExcel(params: any) {
|
||||
return requestClient.download('/iot/device/export-excel', { params });
|
||||
}
|
||||
|
||||
/** 获取设备数量 */
|
||||
export function getDeviceCount(productId: number) {
|
||||
return requestClient.get<number>(`/iot/device/count?productId=${productId}`);
|
||||
}
|
||||
|
||||
/** 获取设备的精简信息列表 */
|
||||
export function getSimpleDeviceList(deviceType?: number, productId?: number) {
|
||||
return requestClient.get<IotDeviceApi.Device[]>('/iot/device/simple-list', {
|
||||
params: { deviceType, productId },
|
||||
});
|
||||
}
|
||||
|
||||
/** 根据产品编号,获取设备的精简信息列表 */
|
||||
export function getDeviceListByProductId(productId: number) {
|
||||
return requestClient.get<IotDeviceApi.Device[]>('/iot/device/simple-list', {
|
||||
params: { productId },
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取导入模板 */
|
||||
export function importDeviceTemplate() {
|
||||
return requestClient.download('/iot/device/get-import-template');
|
||||
}
|
||||
|
||||
/** 获取设备属性最新数据 */
|
||||
export function getLatestDeviceProperties(params: any) {
|
||||
return requestClient.get<IotDeviceApi.DevicePropertyDetail[]>(
|
||||
'/iot/device/property/get-latest',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取设备属性历史数据 */
|
||||
export function getHistoryDevicePropertyList(params: any) {
|
||||
return requestClient.get<PageResult<IotDeviceApi.DeviceProperty>>(
|
||||
'/iot/device/property/history-list',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取设备认证信息 */
|
||||
export function getDeviceAuthInfo(id: number) {
|
||||
return requestClient.get<IotDeviceApi.DeviceAuthInfo>(
|
||||
'/iot/device/get-auth-info',
|
||||
{ params: { id } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询设备消息分页 */
|
||||
export function getDeviceMessagePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<any>>('/iot/device/message/page', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 查询设备消息配对分页 */
|
||||
export function getDeviceMessagePairPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<any>>('/iot/device/message/pair-page', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
/** 发送设备消息 */
|
||||
export function sendDeviceMessage(params: IotDeviceApi.DeviceMessageSendReq) {
|
||||
return requestClient.post('/iot/device/message/send', params);
|
||||
}
|
||||
|
||||
// Export aliases for compatibility
|
||||
export const DeviceApi = {
|
||||
getDevicePage,
|
||||
getDevice,
|
||||
createDevice,
|
||||
updateDevice,
|
||||
updateDeviceGroup,
|
||||
deleteDevice,
|
||||
deleteDeviceList,
|
||||
exportDeviceExcel,
|
||||
getDeviceCount,
|
||||
getSimpleDeviceList,
|
||||
getDeviceListByProductId,
|
||||
importDeviceTemplate,
|
||||
getLatestDeviceProperties,
|
||||
getHistoryDevicePropertyList,
|
||||
getDeviceAuthInfo,
|
||||
getDeviceMessagePage,
|
||||
getDeviceMessagePairPage,
|
||||
sendDeviceMessage,
|
||||
};
|
||||
|
||||
export type DeviceVO = IotDeviceApi.Device;
|
||||
export type IotDeviceAuthInfoVO = IotDeviceApi.DeviceAuthInfo;
|
||||
export type IotDevicePropertyDetailRespVO = IotDeviceApi.DevicePropertyDetail;
|
||||
export type IotDevicePropertyRespVO = IotDeviceApi.DeviceProperty;
|
||||
|
||||
52
apps/web-antd/src/api/iot/device/group/index.ts
Normal file
52
apps/web-antd/src/api/iot/device/group/index.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace IotDeviceGroupApi {
|
||||
/** IoT 设备分组 VO */
|
||||
export interface DeviceGroup {
|
||||
id?: number; // 分组 ID
|
||||
name: string; // 分组名字
|
||||
status?: number; // 分组状态
|
||||
description?: string; // 分组描述
|
||||
deviceCount?: number; // 设备数量
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询设备分组分页 */
|
||||
export function getDeviceGroupPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<IotDeviceGroupApi.DeviceGroup>>(
|
||||
'/iot/device-group/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询设备分组详情 */
|
||||
export function getDeviceGroup(id: number) {
|
||||
return requestClient.get<IotDeviceGroupApi.DeviceGroup>(
|
||||
`/iot/device-group/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增设备分组 */
|
||||
export function createDeviceGroup(data: IotDeviceGroupApi.DeviceGroup) {
|
||||
return requestClient.post('/iot/device-group/create', data);
|
||||
}
|
||||
|
||||
/** 修改设备分组 */
|
||||
export function updateDeviceGroup(data: IotDeviceGroupApi.DeviceGroup) {
|
||||
return requestClient.put('/iot/device-group/update', data);
|
||||
}
|
||||
|
||||
/** 删除设备分组 */
|
||||
export function deleteDeviceGroup(id: number) {
|
||||
return requestClient.delete(`/iot/device-group/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 获取设备分组的精简信息列表 */
|
||||
export function getSimpleDeviceGroupList() {
|
||||
return requestClient.get<IotDeviceGroupApi.DeviceGroup[]>(
|
||||
'/iot/device-group/simple-list',
|
||||
);
|
||||
}
|
||||
|
||||
90
apps/web-antd/src/api/iot/ota/firmware/index.ts
Normal file
90
apps/web-antd/src/api/iot/ota/firmware/index.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace IoTOtaFirmwareApi {
|
||||
/** IoT OTA 固件 VO */
|
||||
export interface Firmware {
|
||||
id?: number;
|
||||
name: string;
|
||||
version: string;
|
||||
productId: number;
|
||||
productName?: string;
|
||||
description?: string;
|
||||
fileUrl?: string;
|
||||
fileMd5?: string;
|
||||
fileSize?: number;
|
||||
status?: number;
|
||||
createTime?: Date;
|
||||
updateTime?: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** IoT OTA 固件 */
|
||||
export interface IoTOtaFirmware {
|
||||
id?: number;
|
||||
name?: string;
|
||||
version?: string;
|
||||
productId?: number;
|
||||
productName?: string;
|
||||
description?: string;
|
||||
fileUrl?: string;
|
||||
fileMd5?: string;
|
||||
fileSize?: number;
|
||||
status?: number;
|
||||
createTime?: Date;
|
||||
updateTime?: Date;
|
||||
}
|
||||
|
||||
/** 查询 OTA 固件分页 */
|
||||
export function getOtaFirmwarePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<IoTOtaFirmwareApi.Firmware>>(
|
||||
'/iot/ota-firmware/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询 OTA 固件详情 */
|
||||
export function getOtaFirmware(id: number) {
|
||||
return requestClient.get<IoTOtaFirmwareApi.Firmware>(
|
||||
`/iot/ota-firmware/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增 OTA 固件 */
|
||||
export function createOtaFirmware(data: IoTOtaFirmware) {
|
||||
return requestClient.post('/iot/ota-firmware/create', data);
|
||||
}
|
||||
|
||||
/** 修改 OTA 固件 */
|
||||
export function updateOtaFirmware(data: IoTOtaFirmware) {
|
||||
return requestClient.put('/iot/ota-firmware/update', data);
|
||||
}
|
||||
|
||||
/** 删除 OTA 固件 */
|
||||
export function deleteOtaFirmware(id: number) {
|
||||
return requestClient.delete(`/iot/ota-firmware/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除 OTA 固件 */
|
||||
export function deleteOtaFirmwareList(ids: number[]) {
|
||||
return requestClient.delete('/iot/ota-firmware/delete-list', {
|
||||
params: { ids: ids.join(',') },
|
||||
});
|
||||
}
|
||||
|
||||
/** 更新 OTA 固件状态 */
|
||||
export function updateOtaFirmwareStatus(id: number, status: number) {
|
||||
return requestClient.put(`/iot/ota-firmware/update-status`, {
|
||||
id,
|
||||
status,
|
||||
});
|
||||
}
|
||||
|
||||
/** 根据产品 ID 查询固件列表 */
|
||||
export function getOtaFirmwareListByProductId(productId: number) {
|
||||
return requestClient.get<IoTOtaFirmwareApi.Firmware[]>(
|
||||
'/iot/ota-firmware/list-by-product-id',
|
||||
{ params: { productId } },
|
||||
);
|
||||
}
|
||||
101
apps/web-antd/src/api/iot/ota/task/index.ts
Normal file
101
apps/web-antd/src/api/iot/ota/task/index.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace IoTOtaTaskApi {
|
||||
/** IoT OTA 升级任务 VO */
|
||||
export interface Task {
|
||||
id?: number;
|
||||
name: string;
|
||||
description?: string;
|
||||
firmwareId: number;
|
||||
firmwareName?: string;
|
||||
productId?: number;
|
||||
productName?: string;
|
||||
deviceScope?: number;
|
||||
deviceIds?: number[];
|
||||
status?: number;
|
||||
successCount?: number;
|
||||
failureCount?: number;
|
||||
pendingCount?: number;
|
||||
createTime?: Date;
|
||||
updateTime?: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** IoT OTA 升级任务 */
|
||||
export interface OtaTask {
|
||||
id?: number;
|
||||
name?: string;
|
||||
description?: string;
|
||||
firmwareId?: number;
|
||||
firmwareName?: string;
|
||||
productId?: number;
|
||||
productName?: string;
|
||||
deviceScope?: number;
|
||||
deviceIds?: number[];
|
||||
status?: number;
|
||||
successCount?: number;
|
||||
failureCount?: number;
|
||||
pendingCount?: number;
|
||||
createTime?: Date;
|
||||
updateTime?: Date;
|
||||
}
|
||||
|
||||
/** 查询 OTA 升级任务分页 */
|
||||
export function getOtaTaskPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<IoTOtaTaskApi.Task>>(
|
||||
'/iot/ota-task/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询 OTA 升级任务详情 */
|
||||
export function getOtaTask(id: number) {
|
||||
return requestClient.get<IoTOtaTaskApi.Task>(`/iot/ota-task/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 新增 OTA 升级任务 */
|
||||
export function createOtaTask(data: OtaTask) {
|
||||
return requestClient.post('/iot/ota-task/create', data);
|
||||
}
|
||||
|
||||
/** 修改 OTA 升级任务 */
|
||||
export function updateOtaTask(data: OtaTask) {
|
||||
return requestClient.put('/iot/ota-task/update', data);
|
||||
}
|
||||
|
||||
/** 删除 OTA 升级任务 */
|
||||
export function deleteOtaTask(id: number) {
|
||||
return requestClient.delete(`/iot/ota-task/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除 OTA 升级任务 */
|
||||
export function deleteOtaTaskList(ids: number[]) {
|
||||
return requestClient.delete('/iot/ota-task/delete-list', {
|
||||
params: { ids: ids.join(',') },
|
||||
});
|
||||
}
|
||||
|
||||
/** 取消 OTA 升级任务 */
|
||||
export function cancelOtaTask(id: number) {
|
||||
return requestClient.put(`/iot/ota-task/cancel?id=${id}`);
|
||||
}
|
||||
|
||||
/** 启动 OTA 升级任务 */
|
||||
export function startOtaTask(id: number) {
|
||||
return requestClient.put(`/iot/ota-task/start?id=${id}`);
|
||||
}
|
||||
|
||||
/** 暂停 OTA 升级任务 */
|
||||
export function pauseOtaTask(id: number) {
|
||||
return requestClient.put(`/iot/ota-task/pause?id=${id}`);
|
||||
}
|
||||
|
||||
/** 恢复 OTA 升级任务 */
|
||||
export function resumeOtaTask(id: number) {
|
||||
return requestClient.put(`/iot/ota-task/resume?id=${id}`);
|
||||
}
|
||||
|
||||
export { IoTOtaTaskApi };
|
||||
|
||||
104
apps/web-antd/src/api/iot/ota/task/record/index.ts
Normal file
104
apps/web-antd/src/api/iot/ota/task/record/index.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace IoTOtaTaskRecordApi {
|
||||
/** IoT OTA 升级任务记录 VO */
|
||||
export interface TaskRecord {
|
||||
id?: number;
|
||||
taskId: number;
|
||||
taskName?: string;
|
||||
deviceId: number;
|
||||
deviceName?: string;
|
||||
firmwareId?: number;
|
||||
firmwareName?: string;
|
||||
firmwareVersion?: string;
|
||||
status?: number;
|
||||
progress?: number;
|
||||
errorMessage?: string;
|
||||
startTime?: Date;
|
||||
endTime?: Date;
|
||||
createTime?: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** IoT OTA 升级任务记录 */
|
||||
export interface OtaTaskRecord {
|
||||
id?: number;
|
||||
taskId?: number;
|
||||
taskName?: string;
|
||||
deviceId?: number;
|
||||
deviceName?: string;
|
||||
firmwareId?: number;
|
||||
firmwareName?: string;
|
||||
firmwareVersion?: string;
|
||||
status?: number;
|
||||
progress?: number;
|
||||
errorMessage?: string;
|
||||
startTime?: Date;
|
||||
endTime?: Date;
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** 查询 OTA 升级任务记录分页 */
|
||||
export function getOtaTaskRecordPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<IoTOtaTaskRecordApi.TaskRecord>>(
|
||||
'/iot/ota-task-record/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询 OTA 升级任务记录详情 */
|
||||
export function getOtaTaskRecord(id: number) {
|
||||
return requestClient.get<IoTOtaTaskRecordApi.TaskRecord>(
|
||||
`/iot/ota-task-record/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 根据任务 ID 查询记录列表 */
|
||||
export function getOtaTaskRecordListByTaskId(taskId: number) {
|
||||
return requestClient.get<IoTOtaTaskRecordApi.TaskRecord[]>(
|
||||
'/iot/ota-task-record/list-by-task-id',
|
||||
{ params: { taskId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 根据设备 ID 查询记录列表 */
|
||||
export function getOtaTaskRecordListByDeviceId(deviceId: number) {
|
||||
return requestClient.get<IoTOtaTaskRecordApi.TaskRecord[]>(
|
||||
'/iot/ota-task-record/list-by-device-id',
|
||||
{ params: { deviceId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 根据固件 ID 查询记录列表 */
|
||||
export function getOtaTaskRecordListByFirmwareId(firmwareId: number) {
|
||||
return requestClient.get<IoTOtaTaskRecordApi.TaskRecord[]>(
|
||||
'/iot/ota-task-record/list-by-firmware-id',
|
||||
{ params: { firmwareId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 重试升级任务记录 */
|
||||
export function retryOtaTaskRecord(id: number) {
|
||||
return requestClient.put(`/iot/ota-task-record/retry?id=${id}`);
|
||||
}
|
||||
|
||||
/** 取消升级任务记录 */
|
||||
export function cancelOtaTaskRecord(id: number) {
|
||||
return requestClient.put(`/iot/ota-task-record/cancel?id=${id}`);
|
||||
}
|
||||
|
||||
/** 获取升级任务记录状态统计 */
|
||||
export function getOtaTaskRecordStatusStatistics(
|
||||
firmwareId?: number,
|
||||
taskId?: number,
|
||||
) {
|
||||
return requestClient.get<Record<string, number>>(
|
||||
'/iot/ota-task-record/status-statistics',
|
||||
{ params: { firmwareId, taskId } },
|
||||
);
|
||||
}
|
||||
|
||||
export { IoTOtaTaskRecordApi };
|
||||
|
||||
58
apps/web-antd/src/api/iot/product/category/index.ts
Normal file
58
apps/web-antd/src/api/iot/product/category/index.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace IotProductCategoryApi {
|
||||
/** IoT 產品分類 VO */
|
||||
export interface ProductCategory {
|
||||
id?: number; // 分類 ID
|
||||
name: string; // 分類名稱
|
||||
parentId?: number; // 父级分類 ID
|
||||
sort?: number; // 分類排序
|
||||
status?: number; // 分類狀態
|
||||
description?: string; // 分類描述
|
||||
createTime?: string; // 創建時間
|
||||
}
|
||||
}
|
||||
|
||||
/** 查詢產品分類分頁 */
|
||||
export function getProductCategoryPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<IotProductCategoryApi.ProductCategory>>(
|
||||
'/iot/product-category/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查詢產品分類詳情 */
|
||||
export function getProductCategory(id: number) {
|
||||
return requestClient.get<IotProductCategoryApi.ProductCategory>(
|
||||
`/iot/product-category/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增產品分類 */
|
||||
export function createProductCategory(
|
||||
data: IotProductCategoryApi.ProductCategory,
|
||||
) {
|
||||
return requestClient.post('/iot/product-category/create', data);
|
||||
}
|
||||
|
||||
/** 修改產品分類 */
|
||||
export function updateProductCategory(
|
||||
data: IotProductCategoryApi.ProductCategory,
|
||||
) {
|
||||
return requestClient.put('/iot/product-category/update', data);
|
||||
}
|
||||
|
||||
/** 刪除產品分類 */
|
||||
export function deleteProductCategory(id: number) {
|
||||
return requestClient.delete(`/iot/product-category/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 獲取產品分類精簡列表 */
|
||||
export function getSimpleProductCategoryList() {
|
||||
return requestClient.get<IotProductCategoryApi.ProductCategory[]>(
|
||||
'/iot/product-category/simple-list',
|
||||
);
|
||||
}
|
||||
|
||||
114
apps/web-antd/src/api/iot/product/product/index.ts
Normal file
114
apps/web-antd/src/api/iot/product/product/index.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace IotProductApi {
|
||||
/** IoT 产品 VO */
|
||||
export interface Product {
|
||||
id?: number; // 产品编号
|
||||
name: string; // 产品名称
|
||||
productKey?: string; // 产品标识
|
||||
protocolId?: number; // 协议编号
|
||||
protocolType?: number; // 接入协议类型
|
||||
categoryId?: number; // 产品所属品类标识符
|
||||
categoryName?: string; // 产品所属品类名称
|
||||
icon?: string; // 产品图标
|
||||
picUrl?: string; // 产品图片
|
||||
description?: string; // 产品描述
|
||||
status?: number; // 产品状态
|
||||
deviceType?: number; // 设备类型
|
||||
locationType?: number; // 定位类型
|
||||
netType?: number; // 联网方式
|
||||
codecType?: string; // 数据格式(编解码器类型)
|
||||
dataFormat?: number; // 数据格式
|
||||
validateType?: number; // 认证方式
|
||||
deviceCount?: number; // 设备数量
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** IOT 产品设备类型枚举类 */
|
||||
export enum DeviceTypeEnum {
|
||||
DEVICE = 0, // 直连设备
|
||||
GATEWAY_SUB = 1, // 网关子设备
|
||||
GATEWAY = 2, // 网关设备
|
||||
}
|
||||
|
||||
/** IOT 产品定位类型枚举类 */
|
||||
export enum LocationTypeEnum {
|
||||
IP = 1, // IP 定位
|
||||
MODULE = 2, // 设备定位
|
||||
MANUAL = 3, // 手动定位
|
||||
}
|
||||
|
||||
/** IOT 数据格式(编解码器类型)枚举类 */
|
||||
export enum CodecTypeEnum {
|
||||
ALINK = 'Alink', // 阿里云 Alink 协议
|
||||
}
|
||||
|
||||
/** 查询产品分页 */
|
||||
export function getProductPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<IotProductApi.Product>>(
|
||||
'/iot/product/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询产品详情 */
|
||||
export function getProduct(id: number) {
|
||||
return requestClient.get<IotProductApi.Product>(`/iot/product/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 新增产品 */
|
||||
export function createProduct(data: IotProductApi.Product) {
|
||||
return requestClient.post('/iot/product/create', data);
|
||||
}
|
||||
|
||||
/** 修改产品 */
|
||||
export function updateProduct(data: IotProductApi.Product) {
|
||||
return requestClient.put('/iot/product/update', data);
|
||||
}
|
||||
|
||||
/** 删除产品 */
|
||||
export function deleteProduct(id: number) {
|
||||
return requestClient.delete(`/iot/product/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 导出产品 Excel */
|
||||
export function exportProduct(params: any) {
|
||||
return requestClient.download('/iot/product/export-excel', { params });
|
||||
}
|
||||
|
||||
/** 更新产品状态 */
|
||||
export function updateProductStatus(id: number, status: number) {
|
||||
return requestClient.put(
|
||||
`/iot/product/update-status?id=${id}&status=${status}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询产品(精简)列表 */
|
||||
export function getSimpleProductList() {
|
||||
return requestClient.get<IotProductApi.Product[]>('/iot/product/simple-list');
|
||||
}
|
||||
|
||||
/** 根据 ProductKey 获取产品信息 */
|
||||
export function getProductByKey(productKey: string) {
|
||||
return requestClient.get<IotProductApi.Product>('/iot/product/get-by-key', {
|
||||
params: { productKey },
|
||||
});
|
||||
}
|
||||
|
||||
// Export aliases for compatibility
|
||||
export const ProductApi = {
|
||||
getProductPage,
|
||||
getProduct,
|
||||
createProduct,
|
||||
updateProduct,
|
||||
deleteProduct,
|
||||
exportProduct,
|
||||
updateProductStatus,
|
||||
getSimpleProductList,
|
||||
getProductByKey,
|
||||
};
|
||||
|
||||
export type ProductVO = IotProductApi.Product;
|
||||
84
apps/web-antd/src/api/iot/rule/data/rule/index.ts
Normal file
84
apps/web-antd/src/api/iot/rule/data/rule/index.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace DataRuleApi {
|
||||
/** IoT 数据流转规则 VO */
|
||||
export interface Rule {
|
||||
id?: number;
|
||||
name: string;
|
||||
description?: string;
|
||||
status?: number;
|
||||
productId?: number;
|
||||
productKey?: string;
|
||||
sourceConfigs?: SourceConfig[];
|
||||
sinkIds?: number[];
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** IoT 数据源配置 */
|
||||
export interface SourceConfig {
|
||||
productId?: number;
|
||||
productKey?: string;
|
||||
deviceId?: number;
|
||||
type?: string;
|
||||
topic?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/** IoT 数据流转规则 */
|
||||
export interface DataRule {
|
||||
id?: number;
|
||||
name?: string;
|
||||
description?: string;
|
||||
status?: number;
|
||||
productId?: number;
|
||||
productKey?: string;
|
||||
sourceConfigs?: any[];
|
||||
sinkIds?: number[];
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** 查询数据流转规则分页 */
|
||||
export function getDataRulePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<DataRuleApi.Rule>>(
|
||||
'/iot/data-rule/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询数据流转规则详情 */
|
||||
export function getDataRule(id: number) {
|
||||
return requestClient.get<DataRuleApi.Rule>(`/iot/data-rule/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 新增数据流转规则 */
|
||||
export function createDataRule(data: DataRule) {
|
||||
return requestClient.post('/iot/data-rule/create', data);
|
||||
}
|
||||
|
||||
/** 修改数据流转规则 */
|
||||
export function updateDataRule(data: DataRule) {
|
||||
return requestClient.put('/iot/data-rule/update', data);
|
||||
}
|
||||
|
||||
/** 删除数据流转规则 */
|
||||
export function deleteDataRule(id: number) {
|
||||
return requestClient.delete(`/iot/data-rule/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除数据流转规则 */
|
||||
export function deleteDataRuleList(ids: number[]) {
|
||||
return requestClient.delete('/iot/data-rule/delete-list', {
|
||||
params: { ids: ids.join(',') },
|
||||
});
|
||||
}
|
||||
|
||||
/** 更新数据流转规则状态 */
|
||||
export function updateDataRuleStatus(id: number, status: number) {
|
||||
return requestClient.put(`/iot/data-rule/update-status`, {
|
||||
id,
|
||||
status,
|
||||
});
|
||||
}
|
||||
|
||||
151
apps/web-antd/src/api/iot/rule/data/sink/index.ts
Normal file
151
apps/web-antd/src/api/iot/rule/data/sink/index.ts
Normal file
@@ -0,0 +1,151 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace DataSinkApi {
|
||||
/** IoT 数据流转目的 VO */
|
||||
export interface Sink {
|
||||
id?: number;
|
||||
name: string;
|
||||
description?: string;
|
||||
status?: number;
|
||||
type: string;
|
||||
config?: any;
|
||||
createTime?: Date;
|
||||
}
|
||||
}
|
||||
|
||||
/** IoT 数据流转目的 */
|
||||
export interface DataSinkVO {
|
||||
id?: number;
|
||||
name?: string;
|
||||
description?: string;
|
||||
status?: number;
|
||||
type?: string;
|
||||
config?: any;
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** IoT 数据目的类型枚举 */
|
||||
export enum IotDataSinkTypeEnum {
|
||||
HTTP = 'HTTP',
|
||||
MQTT = 'MQTT',
|
||||
KAFKA = 'KAFKA',
|
||||
RABBITMQ = 'RABBITMQ',
|
||||
ROCKETMQ = 'ROCKETMQ',
|
||||
REDIS_STREAM = 'REDIS_STREAM',
|
||||
}
|
||||
|
||||
/** HTTP 配置 */
|
||||
export interface HttpConfig {
|
||||
url?: string;
|
||||
method?: string;
|
||||
headers?: Record<string, string>;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
/** MQTT 配置 */
|
||||
export interface MqttConfig {
|
||||
broker?: string;
|
||||
port?: number;
|
||||
topic?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
clientId?: string;
|
||||
qos?: number;
|
||||
}
|
||||
|
||||
/** Kafka 配置 */
|
||||
export interface KafkaMQConfig {
|
||||
bootstrapServers?: string;
|
||||
topic?: string;
|
||||
acks?: string;
|
||||
retries?: number;
|
||||
batchSize?: number;
|
||||
}
|
||||
|
||||
/** RabbitMQ 配置 */
|
||||
export interface RabbitMQConfig {
|
||||
host?: string;
|
||||
port?: number;
|
||||
virtualHost?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
exchange?: string;
|
||||
routingKey?: string;
|
||||
queue?: string;
|
||||
}
|
||||
|
||||
/** RocketMQ 配置 */
|
||||
export interface RocketMQConfig {
|
||||
nameServer?: string;
|
||||
topic?: string;
|
||||
tag?: string;
|
||||
producerGroup?: string;
|
||||
}
|
||||
|
||||
/** Redis Stream 配置 */
|
||||
export interface RedisStreamMQConfig {
|
||||
host?: string;
|
||||
port?: number;
|
||||
password?: string;
|
||||
database?: number;
|
||||
streamKey?: string;
|
||||
maxLen?: number;
|
||||
}
|
||||
|
||||
/** 查询数据流转目的分页 */
|
||||
export function getDataSinkPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<DataSinkApi.Sink>>(
|
||||
'/iot/data-sink/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询数据流转目的详情 */
|
||||
export function getDataSink(id: number) {
|
||||
return requestClient.get<DataSinkApi.Sink>(`/iot/data-sink/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 查询所有数据流转目的列表 */
|
||||
export function getDataSinkList() {
|
||||
return requestClient.get<DataSinkApi.Sink[]>('/iot/data-sink/list');
|
||||
}
|
||||
|
||||
/** 查询数据流转目的简单列表 */
|
||||
export function getDataSinkSimpleList() {
|
||||
return requestClient.get<DataSinkApi.Sink[]>('/iot/data-sink/simple-list');
|
||||
}
|
||||
|
||||
/** 新增数据流转目的 */
|
||||
export function createDataSink(data: DataSinkVO) {
|
||||
return requestClient.post('/iot/data-sink/create', data);
|
||||
}
|
||||
|
||||
/** 修改数据流转目的 */
|
||||
export function updateDataSink(data: DataSinkVO) {
|
||||
return requestClient.put('/iot/data-sink/update', data);
|
||||
}
|
||||
|
||||
/** 删除数据流转目的 */
|
||||
export function deleteDataSink(id: number) {
|
||||
return requestClient.delete(`/iot/data-sink/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除数据流转目的 */
|
||||
export function deleteDataSinkList(ids: number[]) {
|
||||
return requestClient.delete('/iot/data-sink/delete-list', {
|
||||
params: { ids: ids.join(',') },
|
||||
});
|
||||
}
|
||||
|
||||
/** 更新数据流转目的状态 */
|
||||
export function updateDataSinkStatus(id: number, status: number) {
|
||||
return requestClient.put(`/iot/data-sink/update-status`, {
|
||||
id,
|
||||
status,
|
||||
});
|
||||
}
|
||||
|
||||
export { DataSinkApi };
|
||||
|
||||
163
apps/web-antd/src/api/iot/rule/scene/index.ts
Normal file
163
apps/web-antd/src/api/iot/rule/scene/index.ts
Normal file
@@ -0,0 +1,163 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace RuleSceneApi {
|
||||
/** IoT 场景联动规则 VO */
|
||||
export interface SceneRule {
|
||||
id?: number;
|
||||
name: string;
|
||||
description?: string;
|
||||
status?: number;
|
||||
triggers?: Trigger[];
|
||||
actions?: Action[];
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** IoT 场景联动规则触发器 */
|
||||
export interface Trigger {
|
||||
type?: string;
|
||||
productId?: number;
|
||||
deviceId?: number;
|
||||
identifier?: string;
|
||||
operator?: string;
|
||||
value?: any;
|
||||
cronExpression?: string;
|
||||
conditionGroups?: TriggerConditionGroup[];
|
||||
}
|
||||
|
||||
/** IoT 场景联动规则触发条件组 */
|
||||
export interface TriggerConditionGroup {
|
||||
conditions?: TriggerCondition[];
|
||||
operator?: string;
|
||||
}
|
||||
|
||||
/** IoT 场景联动规则触发条件 */
|
||||
export interface TriggerCondition {
|
||||
productId?: number;
|
||||
deviceId?: number;
|
||||
identifier?: string;
|
||||
operator?: string;
|
||||
value?: any;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
/** IoT 场景联动规则动作 */
|
||||
export interface Action {
|
||||
type?: string;
|
||||
productId?: number;
|
||||
deviceId?: number;
|
||||
identifier?: string;
|
||||
value?: any;
|
||||
alertConfigId?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** IoT 场景联动规则 */
|
||||
export interface IotSceneRule {
|
||||
id?: number;
|
||||
name?: string;
|
||||
description?: string;
|
||||
status?: number;
|
||||
triggers?: Trigger[];
|
||||
actions?: Action[];
|
||||
createTime?: Date;
|
||||
}
|
||||
|
||||
/** IoT 场景联动规则触发器 */
|
||||
export interface Trigger {
|
||||
type?: string;
|
||||
productId?: number;
|
||||
deviceId?: number;
|
||||
identifier?: string;
|
||||
operator?: string;
|
||||
value?: any;
|
||||
cronExpression?: string;
|
||||
conditionGroups?: TriggerConditionGroup[];
|
||||
}
|
||||
|
||||
/** IoT 场景联动规则触发条件组 */
|
||||
export interface TriggerConditionGroup {
|
||||
conditions?: TriggerCondition[];
|
||||
operator?: string;
|
||||
}
|
||||
|
||||
/** IoT 场景联动规则触发条件 */
|
||||
export interface TriggerCondition {
|
||||
productId?: number;
|
||||
deviceId?: number;
|
||||
identifier?: string;
|
||||
operator?: string;
|
||||
value?: any;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
/** IoT 场景联动规则动作 */
|
||||
export interface Action {
|
||||
type?: string;
|
||||
productId?: number;
|
||||
deviceId?: number;
|
||||
identifier?: string;
|
||||
value?: any;
|
||||
alertConfigId?: number;
|
||||
}
|
||||
|
||||
/** 查询场景联动规则分页 */
|
||||
export function getSceneRulePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<RuleSceneApi.SceneRule>>(
|
||||
'/iot/scene-rule/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询场景联动规则详情 */
|
||||
export function getSceneRule(id: number) {
|
||||
return requestClient.get<RuleSceneApi.SceneRule>(
|
||||
`/iot/scene-rule/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增场景联动规则 */
|
||||
export function createSceneRule(data: IotSceneRule) {
|
||||
return requestClient.post('/iot/scene-rule/create', data);
|
||||
}
|
||||
|
||||
/** 修改场景联动规则 */
|
||||
export function updateSceneRule(data: IotSceneRule) {
|
||||
return requestClient.put('/iot/scene-rule/update', data);
|
||||
}
|
||||
|
||||
/** 删除场景联动规则 */
|
||||
export function deleteSceneRule(id: number) {
|
||||
return requestClient.delete(`/iot/scene-rule/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除场景联动规则 */
|
||||
export function deleteSceneRuleList(ids: number[]) {
|
||||
return requestClient.delete('/iot/scene-rule/delete-list', {
|
||||
params: { ids: ids.join(',') },
|
||||
});
|
||||
}
|
||||
|
||||
/** 更新场景联动规则状态 */
|
||||
export function updateSceneRuleStatus(id: number, status: number) {
|
||||
return requestClient.put(`/iot/scene-rule/update-status`, {
|
||||
id,
|
||||
status,
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取场景联动规则简单列表 */
|
||||
export function getSimpleRuleSceneList() {
|
||||
return requestClient.get<RuleSceneApi.SceneRule[]>(
|
||||
'/iot/scene-rule/simple-list',
|
||||
);
|
||||
}
|
||||
|
||||
// 别名导出(兼容旧代码)
|
||||
export {
|
||||
getSceneRulePage as getRuleScenePage,
|
||||
deleteSceneRule as deleteRuleScene,
|
||||
updateSceneRuleStatus as updateRuleSceneStatus,
|
||||
};
|
||||
|
||||
84
apps/web-antd/src/api/iot/statistics/index.ts
Normal file
84
apps/web-antd/src/api/iot/statistics/index.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace IotStatisticsApi {
|
||||
/** IoT 统计摘要数据 */
|
||||
export interface StatisticsSummary {
|
||||
productCategoryCount: number;
|
||||
productCount: number;
|
||||
deviceCount: number;
|
||||
deviceMessageCount: number;
|
||||
productCategoryTodayCount: number;
|
||||
productTodayCount: number;
|
||||
deviceTodayCount: number;
|
||||
deviceMessageTodayCount: number;
|
||||
deviceOnlineCount: number;
|
||||
deviceOfflineCount: number;
|
||||
deviceInactiveCount: number;
|
||||
productCategoryDeviceCounts: Record<string, number>;
|
||||
}
|
||||
|
||||
/** 时间戳-数值的键值对类型 */
|
||||
export interface TimeValueItem {
|
||||
[key: string]: number;
|
||||
}
|
||||
|
||||
/** IoT 消息统计数据类型 */
|
||||
export interface DeviceMessageSummary {
|
||||
statType: number;
|
||||
upstreamCounts: TimeValueItem[];
|
||||
downstreamCounts: TimeValueItem[];
|
||||
}
|
||||
|
||||
/** 消息统计数据项(按日期) */
|
||||
export interface DeviceMessageSummaryByDate {
|
||||
time: string;
|
||||
upstreamCount: number;
|
||||
downstreamCount: number;
|
||||
}
|
||||
|
||||
/** 消息统计接口参数 */
|
||||
export interface DeviceMessageReq {
|
||||
interval: number;
|
||||
times?: string[];
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取 IoT 统计摘要数据 */
|
||||
export function getStatisticsSummary() {
|
||||
return requestClient.get<IotStatisticsApi.StatisticsSummary>(
|
||||
'/iot/statistics/get-summary',
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取设备消息的数据统计(按日期) */
|
||||
export function getDeviceMessageSummaryByDate(
|
||||
params: IotStatisticsApi.DeviceMessageReq,
|
||||
) {
|
||||
return requestClient.get<IotStatisticsApi.DeviceMessageSummaryByDate[]>(
|
||||
'/iot/statistics/get-device-message-summary-by-date',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 获取设备消息统计摘要 */
|
||||
export function getDeviceMessageSummary(statType: number) {
|
||||
return requestClient.get<IotStatisticsApi.DeviceMessageSummary>(
|
||||
'/iot/statistics/get-device-message-summary',
|
||||
{ params: { statType } },
|
||||
);
|
||||
}
|
||||
|
||||
// 导出 API 对象(兼容旧代码)
|
||||
export const StatisticsApi = {
|
||||
getStatisticsSummary,
|
||||
getDeviceMessageSummaryByDate,
|
||||
getDeviceMessageSummary,
|
||||
};
|
||||
|
||||
// 导出类型别名(兼容旧代码)
|
||||
export type IotStatisticsSummaryRespVO = IotStatisticsApi.StatisticsSummary;
|
||||
export type IotStatisticsDeviceMessageSummaryRespVO =
|
||||
IotStatisticsApi.DeviceMessageSummary;
|
||||
export type IotStatisticsDeviceMessageSummaryByDateRespVO =
|
||||
IotStatisticsApi.DeviceMessageSummaryByDate;
|
||||
export type IotStatisticsDeviceMessageReqVO = IotStatisticsApi.DeviceMessageReq;
|
||||
206
apps/web-antd/src/api/iot/thingmodel/index.ts
Normal file
206
apps/web-antd/src/api/iot/thingmodel/index.ts
Normal file
@@ -0,0 +1,206 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ThingModelApi {
|
||||
/** IoT 物模型数据 VO */
|
||||
export interface ThingModel {
|
||||
id?: number;
|
||||
productId?: number;
|
||||
productKey?: string;
|
||||
identifier: string;
|
||||
name: string;
|
||||
desc?: string;
|
||||
type: string;
|
||||
property?: ThingModelProperty;
|
||||
event?: ThingModelEvent;
|
||||
service?: ThingModelService;
|
||||
}
|
||||
|
||||
/** IoT 物模型属性 */
|
||||
export interface Property {
|
||||
identifier: string;
|
||||
name: string;
|
||||
accessMode: string;
|
||||
dataType: string;
|
||||
dataSpecs?: any;
|
||||
dataSpecsList?: any[];
|
||||
desc?: string;
|
||||
}
|
||||
|
||||
/** IoT 物模型服务 */
|
||||
export interface Service {
|
||||
identifier: string;
|
||||
name: string;
|
||||
callType: string;
|
||||
inputData?: any[];
|
||||
outputData?: any[];
|
||||
desc?: string;
|
||||
}
|
||||
|
||||
/** IoT 物模型事件 */
|
||||
export interface Event {
|
||||
identifier: string;
|
||||
name: string;
|
||||
type: string;
|
||||
outputData?: any[];
|
||||
desc?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/** IoT 物模型数据 */
|
||||
export interface ThingModelData {
|
||||
id?: number;
|
||||
productId?: number;
|
||||
productKey?: string;
|
||||
identifier?: string;
|
||||
name?: string;
|
||||
desc?: string;
|
||||
type?: string;
|
||||
dataType?: string;
|
||||
property?: ThingModelProperty;
|
||||
event?: ThingModelEvent;
|
||||
service?: ThingModelService;
|
||||
}
|
||||
|
||||
/** IoT 物模型属性 */
|
||||
export interface ThingModelProperty {
|
||||
identifier?: string;
|
||||
name?: string;
|
||||
accessMode?: string;
|
||||
dataType?: string;
|
||||
dataSpecs?: any;
|
||||
dataSpecsList?: any[];
|
||||
desc?: string;
|
||||
}
|
||||
|
||||
/** IoT 物模型服务 */
|
||||
export interface ThingModelService {
|
||||
identifier?: string;
|
||||
name?: string;
|
||||
callType?: string;
|
||||
inputData?: any[];
|
||||
outputData?: any[];
|
||||
desc?: string;
|
||||
}
|
||||
|
||||
/** IoT 物模型事件 */
|
||||
export interface ThingModelEvent {
|
||||
identifier?: string;
|
||||
name?: string;
|
||||
type?: string;
|
||||
outputData?: any[];
|
||||
desc?: string;
|
||||
}
|
||||
|
||||
/** IoT 数据定义(数值型) */
|
||||
export interface DataSpecsNumberData {
|
||||
min?: number | string;
|
||||
max?: number | string;
|
||||
step?: number | string;
|
||||
unit?: string;
|
||||
unitName?: string;
|
||||
}
|
||||
|
||||
/** IoT 数据定义(枚举/布尔型) */
|
||||
export interface DataSpecsEnumOrBoolData {
|
||||
value: number | string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
/** IoT 物模型表单校验规则 */
|
||||
export interface ThingModelFormRules {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/** 验证布尔型名称 */
|
||||
export const validateBoolName = (_rule: any, value: any, callback: any) => {
|
||||
if (!value) {
|
||||
callback(new Error('枚举描述不能为空'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
/** 查询产品物模型分页 */
|
||||
export function getThingModelPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ThingModelApi.ThingModel>>(
|
||||
'/iot/thing-model/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询产品物模型详情 */
|
||||
export function getThingModel(id: number) {
|
||||
return requestClient.get<ThingModelApi.ThingModel>(
|
||||
`/iot/thing-model/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 根据产品 ID 查询物模型列表 */
|
||||
export function getThingModelListByProductId(productId: number) {
|
||||
return requestClient.get<ThingModelApi.ThingModel[]>(
|
||||
'/iot/thing-model/list-by-product-id',
|
||||
{ params: { productId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 根据产品标识查询物模型列表 */
|
||||
export function getThingModelListByProductKey(productKey: string) {
|
||||
return requestClient.get<ThingModelApi.ThingModel[]>(
|
||||
'/iot/thing-model/list-by-product-key',
|
||||
{ params: { productKey } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增物模型 */
|
||||
export function createThingModel(data: ThingModelData) {
|
||||
return requestClient.post('/iot/thing-model/create', data);
|
||||
}
|
||||
|
||||
/** 修改物模型 */
|
||||
export function updateThingModel(data: ThingModelData) {
|
||||
return requestClient.put('/iot/thing-model/update', data);
|
||||
}
|
||||
|
||||
/** 删除物模型 */
|
||||
export function deleteThingModel(id: number) {
|
||||
return requestClient.delete(`/iot/thing-model/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除物模型 */
|
||||
export function deleteThingModelList(ids: number[]) {
|
||||
return requestClient.delete('/iot/thing-model/delete-list', {
|
||||
params: { ids: ids.join(',') },
|
||||
});
|
||||
}
|
||||
|
||||
/** 导入物模型 TSL */
|
||||
export function importThingModelTSL(productId: number, tslData: any) {
|
||||
return requestClient.post('/iot/thing-model/import-tsl', {
|
||||
productId,
|
||||
tslData,
|
||||
});
|
||||
}
|
||||
|
||||
/** 导出物模型 TSL */
|
||||
export function exportThingModelTSL(productId: number) {
|
||||
return requestClient.get<any>('/iot/thing-model/export-tsl', {
|
||||
params: { productId },
|
||||
});
|
||||
}
|
||||
|
||||
// Add a consolidated API object and getThingModelList alias
|
||||
export const ThingModelApi = {
|
||||
getThingModelPage,
|
||||
getThingModel,
|
||||
getThingModelList: getThingModelListByProductId, // alias for compatibility
|
||||
getThingModelListByProductId,
|
||||
getThingModelListByProductKey,
|
||||
createThingModel,
|
||||
updateThingModel,
|
||||
deleteThingModel,
|
||||
deleteThingModelList,
|
||||
importThingModelTSL,
|
||||
exportThingModelTSL,
|
||||
};
|
||||
Reference in New Issue
Block a user