Parcourir la source

refactor(cintas-import): remove automatic summary generation after data import

- Removed automatic summary generation call from calendar summary page
- Eliminated stored procedure execution for summary calculation in import processor
- Updated step status logic to reflect new import flow without summary generation
- Simplified import completion handling by removing summary-related dependencies
vtugulan il y a 6 mois
Parent
commit
adcda6fc74

+ 1 - 3
app/cintas-calendar-summary/page.tsx

@@ -74,8 +74,6 @@ export default function CintasCalendarSummaryPage() {
 
       if (result.success) {
         setCurrentStep(4);
-        // After processing, fetch the summary data
-        await handleGenerateSummary();
       } else {
         setError(result.error || 'Failed to process import data');
       }
@@ -130,7 +128,7 @@ export default function CintasCalendarSummaryPage() {
       title: 'Import Data',
       description: 'Read the Excel file and import data into PostgreSQL database',
       icon: Database,
-      status: currentStep >= 3 ? (summaryData.length > 0 ? 'completed' : 'pending') : 'disabled',
+      status: currentStep > 3 ? 'completed' : (currentStep === 3 ? 'pending' : 'disabled'),
     },
     {
       id: 4,

+ 10 - 22
app/lib/excel-import/database-cintas-import-processor.ts

@@ -21,7 +21,7 @@ export class DatabaseCintasImportProcessor {
   async processCintasImport(importId: number): Promise<ImportResult> {
     try {
       console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Starting import processing for ID: ${importId}`);
-      
+
       // Initialize the progress server if not already done
       if (!this.progressServer.isServerInitialized()) {
         this.progressServer.initialize();
@@ -61,7 +61,7 @@ export class DatabaseCintasImportProcessor {
 
       // Read Excel file directly from database
       console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Starting Excel file reading from database...`);
-      
+
       const sections = await this.reader.readExcelFromDatabase(
         importRecord.fileId!,
         importRecord.layout,
@@ -78,8 +78,8 @@ export class DatabaseCintasImportProcessor {
 
       for (let i = 0; i < sections.length; i++) {
         const section = sections[i];
-        
-        console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Processing section ${i+1}/${sections.length}: ${section.name}`);
+
+        console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Processing section ${i + 1}/${sections.length}: ${section.name}`);
         progress.currentSection = section.name;
         progress.processedSections = i + 1;
         this.progressServer.broadcastProgress(importId, progress);
@@ -88,7 +88,7 @@ export class DatabaseCintasImportProcessor {
           // Ensure table exists for this section
           console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Creating table ${section.tableName} for section ${section.name}`);
           await this.inserter.createImportTable(section.tableName, section.fields);
-          
+
           const insertedRows = await this.inserter.insertSectionData(
             section,
             importId,
@@ -114,18 +114,6 @@ export class DatabaseCintasImportProcessor {
         }
       }
 
-      // Run the stored procedure to calculate summary
-      console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Running summary calculation procedure...`);
-      try {
-        await this.prisma.$executeRawUnsafe(
-          `CALL cintas_calculate_summary(${importId})`
-        );
-        console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Summary calculation completed successfully`);
-      } catch (error) {
-        console.error(`[${new Date().toISOString()}] [DatabaseCintasImport] ERROR: Summary calculation failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
-        progress.errors.push(`Stored procedure error: ${error instanceof Error ? error.message : 'Unknown error'}`);
-      }
-
       progress.status = 'completed';
       this.progressServer.broadcastProgress(importId, progress);
       console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Import processing completed successfully. Total inserted: ${totalInserted}`);
@@ -167,7 +155,7 @@ export class DatabaseCintasImportProcessor {
   ): Promise<ImportResult> {
     try {
       console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Starting import processing from buffer`);
-      
+
       // Initialize progress tracking
       const progress: ImportProgress = {
         importId: 0,
@@ -182,7 +170,7 @@ export class DatabaseCintasImportProcessor {
 
       // Read Excel file directly from buffer
       console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Starting Excel file reading from buffer...`);
-      
+
       const sections = await this.reader.readExcelFromBuffer(
         buffer,
         layoutConfig,
@@ -199,8 +187,8 @@ export class DatabaseCintasImportProcessor {
 
       for (let i = 0; i < sections.length; i++) {
         const section = sections[i];
-        
-        console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Processing section ${i+1}/${sections.length}: ${section.name}`);
+
+        console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Processing section ${i + 1}/${sections.length}: ${section.name}`);
         progress.currentSection = section.name;
         progress.processedSections = i + 1;
         onProgress(progress);
@@ -209,7 +197,7 @@ export class DatabaseCintasImportProcessor {
           // Ensure table exists for this section
           console.log(`[${new Date().toISOString()}] [DatabaseCintasImport] Creating table ${section.tableName} for section ${section.name}`);
           await this.inserter.createImportTable(section.tableName, section.fields);
-          
+
           const insertedRows = await this.inserter.insertSectionData(
             section,
             0, // Use 0 for buffer-based imports