2026-02-08 23:24:12 +08:00
|
|
|
import { useAppConfig } from '@vben/hooks';
|
2026-02-06 16:40:26 +08:00
|
|
|
|
|
|
|
|
import { wvpRequestClient } from '#/api/aiot/request';
|
|
|
|
|
|
2026-02-08 23:24:12 +08:00
|
|
|
const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);
|
|
|
|
|
|
2026-02-06 16:40:26 +08:00
|
|
|
export namespace AiotDeviceApi {
|
|
|
|
|
/** ROI 区域 */
|
|
|
|
|
export interface Roi {
|
|
|
|
|
id?: number;
|
2026-02-08 23:24:12 +08:00
|
|
|
roiId?: string;
|
|
|
|
|
cameraId?: string;
|
|
|
|
|
deviceId?: string;
|
2026-02-06 16:40:26 +08:00
|
|
|
name?: string;
|
2026-02-08 23:24:12 +08:00
|
|
|
roiType?: string; // rectangle | polygon
|
|
|
|
|
coordinates?: string;
|
|
|
|
|
color?: string;
|
|
|
|
|
priority?: number;
|
|
|
|
|
enabled?: number; // 0 | 1
|
|
|
|
|
description?: string;
|
|
|
|
|
algorithms?: RoiAlgoBinding[];
|
2026-02-06 16:40:26 +08:00
|
|
|
}
|
|
|
|
|
|
2026-02-08 23:24:12 +08:00
|
|
|
/** ROI 算法绑定(详情里的嵌套结构) */
|
|
|
|
|
export interface RoiAlgoBinding {
|
|
|
|
|
bind: AlgoBind;
|
|
|
|
|
algorithm?: Algorithm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 算法绑定记录 */
|
|
|
|
|
export interface AlgoBind {
|
|
|
|
|
bindId?: string;
|
|
|
|
|
roiId?: string;
|
|
|
|
|
algoCode?: string;
|
|
|
|
|
enabled?: number;
|
|
|
|
|
params?: string;
|
2026-02-06 16:40:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 算法 */
|
|
|
|
|
export interface Algorithm {
|
|
|
|
|
id?: number;
|
2026-02-08 23:24:12 +08:00
|
|
|
algoCode?: string;
|
|
|
|
|
algoName?: string;
|
2026-02-06 16:40:26 +08:00
|
|
|
description?: string;
|
2026-02-08 23:24:12 +08:00
|
|
|
isActive?: boolean;
|
|
|
|
|
paramSchema?: string;
|
2026-02-06 16:40:26 +08:00
|
|
|
}
|
|
|
|
|
|
2026-02-08 23:24:12 +08:00
|
|
|
/** 摄像头(拉流代理) */
|
|
|
|
|
export interface Camera {
|
|
|
|
|
id?: number;
|
2026-02-09 09:51:37 +08:00
|
|
|
type?: string; // default | ffmpeg
|
2026-02-08 23:24:12 +08:00
|
|
|
app?: string;
|
|
|
|
|
stream?: string;
|
|
|
|
|
srcUrl?: string;
|
2026-02-09 09:51:37 +08:00
|
|
|
timeout?: number;
|
|
|
|
|
rtspType?: string; // 0=TCP, 1=UDP, 2=Multicast
|
|
|
|
|
enable?: boolean;
|
|
|
|
|
enableAudio?: boolean;
|
|
|
|
|
enableMp4?: boolean;
|
|
|
|
|
enableDisableNoneReader?: boolean;
|
|
|
|
|
relatesMediaServerId?: string;
|
|
|
|
|
ffmpegCmdKey?: string;
|
2026-02-08 23:24:12 +08:00
|
|
|
pulling?: boolean;
|
|
|
|
|
mediaServerId?: string;
|
2026-02-06 16:40:26 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-08 23:24:12 +08:00
|
|
|
// ==================== 摄像头管理 API ====================
|
|
|
|
|
|
|
|
|
|
/** 获取摄像头列表 */
|
|
|
|
|
export function getCameraList(params: {
|
|
|
|
|
page: number;
|
|
|
|
|
count: number;
|
|
|
|
|
query?: string;
|
|
|
|
|
pulling?: boolean;
|
|
|
|
|
}) {
|
|
|
|
|
return wvpRequestClient.get<any>('/aiot/device/proxy/list', { params });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 开始拉流 */
|
|
|
|
|
export function startCamera(id: number) {
|
|
|
|
|
return wvpRequestClient.get('/aiot/device/proxy/start', { params: { id } });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 停止拉流 */
|
|
|
|
|
export function stopCamera(id: number) {
|
|
|
|
|
return wvpRequestClient.get('/aiot/device/proxy/stop', { params: { id } });
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-09 09:51:37 +08:00
|
|
|
/** 保存摄像头(新增/编辑) */
|
|
|
|
|
export function saveCamera(data: Partial<AiotDeviceApi.Camera>) {
|
|
|
|
|
return wvpRequestClient.post('/aiot/device/proxy/save', data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 删除摄像头 */
|
|
|
|
|
export function deleteCamera(id: number) {
|
|
|
|
|
return wvpRequestClient.delete('/aiot/device/proxy/delete', {
|
|
|
|
|
params: { id },
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取在线媒体服务器列表 */
|
|
|
|
|
export function getMediaServerList() {
|
|
|
|
|
return wvpRequestClient.get<any>('/aiot/device/server/online/list');
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-06 16:40:26 +08:00
|
|
|
// ==================== ROI 区域管理 API ====================
|
|
|
|
|
|
2026-02-08 23:24:12 +08:00
|
|
|
/** 获取 ROI 列表(分页) */
|
|
|
|
|
export function getRoiList(params: {
|
|
|
|
|
page: number;
|
|
|
|
|
count: number;
|
|
|
|
|
cameraId?: string;
|
|
|
|
|
deviceId?: string;
|
|
|
|
|
query?: string;
|
|
|
|
|
}) {
|
|
|
|
|
return wvpRequestClient.get<any>('/aiot/device/roi/list', { params });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取 ROI 详情 */
|
|
|
|
|
export function getRoiDetail(id: number) {
|
|
|
|
|
return wvpRequestClient.get<any>(`/aiot/device/roi/${id}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取某摄像头的所有 ROI */
|
|
|
|
|
export function getRoiByCameraId(cameraId: string) {
|
|
|
|
|
return wvpRequestClient.get<any>('/aiot/device/roi/channel', {
|
|
|
|
|
params: { cameraId },
|
|
|
|
|
});
|
2026-02-06 16:40:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 保存 ROI */
|
2026-02-08 23:24:12 +08:00
|
|
|
export function saveRoi(data: Partial<AiotDeviceApi.Roi>) {
|
2026-02-06 16:40:26 +08:00
|
|
|
return wvpRequestClient.post('/aiot/device/roi/save', data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 删除 ROI */
|
2026-02-08 23:24:12 +08:00
|
|
|
export function deleteRoi(roiId: string) {
|
|
|
|
|
return wvpRequestClient.delete(`/aiot/device/roi/delete/${roiId}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取截图 URL */
|
|
|
|
|
export function getSnapUrl(app: string, stream: string) {
|
|
|
|
|
return `${apiURL}/aiot/device/roi/snap?app=${encodeURIComponent(app)}&stream=${encodeURIComponent(stream)}&t=${Date.now()}`;
|
2026-02-06 16:40:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== 算法绑定 API ====================
|
|
|
|
|
|
|
|
|
|
/** 绑定算法到 ROI */
|
2026-02-08 23:24:12 +08:00
|
|
|
export function bindAlgo(data: { roiId: string; algoCode: string }) {
|
2026-02-06 16:40:26 +08:00
|
|
|
return wvpRequestClient.post('/aiot/device/roi/bindAlgo', data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 解绑算法 */
|
2026-02-08 23:24:12 +08:00
|
|
|
export function unbindAlgo(bindId: string) {
|
|
|
|
|
return wvpRequestClient.delete('/aiot/device/roi/unbindAlgo', {
|
|
|
|
|
params: { bindId },
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 更新算法参数 */
|
|
|
|
|
export function updateAlgoParams(data: {
|
|
|
|
|
bindId: string;
|
|
|
|
|
params?: string;
|
|
|
|
|
enabled?: number;
|
|
|
|
|
}) {
|
|
|
|
|
return wvpRequestClient.post('/aiot/device/roi/updateAlgoParams', data);
|
2026-02-06 16:40:26 +08:00
|
|
|
}
|
|
|
|
|
|
2026-02-08 23:24:12 +08:00
|
|
|
// ==================== 算法管理 API ====================
|
|
|
|
|
|
2026-02-06 16:40:26 +08:00
|
|
|
/** 获取算法列表 */
|
|
|
|
|
export function getAlgorithmList() {
|
2026-02-08 23:24:12 +08:00
|
|
|
return wvpRequestClient.get<any>('/aiot/device/algorithm/list');
|
2026-02-06 16:40:26 +08:00
|
|
|
}
|
|
|
|
|
|
2026-02-08 23:24:12 +08:00
|
|
|
// ==================== 配置推送 API ====================
|
|
|
|
|
|
|
|
|
|
/** 推送配置到边缘端 */
|
|
|
|
|
export function pushConfig(cameraId: string) {
|
|
|
|
|
return wvpRequestClient.post('/aiot/device/config/push', null, {
|
|
|
|
|
params: { cameraId },
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-02-06 16:40:26 +08:00
|
|
|
|
2026-02-08 23:24:12 +08:00
|
|
|
/** 导出配置 */
|
|
|
|
|
export function exportConfig(cameraId: string) {
|
|
|
|
|
return wvpRequestClient.get<any>('/aiot/device/config/export', {
|
|
|
|
|
params: { cameraId },
|
|
|
|
|
});
|
2026-02-06 16:40:26 +08:00
|
|
|
}
|