地图图例列表代码提交

This commit is contained in:
lilin 2026-07-01 18:19:37 +08:00
parent f3a54bc4eb
commit e0b8dd2e49
5 changed files with 128 additions and 22 deletions

View File

@ -196,4 +196,14 @@ public class MapLegendController {
List<MapLegendVo> tree = mapLegendBizService.getMapLegendTree(flag); List<MapLegendVo> tree = mapLegendBizService.getMapLegendTree(flag);
return ResponseResult.successData(tree); return ResponseResult.successData(tree);
} }
/**
* 地图图例列表
*/
@Operation(summary = "地图图例列表")
@GetMapping("/getModuleMapLegendList")
public ResponseResult getModuleMapLegendList(@RequestParam(required = false) String moduleId) {
List<MapLegendVo> list = mapLegendBizService.getModuleMapLegendList(moduleId);
return ResponseResult.successData(list);
}
} }

View File

@ -87,4 +87,28 @@ public interface MsMapmoduleBMapper extends BaseMapper<MsMapmoduleB> {
+ "</script>") + "</script>")
List<MapLegendVo> getModuleMapLegendList(@Param("moduleId") String moduleId, @Param("sid") String sid, List<MapLegendVo> getModuleMapLegendList(@Param("moduleId") String moduleId, @Param("sid") String sid,
@Param("templateId") String templateId); @Param("templateId") String templateId);
/**
* 查询模块关联的图例列表单参数版本用于地图图例管理页面
*/
@Select("<script>"
+ "SELECT BML.ID, BML.PARENT_ID AS parentId, BML.GROUP_NAME AS groupName, BML.PARENT_NAME AS parentName, "
+ "BML.NAME, BML.CODE, BML.ICON, BML.NAME_EN AS nameEn, BML.LAYER_CODE AS layerCode, "
+ "BML.MIN_ZOOM AS minZoom, BML.MAX_ZOOM AS maxZoom, "
+ "BML.MIN_HEIGHT_THD AS minHeightThd, BML.MAX_HEIGHT_THD AS maxHeightThd, "
+ "BML.IF_SHOW AS ifShow, BML.IS_FILTER AS isFilter, BML.COLOR, BML.SHAPE, BML.MIN_VAL AS minVal, BML.MAX_VAL AS maxVal, "
+ "BML.ORDER_INDEX AS orderIndex, "
+ "BMM.MULTI_SELECT AS multiSelect, BMM.CHECKED AS checked, BMM.CAN_BE_CHECKED AS canBeChecked, "
+ "BMM.ORDER_INDEX AS pSort "
+ "FROM MS_MAPLEGEND_B BML LEFT JOIN MS_MAPMODULE_B BMM ON BML.ID = BMM.RES_ID "
+ "WHERE BMM.RES_TYPE = 'legend' AND BML.IS_DELETED = 0 AND BML.ENABLE = 1 "
+ "<choose>"
+ "<when test=\"moduleId != null and moduleId != ''\"> AND BMM.MODULE_ID = #{moduleId}</when>"
+ "<otherwise> AND BMM.MODULE_ID = 'common'</otherwise>"
+ "</choose>"
+ "ORDER BY BMM.ORDER_INDEX, BML.ORDER_INDEX"
+ "</script>")
List<MapLegendVo> getModuleMapLegendList(@Param("moduleId") String moduleId);
} }

View File

@ -30,4 +30,13 @@ public interface IMapLegendBizService {
*/ */
List<MapLegendVo> getModuleMapLegendList(String moduleId, String systemId, String templateId); List<MapLegendVo> getModuleMapLegendList(String moduleId, String systemId, String templateId);
/**
* 根据模块ID获取模块关联的图例列表单参数版本
*
* @param moduleId 模块ID
* @return 图例列表
*/
List<MapLegendVo> getModuleMapLegendList(String moduleId);
} }

View File

@ -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.IMapLegendBizService;
import com.yfd.platform.qgc_sys.mapLayer.service.IMapLegendService; import com.yfd.platform.qgc_sys.mapLayer.service.IMapLegendService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import cn.hutool.core.collection.CollectionUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -142,4 +143,70 @@ public class MapLegendBizServiceImpl implements IMapLegendBizService {
.sorted(Comparator.comparing(MapLegendVo::getPSort, Comparator.nullsLast(Integer::compareTo))) .sorted(Comparator.comparing(MapLegendVo::getPSort, Comparator.nullsLast(Integer::compareTo)))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override
public List<MapLegendVo> getModuleMapLegendList(String moduleId) {
List<MapLegendVo> list = new ArrayList<>();
// 通过 JOIN 查询 MS_MAPLEGEND_B MS_MAPMODULE_B单参数版本
List<MapLegendVo> bbiMapLegendList = msMapmoduleBMapper.getModuleMapLegendList(moduleId);
if (bbiMapLegendList == null || bbiMapLegendList.isEmpty()) {
return list;
}
// 收集父级ID查询父级图例的layerCode
Set<String> parentIdList = bbiMapLegendList.stream()
.map(MapLegendVo::getParentId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
Map<String, String> layerCodeMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(parentIdList)) {
List<MsMaplegendB> 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<String, List<MapLegendVo>> collect = bbiMapLegendList.stream()
.collect(Collectors.groupingBy(MapLegendVo::getParentName));
// 遍历
Map<String, String> 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<String, List<MapLegendVo>> collect1 = mapLegendVoList.stream()
.collect(Collectors.groupingBy(MapLegendVo::getGroupName));
List<MapLegendVo> childrenList = new ArrayList<>();
for (String groupNameStr : collect1.keySet()) {
List<MapLegendVo> 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<MapLegendVo> 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());
}
} }

View File

@ -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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.DataSourceRequest;
import com.yfd.platform.common.DataSourceResult; import com.yfd.platform.common.DataSourceResult;
import com.yfd.platform.config.ResponseResult; 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.domain.SysMenu;
import com.yfd.platform.system.mapper.SysMenuMapper; import com.yfd.platform.system.mapper.SysMenuMapper;
import com.yfd.platform.utils.DataSourceRequestUtil; 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.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -43,12 +45,16 @@ public class MapmoduleBController {
@Operation(summary = "条件过滤数据列表") @Operation(summary = "条件过滤数据列表")
@PostMapping("/GetKendoList") @PostMapping("/GetKendoList")
public ResponseResult getKendoList(@RequestBody DataSourceRequest dataSourceRequest) { public ResponseResult getKendoList(@RequestBody DataSourceRequest dataSourceRequest) {
// 构建查询条件 // 1. 构建查询条件
QueryWrapper<MsMapmoduleB> wrapper = DataSourceRequestUtil.buildQueryWrapper( QueryWrapper<MsMapmoduleB> wrapper = DataSourceRequestUtil.buildQueryWrapper(
dataSourceRequest, MsMapmoduleB.class); dataSourceRequest, MsMapmoduleB.class);
// 执行分页查询 // 2. 分页参数处理 getMsstbprptList 完全一致
Page<MsMapmoduleB> page = DataSourceRequestUtil.getPage(dataSourceRequest); DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
Page<MsMapmoduleB> page = loadOptions == null ? null
: (Page<MsMapmoduleB>) QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
// 3. 执行分页查询
Page<MsMapmoduleB> resultPage; Page<MsMapmoduleB> resultPage;
if (page != null) { if (page != null) {
resultPage = mapmoduleBService.page(page, wrapper); resultPage = mapmoduleBService.page(page, wrapper);
@ -59,60 +65,50 @@ public class MapmoduleBController {
resultPage.setTotal(list.size()); resultPage.setTotal(list.size());
} }
// 构建 Kendo 数据源结果 // 4. 构建 Kendo 数据源结果
DataSourceResult<MsMapmoduleB> dataSourceResult = new DataSourceResult<>(); DataSourceResult<MsMapmoduleB> dataSourceResult = new DataSourceResult<>();
List<MsMapmoduleB> dataList = resultPage.getRecords(); List<MsMapmoduleB> dataList = resultPage.getRecords();
dataSourceResult.setData(dataList); dataSourceResult.setData(dataList);
dataSourceResult.setTotal(resultPage.getTotal()); dataSourceResult.setTotal(resultPage.getTotal());
// 翻译字典值原有逻辑可能处理其他字段 // 5. 翻译与额外字段填充原有逻辑保持不变
if (dataList != null && !dataList.isEmpty()) { if (dataList != null && !dataList.isEmpty()) {
mapmoduleBService.translateDict(dataList); mapmoduleBService.translateDict(dataList);
// ----- 新增填充 moduleName -----
// 1. 先收集需要从数据库查询的 moduleId排除 "tycd"
Set<String> needQueryIds = dataList.stream() Set<String> needQueryIds = dataList.stream()
.map(MsMapmoduleB::getModuleId) .map(MsMapmoduleB::getModuleId)
.filter(id -> id != null && !"tycd".equals(id)) // 过滤掉 "tycd" .filter(id -> id != null && !"tycd".equals(id))
.collect(Collectors.toSet()); .collect(Collectors.toSet());
Map<String, String> menuNameMap = new HashMap<>(); Map<String, String> menuNameMap = new HashMap<>();
if (!needQueryIds.isEmpty()) { if (!needQueryIds.isEmpty()) {
// 查询 SYS_MENU 假设实体为 SysMenuMapper sysMenuMapper
List<SysMenu> menus = sysMenuMapper.selectList( List<SysMenu> menus = sysMenuMapper.selectList(
new LambdaQueryWrapper<SysMenu>() new LambdaQueryWrapper<SysMenu>()
.in(SysMenu::getId, needQueryIds) // 注意 id 类型需匹配 .in(SysMenu::getId, needQueryIds)
); );
menuNameMap = menus.stream() menuNameMap = menus.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
menu -> String.valueOf(menu.getId()), // 统一转为字符串 menu -> String.valueOf(menu.getId()),
SysMenu::getName SysMenu::getName
)); ));
} }
// 2. 遍历 dataList 设置 moduleName
for (MsMapmoduleB entity : dataList) { for (MsMapmoduleB entity : dataList) {
// 填充 moduleName
String moduleId = entity.getModuleId(); String moduleId = entity.getModuleId();
if (moduleId == null) { if (moduleId == null) {
entity.setModuleName(null); entity.setModuleName(null);
} else if ("tycd".equals(moduleId)) { } else if ("tycd".equals(moduleId)) {
// 特殊处理固定为 "通用菜单"
entity.setModuleName("通用菜单"); entity.setModuleName("通用菜单");
entity.setChecked(1);
} else { } else {
// 从查询结果中获取
entity.setModuleName(menuNameMap.get(moduleId)); entity.setModuleName(menuNameMap.get(moduleId));
// 如果 menuNameMap 中不存在则置 null或保留原值视业务而定
if (entity.getModuleName() == null) {
entity.setModuleName(null); // 或者 entity.setModuleName("");
} }
}
} // 特殊 systemName
// ========== 2. 处理 systemName 特殊值 ==========
for (MsMapmoduleB entity : dataList) {
if ("qgc".equals(entity.getSystemId())) { if ("qgc".equals(entity.getSystemId())) {
entity.setSystemName("qgc"); entity.setSystemName("qgc");
} }
// 其他 systemId 保留字典翻译的结果
} }
} }