fix: Excel数据集重复字段提示优化
This commit is contained in:
parent
fcc2646b3c
commit
b3a8446156
@ -218,9 +218,7 @@ public class DataSetTableService {
|
|||||||
excelSheetDataList.forEach(excelSheetData -> {
|
excelSheetDataList.forEach(excelSheetData -> {
|
||||||
String[] fieldArray = excelSheetData.getFields().stream().map(TableField::getFieldName)
|
String[] fieldArray = excelSheetData.getFields().stream().map(TableField::getFieldName)
|
||||||
.toArray(String[]::new);
|
.toArray(String[]::new);
|
||||||
if (checkIsRepeat(fieldArray)) {
|
checkIsRepeat(fieldArray);
|
||||||
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
|
|
||||||
}
|
|
||||||
excelSheetData.setData(null);
|
excelSheetData.setData(null);
|
||||||
excelSheetData.setJsonArray(null);
|
excelSheetData.setJsonArray(null);
|
||||||
});
|
});
|
||||||
@ -254,9 +252,7 @@ public class DataSetTableService {
|
|||||||
for (ExcelSheetData sheet : datasetTable.getSheets()) {
|
for (ExcelSheetData sheet : datasetTable.getSheets()) {
|
||||||
String[] fieldArray = sheet.getFields().stream().map(TableField::getFieldName)
|
String[] fieldArray = sheet.getFields().stream().map(TableField::getFieldName)
|
||||||
.toArray(String[]::new);
|
.toArray(String[]::new);
|
||||||
if (checkIsRepeat(fieldArray)) {
|
checkIsRepeat(fieldArray);
|
||||||
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ExcelSheetData sheet : datasetTable.getSheets()) {
|
for (ExcelSheetData sheet : datasetTable.getSheets()) {
|
||||||
@ -304,9 +300,7 @@ public class DataSetTableService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String[] fieldArray = sheet.getFields().stream().map(TableField::getFieldName).toArray(String[]::new);
|
String[] fieldArray = sheet.getFields().stream().map(TableField::getFieldName).toArray(String[]::new);
|
||||||
if (checkIsRepeat(fieldArray)) {
|
checkIsRepeat(fieldArray);
|
||||||
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
|
|
||||||
}
|
|
||||||
sheet.setData(null);
|
sheet.setData(null);
|
||||||
sheet.setJsonArray(null);
|
sheet.setJsonArray(null);
|
||||||
excelSheetDataList.add(sheet);
|
excelSheetDataList.add(sheet);
|
||||||
@ -1221,9 +1215,7 @@ public class DataSetTableService {
|
|||||||
List<String[]> data = result.get("dataList");
|
List<String[]> data = result.get("dataList");
|
||||||
List<TableField> fields = result.get("fieldList");
|
List<TableField> fields = result.get("fieldList");
|
||||||
String[] fieldArray = fields.stream().map(TableField::getFieldName).toArray(String[]::new);
|
String[] fieldArray = fields.stream().map(TableField::getFieldName).toArray(String[]::new);
|
||||||
if (checkIsRepeat(fieldArray)) {
|
checkIsRepeat(fieldArray);
|
||||||
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
|
|
||||||
}
|
|
||||||
List<Map<String, Object>> jsonArray = new ArrayList<>();
|
List<Map<String, Object>> jsonArray = new ArrayList<>();
|
||||||
if (CollectionUtils.isNotEmpty(data)) {
|
if (CollectionUtils.isNotEmpty(data)) {
|
||||||
jsonArray = data.stream().map(ele -> {
|
jsonArray = data.stream().map(ele -> {
|
||||||
@ -1305,9 +1297,7 @@ public class DataSetTableService {
|
|||||||
List<String[]> data = result.get("dataList");
|
List<String[]> data = result.get("dataList");
|
||||||
List<TableField> fields = result.get("fieldList");
|
List<TableField> fields = result.get("fieldList");
|
||||||
String[] fieldArray = fields.stream().map(TableField::getFieldName).toArray(String[]::new);
|
String[] fieldArray = fields.stream().map(TableField::getFieldName).toArray(String[]::new);
|
||||||
if (checkIsRepeat(fieldArray)) {
|
checkIsRepeat(fieldArray);
|
||||||
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat"));
|
|
||||||
}
|
|
||||||
List<Map<String, Object>> jsonArray = new ArrayList<>();
|
List<Map<String, Object>> jsonArray = new ArrayList<>();
|
||||||
if (CollectionUtils.isNotEmpty(data)) {
|
if (CollectionUtils.isNotEmpty(data)) {
|
||||||
jsonArray = data.stream().map(ele -> {
|
jsonArray = data.stream().map(ele -> {
|
||||||
@ -2755,15 +2745,22 @@ public class DataSetTableService {
|
|||||||
/*
|
/*
|
||||||
* 判断数组中是否有重复的值
|
* 判断数组中是否有重复的值
|
||||||
*/
|
*/
|
||||||
public static boolean checkIsRepeat(String[] array) {
|
public static void checkIsRepeat(String[] array) {
|
||||||
HashSet<String> hashSet = new HashSet<>();
|
HashSet<String> hashSet = new HashSet<>();
|
||||||
|
HashSet<String> repeat = new HashSet<>();
|
||||||
for (String s : array) {
|
for (String s : array) {
|
||||||
if (StringUtils.isEmpty(s)) {
|
if (StringUtils.isEmpty(s)) {
|
||||||
throw new RuntimeException(Translator.get("i18n_excel_empty_column"));
|
throw new RuntimeException(Translator.get("i18n_excel_empty_column"));
|
||||||
}
|
}
|
||||||
hashSet.add(s);
|
if(hashSet.contains(s)){
|
||||||
|
repeat.add(s);
|
||||||
|
}else {
|
||||||
|
hashSet.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(CollectionUtils.isNotEmpty(repeat)){
|
||||||
|
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat") + ": " + String.valueOf(repeat));
|
||||||
}
|
}
|
||||||
return hashSet.size() != array.length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetTable syncDatasetTableField(String id) throws Exception {
|
public DatasetTable syncDatasetTableField(String id) throws Exception {
|
||||||
|
|||||||
@ -92,7 +92,7 @@ i18n_sql_add_not_matching=The data column of incremental SQL does not match the
|
|||||||
i18n_sql_delete_not_matching=The data column of incremental delete SQL does not match the dataset,
|
i18n_sql_delete_not_matching=The data column of incremental delete SQL does not match the dataset,
|
||||||
i18n_cst_ds_tb_or_field_deleted=Custom dataset union data is deleted or field changed,can not display
|
i18n_cst_ds_tb_or_field_deleted=Custom dataset union data is deleted or field changed,can not display
|
||||||
i18n_no_all_delete_privilege_folder=This folder have sources which have no manage or view privilege,Can Not Be Deleted.
|
i18n_no_all_delete_privilege_folder=This folder have sources which have no manage or view privilege,Can Not Be Deleted.
|
||||||
i18n_excel_field_repeat=Duplicate fields exist, please modify and try again.
|
i18n_excel_field_repeat=Duplicate fields exist:
|
||||||
i18n_schema_is_empty=Database schema is empty
|
i18n_schema_is_empty=Database schema is empty
|
||||||
\u7AD9\u5185\u6D88\u606F=Messages Center
|
\u7AD9\u5185\u6D88\u606F=Messages Center
|
||||||
\u6240\u6709\u6D88\u606F=All Messages
|
\u6240\u6709\u6D88\u606F=All Messages
|
||||||
|
|||||||
@ -92,7 +92,7 @@ i18n_sql_add_not_matching=\u589E\u91CF\u6DFB\u52A0 SQL \u7684\u6570\u636E\u5217\
|
|||||||
i18n_sql_delete_not_matching=\u589E\u91CF\u5220\u9664 SQL \u7684\u6570\u636E\u5217\u4E0E\u6570\u636E\u96C6\u4E0D\u5339\u914D,
|
i18n_sql_delete_not_matching=\u589E\u91CF\u5220\u9664 SQL \u7684\u6570\u636E\u5217\u4E0E\u6570\u636E\u96C6\u4E0D\u5339\u914D,
|
||||||
i18n_cst_ds_tb_or_field_deleted=\u81EA\u5B9A\u4E49\u6570\u636E\u96C6\u6240\u5173\u8054\u6570\u636E\u88AB\u5220\u9664\u6216\u5B57\u6BB5\u53D1\u751F\u53D8\u5316\uFF0C\u65E0\u6CD5\u6B63\u5E38\u663E\u793A
|
i18n_cst_ds_tb_or_field_deleted=\u81EA\u5B9A\u4E49\u6570\u636E\u96C6\u6240\u5173\u8054\u6570\u636E\u88AB\u5220\u9664\u6216\u5B57\u6BB5\u53D1\u751F\u53D8\u5316\uFF0C\u65E0\u6CD5\u6B63\u5E38\u663E\u793A
|
||||||
i18n_no_all_delete_privilege_folder=\u8BE5\u76EE\u5F55\u4E0B\u5B58\u5728\u6CA1\u6709\u7BA1\u7406\u6743\u9650\u6216\u67E5\u770B\u6743\u9650\u7684\u8D44\u6E90\uFF0C\u65E0\u6CD5\u5220\u9664
|
i18n_no_all_delete_privilege_folder=\u8BE5\u76EE\u5F55\u4E0B\u5B58\u5728\u6CA1\u6709\u7BA1\u7406\u6743\u9650\u6216\u67E5\u770B\u6743\u9650\u7684\u8D44\u6E90\uFF0C\u65E0\u6CD5\u5220\u9664
|
||||||
i18n_excel_field_repeat=\u5B58\u5728\u91CD\u590D\u5B57\u6BB5\uFF0C\u8BF7\u4FEE\u6539\u540E\u91CD\u8BD5
|
i18n_excel_field_repeat=\u5b58\u5728\u91cd\u590d\u5b57\u6bb5\uff1a
|
||||||
i18n_schema_is_empty=\u6570\u636E\u5E93 Schema \u4E3A\u7A7A
|
i18n_schema_is_empty=\u6570\u636E\u5E93 Schema \u4E3A\u7A7A
|
||||||
\u7AD9\u5185\u6D88\u606F=\u6D88\u606F\u4E2D\u5FC3
|
\u7AD9\u5185\u6D88\u606F=\u6D88\u606F\u4E2D\u5FC3
|
||||||
\u6240\u6709\u6D88\u606F=\u6240\u6709\u6D88\u606F
|
\u6240\u6709\u6D88\u606F=\u6240\u6709\u6D88\u606F
|
||||||
|
|||||||
@ -92,7 +92,7 @@ i18n_sql_add_not_matching=\u589E\u91CF\u6DFB\u52A0 sql \u7684\u6578\u64DA\u5217\
|
|||||||
i18n_sql_delete_not_matching=\u589E\u91CF\u522A\u9664 sql \u7684\u6578\u64DA\u5217\u8207\u6578\u64DA\u96C6\u4E0D\u5339\u914D,
|
i18n_sql_delete_not_matching=\u589E\u91CF\u522A\u9664 sql \u7684\u6578\u64DA\u5217\u8207\u6578\u64DA\u96C6\u4E0D\u5339\u914D,
|
||||||
i18n_cst_ds_tb_or_field_deleted=\u81EA\u5B9A\u7FA9\u6578\u64DA\u96C6\u6240\u95DC\u806F\u6578\u64DA\u88AB\u522A\u9664\u6216\u5B57\u6BB5\u767C\u751F\u8B8A\u5316\uFF0C\u7121\u6CD5\u6B63\u5E38\u986F\u793A
|
i18n_cst_ds_tb_or_field_deleted=\u81EA\u5B9A\u7FA9\u6578\u64DA\u96C6\u6240\u95DC\u806F\u6578\u64DA\u88AB\u522A\u9664\u6216\u5B57\u6BB5\u767C\u751F\u8B8A\u5316\uFF0C\u7121\u6CD5\u6B63\u5E38\u986F\u793A
|
||||||
i18n_no_all_delete_privilege_folder=\u8A72\u76EE\u9304\u4E0B\u5B58\u5728\u6C92\u6709\u7BA1\u7406\u6B0A\u9650\u6216\u67E5\u770B\u6B0A\u9650\u7684\u8CC7\u6E90\uFF0C\u7121\u6CD5\u522A\u9664
|
i18n_no_all_delete_privilege_folder=\u8A72\u76EE\u9304\u4E0B\u5B58\u5728\u6C92\u6709\u7BA1\u7406\u6B0A\u9650\u6216\u67E5\u770B\u6B0A\u9650\u7684\u8CC7\u6E90\uFF0C\u7121\u6CD5\u522A\u9664
|
||||||
i18n_excel_field_repeat=\u5B58\u5728\u91CD\u5FA9\u5B57\u6BB5\uFF0C\u8ACB\u4FEE\u6539\u5F8C\u91CD\u8BD5
|
i18n_excel_field_repeat=\u5b58\u5728\u91cd\u5fa9\u5b57\u6bb5\uff1a
|
||||||
i18n_schema_is_empty=\u6578\u64DA\u5EAB Schema \u70BA\u7A7A
|
i18n_schema_is_empty=\u6578\u64DA\u5EAB Schema \u70BA\u7A7A
|
||||||
\u7AD9\u5185\u6D88\u606F=\u6D88\u606F\u4E2D\u5FC3
|
\u7AD9\u5185\u6D88\u606F=\u6D88\u606F\u4E2D\u5FC3
|
||||||
\u6240\u6709\u6D88\u606F=\u6240\u6709\u6D88\u606F
|
\u6240\u6709\u6D88\u606F=\u6240\u6709\u6D88\u606F
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user