fix(types): resolve TypeScript unused variable errors
Fix all TS6133 errors (unused variables) across service layer: - Remove unused imports (path, ExtractionProgress type) - Prefix unused parameters with underscore (_session, _totalBatches, etc.) - Remove unused _verbose field and constructor from ExcelParser - Remove unused _importToDatabase method from ExtractorService - Remove unused _importProgress variable This ensures clean type checking and eliminates dead code. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
* 4. Batch insert new records
|
* 4. Batch insert new records
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import path from 'path'
|
|
||||||
import { createLogger } from '../logger'
|
import { createLogger } from '../logger'
|
||||||
import { DiscreteMaterialPlanDAO, type MaterialPlanRecord } from './discrete-material-plan-dao'
|
import { DiscreteMaterialPlanDAO, type MaterialPlanRecord } from './discrete-material-plan-dao'
|
||||||
|
|
||||||
|
|||||||
@@ -577,7 +577,7 @@ export class DiscreteMaterialPlanDAO {
|
|||||||
private buildRowValues(
|
private buildRowValues(
|
||||||
record: MaterialPlanRecord,
|
record: MaterialPlanRecord,
|
||||||
columns: string[],
|
columns: string[],
|
||||||
rowIndex: number,
|
_rowIndex: number,
|
||||||
isSqlServer: boolean,
|
isSqlServer: boolean,
|
||||||
values: any[]
|
values: any[]
|
||||||
): string[] {
|
): string[] {
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ import type {
|
|||||||
ExtractorCoreResult,
|
ExtractorCoreResult,
|
||||||
ExtractionProgress
|
ExtractionProgress
|
||||||
} from '../../types/extractor.types'
|
} from '../../types/extractor.types'
|
||||||
import { createLogger } from '../logger'
|
|
||||||
|
|
||||||
const log = createLogger('ExtractorCore')
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExtractorCore - Handles all web page operations for data extraction
|
* ExtractorCore - Handles all web page operations for data extraction
|
||||||
@@ -142,12 +139,12 @@ export class ExtractorCore {
|
|||||||
* Reference: Python download_batch() method lines 133-175
|
* Reference: Python download_batch() method lines 133-175
|
||||||
*/
|
*/
|
||||||
private async downloadBatch(
|
private async downloadBatch(
|
||||||
session: ErpSession,
|
_session: ErpSession,
|
||||||
popupPage: any,
|
popupPage: any,
|
||||||
workFrame: any,
|
workFrame: any,
|
||||||
orderNumbers: string[],
|
orderNumbers: string[],
|
||||||
batchIndex: number,
|
batchIndex: number,
|
||||||
totalBatches: number,
|
_totalBatches: number,
|
||||||
downloadDir: string
|
downloadDir: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
// Fill order numbers (Python lines 143-145)
|
// Fill order numbers (Python lines 143-145)
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import type {
|
|||||||
ExtractorInput,
|
ExtractorInput,
|
||||||
ExtractorResult,
|
ExtractorResult,
|
||||||
ImportResult,
|
ImportResult,
|
||||||
LogLevel,
|
LogLevel
|
||||||
ExtractionProgress
|
|
||||||
} from '../../types/extractor.types'
|
} from '../../types/extractor.types'
|
||||||
import { DataImportService } from '../database/data-importer'
|
import { DataImportService } from '../database/data-importer'
|
||||||
import { createLogger } from '../logger'
|
import { createLogger } from '../logger'
|
||||||
@@ -72,7 +71,6 @@ export class ExtractorService {
|
|||||||
const totalPoints = 1 + totalBatches + 2
|
const totalPoints = 1 + totalBatches + 2
|
||||||
const progressPerPoint = 100 / totalPoints
|
const progressPerPoint = 100 / totalPoints
|
||||||
const mergeProgress = (1 + totalBatches) * progressPerPoint
|
const mergeProgress = (1 + totalBatches) * progressPerPoint
|
||||||
const importProgress = (1 + totalBatches + 1) * progressPerPoint
|
|
||||||
|
|
||||||
input.onProgress?.('正在合并文件...', mergeProgress, {
|
input.onProgress?.('正在合并文件...', mergeProgress, {
|
||||||
phase: 'merging',
|
phase: 'merging',
|
||||||
@@ -131,7 +129,7 @@ export class ExtractorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info('Starting merge', { fileCount: filePaths.length })
|
log.info('Starting merge', { fileCount: filePaths.length })
|
||||||
const parser = new ExcelParser({ verbose: true })
|
const parser = new ExcelParser()
|
||||||
|
|
||||||
// Collect all orders with full order info and materials
|
// Collect all orders with full order info and materials
|
||||||
// Each order has: { orderInfo: OrderHeader, materials: MaterialRow[] }
|
// Each order has: { orderInfo: OrderHeader, materials: MaterialRow[] }
|
||||||
@@ -306,42 +304,6 @@ export class ExtractorService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Import merged Excel data to database
|
|
||||||
* @param filePath - Path to the merged Excel file
|
|
||||||
* @returns Import result with statistics
|
|
||||||
*/
|
|
||||||
private async importToDatabase(filePath: string): Promise<ImportResult> {
|
|
||||||
log.info('Starting database import', { filePath })
|
|
||||||
|
|
||||||
const importService = new DataImportService()
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await importService.importFromExcel(filePath, 1000)
|
|
||||||
|
|
||||||
log.info('Import completed', {
|
|
||||||
success: result.success,
|
|
||||||
recordsRead: result.recordsRead,
|
|
||||||
recordsDeleted: result.recordsDeleted,
|
|
||||||
recordsImported: result.recordsImported
|
|
||||||
})
|
|
||||||
|
|
||||||
return result
|
|
||||||
} catch (error) {
|
|
||||||
const errorMsg = error instanceof Error ? error.message : String(error)
|
|
||||||
log.error('Import failed', { error: errorMsg })
|
|
||||||
|
|
||||||
return {
|
|
||||||
success: false,
|
|
||||||
recordsRead: 0,
|
|
||||||
recordsDeleted: 0,
|
|
||||||
recordsImported: 0,
|
|
||||||
uniqueSourceNumbers: 0,
|
|
||||||
errors: [errorMsg]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import merged Excel data to database with logging
|
* Import merged Excel data to database with logging
|
||||||
* @param filePath - Path to the merged Excel file
|
* @param filePath - Path to the merged Excel file
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import ExcelJS from 'exceljs'
|
import ExcelJS from 'exceljs'
|
||||||
import type { DiscreteMaterialPlan, ExcelParseOptions, OrderHeader } from '../../types/excel.types'
|
import type { DiscreteMaterialPlan, ExcelParseOptions, OrderHeader } from '../../types/excel.types'
|
||||||
import path from 'path'
|
|
||||||
import { createLogger } from '../logger'
|
import { createLogger } from '../logger'
|
||||||
|
|
||||||
const log = createLogger('ExcelParser')
|
const log = createLogger('ExcelParser')
|
||||||
@@ -53,12 +52,6 @@ export class ExcelParser {
|
|||||||
产品单位: 'unit'
|
产品单位: 'unit'
|
||||||
}
|
}
|
||||||
|
|
||||||
private verbose: boolean
|
|
||||||
|
|
||||||
constructor(options: ExcelParseOptions = {}) {
|
|
||||||
this.verbose = options.verbose || false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse Excel file and extract material plans
|
* Parse Excel file and extract material plans
|
||||||
*/
|
*/
|
||||||
@@ -77,7 +70,7 @@ export class ExcelParser {
|
|||||||
const allRows: any[][] = []
|
const allRows: any[][] = []
|
||||||
|
|
||||||
// Read all rows into memory
|
// Read all rows into memory
|
||||||
worksheet.eachRow((row, rowNumber) => {
|
worksheet.eachRow((row, _rowNumber) => {
|
||||||
allRows.push(row.values as any[])
|
allRows.push(row.values as any[])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user