提交 3e6caadf authored 作者: xiajunjie's avatar xiajunjie

feat(backend):tree delete fix

上级 d922fe11
...@@ -4,7 +4,10 @@ import io.dataease.controller.request.dataset.DataSetGroupRequest; ...@@ -4,7 +4,10 @@ import io.dataease.controller.request.dataset.DataSetGroupRequest;
import io.dataease.dto.dataset.DataSetGroupDTO; import io.dataease.dto.dataset.DataSetGroupDTO;
import java.util.List; import java.util.List;
import java.util.Map;
public interface ExtDataSetGroupMapper { public interface ExtDataSetGroupMapper {
List<DataSetGroupDTO> search(DataSetGroupRequest ChartGroup); List<DataSetGroupDTO> search(DataSetGroupRequest ChartGroup);
Map<String, String> searchIds(String id, String type);
} }
...@@ -41,7 +41,9 @@ ...@@ -41,7 +41,9 @@
<if test="sort != null"> <if test="sort != null">
order by ${sort} order by ${sort}
</if> </if>
</select>
<select id="searchIds" resultType="java.util.Map">
select GET_V_AUTH_MODEL_WITH_CHILDREN(#{id},#{type}) ids
</select> </select>
</mapper> </mapper>
...@@ -3,6 +3,7 @@ package io.dataease.service.chart; ...@@ -3,6 +3,7 @@ package io.dataease.service.chart;
import io.dataease.base.domain.*; import io.dataease.base.domain.*;
import io.dataease.base.mapper.ChartGroupMapper; import io.dataease.base.mapper.ChartGroupMapper;
import io.dataease.base.mapper.ext.ExtChartGroupMapper; 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.AuthUtils;
import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.TreeUtils; import io.dataease.commons.utils.TreeUtils;
...@@ -11,12 +12,14 @@ import io.dataease.controller.request.dataset.DataSetTableRequest; ...@@ -11,12 +12,14 @@ import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.dto.chart.ChartGroupDTO; import io.dataease.dto.chart.ChartGroupDTO;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -27,9 +30,10 @@ public class ChartGroupService { ...@@ -27,9 +30,10 @@ public class ChartGroupService {
private ChartGroupMapper chartGroupMapper; private ChartGroupMapper chartGroupMapper;
@Resource @Resource
private ChartViewService chartViewService; private ChartViewService chartViewService;
@Resource @Resource
private ExtChartGroupMapper extChartGroupMapper; private ExtChartGroupMapper extChartGroupMapper;
@Resource
private ExtDataSetGroupMapper extDataSetGroupMapper;
public ChartGroupDTO save(ChartGroup chartGroup) { public ChartGroupDTO save(ChartGroup chartGroup) {
checkName(chartGroup); checkName(chartGroup);
...@@ -51,9 +55,14 @@ public class ChartGroupService { ...@@ -51,9 +55,14 @@ public class ChartGroupService {
ChartGroup cg = chartGroupMapper.selectByPrimaryKey(id); ChartGroup cg = chartGroupMapper.selectByPrimaryKey(id);
ChartGroupRequest ChartGroup = new ChartGroupRequest(); ChartGroupRequest ChartGroup = new ChartGroupRequest();
BeanUtils.copyBean(ChartGroup, cg); BeanUtils.copyBean(ChartGroup, cg);
List<ChartGroupDTO> tree = tree(ChartGroup); Map<String, String> stringStringMap = extDataSetGroupMapper.searchIds(id, "chart");
String[] split = stringStringMap.get("ids").split(",");
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
getAllId(tree, ids); for (String dsId : split) {
if (StringUtils.isNotEmpty(dsId)) {
ids.add(dsId);
}
}
ChartGroupExample ChartGroupExample = new ChartGroupExample(); ChartGroupExample ChartGroupExample = new ChartGroupExample();
ChartGroupExample.createCriteria().andIdIn(ids); ChartGroupExample.createCriteria().andIdIn(ids);
chartGroupMapper.deleteByExample(ChartGroupExample); chartGroupMapper.deleteByExample(ChartGroupExample);
...@@ -104,6 +113,9 @@ public class ChartGroupService { ...@@ -104,6 +113,9 @@ public class ChartGroupService {
if (StringUtils.isNotEmpty(chartGroup.getId())) { if (StringUtils.isNotEmpty(chartGroup.getId())) {
criteria.andIdNotEqualTo(chartGroup.getId()); criteria.andIdNotEqualTo(chartGroup.getId());
} }
if (ObjectUtils.isNotEmpty(chartGroup.getLevel())) {
criteria.andLevelEqualTo(chartGroup.getLevel());
}
List<ChartGroup> list = chartGroupMapper.selectByExample(chartGroupExample); List<ChartGroup> list = chartGroupMapper.selectByExample(chartGroupExample);
if (list.size() > 0) { if (list.size() > 0) {
throw new RuntimeException(Translator.get("i18n_name_cant_repeat_same_group")); throw new RuntimeException(Translator.get("i18n_name_cant_repeat_same_group"));
......
...@@ -14,15 +14,13 @@ import io.dataease.dto.dataset.DataSetGroupDTO; ...@@ -14,15 +14,13 @@ import io.dataease.dto.dataset.DataSetGroupDTO;
import io.dataease.dto.dataset.DataSetTableDTO; import io.dataease.dto.dataset.DataSetTableDTO;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -59,9 +57,14 @@ public class DataSetGroupService { ...@@ -59,9 +57,14 @@ public class DataSetGroupService {
DatasetGroup dg = datasetGroupMapper.selectByPrimaryKey(id); DatasetGroup dg = datasetGroupMapper.selectByPrimaryKey(id);
DataSetGroupRequest datasetGroup = new DataSetGroupRequest(); DataSetGroupRequest datasetGroup = new DataSetGroupRequest();
BeanUtils.copyBean(datasetGroup, dg); BeanUtils.copyBean(datasetGroup, dg);
List<DataSetGroupDTO> tree = tree(datasetGroup); Map<String, String> stringStringMap = extDataSetGroupMapper.searchIds(id, "dataset");
String[] split = stringStringMap.get("ids").split(",");
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
getAllId(tree, ids); for (String dsId : split) {
if (StringUtils.isNotEmpty(dsId)) {
ids.add(dsId);
}
}
DatasetGroupExample datasetGroupExample = new DatasetGroupExample(); DatasetGroupExample datasetGroupExample = new DatasetGroupExample();
datasetGroupExample.createCriteria().andIdIn(ids); datasetGroupExample.createCriteria().andIdIn(ids);
datasetGroupMapper.deleteByExample(datasetGroupExample); datasetGroupMapper.deleteByExample(datasetGroupExample);
...@@ -117,6 +120,9 @@ public class DataSetGroupService { ...@@ -117,6 +120,9 @@ public class DataSetGroupService {
if (StringUtils.isNotEmpty(datasetGroup.getId())) { if (StringUtils.isNotEmpty(datasetGroup.getId())) {
criteria.andIdNotEqualTo(datasetGroup.getId()); criteria.andIdNotEqualTo(datasetGroup.getId());
} }
if (ObjectUtils.isNotEmpty(datasetGroup.getLevel())) {
criteria.andLevelEqualTo(datasetGroup.getLevel());
}
List<DatasetGroup> list = datasetGroupMapper.selectByExample(datasetGroupExample); List<DatasetGroup> list = datasetGroupMapper.selectByExample(datasetGroupExample);
if (list.size() > 0) { if (list.size() > 0) {
throw new RuntimeException(Translator.get("i18n_name_cant_repeat_same_group")); throw new RuntimeException(Translator.get("i18n_name_cant_repeat_same_group"));
......
...@@ -128,7 +128,11 @@ public class DataSetTableService { ...@@ -128,7 +128,11 @@ public class DataSetTableService {
dataSetTableFieldsService.deleteByTableId(id); dataSetTableFieldsService.deleteByTableId(id);
// 删除同步任务 // 删除同步任务
dataSetTableTaskService.deleteByTableId(id); dataSetTableTaskService.deleteByTableId(id);
deleteDorisTable(id); try {
deleteDorisTable(id);
} catch (Exception e) {
}
} }
private void deleteDorisTable(String datasetId) throws Exception { private void deleteDorisTable(String datasetId) throws Exception {
...@@ -260,13 +264,13 @@ public class DataSetTableService { ...@@ -260,13 +264,13 @@ public class DataSetTableService {
} }
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) { } else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) {
List<DatasetTableTaskLog> datasetTableTaskLogs = dataSetTableTaskLogService.getByTableId(datasetTable.getId()); List<DatasetTableTaskLog> datasetTableTaskLogs = dataSetTableTaskLogService.getByTableId(datasetTable.getId());
if(CollectionUtils.isEmpty(datasetTableTaskLogs)){ if (CollectionUtils.isEmpty(datasetTableTaskLogs)) {
throw new Exception("no records"); 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")); 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()); throw new Exception("Failed to extract data: " + datasetTableTaskLogs.get(0).getInfo());
} }
Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource"); Datasource ds = (Datasource) CommonBeanFactory.getBean("DorisDatasource");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论