From 27cf1e504c161b547206e6dffd1ca0937e01b4de Mon Sep 17 00:00:00 2001 From: lilin <18811154576@163.com> Date: Wed, 1 Jul 2026 09:11:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E4=BE=8B=E6=95=B0=E6=8D=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4=EF=BC=8C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=20=E6=96=B0=E5=A2=9E=20=E4=BF=AE=E6=94=B9=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yfd/platform/config/SecurityConfig.java | 1 + .../yfd/platform/config/SwaggerConfig.java | 4 +- .../controller/MapLayerController.java | 21 +- .../controller/MapLegendController.java | 99 +++++++++- .../qgc_sys/mapLayer/domain/MsMaplegendB.java | 6 + .../qgc_sys/mapLayer/domain/MsMapmoduleB.java | 5 +- .../mapLayer/domain/MsMaptoolboxB.java | 186 ++++++++++++++++++ .../mapLayer/entity/vo/MapLayerVo.java | 80 ++++++++ .../mapLayer/entity/vo/MapLegendVo.java | 97 +++++++++ .../mapLayer/mapper/MsMapmoduleBMapper.java | 76 +++++++ .../mapLayer/mapper/MsMaptoolboxBMapper.java | 15 ++ .../mapLayer/service/IMapLayerBizService.java | 12 ++ .../service/IMapLegendBizService.java | 33 ++++ .../service/impl/MapLayerBizServiceImpl.java | 49 +++++ .../service/impl/MapLegendBizServiceImpl.java | 145 ++++++++++++++ .../controller/MapmoduleBController.java | 69 ++++++- .../qgc_sys/mapcfg/entity/MapmoduleVo.java | 47 +++++ .../mapcfg/service/IMapmoduleBService.java | 9 + .../service/impl/MapmoduleBServiceImpl.java | 91 +++++++++ 19 files changed, 1038 insertions(+), 7 deletions(-) create mode 100644 backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMaptoolboxB.java create mode 100644 backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/entity/vo/MapLayerVo.java create mode 100644 backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/entity/vo/MapLegendVo.java create mode 100644 backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/mapper/MsMaptoolboxBMapper.java create mode 100644 backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/IMapLegendBizService.java create mode 100644 backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/impl/MapLegendBizServiceImpl.java create mode 100644 backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/entity/MapmoduleVo.java diff --git a/backend/src/main/java/com/yfd/platform/config/SecurityConfig.java b/backend/src/main/java/com/yfd/platform/config/SecurityConfig.java index 7648c9b2..bedbb152 100644 --- a/backend/src/main/java/com/yfd/platform/config/SecurityConfig.java +++ b/backend/src/main/java/com/yfd/platform/config/SecurityConfig.java @@ -73,6 +73,7 @@ public class SecurityConfig { // .requestMatchers("/fh/**").permitAll() // .requestMatchers("/data/**").permitAll() .requestMatchers("/mapLayer/**").permitAll() + .requestMatchers("/mapmodule/**").permitAll() .requestMatchers("/mapLegend/**").permitAll() .requestMatchers("/sms/**").permitAll() .requestMatchers(HttpMethod.GET, "/").permitAll() diff --git a/backend/src/main/java/com/yfd/platform/config/SwaggerConfig.java b/backend/src/main/java/com/yfd/platform/config/SwaggerConfig.java index e6a0b033..fd4d2841 100644 --- a/backend/src/main/java/com/yfd/platform/config/SwaggerConfig.java +++ b/backend/src/main/java/com/yfd/platform/config/SwaggerConfig.java @@ -164,10 +164,10 @@ public class SwaggerConfig { } @Bean - public GroupedOpenApi groupSysMlgApi() { + public GroupedOpenApi groupSysMcfgApi() { return GroupedOpenApi.builder() .group("5.1 图例结构管理") - .packagesToScan("com.yfd.platform.qgc_sys.mapLegend.controller") + .packagesToScan("com.yfd.platform.qgc_sys.mapcfg.controller") .build(); } } \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/controller/MapLayerController.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/controller/MapLayerController.java index 981346ce..84c0ef86 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/controller/MapLayerController.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/controller/MapLayerController.java @@ -1,9 +1,11 @@ package com.yfd.platform.qgc_sys.mapLayer.controller; import cn.hutool.core.util.StrUtil; +import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.common.exception.BizException; import com.yfd.platform.config.ResponseResult; import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplayerB; +import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplegendB; import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLayerAo; import com.yfd.platform.qgc_sys.mapLayer.service.IMapLayerBizService; import com.yfd.platform.qgc_sys.mapLayer.service.IMapLayerService; @@ -37,7 +39,24 @@ public class MapLayerController { @PostMapping("/getAllMapLayerTree") public ResponseResult getAllMapLayerTree(@RequestBody MapLayerAo flag) { List tree = mapLayerBizService.getMapLayerTree(flag); - return ResponseResult.successData(tree); + // 构建 Kendo 数据源结果 + DataSourceResult dataSourceResult = new DataSourceResult<>(); + dataSourceResult.setData(tree); + // 计算总节点数 + long total = countTreeNodes(tree); + dataSourceResult.setTotal(tree.size()); + return ResponseResult.successData(dataSourceResult); + } + private long countTreeNodes(List nodes) { + if (nodes == null) return 0; + long count = 0; + for (MsMaplayerB node : nodes) { + count++; // 当前节点 + if (node.getChildren() != null && !node.getChildren().isEmpty()) { + count += countTreeNodes(node.getChildren()); + } + } + return count; } /** 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 f038b8e7..bb5830c7 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 @@ -3,21 +3,32 @@ package com.yfd.platform.qgc_sys.mapLayer.controller; import cn.hutool.core.collection.CollectionUtil; 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.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yfd.platform.common.DataSourceRequest; import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.common.exception.BizException; import com.yfd.platform.config.ResponseResult; +import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplayerB; import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplegendB; +import com.yfd.platform.qgc_sys.mapLayer.mapper.MsMaplayerBMapper; +import com.yfd.platform.qgc_sys.mapLayer.service.IMapLayerService; import com.yfd.platform.qgc_sys.mapLayer.service.IMapLegendService; +import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLegendVo; +import com.yfd.platform.qgc_sys.mapLayer.service.IMapLegendBizService; import com.yfd.platform.utils.DataSourceRequestUtil; +import com.yfd.platform.utils.SecurityUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.List; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; /** * 地图图例管理 @@ -32,6 +43,11 @@ public class MapLegendController { @Resource private IMapLegendService mapLegendService; + @Resource + private IMapLegendBizService mapLegendBizService; + + @Resource + private MsMaplayerBMapper msMaplayerBMapper; // 新增注入 /** * 条件过滤数据列表(Kendo UI 数据源) */ @@ -54,6 +70,68 @@ public class MapLegendController { resultPage.setTotal(list.size()); } + List records = resultPage.getRecords(); + if (records != null && !records.isEmpty()) { + // ---------- 2. 批量获取父级信息(用于 parentCode、parentName)---------- + Set parentIds = records.stream() + .filter(e -> e.getDataType() != null && e.getDataType() == 2) // 只处理图例数据 + .map(MsMaplegendB::getParentId) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + + Map parentMap = new HashMap<>(); + if (!parentIds.isEmpty()) { + List parents = mapLegendService.listByIds(parentIds); + parentMap = parents.stream() + .collect(Collectors.toMap(MsMaplegendB::getId, Function.identity())); + } + + // ---------- 3. 批量获取图层名称(根据 layerCode 查 MS_MAPLAYER_B)---------- + Set layerCodes = records.stream() + .map(MsMaplegendB::getLayerCode) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + + Map layerCodeNameMap = new HashMap<>(); + if (!layerCodes.isEmpty()) { + // 使用 Mapper 查询 + List layerList = msMaplayerBMapper.selectList( + new LambdaQueryWrapper() + .in(MsMaplayerB::getCode, layerCodes) + ); + layerCodeNameMap = layerList.stream() + .collect(Collectors.toMap(MsMaplayerB::getCode, MsMaplayerB::getTitle)); + } + + // ---------- 4. 遍历记录,填充三个额外字段 ---------- + for (MsMaplegendB entity : records) { + // 4.1 填充 parentCode / parentName(仅 dataType=2) + if (entity.getDataType() != null && entity.getDataType() == 2) { + String parentId = entity.getParentId(); + if (parentId != null && parentMap.containsKey(parentId)) { + MsMaplegendB parent = parentMap.get(parentId); + entity.setParentCode(parent.getCode()); + entity.setParentName(parent.getName()); + } else { + entity.setParentCode(null); + entity.setParentName(null); + } + } else { + // 非 dataType=2 的记录,这两个字段置空 + entity.setParentCode(null); + entity.setParentName(null); + } + + // 4.2 填充 layerCodeName(所有记录均可填充,如果图层不存在则置空) + String layerCode = entity.getLayerCode(); + if (layerCode != null && layerCodeNameMap.containsKey(layerCode)) { + entity.setLayerCodeName(layerCodeNameMap.get(layerCode)); + } else { + entity.setLayerCodeName(null); + } + } + } + // 构建 Kendo 数据源结果 DataSourceResult dataSourceResult = new DataSourceResult<>(); dataSourceResult.setData(resultPage.getRecords()); @@ -86,6 +164,15 @@ public class MapLegendController { if (legend.getDataType() == 2 && StrUtil.isBlank(legend.getLayerCode())) { throw new BizException("关联的图层编码(layerCode)不能为空."); } + if (StrUtil.isNotBlank(legend.getName())){ + if(StrUtil.isBlank(legend.getGroupName())){ + legend.setGroupName(legend.getName()); + } + if(StrUtil.isBlank(legend.getParentName())){ + legend.setGroupName(legend.getName()); + } + } + legend.setRecordUser(SecurityUtils.getUserId()); mapLegendService.saveOrUpdate(legend); return ResponseResult.success("保存成功."); } @@ -99,4 +186,14 @@ public class MapLegendController { mapLegendService.delelteByIds(ids); return ResponseResult.success("删除成功."); } + + /** + * 地图图例管理图层树(下拉选) + */ + @Operation(summary = "地图图例管理图层树(下拉选)") + @GetMapping("/getAllMapLegendTree") + public ResponseResult getAllMapLayerTree(Integer flag) { + List tree = mapLegendBizService.getMapLegendTree(flag); + return ResponseResult.successData(tree); + } } diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMaplegendB.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMaplegendB.java index 6147f6c3..3e2151d7 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMaplegendB.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMaplegendB.java @@ -131,4 +131,10 @@ public class MsMaplegendB implements Serializable { @TableField("IS_FILTER") private Integer isFilter; + + @TableField(exist = false) + private String layerCodeName; + + @TableField(exist = false) + private String parentCode; } \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMapmoduleB.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMapmoduleB.java index aac57f40..84c2f75d 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMapmoduleB.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMapmoduleB.java @@ -80,11 +80,14 @@ public class MsMapmoduleB implements Serializable { @TableField("TEMPLATE_ID") private String templateId; + @TableField("SYSTEM_ID") + private String systemId; + /** * 归属的系统ID(非数据库字段,用于字典翻译) */ @TableField(exist = false) - private String systemId; + private String systemName; /** * 菜单名称(非数据库字段,用于字典翻译) diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMaptoolboxB.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMaptoolboxB.java new file mode 100644 index 00000000..1439c017 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/domain/MsMaptoolboxB.java @@ -0,0 +1,186 @@ +package com.yfd.platform.qgc_sys.mapLayer.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 地图工具箱表 + * + * @author migration + */ +@Data +@TableName("MS_MAPTOOLBOX_B") +public class MsMaptoolboxB implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** + * 名称 + */ + @TableField("NAME") + private String name; + + /** + * 名称(英文) + */ + @TableField("NAME_EN") + private String nameEn; + + /** + * 编码 + */ + @TableField("CODE") + private String code; + + /** + * 地图模式 + */ + @TableField("MAP_MODEL") + private String mapModel; + + /** + * 所属父节点 + */ + @TableField("PATENT_ID") + private String patentId; + + /** + * 树全路径 + */ + @TableField("FULL_PATH") + private String fullPath; + + /** + * 层级 + */ + @TableField("TREE_LEVEL") + private Integer treeLevel; + + /** + * 是否有子集 + */ + @TableField("HAS_CHILDREN") + private Integer hasChildren; + + /** + * 图标 + */ + @TableField("ICON") + private String icon; + + /** + * 备注 + */ + @TableField("DESCRIPTION") + private String description; + + /** + * 是否启用 + */ + @TableField("ENABLE") + private Integer enable; + + /** + * 系统内置项 + */ + @TableField("INTERNAL") + private Integer internal; + + /** + * 排序 + */ + @TableField("ORDER_INDEX") + private Integer orderIndex; + + /** + * 过滤内容 + */ + @TableField("FILTER_CONTENT") + private String filterContent; + + /** + * 创建人 + */ + @TableField("RECORD_USER") + private String recordUser; + + /** + * 创建时间 + */ + @TableField("RECORD_TIME") + private Date recordTime; + + /** + * 更新人 + */ + @TableField("MODIFY_USER") + private String modifyUser; + + /** + * 更新时间 + */ + @TableField("MODIFY_TIME") + private Date modifyTime; + + /** + * 是否已删除 + */ + @TableField("IS_DELETED") + private Integer isDeleted; + + /** + * 删除人 + */ + @TableField("DELETE_USER") + private String deleteUser; + + /** + * 删除时间 + */ + @TableField("DELETE_TIME") + private Date deleteTime; + + /** + * 类型:0-功能区 1-地形 2-图例 + */ + @TableField("TOOL_TYPE") + private Integer toolType; + + /** + * 归属的系统ID(非数据库字段,来自MS_MAPMODULE_B关联) + */ + @TableField(exist = false) + private String systemId; + + /** + * 是否默认勾选(非数据库字段,来自MS_MAPMODULE_B关联) + */ + @TableField(exist = false) + private Integer checked; + + /** + * 是否可勾选(非数据库字段,来自MS_MAPMODULE_B关联) + */ + @TableField(exist = false) + private Integer canBeChecked; + + /** + * 是否多选(非数据库字段,来自MS_MAPMODULE_B关联) + */ + @TableField(exist = false) + private Integer multiSelect; + + /** 子级集合(非数据库字段) */ + @TableField(exist = false) + private List children; +} diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/entity/vo/MapLayerVo.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/entity/vo/MapLayerVo.java new file mode 100644 index 00000000..55c7ad5e --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/entity/vo/MapLayerVo.java @@ -0,0 +1,80 @@ +package com.yfd.platform.qgc_sys.mapLayer.entity.vo; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 地图图层管理封装VO + * + * @author migration + */ +@Data +@Schema(description = "地图图层管理封装VO") +public class MapLayerVo { + + @Schema(description = "主键") + private String id; + + @Schema(description = "父id") + private String parentId; + + @Schema(description = "标题名称") + private String title; + + @Schema(description = "图层标识") + @JsonProperty(value = "key") + private String code; + + @Schema(description = "标签层级") + @JsonProperty(value = "labelLevel") + private Integer labelLevel; + + @Schema(description = "是否可以选择:0=否 1=是") + private Integer checkable; + + @Schema(description = "图层分类") + private String type; + + @Schema(description = "图层上下层层级关系") + @JsonProperty(value = "zIndex") + private String zIndex; + + @Schema(description = "各类站点图层对应类型") + private String sttpType; + + @Schema(description = "图层展示数据格式") + private String layers; + + @Schema(description = "url地址") + private String url; + + @Schema(description = "3D url地址") + private String urlThd; + + @Schema(description = "图层透明度") + private BigDecimal opacity; + + @Schema(description = "子级集合") + private List children; + + @Schema(description = "参数json") + private String paramJson; + + @Schema(description = "排序") + private String orderIndex; + + @Schema(description = "是否默认勾选:0=否 1=是") + private Integer checked; + + @Schema(description = "是否可勾选:0=否 1=是") + private Integer canBeChecked; + + @Schema(description = "是否多选:0=否 1=是") + private Integer multiSelect; + @Schema(description = "参数设置:steady=静态 dynamic=动态") + private String options; +} diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/entity/vo/MapLegendVo.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/entity/vo/MapLegendVo.java new file mode 100644 index 00000000..3ad7fa4a --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/entity/vo/MapLegendVo.java @@ -0,0 +1,97 @@ +package com.yfd.platform.qgc_sys.mapLayer.entity.vo; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 地图图例VO + * + * @author migration + */ +@Data +@Schema(description = "地图图例VO") +public class MapLegendVo { + + @Schema(description = "图例id") + private String id; + + @Schema(description = "父级id") + private String parentId; + + @Schema(description = "分组名") + private String groupName; + + @Schema(description = "层级名称") + private String parentName; + + @Schema(description = "图例名") + private String name; + + @Schema(description = "图例code") + private String code; + + @Schema(description = "图例icon") + private String icon; + + @Schema(description = "图例英文(对应描点数据中的状态)") + private String nameEn; + + @Schema(description = "图层code") + private String layerCode; + + @Schema(description = "是否多选;0=否;1=是") + private Integer multiSelect; + + @Schema(description = "是否默认勾选;0=否;1=是") + private Integer checked; + + @Schema(description = "是否可勾选;0=否;1=是") + private Integer canBeChecked; + + @Schema(description = "子排序") + private Integer orderIndex; + + @Schema(description = "父排序") + private Integer pSort; + + @Schema(description = "最小缩放等级") + private Integer minZoom; + + @Schema(description = "最大缩放等级") + private Integer maxZoom; + + @Schema(description = "最小高程-三维") + private BigDecimal minHeightThd; + + @Schema(description = "最大高程-三维") + private BigDecimal maxHeightThd; + + @Schema(description = "是否显示;0=否;1=是") + private Integer ifShow; + + @Schema(description = "是否过滤;0=否;1=是") + private Integer isFilter; + + @JsonProperty(value = "color") + @Schema(description = "图例颜色") + private String color; + + @JsonProperty(value = "shape") + @Schema(description = "图例形状") + private String shape; + + @JsonProperty(value = "minVal") + @Schema(description = "区间最小值") + private BigDecimal minVal; + + @JsonProperty(value = "maxVal") + @Schema(description = "区间最大值") + private BigDecimal maxVal; + + @Schema(description = "子级") + private List childrenList; +} \ No newline at end of file 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 774e4c00..e219ae10 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 @@ -2,7 +2,14 @@ package com.yfd.platform.qgc_sys.mapLayer.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.yfd.platform.qgc_sys.mapLayer.domain.MsMapmoduleB; +import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaptoolboxB; +import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLayerVo; +import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLegendVo; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; /** * 地图与菜单映射表 Mapper 接口 @@ -11,4 +18,73 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface MsMapmoduleBMapper extends BaseMapper { + + /** + * 查询地图图层树(关联MS_MAPMODULE_B与MS_MAPLAYER_B) + */ + @Select("") + List getMapLayerTree(@Param("moduleId") String moduleId, @Param("sid") String sid, + @Param("templateId") String templateId); + + /** + * 查询地图工具箱(关联MS_MAPMODULE_B与MS_MAPTOOLBOX_B) + */ + @Select("") + List getMapToolBox(@Param("moduleId") String moduleId, @Param("sid") String sid, + @Param("templateId") String templateId); + + /** + * 查询模块关联的图例列表(关联MS_MAPMODULE_B与MS_MAPLEGEND_B) + */ + @Select("") + List getModuleMapLegendList(@Param("moduleId") String moduleId, @Param("sid") String sid, + @Param("templateId") String templateId); } \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/mapper/MsMaptoolboxBMapper.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/mapper/MsMaptoolboxBMapper.java new file mode 100644 index 00000000..cff67cc6 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/mapper/MsMaptoolboxBMapper.java @@ -0,0 +1,15 @@ +package com.yfd.platform.qgc_sys.mapLayer.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaptoolboxB; +import org.apache.ibatis.annotations.Mapper; + +/** + * 地图工具箱表 Mapper 接口 + * + * @author migration + */ +@Mapper +public interface MsMaptoolboxBMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/IMapLayerBizService.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/IMapLayerBizService.java index f0933a77..6705b7df 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/IMapLayerBizService.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/IMapLayerBizService.java @@ -2,6 +2,7 @@ package com.yfd.platform.qgc_sys.mapLayer.service; import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplayerB; import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLayerAo; +import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLayerVo; import java.util.List; @@ -19,4 +20,15 @@ public interface IMapLayerBizService { * @return 图层树列表 */ List getMapLayerTree(MapLayerAo flag); + + /** + * 根据模块ID、系统ID、模板ID获取地图图层树(关联MS_MAPMODULE_B) + * + * @param moduleId 模块ID + * @param systemId 系统ID + * @param templateId 模板ID + * @return 图层树列表 + */ + List getMapLayerTree(String moduleId, String systemId, String templateId); + } \ 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 new file mode 100644 index 00000000..30d35833 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/IMapLegendBizService.java @@ -0,0 +1,33 @@ +package com.yfd.platform.qgc_sys.mapLayer.service; + +import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLegendVo; + +import java.util.List; + +/** + * 地图图例业务服务接口 + * + * @author migration + */ +public interface IMapLegendBizService { + + /** + * 获取地图图例树(下拉选) + * + * @param flag 数据类型过滤:null=全部, 1=结构, 2=数据 + * @return 图例树 + */ + List getMapLegendTree(Integer flag); + + + /** + * 根据模块ID、系统ID、模板ID获取模块关联的图例列表 + * + * @param moduleId 模块ID + * @param systemId 系统ID + * @param templateId 模板ID + * @return 图例列表 + */ + List getModuleMapLegendList(String moduleId, String systemId, String templateId); + +} \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/impl/MapLayerBizServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/impl/MapLayerBizServiceImpl.java index 4ba92e0a..0bab5095 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/impl/MapLayerBizServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/impl/MapLayerBizServiceImpl.java @@ -4,7 +4,9 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplayerB; import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLayerAo; +import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLayerVo; import com.yfd.platform.qgc_sys.mapLayer.mapper.MsMaplayerBMapper; +import com.yfd.platform.qgc_sys.mapLayer.mapper.MsMapmoduleBMapper; import com.yfd.platform.qgc_sys.mapLayer.service.IMapLayerBizService; import com.yfd.platform.system.domain.SysDictionary; import com.yfd.platform.system.domain.SysDictionaryItems; @@ -38,6 +40,9 @@ public class MapLayerBizServiceImpl implements IMapLayerBizService { @Resource private SysUserMapper sysUserMapper; + @Resource + private MsMapmoduleBMapper msMapmoduleBMapper; + @Override public List getMapLayerTree(MapLayerAo flag) { // 1. 查询字典 "DTZJLX" 获取需要排除的图层类型 @@ -159,6 +164,50 @@ public class MapLayerBizServiceImpl implements IMapLayerBizService { if (children != null && !children.isEmpty()) { parent.setChildren(children); convertTree(children, childrenMap); + }else { + // 当没有子节点时,显式设置为空列表,保证 JSON 输出为 [] 而不是 null + parent.setChildren(new ArrayList<>()); + } + } + } + + @Override + public List getMapLayerTree(String moduleId, String systemId, String templateId) { + // 通过 JOIN 查询 MS_MAPLAYER_B 和 MS_MAPMODULE_B + List allLayers = msMapmoduleBMapper.getMapLayerTree(moduleId, systemId, templateId); + + if (allLayers == null || allLayers.isEmpty()) { + return new ArrayList<>(); + } + + // 取第一级 + List parents = allLayers.stream() + .filter(p -> StrUtil.isBlank(p.getParentId())) + .collect(Collectors.toList()); + + // 通过父级id分组子节点 + Map> childrenMap = allLayers.stream() + .filter(p -> StrUtil.isNotBlank(p.getParentId())) + .collect(Collectors.groupingBy(MapLayerVo::getParentId)); + + // 递归构建树 + convertLayerVoTree(parents, childrenMap); + return parents; + } + + /** + * 递归转换图层VO为树结构 + */ + private void convertLayerVoTree(List parents, Map> childrenMap) { + if (parents == null || parents.isEmpty()) { + return; + } + for (MapLayerVo parent : parents) { + String id = parent.getId(); + List children = childrenMap.get(id); + if (children != null && !children.isEmpty()) { + parent.setChildren(children); + convertLayerVoTree(children, childrenMap); } } } 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 new file mode 100644 index 00000000..cdc7a489 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapLayer/service/impl/MapLegendBizServiceImpl.java @@ -0,0 +1,145 @@ +package com.yfd.platform.qgc_sys.mapLayer.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplegendB; +import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLegendVo; +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 org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 地图图例业务服务实现类 + * + * @author migration + */ +@Service +public class MapLegendBizServiceImpl implements IMapLegendBizService { + + @Resource + private IMapLegendService legendService; + @Resource + private MsMapmoduleBMapper msMapmoduleBMapper; + /** + * 数据类型枚举:1=结构 + */ + private static final int DATA_TYPE_STRUCT = 1; + /** + * 数据类型枚举:2=数据 + */ + private static final int DATA_TYPE_DATA = 2; + + @Override + public List getMapLegendTree(Integer flag) { + // 查询所有数据 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(MsMaplegendB::getIsDeleted, 0); + if (flag != null) { + if (flag == DATA_TYPE_STRUCT) { + wrapper.eq(MsMaplegendB::getDataType, DATA_TYPE_STRUCT); + } else if (flag == DATA_TYPE_DATA) { + wrapper.eq(MsMaplegendB::getDataType, DATA_TYPE_DATA); + } + } + List legendList = legendService.list(wrapper); + + // 转换为VO + List list = new ArrayList<>(); + for (MsMaplegendB legend : legendList) { + MapLegendVo vo = new MapLegendVo(); + BeanUtil.copyProperties(legend, vo); + list.add(vo); + } + + // 取第一级 + List parents = list.stream() + .filter(p -> StringUtils.isBlank(p.getParentId())) + .sorted(Comparator.comparing(MapLegendVo::getOrderIndex, Comparator.nullsLast(Integer::compareTo))) + .collect(Collectors.toList()); + + // 通过父级id分组 + Map> mapList = list.stream() + .filter(p -> StringUtils.isNotBlank(p.getParentId())) + .collect(Collectors.groupingBy(MapLegendVo::getParentId)); + + // 递归转换数据为树结构 + convertTree(parents, mapList); + return parents; + } + + /** + * 递归转换树结构 + */ + private void convertTree(List parents, Map> subList) { + if (parents == null || parents.isEmpty()) { + return; + } + for (MapLegendVo p : parents) { + String id = p.getId(); + for (Map.Entry> entry : subList.entrySet()) { + String pid = entry.getKey(); + List children = entry.getValue(); + if (id.equals(pid)) { + p.setChildrenList(children); + convertTree(children, subList); + } + } + } + } + + + @Override + public List getModuleMapLegendList(String moduleId, String systemId, String templateId) { + List list = new ArrayList<>(); + // 通过 JOIN 查询 MS_MAPLEGEND_B 和 MS_MAPMODULE_B + List bbiMapLegendList = msMapmoduleBMapper.getModuleMapLegendList(moduleId, systemId, templateId); + + if (bbiMapLegendList == null || bbiMapLegendList.isEmpty()) { + return list; + } + + // 按父级分组 + Map> collect = bbiMapLegendList.stream() + .collect(Collectors.groupingBy(MapLegendVo::getParentName)); + + // 遍历 + collect.forEach((str, mapLegendVoList) -> { + MapLegendVo mapLegendVo = new MapLegendVo(); + mapLegendVo.setName(str); + mapLegendVo.setPSort(mapLegendVoList.get(0).getPSort()); + // 按子级分组名分组 + 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 09204d83..0ddd61ef 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 @@ -1,5 +1,6 @@ package com.yfd.platform.qgc_sys.mapcfg.controller; 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.DataSourceRequest; @@ -8,13 +9,17 @@ import com.yfd.platform.config.ResponseResult; import com.yfd.platform.common.exception.BizException; import com.yfd.platform.qgc_sys.mapLayer.domain.MsMapmoduleB; import com.yfd.platform.qgc_sys.mapcfg.service.IMapmoduleBService; +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 io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import org.springframework.web.bind.annotation.*; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * 地图菜单配置控制层 @@ -29,6 +34,9 @@ public class MapmoduleBController { @Resource private IMapmoduleBService mapmoduleBService; + @Resource + private SysMenuMapper sysMenuMapper; + /** * 条件过滤数据列表(Kendo UI 数据源) */ @@ -57,9 +65,55 @@ public class MapmoduleBController { dataSourceResult.setData(dataList); dataSourceResult.setTotal(resultPage.getTotal()); - // 翻译字典值(菜单名称) + // 翻译字典值(原有逻辑,可能处理其他字段) 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" + .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 类型需匹配 + ); + menuNameMap = menus.stream() + .collect(Collectors.toMap( + menu -> String.valueOf(menu.getId()), // 统一转为字符串 + SysMenu::getName + )); + } + + // 2. 遍历 dataList 设置 moduleName + for (MsMapmoduleB entity : dataList) { + String moduleId = entity.getModuleId(); + if (moduleId == null) { + entity.setModuleName(null); + } else if ("tycd".equals(moduleId)) { + // 特殊处理:固定为 "通用菜单" + entity.setModuleName("通用菜单"); + } else { + // 从查询结果中获取 + entity.setModuleName(menuNameMap.get(moduleId)); + // 如果 menuNameMap 中不存在,则置 null(或保留原值,视业务而定) + if (entity.getModuleName() == null) { + entity.setModuleName(null); // 或者 entity.setModuleName(""); + } + } + } + // ========== 2. 处理 systemName 特殊值 ========== + for (MsMapmoduleB entity : dataList) { + if ("qgc".equals(entity.getSystemId())) { + entity.setSystemName("qgc"); + } + // 其他 systemId 保留字典翻译的结果 + } } return ResponseResult.successData(dataSourceResult); @@ -98,4 +152,15 @@ public class MapmoduleBController { mapmoduleBService.delelteByIds(ids); return ResponseResult.success("删除成功."); } + + + /** + * 地图图层管理数据 + */ + @Operation(summary = "地图图层管理数据") + @PostMapping("/getMapData") + public ResponseResult getMapData(@RequestBody MsMapmoduleB mapmoduleB) { + MapmoduleVo result = mapmoduleBService.getMapData(mapmoduleB); + return ResponseResult.successData(result); + } } \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/entity/MapmoduleVo.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/entity/MapmoduleVo.java new file mode 100644 index 00000000..30134555 --- /dev/null +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/entity/MapmoduleVo.java @@ -0,0 +1,47 @@ +package com.yfd.platform.qgc_sys.mapcfg.entity; + +import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaptoolboxB; +import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLayerVo; +import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLegendVo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +/** + * 地图与菜单查询返回实体类 + * + * @author migration + */ +@Data +@Schema(description = "地图菜单配置实体类") +public class MapmoduleVo { + + /** GIS地图多功能区 */ + @Schema(description = "GIS地图多功能区") + private List maptoolbox; + + /** GIS默认数据加载 - 地形 */ + @Schema(description = "GIS默认数据加载 - 地形") + private List terrain; + + /** GIS默认数据加载 - 图例 */ + @Schema(description = "GIS默认数据加载 - 图例") + private List legend; + + /** GIS默认数据加载 - 内容模块 */ + @Schema(description = "GIS默认数据加载 - 内容模块") + private List content; + + /** GIS默认数据加载 - 环保监测 */ + @Schema(description = "GIS默认数据加载 - 环保监测") + private List hbcj; + + /** GIS图层区 */ + @Schema(description = "GIS图层区") + private List mapLayerVos; + + /** 地图图例 */ + @Schema(description = "地图图例") + private List mapLegendVos; +} \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/service/IMapmoduleBService.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/service/IMapmoduleBService.java index 26c34a34..c6dcf69c 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/service/IMapmoduleBService.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/service/IMapmoduleBService.java @@ -2,6 +2,7 @@ package com.yfd.platform.qgc_sys.mapcfg.service; import com.baomidou.mybatisplus.extension.service.IService; import com.yfd.platform.qgc_sys.mapLayer.domain.MsMapmoduleB; +import com.yfd.platform.qgc_sys.mapcfg.entity.MapmoduleVo; import java.util.List; @@ -33,4 +34,12 @@ public interface IMapmoduleBService extends IService { * @param ids ID列表 */ void delelteByIds(List ids); + + /** + * 获取地图数据(图层树、图例、工具箱) + * + * @param mapmoduleB 查询参数 + * @return 地图数据 + */ + MapmoduleVo getMapData(MsMapmoduleB mapmoduleB); } \ No newline at end of file diff --git a/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/service/impl/MapmoduleBServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/service/impl/MapmoduleBServiceImpl.java index d650bb50..1b7b5098 100644 --- a/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/service/impl/MapmoduleBServiceImpl.java +++ b/backend/src/main/java/com/yfd/platform/qgc_sys/mapcfg/service/impl/MapmoduleBServiceImpl.java @@ -4,8 +4,15 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.yfd.platform.qgc_sys.mapLayer.domain.MsMapmoduleB; +import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaptoolboxB; import com.yfd.platform.qgc_sys.mapLayer.mapper.MsMapmoduleBMapper; +import com.yfd.platform.qgc_sys.mapLayer.service.IMapLayerBizService; +import com.yfd.platform.qgc_sys.mapLayer.service.IMapLegendBizService; import com.yfd.platform.qgc_sys.mapcfg.service.IMapmoduleBService; +import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLayerVo; +import com.yfd.platform.qgc_sys.mapLayer.entity.vo.MapLegendVo; +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.SecurityUtils; @@ -29,6 +36,13 @@ public class MapmoduleBServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); + // lambdaQueryWrapper.eq(MsTemplateB::getIsDefault, 1); + // lambdaQueryWrapper.eq(MsTemplateB::getIsDeleted, 0); + // lambdaQueryWrapper.eq(MsTemplateB::getModuleId, mapmoduleB.getModuleId()); + // MsTemplateB msTemplateB = msTemplateBMapper.selectOne(lambdaQueryWrapper); + // if (msTemplateB != null) { + // templateId = msTemplateB.getId(); + // } + // } else { + // templateId = mapmoduleB.getTemplateId(); + // } + // ========== 预留代码结束 ========== + + MapmoduleVo mapmoduleVo = new MapmoduleVo(); + + // 1. GIS图层区 + List layer = mapLayerBizService.getMapLayerTree( + mapmoduleB.getModuleId(), mapmoduleB.getSystemId(), templateId); + mapmoduleVo.setMapLayerVos(layer); + + // 2. 地图图例 + List legend = mapLegendBizService.getModuleMapLegendList( + mapmoduleB.getModuleId(), mapmoduleB.getSystemId(), templateId); + mapmoduleVo.setMapLegendVos(legend); + + // 3. 地图工具箱 + List mapToolBox = baseMapper.getMapToolBox( + mapmoduleB.getModuleId(), mapmoduleB.getSystemId(), templateId); + + // 按toolType分组 + Map> groupedByType = mapToolBox.stream() + .collect(Collectors.groupingBy(MsMaptoolboxB::getToolType)); + + // 图例(toolType=2) + mapmoduleVo.setLegend(groupedByType.get(2)); + + // 内容模块(toolType=3) + List contentLayerTree = getContentLayerTree(groupedByType); + mapmoduleVo.setContent(contentLayerTree); + + // 环保监测(toolType=4) + mapmoduleVo.setHbcj(groupedByType.get(4)); + + return mapmoduleVo; + } + + /** + * 获取内容模块图层树 + */ + private List getContentLayerTree(Map> groupedByType) { + List msMaptoolboxBList = new java.util.ArrayList<>(); + List contentToolBoxList = groupedByType.get(3); + if (contentToolBoxList != null) { + for (MsMaptoolboxB msMaptoolboxB : contentToolBoxList) { + if (StrUtil.isNotBlank(msMaptoolboxB.getPatentId())) { + // 如果内容模块没有进行配置,则默认全部勾选 + if (msMaptoolboxB.getChecked() == null) { + msMaptoolboxB.setChecked(1); + } + msMaptoolboxBList.add(msMaptoolboxB); + } + } + } + return msMaptoolboxBList; + } } \ No newline at end of file