refactor(api-rfid-dashboard): 优化接口设计并更新类型定义

- 调整实时统计数据接口参数,支持不传限制数量获取全部告警
- 替换设备状态列表接口为位置树接口,位置类型3表示设备节点
- 移除设备状态列表接口参数,简化请求调用
- 成功率趋势接口取消类型参数,改为返回包含今日与昨日的数据
- 新增兼容旧接口名的函数,方便代码逐步迁移
- 类型定义中将设备状态列表替换为位置树结构
- 位置树节点新增设备及层级相关字段,支持树形结构及WebSocket数据匹配
- 新增WebSocket实时读取记录类型定义,完善实时数据结构
- 成功率趋势数据接口更新,区分今日与昨日成功率字段
main
zangch@mesnac.com 3 weeks ago
parent 631a88fd03
commit ecdf6e18b9

@ -3,7 +3,7 @@ import { AxiosPromise } from 'axios';
import { import {
DashboardVO, DashboardVO,
RealtimeStats, RealtimeStats,
DeviceStatusVO, LocationTreeNode,
SuccessRateTrend, SuccessRateTrend,
StatisticsOverview, StatisticsOverview,
AlarmStatVO AlarmStatVO
@ -12,44 +12,41 @@ import {
// ==================== 新增接口(按需刷新) ==================== // ==================== 新增接口(按需刷新) ====================
/** /**
* 1 * 1
* 线线+ * 线线+
* *
* @param alarmLimit 10 * @param alarmLimit
*/ */
export const getRealtimeStats = (alarmLimit?: number): AxiosPromise<RealtimeStats> => { export const getRealtimeStats = (alarmLimit?: number): AxiosPromise<RealtimeStats> => {
return request({ return request({
url: '/rfid/dashboard/realtime', url: '/rfid/dashboard/realtime',
method: 'get', method: 'get',
params: { alarmLimit } params: alarmLimit ? { alarmLimit } : {}
}); });
}; };
/** /**
* 2 * 2
* 线 * 3
* * WebSocket
* @param locationId ID * deviceId WebSocket
*/ */
export const getDeviceStatusList = (locationId?: number): AxiosPromise<DeviceStatusVO[]> => { export const getLocationTree = (): AxiosPromise<LocationTreeNode[]> => {
return request({ return request({
url: '/rfid/dashboard/deviceStatus', url: '/rfid/dashboard/deviceStatus',
method: 'get', method: 'get'
params: { locationId }
}); });
}; };
/** /**
* 3 * 3
* *
* * 24
* @param type today-yesterday-
*/ */
export const getSuccessRateTrends = (type?: string): AxiosPromise<SuccessRateTrend[]> => { export const getSuccessRateTrends = (): AxiosPromise<SuccessRateTrend[]> => {
return request({ return request({
url: '/rfid/dashboard/successRate', url: '/rfid/dashboard/successRate',
method: 'get', method: 'get'
params: { type }
}); });
}; };
@ -90,3 +87,11 @@ export const getAlarmStats = (limit?: number): AxiosPromise<AlarmStatVO[]> => {
params: { limit } params: { limit }
}); });
}; };
/**
* getDashboardStats
* getDashboardData便
*/
export const getDashboardStats = (locationId?: number): AxiosPromise<DashboardVO> => {
return getDashboardData(locationId);
};

@ -8,8 +8,8 @@
export interface DashboardVO { export interface DashboardVO {
/** 统计概览 */ /** 统计概览 */
overview: StatisticsOverview; overview: StatisticsOverview;
/** 设备状态列表 */ /** 位置树(含设备信息) */
deviceStatusList: DeviceStatusVO[]; locationTree: LocationTreeNode[];
/** 成功率趋势数据 */ /** 成功率趋势数据 */
successRateTrends: SuccessRateTrend[]; successRateTrends: SuccessRateTrend[];
/** 告警统计列表 */ /** 告警统计列表 */
@ -58,49 +58,74 @@ export interface RealtimeStats {
} }
/** /**
* * 2
* locationType = 3
* deviceId WebSocket
*/ */
export interface LatestReadRecord { export interface LocationTreeNode {
/** 工位名称 */ // ==================== 位置信息 ====================
stationName: string; /** 位置ID */
/** 条码信息 */ id: number;
barcode: string; /** 位置编号 */
/** 读取时间 */ locationCode: string;
recordTime: string; /** 位置别名 */
/** 读取状态 (1-成功;0-失败) */ locationAlias: string;
readStatus: string; /** 位置类型 (1-车间; 2-工序; 3-工位/设备) */
locationType: string;
/** 父级位置ID */
parentId: number | null;
// ==================== 设备信息(仅当 locationType=3 时有值) ====================
/** 设备ID前端用于匹配 WebSocket 数据) */
deviceId?: number;
/** 设备编号 */
deviceCode?: string;
/** 设备名称 */
deviceName?: string;
/** 在线状态 (1-在线; 0-离线) */
onlineStatus?: string;
/** 告警状态 (0-正常; 1-告警) */
alarmStatus?: string;
// ==================== 子节点 ====================
/** 子节点列表 */
children?: LocationTreeNode[];
} }
/** /**
* 2 * WebSocket
* + * C# deviceId
*/ */
export interface DeviceStatusVO { export interface WebSocketReadRecord {
/** 设备ID */ /** 记录ID */
objid: number;
/** 设备ID用于匹配位置树中的设备节点 */
deviceId: number; deviceId: number;
/** 设备编号 */ /** 读取状态 (1-成功; 0-失败) */
deviceCode: string; readStatus: string;
/** 设备名称 */ /** 标签信息/条码 */
deviceName: string; epcStr: string;
/** 所属位置ID */ /** 是否报警 (1-是; 0-否) */
locationId: number; alarmFlag: string;
/** 位置别名 */ /** 告警级别 */
locationAlias: string; alarmLevel: string;
/** 在线状态 (1-在线;0-离线) */ /** 告警类型 */
onlineStatus: string; alarmType: string;
/** 告警状态 (0-正常;1-告警) */ /** 告警内容 */
alarmStatus: string; alarmAction: string;
/** 最新读取记录 */ /** 记录时间 (ISO 8601 格式) */
latestRecord?: LatestReadRecord; recordTime: string;
} }
/** /**
* 3 * 3
* *
*/ */
export interface SuccessRateTrend { export interface SuccessRateTrend {
/** 时间点(小时,如 "09:00" */ /** 时间点(小时,如 "09:00" */
timePoint: string; timePoint: string;
/** 成功率(百分比,如 98.5 */ /** 今日成功率(百分比,如 98.5 */
successRate: number | null; successRate: number | null;
/** 昨日同一小时成功率 */
yesterdaySuccessRate: number | null;
} }

Loading…
Cancel
Save