7 changed files with 317 additions and 222 deletions
@ -0,0 +1,27 @@ |
|||||
|
namespace CellularManagement.Domain.Models; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 设备运行时状态DTO(用于SQL查询结果映射)
|
||||
|
/// </summary>
|
||||
|
public class DeviceRuntimeDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 设备编号
|
||||
|
/// </summary>
|
||||
|
public string DeviceCode { get; set; } = null!; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 运行时状态
|
||||
|
/// </summary>
|
||||
|
public int RuntimeStatus { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 运行编码
|
||||
|
/// </summary>
|
||||
|
public string? RuntimeCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 网络栈配置编号
|
||||
|
/// </summary>
|
||||
|
public string? NetworkStackCode { get; set; } |
||||
|
} |
@ -0,0 +1,144 @@ |
|||||
|
import { httpClient } from '@/lib/http-client'; |
||||
|
import { OperationResult } from '@/types/auth'; |
||||
|
import { API_PATHS } from '@/constants/api'; |
||||
|
|
||||
|
// 设备运行时状态枚举
|
||||
|
export enum DeviceRuntimeStatus { |
||||
|
Running = 1, |
||||
|
Stopped = 2, |
||||
|
Error = 3, |
||||
|
Unknown = 4 |
||||
|
} |
||||
|
|
||||
|
// 获取协议日志请求接口
|
||||
|
export interface GetProtocolLogsRequest { |
||||
|
deviceCode?: string; |
||||
|
startTimestamp?: number; |
||||
|
endTimestamp?: number; |
||||
|
layerType?: string; |
||||
|
deviceRuntimeStatus?: DeviceRuntimeStatus; |
||||
|
runtimeCodes?: string[]; |
||||
|
runtimeStatuses?: number[]; |
||||
|
orderByDescending?: boolean; |
||||
|
} |
||||
|
|
||||
|
// 协议日志数据接口
|
||||
|
export interface ProtocolLogDto { |
||||
|
id: string; |
||||
|
messageId: number; |
||||
|
layerType: number; |
||||
|
messageDetailJson?: string; |
||||
|
cellID?: number; |
||||
|
imsi?: string; |
||||
|
direction: number; |
||||
|
ueid?: number; |
||||
|
plmn?: string; |
||||
|
timeMs: number; |
||||
|
timestamp: number; |
||||
|
info?: string; |
||||
|
message?: string; |
||||
|
deviceCode: string; |
||||
|
runtimeCode: string; |
||||
|
messageDetail?: string[]; |
||||
|
time: string; // TimeSpan 在 TypeScript 中表示为字符串
|
||||
|
} |
||||
|
|
||||
|
// 获取协议日志响应接口
|
||||
|
export interface GetProtocolLogsResponse { |
||||
|
deviceCode?: string; |
||||
|
items: ProtocolLogDto[]; |
||||
|
} |
||||
|
|
||||
|
class ProtocolLogsService { |
||||
|
private readonly baseUrl = API_PATHS.PROTOCOL_LOGS; |
||||
|
|
||||
|
/** |
||||
|
* 获取协议日志 |
||||
|
* 统一的POST接口,支持按设备代码查询或查询所有设备的协议日志 |
||||
|
* @param request 查询请求参数 |
||||
|
* @returns 协议日志列表 |
||||
|
*/ |
||||
|
async getProtocolLogs(request: GetProtocolLogsRequest = {}): Promise<OperationResult<GetProtocolLogsResponse>> { |
||||
|
return httpClient.post<GetProtocolLogsResponse>(`${this.baseUrl}/logs`, request); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 按设备代码获取协议日志(便捷方法) |
||||
|
* @param deviceCode 设备代码 |
||||
|
* @param options 其他查询选项 |
||||
|
* @returns 协议日志列表 |
||||
|
*/ |
||||
|
async getProtocolLogsByDevice( |
||||
|
deviceCode: string, |
||||
|
options: Omit<GetProtocolLogsRequest, 'deviceCode'> = {} |
||||
|
): Promise<OperationResult<GetProtocolLogsResponse>> { |
||||
|
return this.getProtocolLogs({ |
||||
|
deviceCode, |
||||
|
...options |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取所有设备的协议日志(便捷方法) |
||||
|
* @param options 查询选项 |
||||
|
* @returns 协议日志列表 |
||||
|
*/ |
||||
|
async getAllProtocolLogs( |
||||
|
options: Omit<GetProtocolLogsRequest, 'deviceCode'> = {} |
||||
|
): Promise<OperationResult<GetProtocolLogsResponse>> { |
||||
|
return this.getProtocolLogs(options); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 按时间范围获取协议日志(便捷方法) |
||||
|
* @param startTimestamp 开始时间戳 |
||||
|
* @param endTimestamp 结束时间戳 |
||||
|
* @param options 其他查询选项 |
||||
|
* @returns 协议日志列表 |
||||
|
*/ |
||||
|
async getProtocolLogsByTimeRange( |
||||
|
startTimestamp: number, |
||||
|
endTimestamp: number, |
||||
|
options: Omit<GetProtocolLogsRequest, 'startTimestamp' | 'endTimestamp'> = {} |
||||
|
): Promise<OperationResult<GetProtocolLogsResponse>> { |
||||
|
return this.getProtocolLogs({ |
||||
|
startTimestamp, |
||||
|
endTimestamp, |
||||
|
...options |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 按协议层类型获取协议日志(便捷方法) |
||||
|
* @param layerType 协议层类型 |
||||
|
* @param options 其他查询选项 |
||||
|
* @returns 协议日志列表 |
||||
|
*/ |
||||
|
async getProtocolLogsByLayerType( |
||||
|
layerType: string, |
||||
|
options: Omit<GetProtocolLogsRequest, 'layerType'> = {} |
||||
|
): Promise<OperationResult<GetProtocolLogsResponse>> { |
||||
|
return this.getProtocolLogs({ |
||||
|
layerType, |
||||
|
...options |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 按设备运行时状态获取协议日志(便捷方法) |
||||
|
* @param deviceRuntimeStatus 设备运行时状态 |
||||
|
* @param options 其他查询选项 |
||||
|
* @returns 协议日志列表 |
||||
|
*/ |
||||
|
async getProtocolLogsByRuntimeStatus( |
||||
|
deviceRuntimeStatus: DeviceRuntimeStatus, |
||||
|
options: Omit<GetProtocolLogsRequest, 'deviceRuntimeStatus'> = {} |
||||
|
): Promise<OperationResult<GetProtocolLogsResponse>> { |
||||
|
return this.getProtocolLogs({ |
||||
|
deviceRuntimeStatus, |
||||
|
...options |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export const protocolLogsService = new ProtocolLogsService(); |
Loading…
Reference in new issue