diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtDataSetGroupMapper.java b/backend/src/main/java/io/dataease/base/mapper/ext/ExtDataSetGroupMapper.java index 0c526dd442..ec186c911e 100644 --- a/backend/src/main/java/io/dataease/base/mapper/ext/ExtDataSetGroupMapper.java +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtDataSetGroupMapper.java @@ -4,7 +4,10 @@ import io.dataease.controller.request.dataset.DataSetGroupRequest; import io.dataease.dto.dataset.DataSetGroupDTO; import java.util.List; +import java.util.Map; public interface ExtDataSetGroupMapper { List search(DataSetGroupRequest ChartGroup); + + Map searchIds(String id, String type); } diff --git a/backend/src/main/java/io/dataease/base/mapper/ext/ExtDataSetGroupMapper.xml b/backend/src/main/java/io/dataease/base/mapper/ext/ExtDataSetGroupMapper.xml index a94956c4f5..5a881f4bf2 100644 --- a/backend/src/main/java/io/dataease/base/mapper/ext/ExtDataSetGroupMapper.xml +++ b/backend/src/main/java/io/dataease/base/mapper/ext/ExtDataSetGroupMapper.xml @@ -41,7 +41,9 @@ order by ${sort} + - + diff --git a/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java b/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java index c5dd35107e..94792dec80 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java @@ -3,6 +3,7 @@ package io.dataease.service.chart; import io.dataease.base.domain.*; import io.dataease.base.mapper.ChartGroupMapper; import io.dataease.base.mapper.ext.ExtChartGroupMapper; +import io.dataease.base.mapper.ext.ExtDataSetGroupMapper; import io.dataease.commons.utils.AuthUtils; import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.TreeUtils; @@ -11,12 +12,14 @@ import io.dataease.controller.request.dataset.DataSetTableRequest; import io.dataease.dto.chart.ChartGroupDTO; import io.dataease.i18n.Translator; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; @@ -27,9 +30,10 @@ public class ChartGroupService { private ChartGroupMapper chartGroupMapper; @Resource private ChartViewService chartViewService; - @Resource private ExtChartGroupMapper extChartGroupMapper; + @Resource + private ExtDataSetGroupMapper extDataSetGroupMapper; public ChartGroupDTO save(ChartGroup chartGroup) { checkName(chartGroup); @@ -51,9 +55,14 @@ public class ChartGroupService { ChartGroup cg = chartGroupMapper.selectByPrimaryKey(id); ChartGroupRequest ChartGroup = new ChartGroupRequest(); BeanUtils.copyBean(ChartGroup, cg); - List tree = tree(ChartGroup); + Map stringStringMap = extDataSetGroupMapper.searchIds(id, "chart"); + String[] split = stringStringMap.get("ids").split(","); List ids = new ArrayList<>(); - getAllId(tree, ids); + for (String dsId : split) { + if (StringUtils.isNotEmpty(dsId)) { + ids.add(dsId); + } + } ChartGroupExample ChartGroupExample = new ChartGroupExample(); ChartGroupExample.createCriteria().andIdIn(ids); chartGroupMapper.deleteByExample(ChartGroupExample); @@ -104,6 +113,9 @@ public class ChartGroupService { if (StringUtils.isNotEmpty(chartGroup.getId())) { criteria.andIdNotEqualTo(chartGroup.getId()); } + if (ObjectUtils.isNotEmpty(chartGroup.getLevel())) { + criteria.andLevelEqualTo(chartGroup.getLevel()); + } List list = chartGroupMapper.selectByExample(chartGroupExample); if (list.size() > 0) { throw new RuntimeException(Translator.get("i18n_name_cant_repeat_same_group")); diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java index d3b31b2b58..9de794919f 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java @@ -14,15 +14,13 @@ import io.dataease.dto.dataset.DataSetGroupDTO; import io.dataease.dto.dataset.DataSetTableDTO; import io.dataease.i18n.Translator; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; /** @@ -59,9 +57,14 @@ public class DataSetGroupService { DatasetGroup dg = datasetGroupMapper.selectByPrimaryKey(id); DataSetGroupRequest datasetGroup = new DataSetGroupRequest(); BeanUtils.copyBean(datasetGroup, dg); - List tree = tree(datasetGroup); + Map stringStringMap = extDataSetGroupMapper.searchIds(id, "dataset"); + String[] split = stringStringMap.get("ids").split(","); List ids = new ArrayList<>(); - getAllId(tree, ids); + for (String dsId : split) { + if (StringUtils.isNotEmpty(dsId)) { + ids.add(dsId); + } + } DatasetGroupExample datasetGroupExample = new DatasetGroupExample(); datasetGroupExample.createCriteria().andIdIn(ids); datasetGroupMapper.deleteByExample(datasetGroupExample); @@ -117,6 +120,9 @@ public class DataSetGroupService { if (StringUtils.isNotEmpty(datasetGroup.getId())) { criteria.andIdNotEqualTo(datasetGroup.getId()); } + if (ObjectUtils.isNotEmpty(datasetGroup.getLevel())) { + criteria.andLevelEqualTo(datasetGroup.getLevel()); + } List list = datasetGroupMapper.selectByExample(datasetGroupExample); if (list.size() > 0) { throw new RuntimeException(Translator.get("i18n_name_cant_repeat_same_group")); 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 d3f00a6633..4283b3aae7 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -128,7 +128,11 @@ public class DataSetTableService { dataSetTableFieldsService.deleteByTableId(id); // 删除同步任务 dataSetTableTaskService.deleteByTableId(id); - deleteDorisTable(id); + try { + deleteDorisTable(id); + } catch (Exception e) { + + } } private void deleteDorisTable(String datasetId) throws Exception { @@ -260,13 +264,13 @@ public class DataSetTableService { } } else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) { List datasetTableTaskLogs = dataSetTableTaskLogService.getByTableId(datasetTable.getId()); - if(CollectionUtils.isEmpty(datasetTableTaskLogs)){ + if (CollectionUtils.isEmpty(datasetTableTaskLogs)) { throw new Exception("no records"); } - if(datasetTableTaskLogs.get(0).getStatus().equalsIgnoreCase(JobStatus.Underway.name())){ + if (datasetTableTaskLogs.get(0).getStatus().equalsIgnoreCase(JobStatus.Underway.name())) { throw new Exception(Translator.get("i18n_processing_data")); } - if(datasetTableTaskLogs.get(0).getStatus().equalsIgnoreCase(JobStatus.Error.name())){ + if (datasetTableTaskLogs.get(0).getStatus().equalsIgnoreCase(JobStatus.Error.name())) { throw new Exception("Failed to extract data: " + datasetTableTaskLogs.get(0).getInfo()); } Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource");