Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
wangjiahao 2021-05-26 14:09:43 +08:00
commit 0aff0ba5e2
8 changed files with 51 additions and 10 deletions

View File

@ -1,5 +1,6 @@
package io.dataease.base.mapper.ext;
import io.dataease.base.domain.DatasetTableUnion;
import io.dataease.dto.dataset.DataSetTableUnionDTO;
import java.util.List;
@ -8,4 +9,8 @@ public interface ExtDatasetTableUnionMapper {
List<DataSetTableUnionDTO> selectBySourceTableId(String tableId);
List<DataSetTableUnionDTO> selectByTargetTableId(String tableId);
List<DataSetTableUnionDTO> selectUsedFieldBySource(DatasetTableUnion datasetTableUnion);
List<DataSetTableUnionDTO> selectUsedFieldByTarget(DatasetTableUnion datasetTableUnion);
}

View File

@ -39,4 +39,28 @@
where dtu.target_table_id = #{tableId,jdbcType=VARCHAR}
order by dtu.create_time
</select>
<select id="selectUsedFieldBySource" resultMap="BaseResultMap"
parameterType="io.dataease.base.domain.DatasetTableUnion">
select * from dataset_table_union
where source_table_id = #{sourceTableId,jdbcType=VARCHAR}
and target_table_id = #{targetTableId,jdbcType=VARCHAR}
and (source_table_field_id = #{sourceTableFieldId,jdbcType=VARCHAR}
or target_table_field_id = #{targetTableFieldId,jdbcType=VARCHAR})
<if test="id != null">
and id != #{id,jdbcType=VARCHAR}
</if>
</select>
<select id="selectUsedFieldByTarget" resultMap="BaseResultMap"
parameterType="io.dataease.base.domain.DatasetTableUnion">
select * from dataset_table_union
where source_table_id = #{targetTableId,jdbcType=VARCHAR}
and target_table_id = #{sourceTableId,jdbcType=VARCHAR}
and (source_table_field_id = #{targetTableFieldId,jdbcType=VARCHAR}
or target_table_field_id = #{sourceTableFieldId,jdbcType=VARCHAR})
<if test="id != null">
and id != #{id,jdbcType=VARCHAR}
</if>
</select>
</mapper>

View File

@ -867,14 +867,15 @@ public class DataSetTableService {
}
public Boolean checkDorisTableIsExists(String id) throws Exception {
Datasource dorisDatasource = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(dorisDatasource);
QueryProvider qp = ProviderFactory.getQueryProvider(dorisDatasource.getType());
datasourceRequest.setQuery(qp.searchTable(DorisTableUtils.dorisName(id)));
List<String[]> data = jdbcProvider.getData(datasourceRequest);
return CollectionUtils.isNotEmpty(data);
// Datasource dorisDatasource = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
// JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
// DatasourceRequest datasourceRequest = new DatasourceRequest();
// datasourceRequest.setDatasource(dorisDatasource);
// QueryProvider qp = ProviderFactory.getQueryProvider(dorisDatasource.getType());
// datasourceRequest.setQuery(qp.searchTable(DorisTableUtils.dorisName(id)));
// List<String[]> data = jdbcProvider.getData(datasourceRequest);
// return CollectionUtils.isNotEmpty(data);
return true;
}
public void updateDatasetTableStatus(){

View File

@ -77,6 +77,7 @@ public class DataSetTableUnionService {
}
private void checkUnion(DatasetTableUnion datasetTableUnion) {
// check 关联关系是否存在
DatasetTableUnionExample datasetTableUnionExample = new DatasetTableUnionExample();
DatasetTableUnionExample.Criteria criteria = datasetTableUnionExample.createCriteria();
if (StringUtils.isNotEmpty(datasetTableUnion.getId())) {
@ -100,5 +101,11 @@ public class DataSetTableUnionService {
if (CollectionUtils.isNotEmpty(sourceResult) || CollectionUtils.isNotEmpty(targetResult)) {
throw new RuntimeException(Translator.get("i18n_union_already_exists"));
}
// check 同一字段是否在两个关联表中重复出现
List<DataSetTableUnionDTO> sourceResult1 = extDatasetTableUnionMapper.selectUsedFieldBySource(datasetTableUnion);
List<DataSetTableUnionDTO> targetResult1 = extDatasetTableUnionMapper.selectUsedFieldByTarget(datasetTableUnion);
if (CollectionUtils.isNotEmpty(sourceResult1) || CollectionUtils.isNotEmpty(targetResult1)) {
throw new RuntimeException(Translator.get("i18n_union_field_exists"));
}
}
}

View File

@ -0,0 +1 @@
ALTER TABLE `dataease`.`dataset_table` ADD COLUMN `sync_status` VARCHAR(45) NULL AFTER `create_time`;

View File

@ -236,4 +236,5 @@ i18n_same_folder_can_not_repeat=Same Folder Can Not Repeat
i18n_default_panel=Default Panel
i18n_panel_list=Panel List
i18n_processing_data=Processing data now, Refresh later
i18n_union_already_exists=Union relation already exists
i18n_union_already_exists=Union relation already exists
i18n_union_field_exists=The same field can't in two dataset

View File

@ -238,3 +238,4 @@ i18n_default_panel=默认仪表盘
i18n_panel_list=仪表盘列表
i18n_processing_data=正在处理数据,稍后刷新
i18n_union_already_exists=关联关系已存在
i18n_union_field_exists=两个数据集之间关联不能出现多次相同字段

View File

@ -237,4 +237,5 @@ i18n_same_folder_can_not_repeat=相同的目录下名称不能重复
i18n_default_panel=默认仪表盘
i18n_panel_list=仪表盘列表
i18n_processing_data=正在處理數據,稍後刷新
i18n_union_already_exists=關聯關系已存在
i18n_union_already_exists=關聯關系已存在
i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字段