fix: 保存 excel 数据集的字段出错

This commit is contained in:
taojinlong 2021-05-18 15:17:57 +08:00
parent f07065b6f2
commit 314d886b2c

View File

@ -481,10 +481,8 @@ public class DataSetTableService {
DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class); DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class);
String path = dataTableInfoDTO.getData(); String path = dataTableInfoDTO.getData();
File file = new File(path); File file = new File(path);
// save field
Map<String, Object> map = parseExcel(path.substring(path.lastIndexOf("/") + 1), new FileInputStream(file), false); Map<String, Object> map = parseExcel(path.substring(path.lastIndexOf("/") + 1), new FileInputStream(file), false);
fields = (List<TableFiled>) map.get("fields"); fields = (List<TableFiled>) map.get("fields");
// List<Map<String, Object>> data = (List<Map<String, Object>>) map.get("data");
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom")) { } else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "custom")) {
// save field // save field
DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class); DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class);
@ -508,7 +506,10 @@ public class DataSetTableService {
createDorisView(DorisTableUtils.dorisName(datasetTable.getId()), getCustomSQL(dataTableInfoDTO, dataSetTableUnionService.listByTableId(dataTableInfoDTO.getList().get(0).getTableId()))); createDorisView(DorisTableUtils.dorisName(datasetTable.getId()), getCustomSQL(dataTableInfoDTO, dataSetTableUnionService.listByTableId(dataTableInfoDTO.getList().get(0).getTableId())));
return; return;
} }
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); QueryProvider qp = null;
if(!ObjectUtils.isEmpty(ds)) {
qp = ProviderFactory.getQueryProvider(ds.getType());
}
if (CollectionUtils.isNotEmpty(fields)) { if (CollectionUtils.isNotEmpty(fields)) {
for (int i = 0; i < fields.size(); i++) { for (int i = 0; i < fields.size(); i++) {
TableFiled filed = fields.get(i); TableFiled filed = fields.get(i);
@ -670,6 +671,9 @@ public class DataSetTableService {
tableFiled.setFieldName(readCell(row.getCell(j))); tableFiled.setFieldName(readCell(row.getCell(j)));
tableFiled.setRemarks(readCell(row.getCell(j))); tableFiled.setRemarks(readCell(row.getCell(j)));
tableFiled.setFieldType("TEXT"); tableFiled.setFieldType("TEXT");
if(StringUtils.isEmpty(tableFiled.getFieldName())){
continue;
}
fields.add(tableFiled); fields.add(tableFiled);
} else { } else {
r[j] = readCell(row.getCell(j)); r[j] = readCell(row.getCell(j));