fix: 修复不能创建关联数据集问题

This commit is contained in:
wangjiahao 2022-06-02 18:25:10 +08:00
parent 3a1e4db6e0
commit 6bee78446f

View File

@ -1,6 +1,7 @@
package io.dataease.service.dataset; package io.dataease.service.dataset;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import io.dataease.auth.annotation.DeCleaner; import io.dataease.auth.annotation.DeCleaner;
@ -585,9 +586,9 @@ public class DataSetTableService {
} else { } else {
// check doris table // check doris table
if (!checkEngineTableIsExists(dataSetTableRequest.getId())) { if (!checkEngineTableIsExists(dataSetTableRequest.getId())) {
if(dataSetTableRequest.isPreviewForTask()){ if (dataSetTableRequest.isPreviewForTask()) {
return map; return map;
}else { } else {
throw new RuntimeException(Translator.get("i18n_data_not_sync")); throw new RuntimeException(Translator.get("i18n_data_not_sync"));
} }
} }
@ -1346,7 +1347,11 @@ public class DataSetTableService {
String configuration = ds.getConfiguration(); String configuration = ds.getConfiguration();
JsonObject jsonObject = JsonParser.parseString(configuration).getAsJsonObject(); JsonObject jsonObject = JsonParser.parseString(configuration).getAsJsonObject();
String schema = jsonObject.get("schema").getAsString(); JsonElement schemaJson = jsonObject.get("schema");
String schema = null;
if (schemaJson != null) {
schema = schemaJson.getAsString();
}
String joinPrefix = ""; String joinPrefix = "";
if (StringUtils.isNotEmpty(schema) && (StringUtils.equalsIgnoreCase(ds.getType(), DatasourceTypes.db2.getType()) || if (StringUtils.isNotEmpty(schema) && (StringUtils.equalsIgnoreCase(ds.getType(), DatasourceTypes.db2.getType()) ||
StringUtils.equalsIgnoreCase(ds.getType(), DatasourceTypes.sqlServer.getType()) || StringUtils.equalsIgnoreCase(ds.getType(), DatasourceTypes.sqlServer.getType()) ||
@ -1907,7 +1912,7 @@ public class DataSetTableService {
List<String> oldFields = datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.toList()); List<String> oldFields = datasetTableFields.stream().map(DatasetTableField::getOriginName).collect(Collectors.toList());
if(editType == 1){ if (editType == 1) {
for (ExcelSheetData excelSheetData : excelSheetDataList) { for (ExcelSheetData excelSheetData : excelSheetDataList) {
List<TableField> tableFields = excelSheetData.getFields(); List<TableField> tableFields = excelSheetData.getFields();
List<String> newFields = tableFields.stream().map(TableField::getRemarks).collect(Collectors.toList()); List<String> newFields = tableFields.stream().map(TableField::getRemarks).collect(Collectors.toList());
@ -1918,7 +1923,7 @@ public class DataSetTableService {
if (retrunSheetDataList.size() == 0) { if (retrunSheetDataList.size() == 0) {
DataEaseException.throwException(Translator.get("i18n_excel_column_change")); DataEaseException.throwException(Translator.get("i18n_excel_column_change"));
} }
}else { } else {
List<DatasetTableField> extFields = fields.stream().filter(datasetTableField -> datasetTableField.getExtField() > 0).collect(Collectors.toList()); List<DatasetTableField> extFields = fields.stream().filter(datasetTableField -> datasetTableField.getExtField() > 0).collect(Collectors.toList());
List<String> extFieldsRefIds = new ArrayList<>(); List<String> extFieldsRefIds = new ArrayList<>();
for (DatasetTableField extField : extFields) { for (DatasetTableField extField : extFields) {
@ -1928,7 +1933,7 @@ public class DataSetTableService {
Matcher matcher = pattern.matcher(originField); Matcher matcher = pattern.matcher(originField);
while (matcher.find()) { while (matcher.find()) {
String id = matcher.group(1); String id = matcher.group(1);
if(!extFieldsRefIds.contains(id)){ if (!extFieldsRefIds.contains(id)) {
extFieldsRefIds.add(id); extFieldsRefIds.add(id);
} }
} }
@ -1939,12 +1944,12 @@ public class DataSetTableService {
List<String> newFields = tableFields.stream().map(TableField::getRemarks).collect(Collectors.toList()); List<String> newFields = tableFields.stream().map(TableField::getRemarks).collect(Collectors.toList());
if (oldFields.equals(newFields)) { if (oldFields.equals(newFields)) {
excelSheetData.setChangeFiled(false); excelSheetData.setChangeFiled(false);
}else { } else {
excelSheetData.setChangeFiled(true); excelSheetData.setChangeFiled(true);
} }
boolean effectExtField = false; boolean effectExtField = false;
for (String extFieldsRefName : extFieldsRefNames) { for (String extFieldsRefName : extFieldsRefNames) {
if(!newFields.contains(extFieldsRefName)){ if (!newFields.contains(extFieldsRefName)) {
effectExtField = true; effectExtField = true;
} }
} }
@ -1956,7 +1961,7 @@ public class DataSetTableService {
DataEaseException.throwException(Translator.get("i18n_excel_column_change")); DataEaseException.throwException(Translator.get("i18n_excel_column_change"));
} }
} }
}else { } else {
retrunSheetDataList = excelSheetDataList; retrunSheetDataList = excelSheetDataList;
} }
retrunSheetDataList = retrunSheetDataList.stream() retrunSheetDataList = retrunSheetDataList.stream()
@ -2374,7 +2379,7 @@ public class DataSetTableService {
return datasetTable; return datasetTable;
} }
public int updateByExampleSelective(DatasetTable record, DatasetTableExample example ){ public int updateByExampleSelective(DatasetTable record, DatasetTableExample example) {
return datasetTableMapper.updateByExampleSelective(record, example); return datasetTableMapper.updateByExampleSelective(record, example);
} }
} }