diff --git a/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java b/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java index 9a7ba2f7ac..df05e2cdc7 100644 --- a/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java +++ b/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java @@ -1,6 +1,7 @@ package io.dataease.controller.request.dataset; import io.dataease.base.domain.DatasetTable; +import io.dataease.datasource.dto.TableFiled; import lombok.Getter; import lombok.Setter; @@ -21,4 +22,5 @@ public class DataSetTableRequest extends DatasetTable { private Integer editType; private Boolean isRename; private List typeFilter; + private List fields; } diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 836e3b4435..b76cb15f64 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -97,7 +97,7 @@ public class DataSetTableService { } } - private void extractData(DataSetTableRequest datasetTable) throws Exception{ + private void extractData(DataSetTableRequest datasetTable) throws Exception { if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) { commonThreadPool.addTask(() -> { extractDataService.extractExcelData(datasetTable.getId(), "all_scope"); @@ -154,7 +154,7 @@ public class DataSetTableService { }); } else if (datasetTable.getEditType() == 1) { commonThreadPool.addTask(() -> { - extractDataService.extractExcelData(datasetTable.getId(), "add_scope"); + extractDataService.extractExcelData(datasetTable.getId(), "add_scope"); }); } } @@ -664,11 +664,12 @@ public class DataSetTableService { datasourceRequest.setQuery(sqlAsTable); fields = datasourceProvider.fetchResultField(datasourceRequest); } else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) { - DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class); + /*DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class); String path = dataTableInfoDTO.getData(); File file = new File(path); Map map = parseExcel(path.substring(path.lastIndexOf("/") + 1), new FileInputStream(file), false); - fields = (List) map.get("fields"); + fields = (List) map.get("fields");*/ + fields = dataSetTableRequest.getFields(); } else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom")) { // save field DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class); @@ -882,7 +883,7 @@ public class DataSetTableService { String filename = file.getOriginalFilename(); // parse file Map fileMap = parseExcel(filename, file.getInputStream(), true); - if(StringUtils.isNotEmpty(tableId)){ + if (StringUtils.isNotEmpty(tableId)) { List datasetTableFields = dataSetTableFieldsService.getFieldsByTableId(tableId); datasetTableFields.sort((o1, o2) -> { if (o1.getColumnIndex() == null) { @@ -893,9 +894,9 @@ public class DataSetTableService { } return o1.getColumnIndex().compareTo(o2.getColumnIndex()); }); - List fields = (List)fileMap.get("fields"); + List fields = (List) fileMap.get("fields"); List newFields = fields.stream().map(TableFiled::getRemarks).collect(Collectors.toList()); - List oldFields = datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.toList()); + List oldFields = datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.toList()); if (!oldFields.equals(newFields)) { DataEaseException.throwException(Translator.get("i18n_excel_colume_change")); } @@ -1073,7 +1074,7 @@ public class DataSetTableService { double eps = 1e-10; if (value - Math.floor(value) < eps) { if (cellType) { - if (StringUtils.isEmpty(tableFiled.getFieldType()) || tableFiled.getFieldType().equalsIgnoreCase("TEXT")){ + if (StringUtils.isEmpty(tableFiled.getFieldType()) || tableFiled.getFieldType().equalsIgnoreCase("TEXT")) { tableFiled.setFieldType("LONG"); } } @@ -1124,7 +1125,7 @@ public class DataSetTableService { double eps = 1e-10; if (value - Math.floor(value) < eps) { if (cellType) { - if (StringUtils.isEmpty(tableFiled.getFieldType()) || tableFiled.getFieldType().equalsIgnoreCase("TEXT")){ + if (StringUtils.isEmpty(tableFiled.getFieldType()) || tableFiled.getFieldType().equalsIgnoreCase("TEXT")) { tableFiled.setFieldType("LONG"); } } diff --git a/frontend/src/views/dataset/add/AddExcel.vue b/frontend/src/views/dataset/add/AddExcel.vue index 6a53b3275f..40de024f65 100644 --- a/frontend/src/views/dataset/add/AddExcel.vue +++ b/frontend/src/views/dataset/add/AddExcel.vue @@ -69,7 +69,52 @@ :field="field.fieldName" :title="field.remarks" :resizable="true" - /> + > + + @@ -109,7 +154,13 @@ export default { headers: { Authorization: token, 'Accept-Language': i18n.locale.replace('_', '-') }, baseUrl: process.env.VUE_APP_BASE_API, path: '', - uploading: false + uploading: false, + fieldOptions: [ + { label: this.$t('dataset.text'), value: 'TEXT' }, + { label: this.$t('dataset.time'), value: 'DATETIME' }, + { label: this.$t('dataset.value'), value: 'LONG' }, + { label: this.$t('dataset.value') + '(' + this.$t('dataset.float') + ')', value: 'DOUBLE' } + ] } }, watch: { @@ -207,7 +258,8 @@ export default { type: 'excel', mode: parseInt(this.mode), // info: '{"data":"' + this.path + '"}', - info: JSON.stringify({ data: this.path }) + info: JSON.stringify({ data: this.path }), + fields: this.fields } } else { table = {