diff --git a/core/core-backend/src/main/java/io/dataease/map/manage/MapManage.java b/core/core-backend/src/main/java/io/dataease/map/manage/MapManage.java index 448339da25..f774538ef8 100644 --- a/core/core-backend/src/main/java/io/dataease/map/manage/MapManage.java +++ b/core/core-backend/src/main/java/io/dataease/map/manage/MapManage.java @@ -1,5 +1,7 @@ package io.dataease.map.manage; +import cn.hutool.core.collection.ListUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.dataease.api.map.dto.GeometryNodeCreator; import io.dataease.api.map.vo.AreaNode; import io.dataease.constant.StaticResourceConstants; @@ -29,6 +31,7 @@ import java.util.HashMap; import java.util.List; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; +import java.util.stream.Stream; import static io.dataease.constant.CacheConstant.CommonCacheConstant.WORLD_MAP_CACHE; @@ -147,10 +150,30 @@ public class MapManage { if (!StringUtils.startsWith(code, GEO_PREFIX)) { DEException.throwException("内置Geometry,禁止删除"); } - coreAreaCustomMapper.deleteById(code); - File file = buildGeoFile(code); - if (file.exists()) { - file.delete(); + CoreAreaCustom coreAreaCustom = coreAreaCustomMapper.selectById(code); + if (ObjectUtils.isEmpty(coreAreaCustom)) { + DEException.throwException("Geometry code 不存在!"); + } + List codeResultList = new ArrayList<>(); + codeResultList.add(code); + childTreeIdList(ListUtil.of(code), codeResultList); + coreAreaCustomMapper.deleteBatchIds(codeResultList); + codeResultList.forEach(id -> { + File file = buildGeoFile(id); + if (file.exists()) { + file.delete(); + } + }); + } + + public void childTreeIdList(List pidList, List resultList) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in("pid", pidList); + List coreAreaCustoms = coreAreaCustomMapper.selectList(queryWrapper); + if (CollectionUtils.isNotEmpty(coreAreaCustoms)) { + List codeList = coreAreaCustoms.stream().map(CoreAreaCustom::getId).toList(); + resultList.addAll(codeList); + childTreeIdList(codeList, resultList); } } diff --git a/core/core-frontend/src/views/system/parameter/map/Geometry.vue b/core/core-frontend/src/views/system/parameter/map/Geometry.vue index 67244cba94..0c899a1066 100644 --- a/core/core-frontend/src/views/system/parameter/map/Geometry.vue +++ b/core/core-frontend/src/views/system/parameter/map/Geometry.vue @@ -40,6 +40,7 @@