|
|
@@ -1,5 +1,4 @@
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
|
-/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
|
import * as XLSX from 'xlsx';
|
|
|
import { ReadSectionData, LayoutSectionField, SectionTypeEnum, FieldTypeEnum, ImportProgress } from './types';
|
|
|
import { prisma } from '@/lib/prisma';
|
|
|
@@ -7,16 +6,16 @@ import { prisma } from '@/lib/prisma';
|
|
|
// Simple logger utility for debugging
|
|
|
const logger = {
|
|
|
debug: (message: string, ...args: any[]) => {
|
|
|
- //console.debug(`[DatabaseExcelReaderService] ${new Date().toISOString()} - ${message}`, ...args);
|
|
|
+ console.debug(`[DatabaseExcelReaderService] ${new Date().toISOString()} - ${message}`, ...args);
|
|
|
},
|
|
|
info: (message: string, ...args: any[]) => {
|
|
|
- //console.info(`[DatabaseExcelReaderService] ${new Date().toISOString()} - ${message}`, ...args);
|
|
|
+ console.info(`[DatabaseExcelReaderService] ${new Date().toISOString()} - ${message}`, ...args);
|
|
|
},
|
|
|
warn: (message: string, ...args: any[]) => {
|
|
|
- //console.warn(`[DatabaseExcelReaderService] ${new Date().toISOString()} - ${message}`, ...args);
|
|
|
+ console.warn(`[DatabaseExcelReaderService] ${new Date().toISOString()} - ${message}`, ...args);
|
|
|
},
|
|
|
error: (message: string, ...args: any[]) => {
|
|
|
- //console.error(`[DatabaseExcelReaderService] ${new Date().toISOString()} - ${message}`, ...args);
|
|
|
+ console.error(`[DatabaseExcelReaderService] ${new Date().toISOString()} - ${message}`, ...args);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -310,12 +309,12 @@ export class DatabaseExcelReaderService {
|
|
|
});
|
|
|
|
|
|
if (cellValue !== null && cellValue !== undefined && cellValue !== '') {
|
|
|
- console.log(field.name, field.dataType, field.dataTypeFormat, cellValue, field.parsedType);
|
|
|
const value = this.convertCellValue(
|
|
|
+ field.dataType,
|
|
|
+ field.dataTypeFormat,
|
|
|
cellValue,
|
|
|
field.parsedType || FieldTypeEnum.String
|
|
|
);
|
|
|
-
|
|
|
logger.debug(`Value converted`, {
|
|
|
fieldName: field.name,
|
|
|
originalValue: cellValue,
|
|
|
@@ -513,7 +512,7 @@ export class DatabaseExcelReaderService {
|
|
|
return mappedType;
|
|
|
}
|
|
|
|
|
|
- private convertCellValue(value: any, fieldType: FieldTypeEnum): any {
|
|
|
+ private convertCellValue(dataType: string, dataTypeFormat: string | undefined, value: any, fieldType: FieldTypeEnum): any {
|
|
|
if (value === null || value === undefined) {
|
|
|
logger.debug(`Converting null/undefined value to null`, { fieldType: FieldTypeEnum[fieldType] });
|
|
|
return null;
|
|
|
@@ -526,8 +525,9 @@ export class DatabaseExcelReaderService {
|
|
|
});
|
|
|
|
|
|
const convertedValue = (() => {
|
|
|
- if (fieldType === FieldTypeEnum.Date)
|
|
|
- console.log(value, fieldType);
|
|
|
+ if (dataType === "DATE")
|
|
|
+ return XLSX.SSF.format(dataTypeFormat || 'yyyy-mm-dd', value);
|
|
|
+
|
|
|
switch (fieldType) {
|
|
|
case FieldTypeEnum.Time:
|
|
|
if (typeof value === 'number') {
|