| | |
| | | batteryNo: string |
| | | collectorId: number |
| | | collectorName?: string | null |
| | | binding: { bindingId?: number; channelId: number; expectedBarcode: string | null; claimStatus?: string; cabinetCode?: string | null; cabinetName?: string | null; displayNo?: string | null } |
| | | binding: { bindingId?: number; channelId: number; expectedBarcode: string | null; claimStatus?: string; cabinetCode?: string | null; cabinetName?: string | null; displayNo?: string | null; devtype?: number | null; devid?: number | null; subdevid?: number | null; chlid?: number | null } |
| | | collectorChannels: Array<{ |
| | | mappingId?: number |
| | | measurementCode: string |
| | |
| | | return (await request<TestIntegrityResponse>(`/system/test/${testId}/integrity`)).data |
| | | } |
| | | |
| | | export interface BtsRecord { |
| | | sequenceId: number |
| | | deviceTime: string |
| | | currentA: number |
| | | voltageV: number |
| | | capacityAh: number |
| | | energyWh: number |
| | | cycleNo: number |
| | | stepNo: number |
| | | stepName: string |
| | | stepType: string |
| | | } |
| | | |
| | | export interface BtsStepRecord { |
| | | cycleNo: number |
| | | stepNo: number |
| | | stepName: string |
| | | stepType: string |
| | | recordCount: number |
| | | startedAt: string |
| | | endedAt: string |
| | | capacityAh: number |
| | | energyWh: number |
| | | } |
| | | |
| | | export interface BtsCycleRecord { |
| | | cycleNo: number |
| | | recordCount: number |
| | | startedAt: string |
| | | endedAt: string |
| | | chargeCapacityAh: number |
| | | dischargeCapacityAh: number |
| | | chargeEnergyWh: number |
| | | dischargeEnergyWh: number |
| | | } |
| | | |
| | | async function getSimulatorChannelData<T>(deviceId: number, channelId: number, kind: 'records' | 'steps' | 'cycles'): Promise<T[]> { |
| | | const token = getAuthToken() |
| | | const response = await fetch(`${import.meta.env.VITE_API_BASE_URL || '/dev-api'}/dev/bts-simulator/devices/${deviceId}/channels/${channelId}/${kind}`, { headers: token ? { Authorization: `Bearer ${token}` } : undefined }) |
| | | if (!response.ok) throw new Error(`检测柜${kind}数据加载失败(${response.status})`) |
| | | const result = await response.json() as T[] |
| | | return Array.isArray(result) ? result : [] |
| | | } |
| | | |
| | | export function getBtsRecords(deviceId: number, channelId: number): Promise<BtsRecord[]> { |
| | | return getSimulatorChannelData<BtsRecord>(deviceId, channelId, 'records') |
| | | } |
| | | |
| | | export function getBtsSteps(deviceId: number, channelId: number): Promise<BtsStepRecord[]> { |
| | | return getSimulatorChannelData<BtsStepRecord>(deviceId, channelId, 'steps') |
| | | } |
| | | |
| | | export function getBtsCycles(deviceId: number, channelId: number): Promise<BtsCycleRecord[]> { |
| | | return getSimulatorChannelData<BtsCycleRecord>(deviceId, channelId, 'cycles') |
| | | } |
| | | |
| | | export type TestLiveEvent = 'snapshot' | 'device-status' | 'reception-status' | 'test-status' | 'exception' | 'integrity' | 'heartbeat' |
| | | |
| | | /** 使用 fetch 流读取鉴权 SSE;调用返回函数关闭连接,断线由页面决定是否重连。 */ |