From 97916765d5de4418df87d8f354fabfb813abba0d Mon Sep 17 00:00:00 2001 From: "zangch@mesnac.com" Date: Wed, 26 Nov 2025 15:13:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(api/rfid):=20=E6=96=B0=E5=A2=9E=E7=9C=8B?= =?UTF-8?q?=E6=9D=BF=E6=8C=89=E9=9C=80=E5=88=B7=E6=96=B0=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=8A=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加获取实时统计数据接口,支持告警列表数量限制 - 新增设备状态列表接口,支持按位置筛选 - 新增成功率趋势接口,按小时统计,支持类型参数 - 保留原有完整看板数据接口及统计概览接口 - 新增告警统计列表接口,支持限制数量 - 新增完整看板数据相关类型定义,涵盖统计概览、设备状态、 成功率趋势和告警统计等结构 - 定义最新读取记录类型,用于设备状态最新读取信息描述 --- src/api/rfid/dashboard/index.ts | 91 +++++++++++++++++++++++++-- src/api/rfid/dashboard/types.ts | 106 ++++++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+), 5 deletions(-) create mode 100644 src/api/rfid/dashboard/types.ts diff --git a/src/api/rfid/dashboard/index.ts b/src/api/rfid/dashboard/index.ts index 77b21fa..e96f39f 100644 --- a/src/api/rfid/dashboard/index.ts +++ b/src/api/rfid/dashboard/index.ts @@ -1,11 +1,92 @@ import request from '@/utils/request'; +import { AxiosPromise } from 'axios'; +import { + DashboardVO, + RealtimeStats, + DeviceStatusVO, + SuccessRateTrend, + StatisticsOverview, + AlarmStatVO +} from './types'; + +// ==================== 新增接口(按需刷新) ==================== /** - * 获取首页统计数据 + * 【新接口1】获取实时统计数据(按秒刷新) + * 包含:顶部统计(设备数量、在线数量、离线数量、告警数量)+ 告警统计列表 + * + * @param alarmLimit 告警列表限制数量(默认10条) */ -export const getDashboardStats = () => { +export const getRealtimeStats = (alarmLimit?: number): AxiosPromise => { return request({ - url: '/rfid/dashboard/stats', + url: '/rfid/dashboard/realtime', + method: 'get', + params: { alarmLimit } + }); +}; + +/** + * 【新接口2】获取设备状态列表(定时刷新) + * 包含每个设备的在线状态、告警状态及最新读取记录 + * + * @param locationId 位置ID(可选,用于按位置筛选) + */ +export const getDeviceStatusList = (locationId?: number): AxiosPromise => { + return request({ + url: '/rfid/dashboard/deviceStatus', + method: 'get', + params: { locationId } + }); +}; + +/** + * 【新接口3】获取成功率趋势(按小时统计) + * 不需要频繁刷新 + * + * @param type 类型:today-今日(默认),yesterday-昨日 + */ +export const getSuccessRateTrends = (type?: string): AxiosPromise => { + return request({ + url: '/rfid/dashboard/successRate', + method: 'get', + params: { type } + }); +}; + +// ==================== 原有接口(保留) ==================== + +/** + * 获取完整看板数据 + * + * @param locationId 位置ID(可选) + */ +export const getDashboardData = (locationId?: number): AxiosPromise => { + return request({ + url: '/rfid/dashboard/data', + method: 'get', + params: { locationId } + }); +}; + +/** + * 获取统计概览 + */ +export const getOverview = (): AxiosPromise => { + return request({ + url: '/rfid/dashboard/overview', method: 'get' - }) -} + }); +}; + +/** + * 获取告警统计列表 + * + * @param limit 限制数量(默认10条) + */ +export const getAlarmStats = (limit?: number): AxiosPromise => { + return request({ + url: '/rfid/dashboard/alarmStats', + method: 'get', + params: { limit } + }); +}; diff --git a/src/api/rfid/dashboard/types.ts b/src/api/rfid/dashboard/types.ts new file mode 100644 index 0000000..c24ce0d --- /dev/null +++ b/src/api/rfid/dashboard/types.ts @@ -0,0 +1,106 @@ +/** + * 看板数据类型定义 + */ + +/** + * 完整看板数据(原接口返回) + */ +export interface DashboardVO { + /** 统计概览 */ + overview: StatisticsOverview; + /** 设备状态列表 */ + deviceStatusList: DeviceStatusVO[]; + /** 成功率趋势数据 */ + successRateTrends: SuccessRateTrend[]; + /** 告警统计列表 */ + alarmStats: AlarmStatVO[]; +} + +/** + * 统计概览 + */ +export interface StatisticsOverview { + /** 设备总数 */ + deviceTotal: number; + /** 在线数量 */ + onlineCount: number; + /** 离线数量 */ + offlineCount: number; + /** 告警数量 */ + alarmCount: number; +} + +/** + * 告警统计 + */ +export interface AlarmStatVO { + /** 告警时间 */ + alarmTime: string; + /** 设备名称 */ + deviceName: string; + /** 位置 */ + location: string; + /** 告警级别 */ + alarmLevel: string; + /** 告警行为 */ + alarmAction: string; +} + +/** + * 实时统计数据(接口1返回) + * 按秒刷新:顶部统计 + 告警列表 + */ +export interface RealtimeStats { + /** 统计概览 */ + overview: StatisticsOverview; + /** 告警统计列表 */ + alarmStats: AlarmStatVO[]; +} + +/** + * 最新读取记录 + */ +export interface LatestReadRecord { + /** 工位名称 */ + stationName: string; + /** 条码信息 */ + barcode: string; + /** 读取时间 */ + recordTime: string; + /** 读取状态 (1-成功;0-失败) */ + readStatus: string; +} + +/** + * 设备状态(接口2返回) + * 定时刷新:设备树 + 设备最新读取记录 + */ +export interface DeviceStatusVO { + /** 设备ID */ + deviceId: number; + /** 设备编号 */ + deviceCode: string; + /** 设备名称 */ + deviceName: string; + /** 所属位置ID */ + locationId: number; + /** 位置别名 */ + locationAlias: string; + /** 在线状态 (1-在线;0-离线) */ + onlineStatus: string; + /** 告警状态 (0-正常;1-告警) */ + alarmStatus: string; + /** 最新读取记录 */ + latestRecord?: LatestReadRecord; +} + +/** + * 成功率趋势(接口3返回) + * 按小时统计 + */ +export interface SuccessRateTrend { + /** 时间点(小时,如 "09:00") */ + timePoint: string; + /** 成功率(百分比,如 98.5) */ + successRate: number | null; +}