You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
5.8 KiB
TypeScript
83 lines
5.8 KiB
TypeScript
/** Mock 数据:采集日志模块
|
|
* 参考 alert.ts 的结构,提供 5 种端点的 Mock 数据
|
|
*/
|
|
import type { MockMethod } from './types'
|
|
|
|
interface CollectAnalysis {
|
|
id: number
|
|
analysisTime: string
|
|
collectAddressId: number
|
|
addressName?: string
|
|
machineId: number
|
|
machineName?: string
|
|
analysisType: string
|
|
previousProgram?: string
|
|
currentProgram?: string
|
|
partCountDelta?: number
|
|
analysisSummary?: string
|
|
}
|
|
|
|
interface CollectCycle {
|
|
id: number
|
|
cycleTime: string
|
|
collectAddressId: number
|
|
addressName?: string
|
|
totalMachines: number
|
|
successCount: number
|
|
failCount: number
|
|
hasAnomaly: number
|
|
changeDistribution?: string
|
|
cycleSummary?: string
|
|
}
|
|
|
|
interface CollectRaw {
|
|
id: number
|
|
logTime: string
|
|
sourceAddress?: string
|
|
contentPreview?: string
|
|
}
|
|
|
|
const analyses: CollectAnalysis[] = [
|
|
{ id: 1, analysisTime: '2026-05-05 10:30:00', collectAddressId: 1, addressName: 'FANUC-A栋', machineId: 1, machineName: '西-1.8', analysisType: 'NORMAL_UNCHANGED', previousProgram: 'O001', currentProgram: 'O002', partCountDelta: 0, analysisSummary: 'O001 → O002 程序切换后无产量变化' },
|
|
{ id: 2, analysisTime: '2026-05-05 11:15:00', collectAddressId: 1, addressName: 'FANUC-A栋', machineId: 2, machineName: '西-1.10', analysisType: 'PART_COUNT_INCREASE', previousProgram: 'O003', currentProgram: 'O004', partCountDelta: 25, analysisSummary: '产量增加,来自新作业' },
|
|
{ id: 3, analysisTime: '2026-05-05 12:05:00', collectAddressId: 2, addressName: 'FANUC-B栋', machineId: 3, machineName: '西-2.1', analysisType: 'PROGRAM_SWITCH', previousProgram: 'M5', currentProgram: 'M6', partCountDelta: -5, analysisSummary: '切换程序导致产量略降' },
|
|
{ id: 4, analysisTime: '2026-05-05 12:30:00', collectAddressId: 3, addressName: 'FANUC-C栋', machineId: 4, machineName: '东-3.2', analysisType: 'DEVICE_ONLINE', previousProgram: 'P10', currentProgram: 'P10', partCountDelta: 0, analysisSummary: '设备在线,正常运行' },
|
|
{ id: 5, analysisTime: '2026-05-05 13:01:00', collectAddressId: 1, addressName: 'FANUC-A栋', machineId: 1, machineName: '西-1.8', analysisType: 'DATA_ANOMALY', previousProgram: 'O001', currentProgram: 'O001', partCountDelta: 0, analysisSummary: '检测到产量异常,需人工复核' },
|
|
{ id: 6, analysisTime: '2026-05-05 14:22:00', collectAddressId: 2, addressName: 'FANUC-B栋', machineId: 6, machineName: '西-2.6', analysisType: 'COLLECTION_FAILED', previousProgram: 'O010', currentProgram: 'O010', partCountDelta: 0, analysisSummary: '日志采集失败' },
|
|
{ id: 7, analysisTime: '2026-05-05 15:40:00', collectAddressId: 2, addressName: 'FANUC-B栋', machineId: 7, machineName: '西-2.7', analysisType: 'NEW_DEVICE_FOUND', previousProgram: 'O222', currentProgram: 'O223', partCountDelta: 0, analysisSummary: '发现新设备并加入采集' },
|
|
{ id: 8, analysisTime: '2026-05-05 16:12:00', collectAddressId: 3, addressName: 'FANUC-C栋', machineId: 8, machineName: '东-3.4', analysisType: 'MANUAL_RESET', previousProgram: 'N/A', currentProgram: 'N/A', partCountDelta: 0, analysisSummary: '管理员手动重置状态' },
|
|
]
|
|
|
|
const cycles: CollectCycle[] = [
|
|
{ id: 1, cycleTime: '2026-05-05 10:30:00', collectAddressId: 1, addressName: 'FANUC-A栋', totalMachines: 8, successCount: 7, failCount: 1, hasAnomaly: 0, changeDistribution: '{"PROGRAM_SWITCH":2,"PART_COUNT_INCREASE":3,"NORMAL_UNCHANGED":3}', cycleSummary: '共8台机床完成分析' },
|
|
{ id: 2, cycleTime: '2026-05-05 11:30:00', collectAddressId: 1, addressName: 'FANUC-A栋', totalMachines: 8, successCount: 8, failCount: 0, hasAnomaly: 0, changeDistribution: '{"PROGRAM_SWITCH":0,"PART_COUNT_INCREASE":0,"NORMAL_UNCHANGED":8}', cycleSummary: '稳定分析周期' },
|
|
{ id: 3, cycleTime: '2026-05-05 13:00:00', collectAddressId: 2, addressName: 'FANUC-B栋', totalMachines: 5, successCount: 4, failCount: 1, hasAnomaly: 1, changeDistribution: '{"DATA_ANOMALY":1}', cycleSummary: '存在数据异常' },
|
|
{ id: 4, cycleTime: '2026-05-05 14:40:00', collectAddressId: 3, addressName: 'FANUC-C栋', totalMachines: 6, successCount: 6, failCount: 0, hasAnomaly: 0, cycleSummary: '全部机床完成' },
|
|
{ id: 5, cycleTime: '2026-05-05 15:20:00', collectAddressId: 1, addressName: 'FANUC-A栋', totalMachines: 8, successCount: 7, failCount: 1, hasAnomaly: 0, cycleSummary: '混合情况' },
|
|
]
|
|
|
|
const raws: CollectRaw[] = [
|
|
{ id: 1, logTime: '2026-05-05 10:28:12', sourceAddress: 'FANUC-A栋', contentPreview: '{"a":1,"b":2}' },
|
|
{ id: 2, logTime: '2026-05-05 11:29:45', sourceAddress: 'FANUC-B栋', contentPreview: '{"c":3,"d":4}' },
|
|
{ id: 3, logTime: '2026-05-05 12:31:02', sourceAddress: 'FANUC-C栋', contentPreview: '{"x":9,"y":8}' },
|
|
{ id: 4, logTime: '2026-05-05 13:45:10', sourceAddress: 'FANUC-A栋', contentPreview: '{"m":5}' },
|
|
{ id: 5, logTime: '2026-05-05 14:05:33', sourceAddress: 'FANUC-B栋', contentPreview: '{"n":6}' },
|
|
]
|
|
|
|
const mock: MockMethod[] = [
|
|
{ url: '/mock-api/admin/collect-log/analysis', method: 'get', response: () => ({ code: 0, data: { items: analyses, total: analyses.length, page: 1, pageSize: 20 } }) },
|
|
{ url: '/mock-api/admin/collect-log/analysis/:id', method: 'get', response: (req) => {
|
|
const id = Number(req.params.id)
|
|
const item = analyses.find(a => a.id === id)
|
|
return { code: 0, data: item || {} }
|
|
} },
|
|
{ url: '/mock-api/admin/collect-log/analysis/by-raw/:rawLogId', method: 'get', response: (req) => {
|
|
// 简单模拟:返回全部分析供查看关联
|
|
return { code: 0, data: { items: analyses } }
|
|
} },
|
|
{ url: '/mock-api/admin/collect-log/cycle', method: 'get', response: () => ({ code: 0, data: { items: cycles, total: cycles.length, page: 1, pageSize: 20 } }) },
|
|
{ url: '/mock-api/admin/collect-log/raw', method: 'get', response: () => ({ code: 0, data: { items: raws, total: raws.length, page: 1, pageSize: 20 } }) },
|
|
]
|
|
|
|
export default mock
|