...
|
...
|
@@ -31,6 +31,12 @@ func (ptr *PreviewDataTableService) Preview(ctx *domain.Context, fileId int, fie |
|
|
if tempFile, _ := fileCache.Get(redis.KeyTemporaryFileInfo(fileId)); tempFile != nil {
|
|
|
isSourceFile = false
|
|
|
fields = tempFile.Fields
|
|
|
} else if file.FileInfo.TableId > 0 {
|
|
|
tableRepository, _ := repository.NewTableRepository(ptr.transactionContext)
|
|
|
table, _ := tableRepository.FindOne(map[string]interface{}{"tableId": file.FileInfo.TableId})
|
|
|
if table != nil {
|
|
|
fields = table.Fields(false)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Load Data From Excel(python api)
|
...
|
...
|
@@ -52,8 +58,11 @@ func (ptr *PreviewDataTableService) Preview(ctx *domain.Context, fileId int, fie |
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if len(fields) == 0 {
|
|
|
fields = response.Fields
|
|
|
}
|
|
|
cache := redis.NewFileCacheService()
|
|
|
tempFile, err := cache.Update(redis.KeyTemporaryFileInfo(file.FileId), file, response.Fields, response.Total)
|
|
|
tempFile, err := cache.Update(redis.KeyTemporaryFileInfo(file.FileId), file, fields, response.Total)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -92,7 +101,15 @@ func (d *FilePreviewDto) Load(fileId int, m *domain.DataLoadDataTable, file *red |
|
|
d.ObjectId = fileId
|
|
|
d.ObjectType = domain.ObjectFile
|
|
|
d.TableType = domain.ExcelTable.ToString()
|
|
|
d.Fields = m.Fields
|
|
|
for i, f := range file.Fields {
|
|
|
d.Fields = append(d.Fields, &domain.Field{
|
|
|
Index: i + 1,
|
|
|
Name: f.Name,
|
|
|
SQLName: f.Name,
|
|
|
SQLType: f.SQLType,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
var fields []*domain.Field
|
|
|
mapData := domain.ToFieldData(m.Fields, formatData(m.Data, func(s string) string {
|
|
|
if s == "<NA>" {
|
...
|
...
|
@@ -103,7 +120,7 @@ func (d *FilePreviewDto) Load(fileId int, m *domain.DataLoadDataTable, file *red |
|
|
d.Data = domain.GripData(mapData, int64(m.Total))
|
|
|
d.PageNumber = m.PageNumber
|
|
|
|
|
|
for _, f := range m.Fields {
|
|
|
for _, f := range file.Fields {
|
|
|
copyField := f.Copy()
|
|
|
for _, e := range file.ConvertTypeErrors {
|
|
|
if e.FieldName == copyField.Name {
|
...
|
...
|
|