feat(extractor): add operation history tracking
Add a new operation history feature for the extractor module that tracks all extraction operations with persistent database storage. Features: - Records extraction operations with batch tracking (UUID-based) - Preserves production ID to order number mapping - Shows batch statistics (orders, records, success/failure counts) - Expandable details for each batch showing individual order records - User-based permission: Admin sees all records, User sees own records only - Delete functionality with permission validation Database: - New ExtractorOperationHistory table schema - Supports both SQL Server and MySQL - Indexed on BatchId, UserId, and OperationTime Files: - Add DAO class for history operations - Add IPC handler with permission checks - Add preload API wrapper - Add React modal component with expandable batch details - Integrate history recording into extractor handler - Add operation history button to ExtractorPage Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
} from './materials'
|
||||
import { loggerApi } from './logger'
|
||||
import { playwrightBrowserApi } from './browser-download'
|
||||
import { operationHistoryApi } from './operation-history'
|
||||
|
||||
export const api = {
|
||||
process: processApi,
|
||||
@@ -35,7 +36,8 @@ export const api = {
|
||||
logger: loggerApi,
|
||||
report: reportApi,
|
||||
update: updateApi,
|
||||
playwrightBrowser: playwrightBrowserApi
|
||||
playwrightBrowser: playwrightBrowserApi,
|
||||
operationHistory: operationHistoryApi
|
||||
} as const
|
||||
|
||||
export type ElectronApi = typeof api
|
||||
|
||||
30
src/preload/api/operation-history.ts
Normal file
30
src/preload/api/operation-history.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { IPC_CHANNELS } from '../../shared/ipc-channels'
|
||||
import { invokeIpc } from '../lib/ipc'
|
||||
import type {
|
||||
BatchStats,
|
||||
OperationHistoryRecord,
|
||||
GetBatchesOptions
|
||||
} from '../../main/types/operation-history.types'
|
||||
import type { IpcResult } from '../../main/types/ipc.types'
|
||||
|
||||
export const operationHistoryApi = {
|
||||
/**
|
||||
* Get list of operation batches
|
||||
* Admin users receive all batches, regular users only their own
|
||||
*/
|
||||
getBatches: (options?: GetBatchesOptions): Promise<IpcResult<BatchStats[]>> =>
|
||||
invokeIpc(IPC_CHANNELS.OPERATION_HISTORY_GET_BATCHES, options),
|
||||
|
||||
/**
|
||||
* Get detailed records for a specific batch
|
||||
*/
|
||||
getBatchDetails: (batchId: string): Promise<IpcResult<OperationHistoryRecord[]>> =>
|
||||
invokeIpc(IPC_CHANNELS.OPERATION_HISTORY_GET_BATCH_DETAILS, batchId),
|
||||
|
||||
/**
|
||||
* Delete a batch
|
||||
* Admin users can delete any batch, regular users only their own
|
||||
*/
|
||||
deleteBatch: (batchId: string): Promise<IpcResult<{ deleted: boolean }>> =>
|
||||
invokeIpc(IPC_CHANNELS.OPERATION_HISTORY_DELETE_BATCH, batchId)
|
||||
} as const
|
||||
32
src/preload/index.d.ts
vendored
32
src/preload/index.d.ts
vendored
@@ -157,6 +157,37 @@ export interface PlaywrightBrowserAPI {
|
||||
onProgress: (callback: (data: DownloadProgress) => void) => () => void
|
||||
}
|
||||
|
||||
export interface OperationHistoryAPI {
|
||||
getBatches: (options?: { limit?: number; offset?: number }) => Promise<IpcResult<BatchStats[]>>
|
||||
getBatchDetails: (batchId: string) => Promise<IpcResult<OperationHistoryRecord[]>>
|
||||
deleteBatch: (batchId: string) => Promise<IpcResult<{ deleted: boolean }>>
|
||||
}
|
||||
|
||||
export interface BatchStats {
|
||||
batchId: string
|
||||
userId: number
|
||||
username: string
|
||||
operationTime: string
|
||||
status: string
|
||||
totalOrders: number
|
||||
totalRecords: number
|
||||
successCount: number
|
||||
failedCount: number
|
||||
}
|
||||
|
||||
export interface OperationHistoryRecord {
|
||||
id?: number
|
||||
batchId: string
|
||||
userId: number
|
||||
username: string
|
||||
productionId: string | null
|
||||
orderNumber: string
|
||||
operationTime: Date
|
||||
status: string
|
||||
recordCount: number | null
|
||||
errorMessage: string | null
|
||||
}
|
||||
|
||||
export interface ProcessAPI {
|
||||
versions: {
|
||||
electron: string
|
||||
@@ -185,6 +216,7 @@ declare global {
|
||||
report: ReportAPI
|
||||
update: UpdateAPI
|
||||
playwrightBrowser: PlaywrightBrowserAPI
|
||||
operationHistory: OperationHistoryAPI
|
||||
}
|
||||
api: unknown
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user