diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/controller/MapLegendController.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/controller/MapLegendController.java index bb5830c7..87e3187a 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/controller/MapLegendController.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/controller/MapLegendController.java @@ -196,4 +196,14 @@ public class MapLegendController { List tree = mapLegendBizService.getMapLegendTree(flag); return ResponseResult.successData(tree); } + + /** + * 地图图例列表 + */ + @Operation(summary = "地图图例列表") + @GetMapping("/getModuleMapLegendList") + public ResponseResult getModuleMapLegendList(@RequestParam(required = false) String moduleId) { + List list = mapLegendBizService.getModuleMapLegendList(moduleId); + return ResponseResult.successData(list); + } } diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/mapper/MsMapmoduleBMapper.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/mapper/MsMapmoduleBMapper.java index e219ae10..d0858123 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/mapper/MsMapmoduleBMapper.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/mapper/MsMapmoduleBMapper.java @@ -87,4 +87,28 @@ public interface MsMapmoduleBMapper extends BaseMapper { + "") List getModuleMapLegendList(@Param("moduleId") String moduleId, @Param("sid") String sid, @Param("templateId") String templateId); + + + /** + * 查询模块关联的图例列表(单参数版本,用于地图图例管理页面) + */ + @Select("") + List getModuleMapLegendList(@Param("moduleId") String moduleId); + } \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/IMapLegendBizService.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/IMapLegendBizService.java index 30d35833..23874190 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/IMapLegendBizService.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/IMapLegendBizService.java @@ -30,4 +30,13 @@ public interface IMapLegendBizService { */ List getModuleMapLegendList(String moduleId, String systemId, String templateId); + /** + * 根据模块ID获取模块关联的图例列表(单参数版本) + * + * @param moduleId 模块ID + * @return 图例列表 + */ + List getModuleMapLegendList(String moduleId); + + } \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/impl/MapLegendBizServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/impl/MapLegendBizServiceImpl.java index cdc7a489..5ca81ae0 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/impl/MapLegendBizServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/impl/MapLegendBizServiceImpl.java @@ -8,6 +8,7 @@ import com.yfd.platform.qgc_sys.mapLayer.mapper.MsMapmoduleBMapper; import com.yfd.platform.qgc_sys.mapLayer.service.IMapLegendBizService; import com.yfd.platform.qgc_sys.mapLayer.service.IMapLegendService; import jakarta.annotation.Resource; +import cn.hutool.core.collection.CollectionUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -142,4 +143,70 @@ public class MapLegendBizServiceImpl implements IMapLegendBizService { .sorted(Comparator.comparing(MapLegendVo::getPSort, Comparator.nullsLast(Integer::compareTo))) .collect(Collectors.toList()); } + + @Override + public List getModuleMapLegendList(String moduleId) { + List list = new ArrayList<>(); + // 通过 JOIN 查询 MS_MAPLEGEND_B 和 MS_MAPMODULE_B(单参数版本) + List bbiMapLegendList = msMapmoduleBMapper.getModuleMapLegendList(moduleId); + + if (bbiMapLegendList == null || bbiMapLegendList.isEmpty()) { + return list; + } + + // 收集父级ID,查询父级图例的layerCode + Set parentIdList = bbiMapLegendList.stream() + .map(MapLegendVo::getParentId) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + Map layerCodeMap = new HashMap<>(); + if (CollectionUtil.isNotEmpty(parentIdList)) { + List parentLegendList = legendService.lambdaQuery() + .in(MsMaplegendB::getId, parentIdList) + .list(); + layerCodeMap = parentLegendList.stream() + .filter(item -> item.getLayerCode() != null) + .collect(Collectors.toMap(MsMaplegendB::getId, MsMaplegendB::getLayerCode, (v1, v2) -> v1)); + } + + // 按父级分组 + Map> collect = bbiMapLegendList.stream() + .collect(Collectors.groupingBy(MapLegendVo::getParentName)); + + // 遍历 + Map finalLayerCodeMap = layerCodeMap; + collect.forEach((str, mapLegendVoList) -> { + MapLegendVo mapLegendVo = new MapLegendVo(); + mapLegendVo.setName(str); + mapLegendVo.setPSort(mapLegendVoList.get(0).getPSort()); + mapLegendVo.setLayerCode(finalLayerCodeMap.get(mapLegendVoList.get(0).getParentId())); + // 按子级分组名分组 + Map> collect1 = mapLegendVoList.stream() + .collect(Collectors.groupingBy(MapLegendVo::getGroupName)); + List childrenList = new ArrayList<>(); + for (String groupNameStr : collect1.keySet()) { + List list1 = collect1.get(groupNameStr); + // 如果子级和父级名称相同,则不用子级 + if (groupNameStr.equalsIgnoreCase(str)) { + childrenList = list1; + } else { + MapLegendVo mapLegendVoChild = new MapLegendVo(); + mapLegendVoChild.setName(groupNameStr); + if (null != list1 && list1.size() > 0) { + mapLegendVoChild.setPSort(list1.get(0).getPSort()); + } + mapLegendVoChild.setChildrenList(list1); + childrenList.add(mapLegendVoChild); + } + } + List collect2 = childrenList.stream() + .sorted(Comparator.comparing(MapLegendVo::getPSort, Comparator.nullsLast(Integer::compareTo))) + .collect(Collectors.toList()); + mapLegendVo.setChildrenList(collect2); + list.add(mapLegendVo); + }); + return list.stream() + .sorted(Comparator.comparing(MapLegendVo::getPSort, Comparator.nullsLast(Integer::compareTo))) + .collect(Collectors.toList()); + } } \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/controller/MapmoduleBController.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/controller/MapmoduleBController.java index 0ddd61ef..e0b8ba83 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/controller/MapmoduleBController.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/controller/MapmoduleBController.java @@ -3,6 +3,7 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yfd.platform.common.DataSourceLoadOptionsBase; import com.yfd.platform.common.DataSourceRequest; import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.config.ResponseResult; @@ -13,6 +14,7 @@ import com.yfd.platform.qgc_sys.mapcfg.entity.MapmoduleVo; import com.yfd.platform.system.domain.SysMenu; import com.yfd.platform.system.mapper.SysMenuMapper; import com.yfd.platform.utils.DataSourceRequestUtil; +import com.yfd.platform.utils.QgcQueryWrapperUtil; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; @@ -43,12 +45,16 @@ public class MapmoduleBController { @Operation(summary = "条件过滤数据列表") @PostMapping("/GetKendoList") public ResponseResult getKendoList(@RequestBody DataSourceRequest dataSourceRequest) { - // 构建查询条件 + // 1. 构建查询条件 QueryWrapper wrapper = DataSourceRequestUtil.buildQueryWrapper( dataSourceRequest, MsMapmoduleB.class); - // 执行分页查询 - Page page = DataSourceRequestUtil.getPage(dataSourceRequest); + // 2. 分页参数处理(与 getMsstbprptList 完全一致) + DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest(); + Page page = loadOptions == null ? null + : (Page) QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake()); + + // 3. 执行分页查询 Page resultPage; if (page != null) { resultPage = mapmoduleBService.page(page, wrapper); @@ -59,60 +65,50 @@ public class MapmoduleBController { resultPage.setTotal(list.size()); } - // 构建 Kendo 数据源结果 + // 4. 构建 Kendo 数据源结果 DataSourceResult dataSourceResult = new DataSourceResult<>(); List dataList = resultPage.getRecords(); dataSourceResult.setData(dataList); dataSourceResult.setTotal(resultPage.getTotal()); - // 翻译字典值(原有逻辑,可能处理其他字段) + // 5. 翻译与额外字段填充(原有逻辑保持不变) if (dataList != null && !dataList.isEmpty()) { mapmoduleBService.translateDict(dataList); - // ----- 新增:填充 moduleName ----- - // 1. 先收集需要从数据库查询的 moduleId(排除 "tycd") Set needQueryIds = dataList.stream() .map(MsMapmoduleB::getModuleId) - .filter(id -> id != null && !"tycd".equals(id)) // 过滤掉 "tycd" + .filter(id -> id != null && !"tycd".equals(id)) .collect(Collectors.toSet()); Map menuNameMap = new HashMap<>(); if (!needQueryIds.isEmpty()) { - // 查询 SYS_MENU 表(假设实体为 SysMenu,Mapper 为 sysMenuMapper) List menus = sysMenuMapper.selectList( new LambdaQueryWrapper() - .in(SysMenu::getId, needQueryIds) // 注意 id 类型需匹配 + .in(SysMenu::getId, needQueryIds) ); menuNameMap = menus.stream() .collect(Collectors.toMap( - menu -> String.valueOf(menu.getId()), // 统一转为字符串 + menu -> String.valueOf(menu.getId()), SysMenu::getName )); } - // 2. 遍历 dataList 设置 moduleName for (MsMapmoduleB entity : dataList) { + // 填充 moduleName String moduleId = entity.getModuleId(); if (moduleId == null) { entity.setModuleName(null); } else if ("tycd".equals(moduleId)) { - // 特殊处理:固定为 "通用菜单" entity.setModuleName("通用菜单"); + entity.setChecked(1); } else { - // 从查询结果中获取 entity.setModuleName(menuNameMap.get(moduleId)); - // 如果 menuNameMap 中不存在,则置 null(或保留原值,视业务而定) - if (entity.getModuleName() == null) { - entity.setModuleName(null); // 或者 entity.setModuleName(""); - } } - } - // ========== 2. 处理 systemName 特殊值 ========== - for (MsMapmoduleB entity : dataList) { + + // 特殊 systemName if ("qgc".equals(entity.getSystemId())) { entity.setSystemName("qgc"); } - // 其他 systemId 保留字典翻译的结果 } }