图层管理图例管理代码提交,查询 新增 修改 删除
This commit is contained in:
parent
47fa1688d6
commit
4ad2014e61
@ -71,6 +71,8 @@ public class SecurityConfig {
|
||||
// .requestMatchers("/fp/**").permitAll()
|
||||
// .requestMatchers("/fh/**").permitAll()
|
||||
// .requestMatchers("/data/**").permitAll()
|
||||
.requestMatchers("/mapLayer/**").permitAll()
|
||||
.requestMatchers("/mapLegend/**").permitAll()
|
||||
.requestMatchers("/sms/**").permitAll()
|
||||
.requestMatchers(HttpMethod.GET, "/").permitAll()
|
||||
.requestMatchers(HttpMethod.GET,
|
||||
|
||||
@ -146,4 +146,20 @@ public class SwaggerConfig {
|
||||
.packagesToScan("com.yfd.platform.qgc_eng.eq.controller")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi groupSysApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("5. 图层管理")
|
||||
.packagesToScan("com.yfd.platform.qgc_sys.mapLayer.controller")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi groupSysMlgApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("5.1 图例结构管理")
|
||||
.packagesToScan("com.yfd.platform.qgc_sys.mapLegend.controller")
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package com.yfd.platform.qgc_sys.mapLayer.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.entity.vo.MapLayerAo;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.service.IMapLayerBizService;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.service.IMapLayerService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 地图图层管理
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mapLayer")
|
||||
@Tag(name = "地图图层管理")
|
||||
public class MapLayerController {
|
||||
|
||||
@Resource
|
||||
private IMapLayerBizService mapLayerBizService;
|
||||
|
||||
@Resource
|
||||
private IMapLayerService layerService;
|
||||
|
||||
/**
|
||||
* 地图图层管理图层树(所有)
|
||||
*/
|
||||
@Operation(summary = "地图图层管理图层树(所有)")
|
||||
@PostMapping("/getAllMapLayerTree")
|
||||
public ResponseResult getAllMapLayerTree(@RequestBody MapLayerAo flag) {
|
||||
List<MsMaplayerB> tree = mapLayerBizService.getMapLayerTree(flag);
|
||||
return ResponseResult.successData(tree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图层新增修改
|
||||
*/
|
||||
@Operation(summary = "图层新增修改")
|
||||
@PostMapping("/save")
|
||||
public ResponseResult addLayer(@RequestBody MsMaplayerB layer) {
|
||||
if (layer == null) {
|
||||
return ResponseResult.error("图层信息不能为空.");
|
||||
}
|
||||
if (StrUtil.isBlank(layer.getCode())) {
|
||||
throw new BizException("图层编码(code)不能为空.");
|
||||
}
|
||||
if (StrUtil.isBlank(layer.getTitle())) {
|
||||
throw new BizException("图层名称(title)不能为空.");
|
||||
}
|
||||
layerService.saveOrUpdate(layer);
|
||||
return ResponseResult.success("保存成功.");
|
||||
}
|
||||
|
||||
/**
|
||||
* 图层删除
|
||||
*/
|
||||
@Operation(summary = "图层删除")
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult deleteLayer(@RequestBody List<String> ids) {
|
||||
layerService.delelteByIds(ids);
|
||||
return ResponseResult.success("删除成功.");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,102 @@
|
||||
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.QueryWrapper;
|
||||
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.MsMaplegendB;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.service.IMapLegendService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 地图图例管理
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mapLegend")
|
||||
@Tag(name = "地图图例管理")
|
||||
public class MapLegendController {
|
||||
|
||||
@Resource
|
||||
private IMapLegendService mapLegendService;
|
||||
|
||||
/**
|
||||
* 条件过滤数据列表(Kendo UI 数据源)
|
||||
*/
|
||||
@Operation(summary = "条件过滤数据列表")
|
||||
@PostMapping("/GetKendoList")
|
||||
public ResponseResult getKendoList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
// 构建查询条件
|
||||
QueryWrapper<MsMaplegendB> wrapper = DataSourceRequestUtil.buildQueryWrapper(
|
||||
dataSourceRequest, MsMaplegendB.class);
|
||||
|
||||
// 执行分页查询
|
||||
Page<MsMaplegendB> page = DataSourceRequestUtil.getPage(dataSourceRequest);
|
||||
Page<MsMaplegendB> resultPage;
|
||||
if (page != null) {
|
||||
resultPage = mapLegendService.page(page, wrapper);
|
||||
} else {
|
||||
List<MsMaplegendB> list = mapLegendService.list(wrapper);
|
||||
resultPage = new Page<>();
|
||||
resultPage.setRecords(list);
|
||||
resultPage.setTotal(list.size());
|
||||
}
|
||||
|
||||
// 构建 Kendo 数据源结果
|
||||
DataSourceResult<MsMaplegendB> dataSourceResult = new DataSourceResult<>();
|
||||
dataSourceResult.setData(resultPage.getRecords());
|
||||
dataSourceResult.setTotal(resultPage.getTotal());
|
||||
|
||||
return ResponseResult.successData(dataSourceResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图例新增修改
|
||||
*/
|
||||
@Operation(summary = "图例新增修改")
|
||||
@PostMapping("/save")
|
||||
public ResponseResult addLayer(@RequestBody MsMaplegendB legend) {
|
||||
if (legend == null) {
|
||||
return ResponseResult.error("图例信息不能为空.");
|
||||
}
|
||||
if (StrUtil.isBlank(legend.getCode())) {
|
||||
throw new BizException("图例类型(code: pointLayer=用于锚点,baseLayer=地图GIS)不能为空.");
|
||||
}
|
||||
if (StrUtil.isBlank(legend.getName())) {
|
||||
throw new BizException("图例名称(name)不能为空.");
|
||||
}
|
||||
if (StrUtil.isBlank(legend.getNameEn())) {
|
||||
throw new BizException("图例编码(nameEn)不能为空.");
|
||||
}
|
||||
if (legend.getDataType() == null) {
|
||||
throw new BizException("图例数据类型(dataType: 1=结构,2=数据)不能为空.");
|
||||
}
|
||||
if (legend.getDataType() == 2 && StrUtil.isBlank(legend.getLayerCode())) {
|
||||
throw new BizException("关联的图层编码(layerCode)不能为空.");
|
||||
}
|
||||
mapLegendService.saveOrUpdate(legend);
|
||||
return ResponseResult.success("保存成功.");
|
||||
}
|
||||
|
||||
/**
|
||||
* 图例删除
|
||||
*/
|
||||
@Operation(summary = "图例删除")
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult deleteLayer(@RequestBody List<String> ids) {
|
||||
mapLegendService.delelteByIds(ids);
|
||||
return ResponseResult.success("删除成功.");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,191 @@
|
||||
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.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地图图层表
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Data
|
||||
@TableName("MS_MAPLAYER_B")
|
||||
public class MsMaplayerB implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
/** 类型 */
|
||||
@TableField("TYPE")
|
||||
private String type;
|
||||
|
||||
/** 标识字段 */
|
||||
@TableField("KEY")
|
||||
private String key;
|
||||
|
||||
/** 编码 */
|
||||
@TableField("CODE")
|
||||
private String code;
|
||||
|
||||
/** 名称 */
|
||||
@TableField("TITLE")
|
||||
private String title;
|
||||
|
||||
/** 名称英文 */
|
||||
@TableField("TITLE_EN")
|
||||
private String titleEn;
|
||||
|
||||
/** 所属父节点 */
|
||||
@TableField("PARENT_ID")
|
||||
private String parentId;
|
||||
|
||||
/** 树全路径 */
|
||||
@TableField("FULL_PATH")
|
||||
private String fullPath;
|
||||
|
||||
/** 层级 */
|
||||
@TableField("TREE_LEVEL")
|
||||
private Integer treeLevel;
|
||||
|
||||
/** 是否有子集:0=否 1=有 */
|
||||
@TableField("HAS_CHILDREN")
|
||||
private Integer hasChildren;
|
||||
|
||||
/** 对应锚点接口 */
|
||||
@TableField("URL")
|
||||
private String url;
|
||||
|
||||
/** 对应三维锚点接口 */
|
||||
@TableField("URL_THD")
|
||||
private String urlThd;
|
||||
|
||||
/** 参数设置 */
|
||||
@TableField("OPTIONS")
|
||||
private String options;
|
||||
|
||||
/** 访问令牌 */
|
||||
@TableField("TOKEN")
|
||||
private String token;
|
||||
|
||||
/** 用户名 */
|
||||
@TableField("USERNAME")
|
||||
private String username;
|
||||
|
||||
/** 密码 */
|
||||
@TableField("PASSWORD")
|
||||
private String password;
|
||||
|
||||
/** 地图中心点经度 */
|
||||
@TableField("CENTER_LGTD")
|
||||
private BigDecimal centerLgtd;
|
||||
|
||||
/** 地图中心点纬度 */
|
||||
@TableField("CENTER_LTTD")
|
||||
private BigDecimal centerLttd;
|
||||
|
||||
/** 默认缩放级别 */
|
||||
@TableField("DEFAULT_ZOOM")
|
||||
private String defaultZoom;
|
||||
|
||||
/** 所属国家 */
|
||||
@TableField("COUNTRY")
|
||||
private String country;
|
||||
|
||||
/** 图标 */
|
||||
@TableField("ICON")
|
||||
private String icon;
|
||||
|
||||
/** 是否可选择:0=否 1=是 */
|
||||
@TableField("CHECKABLE")
|
||||
private Integer checkable;
|
||||
|
||||
/** 图层上下层层级关系 */
|
||||
@TableField("Z_INDEX")
|
||||
private String zIndex;
|
||||
|
||||
/** 各类站点图层对应类型 */
|
||||
@TableField("STTP_TYPE")
|
||||
private String sttpType;
|
||||
|
||||
/** 图层展示数据格式 */
|
||||
@TableField("LAYERS")
|
||||
private String layers;
|
||||
|
||||
/** 图层透明度 */
|
||||
@TableField("OPACITY")
|
||||
private BigDecimal opacity;
|
||||
|
||||
/** 额外参数 */
|
||||
@TableField("PARAMJSON")
|
||||
private String paramJson;
|
||||
|
||||
/** 备注 */
|
||||
@TableField("DESCRIPTION")
|
||||
private String description;
|
||||
|
||||
/** 是否启用:0=禁用 1=启用 */
|
||||
@TableField("ENABLE")
|
||||
private Integer enable;
|
||||
|
||||
/** 排序 */
|
||||
@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;
|
||||
|
||||
/** 是否已删除:0=未删除 1=已删除 */
|
||||
@TableField("IS_DELETED")
|
||||
private Integer isDeleted;
|
||||
|
||||
/** 删除人 */
|
||||
@TableField("DELETE_USER")
|
||||
private String deleteUser;
|
||||
|
||||
/** 删除时间 */
|
||||
@TableField("DELETE_TIME")
|
||||
private Date deleteTime;
|
||||
|
||||
/** 数据类型:1=结构,2=数据 */
|
||||
@TableField("DATA_TYPE")
|
||||
private Integer dataType;
|
||||
|
||||
/** 标签层级 */
|
||||
@TableField("LABEL_LEVEL")
|
||||
private Integer labelLevel;
|
||||
|
||||
/** 子级集合(非数据库字段) */
|
||||
@TableField(exist = false)
|
||||
private List<MsMaplayerB> children;
|
||||
|
||||
/** 创建人名称(非数据库字段) */
|
||||
@TableField(exist = false)
|
||||
private String displayRecordUser;
|
||||
}
|
||||
@ -0,0 +1,134 @@
|
||||
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.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 地图图例表
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Data
|
||||
@TableName("MS_MAPLEGEND_B")
|
||||
public class MsMaplegendB 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("ICON")
|
||||
private String icon;
|
||||
|
||||
@TableField("GROUP_NAME")
|
||||
private String groupName;
|
||||
|
||||
@TableField("PARENT_NAME")
|
||||
private String parentName;
|
||||
|
||||
@TableField("LAYER_CODE")
|
||||
private String layerCode;
|
||||
|
||||
@TableField("MIN_ZOOM")
|
||||
private Integer minZoom;
|
||||
|
||||
@TableField("MAX_ZOOM")
|
||||
private Integer maxZoom;
|
||||
|
||||
@TableField("MIN_HEIGHT_THD")
|
||||
private BigDecimal minHeightThd;
|
||||
|
||||
@TableField("MAX_HEIGHT_THD")
|
||||
private BigDecimal maxHeightThd;
|
||||
|
||||
@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;
|
||||
|
||||
@TableField("IF_SHOW")
|
||||
private Integer ifShow;
|
||||
|
||||
@TableField("EXPRESSION")
|
||||
private String expression;
|
||||
|
||||
@TableField("EXT")
|
||||
private String ext;
|
||||
|
||||
@TableField("DATA_TYPE")
|
||||
private Integer dataType;
|
||||
|
||||
@TableField("PARENT_ID")
|
||||
private String parentId;
|
||||
|
||||
@TableField("FULL_PATH")
|
||||
private String fullPath;
|
||||
|
||||
@TableField("TREE_LEVEL")
|
||||
private Integer treeLevel;
|
||||
|
||||
@TableField("HAS_CHILDREN")
|
||||
private Integer hasChildren;
|
||||
|
||||
@TableField("COLOR")
|
||||
private String color;
|
||||
|
||||
@TableField("SHAPE")
|
||||
private String shape;
|
||||
|
||||
@TableField("MIN_VAL")
|
||||
private BigDecimal minVal;
|
||||
|
||||
@TableField("MAX_VAL")
|
||||
private BigDecimal maxVal;
|
||||
|
||||
@TableField("IS_FILTER")
|
||||
private Integer isFilter;
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 地图与菜单映射表
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Data
|
||||
@TableName("MS_MAPMODULE_B")
|
||||
public class MsMapmoduleB implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
@TableField("MODULE_ID")
|
||||
private String moduleId;
|
||||
|
||||
@TableField("RES_TYPE")
|
||||
private String resType;
|
||||
|
||||
@TableField("RES_ID")
|
||||
private String resId;
|
||||
|
||||
@TableField("CHILD_NODE")
|
||||
private Integer childNode;
|
||||
|
||||
@TableField("MULTI_SELECT")
|
||||
private Integer multiSelect;
|
||||
|
||||
@TableField("CAN_BE_CHECKED")
|
||||
private Integer canBeChecked;
|
||||
|
||||
@TableField("CHECKED")
|
||||
private Integer checked;
|
||||
|
||||
@TableField("DESCRIPTION")
|
||||
private String description;
|
||||
|
||||
@TableField("ENABLE")
|
||||
private Integer enable;
|
||||
|
||||
@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;
|
||||
|
||||
@TableField("TEMPLATE_ID")
|
||||
private String templateId;
|
||||
|
||||
/**
|
||||
* 归属的系统ID(非数据库字段,用于字典翻译)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String systemId;
|
||||
|
||||
/**
|
||||
* 菜单名称(非数据库字段,用于字典翻译)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String moduleName;
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.yfd.platform.qgc_sys.mapLayer.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 地图图层查询参数
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Data
|
||||
public class MapLayerAo {
|
||||
|
||||
/** 图层名称(模糊查询) */
|
||||
private String title;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.yfd.platform.qgc_sys.mapLayer.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplayerB;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 地图图层表 Mapper 接口
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Mapper
|
||||
public interface MsMaplayerBMapper extends BaseMapper<MsMaplayerB> {
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.yfd.platform.qgc_sys.mapLayer.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplegendB;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 地图图例表 Mapper 接口
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Mapper
|
||||
public interface MsMaplegendBMapper extends BaseMapper<MsMaplegendB> {
|
||||
}
|
||||
@ -0,0 +1,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 org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 地图与菜单映射表 Mapper 接口
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Mapper
|
||||
public interface MsMapmoduleBMapper extends BaseMapper<MsMapmoduleB> {
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
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 java.util.List;
|
||||
|
||||
/**
|
||||
* 地图图层业务服务接口
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
public interface IMapLayerBizService {
|
||||
|
||||
/**
|
||||
* 获取所有地图图层树
|
||||
*
|
||||
* @param flag 查询参数
|
||||
* @return 图层树列表
|
||||
*/
|
||||
List<MsMaplayerB> getMapLayerTree(MapLayerAo flag);
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.yfd.platform.qgc_sys.mapLayer.service;
|
||||
|
||||
import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplayerB;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地图图层基础服务接口
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
public interface IMapLayerService {
|
||||
|
||||
/**
|
||||
* 新增或修改图层
|
||||
*
|
||||
* @param layer 图层实体
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean saveOrUpdate(MsMaplayerB layer);
|
||||
|
||||
/**
|
||||
* 根据ID列表删除图层
|
||||
*
|
||||
* @param ids 图层ID列表
|
||||
*/
|
||||
void delelteByIds(List<String> ids);
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.yfd.platform.qgc_sys.mapLayer.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplegendB;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地图图例基础服务接口
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
public interface IMapLegendService extends IService<MsMaplegendB> {
|
||||
|
||||
/**
|
||||
* 根据ID列表删除图例
|
||||
*
|
||||
* @param ids 图例ID列表
|
||||
*/
|
||||
void delelteByIds(List<String> ids);
|
||||
}
|
||||
@ -0,0 +1,165 @@
|
||||
package com.yfd.platform.qgc_sys.mapLayer.service.impl;
|
||||
|
||||
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.mapper.MsMaplayerBMapper;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.service.IMapLayerBizService;
|
||||
import com.yfd.platform.system.domain.SysDictionary;
|
||||
import com.yfd.platform.system.domain.SysDictionaryItems;
|
||||
import com.yfd.platform.system.domain.SysUser;
|
||||
import com.yfd.platform.system.mapper.SysDictionaryItemsMapper;
|
||||
import com.yfd.platform.system.mapper.SysDictionaryMapper;
|
||||
import com.yfd.platform.system.mapper.SysUserMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 地图图层业务服务实现
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Service
|
||||
public class MapLayerBizServiceImpl implements IMapLayerBizService {
|
||||
|
||||
@Resource
|
||||
private MsMaplayerBMapper msMaplayerBMapper;
|
||||
|
||||
@Resource
|
||||
private SysDictionaryMapper sysDictionaryMapper;
|
||||
|
||||
@Resource
|
||||
private SysDictionaryItemsMapper sysDictionaryItemsMapper;
|
||||
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Override
|
||||
public List<MsMaplayerB> getMapLayerTree(MapLayerAo flag) {
|
||||
// 1. 查询字典 "DTZJLX" 获取需要排除的图层类型
|
||||
Set<String> excludeTypes = getExcludeTypes();
|
||||
|
||||
// 2. 查询所有未删除的图层数据,排除特殊类型,支持按名称模糊查询
|
||||
LambdaQueryWrapper<MsMaplayerB> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MsMaplayerB::getIsDeleted, 0);
|
||||
|
||||
// 排除特殊类型
|
||||
if (!excludeTypes.isEmpty()) {
|
||||
wrapper.and(w -> w.notIn(MsMaplayerB::getType, excludeTypes).or().isNull(MsMaplayerB::getType));
|
||||
}
|
||||
|
||||
// 按名称模糊查询
|
||||
if (StrUtil.isNotBlank(flag.getTitle())) {
|
||||
wrapper.like(MsMaplayerB::getTitle, flag.getTitle());
|
||||
}
|
||||
|
||||
List<MsMaplayerB> mapLayers = msMaplayerBMapper.selectList(wrapper);
|
||||
|
||||
// 3. 当按名称过滤时,补充缺失的父级节点
|
||||
if (StrUtil.isNotBlank(flag.getTitle()) && !mapLayers.isEmpty()) {
|
||||
Set<String> hasKeys = mapLayers.stream()
|
||||
.filter(it -> StrUtil.isNotBlank(it.getKey()))
|
||||
.map(MsMaplayerB::getKey)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Set<String> idList = new HashSet<>();
|
||||
for (MsMaplayerB layer : mapLayers) {
|
||||
if (StrUtil.isNotBlank(layer.getFullPath()) && StrUtil.isNotBlank(layer.getKey())) {
|
||||
String[] ids = layer.getFullPath().replace(layer.getKey() + ",", "").split(",");
|
||||
for (String id : ids) {
|
||||
if (StrUtil.isNotBlank(id) && !hasKeys.contains(id)) {
|
||||
idList.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!idList.isEmpty()) {
|
||||
LambdaQueryWrapper<MsMaplayerB> parentWrapper = new LambdaQueryWrapper<>();
|
||||
parentWrapper.eq(MsMaplayerB::getIsDeleted, 0)
|
||||
.in(MsMaplayerB::getKey, idList);
|
||||
List<MsMaplayerB> parentLayers = msMaplayerBMapper.selectList(parentWrapper);
|
||||
if (!parentLayers.isEmpty()) {
|
||||
mapLayers.addAll(parentLayers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 填充创建人名称
|
||||
if (!mapLayers.isEmpty()) {
|
||||
LambdaQueryWrapper<SysUser> userWrapper = new LambdaQueryWrapper<>();
|
||||
List<SysUser> users = sysUserMapper.selectList(userWrapper);
|
||||
Map<String, String> userMap = users.stream()
|
||||
.collect(Collectors.toMap(SysUser::getId, SysUser::getNickname, (v1, v2) -> v1));
|
||||
|
||||
for (MsMaplayerB layer : mapLayers) {
|
||||
if (StrUtil.isNotBlank(layer.getRecordUser())) {
|
||||
layer.setDisplayRecordUser(userMap.get(layer.getRecordUser()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 构建树结构:取第一级
|
||||
List<MsMaplayerB> parents = mapLayers.stream()
|
||||
.filter(p -> StrUtil.isBlank(p.getParentId()))
|
||||
.sorted(Comparator.comparing(MsMaplayerB::getRecordTime, Comparator.nullsLast(Comparator.reverseOrder())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 通过父级id分组子节点
|
||||
Map<String, List<MsMaplayerB>> childrenMap = mapLayers.stream()
|
||||
.filter(p -> StrUtil.isNotBlank(p.getParentId()))
|
||||
.collect(Collectors.groupingBy(MsMaplayerB::getParentId));
|
||||
|
||||
// 递归构建树
|
||||
convertTree(parents, childrenMap);
|
||||
|
||||
return parents;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典 "DTZJLX" 中需要排除的图层类型值
|
||||
*/
|
||||
private Set<String> getExcludeTypes() {
|
||||
Set<String> excludeTypes = new HashSet<>();
|
||||
try {
|
||||
LambdaQueryWrapper<SysDictionary> dictWrapper = new LambdaQueryWrapper<>();
|
||||
dictWrapper.eq(SysDictionary::getDictCode, "DTZJLX");
|
||||
SysDictionary dictionary = sysDictionaryMapper.selectOne(dictWrapper);
|
||||
if (dictionary != null) {
|
||||
LambdaQueryWrapper<SysDictionaryItems> itemWrapper = new LambdaQueryWrapper<>();
|
||||
itemWrapper.eq(SysDictionaryItems::getDictId, dictionary.getId());
|
||||
List<SysDictionaryItems> items = sysDictionaryItemsMapper.selectList(itemWrapper);
|
||||
if (items != null) {
|
||||
excludeTypes = items.stream()
|
||||
.map(SysDictionaryItems::getDictName)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 字典查询失败时不中断主流程
|
||||
}
|
||||
return excludeTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归转换图层数据为树结构
|
||||
*/
|
||||
private void convertTree(List<MsMaplayerB> parents, Map<String, List<MsMaplayerB>> childrenMap) {
|
||||
if (parents == null || parents.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (MsMaplayerB parent : parents) {
|
||||
String id = parent.getId();
|
||||
List<MsMaplayerB> children = childrenMap.get(id);
|
||||
if (children != null && !children.isEmpty()) {
|
||||
parent.setChildren(children);
|
||||
convertTree(children, childrenMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,256 @@
|
||||
package com.yfd.platform.qgc_sys.mapLayer.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.yfd.platform.common.exception.BizException;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplegendB;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplayerB;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.domain.MsMapmoduleB;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.mapper.MsMaplegendBMapper;
|
||||
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.IMapLayerService;
|
||||
import com.yfd.platform.utils.SecurityUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 地图图层基础服务实现
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Service
|
||||
public class MapLayerServiceImpl implements IMapLayerService {
|
||||
|
||||
@Resource
|
||||
private MsMaplayerBMapper msMaplayerBMapper;
|
||||
|
||||
@Resource
|
||||
private MsMaplegendBMapper msMaplegendBMapper;
|
||||
|
||||
@Resource
|
||||
private MsMapmoduleBMapper msMapmoduleBMapper;
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdate(MsMaplayerB layer) {
|
||||
// 校验编码唯一性
|
||||
if (hasSameCode(layer)) {
|
||||
throw new BizException("存在相同编码的数据");
|
||||
}
|
||||
|
||||
// 当type等于SLDT/DXDT/YXDT,校验地图json格式
|
||||
String paramJson = layer.getParamJson();
|
||||
String type = layer.getType();
|
||||
if (("SLDT".equals(type) || "DXDT".equals(type) || "YXDT".equals(type))
|
||||
&& StrUtil.isNotBlank(paramJson)) {
|
||||
try {
|
||||
JSONUtil.toBean(paramJson, HashMap.class);
|
||||
} catch (Exception e) {
|
||||
throw new BizException("请检查地图json格式");
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(layer.getId())) {
|
||||
// 修改
|
||||
msMaplayerBMapper.updateById(layer);
|
||||
|
||||
// 判断是否启用且有子级,则子数据都要设置为启用状态
|
||||
if (layer.getEnable() != null && layer.getEnable() == 1
|
||||
&& layer.getHasChildren() != null && layer.getHasChildren() == 1) {
|
||||
LambdaQueryWrapper<MsMaplayerB> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MsMaplayerB::getIsDeleted, 0)
|
||||
.like(MsMaplayerB::getFullPath, layer.getId() + ",");
|
||||
List<MsMaplayerB> children = msMaplayerBMapper.selectList(wrapper);
|
||||
for (MsMaplayerB child : children) {
|
||||
MsMaplayerB temp = new MsMaplayerB();
|
||||
temp.setId(child.getId());
|
||||
temp.setEnable(1);
|
||||
msMaplayerBMapper.updateById(temp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 新增
|
||||
String id = IdUtil.fastSimpleUUID();
|
||||
layer.setId(id);
|
||||
|
||||
// 获取同级子节点,计算最大排序号
|
||||
List<MsMaplayerB> subList = getSubList(layer.getParentId());
|
||||
Integer maxOrderIndex = getMaxOrderIndex(subList);
|
||||
layer.setOrderIndex(maxOrderIndex + 1);
|
||||
|
||||
MsMaplayerB parentLayer = null;
|
||||
if (StrUtil.isNotBlank(layer.getParentId())) {
|
||||
// 获取父级信息
|
||||
parentLayer = msMaplayerBMapper.selectById(layer.getParentId());
|
||||
if (parentLayer == null) {
|
||||
throw new BizException("获取父级图层信息失败.请检查父级图层(parentId)是否存在.");
|
||||
}
|
||||
// 设置key
|
||||
layer.setKey(parentLayer.getKey() + "-" + layer.getOrderIndex());
|
||||
// 设置fullPath
|
||||
layer.setFullPath(parentLayer.getFullPath() + layer.getKey() + ",");
|
||||
// 设置treeLevel
|
||||
layer.setTreeLevel(parentLayer.getTreeLevel() + 1);
|
||||
// 设置hasChildren
|
||||
layer.setHasChildren(0);
|
||||
} else {
|
||||
// 无父级,则为创建的顶级图层
|
||||
layer.setTreeLevel(1);
|
||||
layer.setKey("0-" + layer.getOrderIndex());
|
||||
layer.setFullPath(layer.getKey() + ",");
|
||||
layer.setHasChildren(0);
|
||||
}
|
||||
|
||||
// 设置可选
|
||||
layer.setCheckable(0);
|
||||
// 设置不可用
|
||||
layer.setEnable(0);
|
||||
|
||||
String userId = getCurrentUserId();
|
||||
layer.setRecordUser(userId);
|
||||
layer.setModifyUser(userId);
|
||||
layer.setRecordTime(new Date());
|
||||
|
||||
msMaplayerBMapper.insert(layer);
|
||||
|
||||
// 新增完成后,设置父级hasChildren为1
|
||||
if (parentLayer != null) {
|
||||
MsMaplayerB temp = new MsMaplayerB();
|
||||
temp.setId(parentLayer.getId());
|
||||
temp.setHasChildren(1);
|
||||
msMaplayerBMapper.updateById(temp);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delelteByIds(List<String> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (String id : ids) {
|
||||
// 根据id查询是否有子级数据
|
||||
MsMaplayerB layer = msMaplayerBMapper.selectById(id);
|
||||
if (layer == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<MsMaplayerB> childWrapper = new LambdaQueryWrapper<>();
|
||||
childWrapper.eq(MsMaplayerB::getParentId, id);
|
||||
List<MsMaplayerB> children = msMaplayerBMapper.selectList(childWrapper);
|
||||
if (!children.isEmpty()) {
|
||||
throw new BizException("有子级图层,无法删除.");
|
||||
}
|
||||
|
||||
// 判断是否启用
|
||||
if (layer.getEnable() != null && layer.getEnable() == 1) {
|
||||
throw new BizException("无法删除已启用的图层.");
|
||||
}
|
||||
|
||||
// 判断是否已经关联了图例
|
||||
QueryWrapper<MsMaplegendB> legendWrapper = new QueryWrapper<>();
|
||||
legendWrapper.eq("LAYER_CODE", layer.getCode());
|
||||
legendWrapper.eq("IS_DELETED", 0);
|
||||
List<MsMaplegendB> legendList = msMaplegendBMapper.selectList(legendWrapper);
|
||||
if (!legendList.isEmpty()) {
|
||||
throw new BizException("图层关联了图例,无法删除.");
|
||||
}
|
||||
|
||||
// 判断父级是否存在
|
||||
if (StrUtil.isBlank(layer.getParentId())) {
|
||||
// 逻辑删除
|
||||
msMaplayerBMapper.deleteById(id);
|
||||
} else {
|
||||
MsMaplayerB parent = msMaplayerBMapper.selectById(layer.getParentId());
|
||||
// 逻辑删除
|
||||
msMaplayerBMapper.deleteById(id);
|
||||
|
||||
// 判断父级下是否只有一个子级,如果是当前图层,则设置父级hasChildren为0
|
||||
if (parent != null) {
|
||||
LambdaQueryWrapper<MsMaplayerB> siblingWrapper = new LambdaQueryWrapper<>();
|
||||
siblingWrapper.eq(MsMaplayerB::getParentId, parent.getId());
|
||||
List<MsMaplayerB> siblings = msMaplayerBMapper.selectList(siblingWrapper);
|
||||
if (siblings.size() == 1 && id.equals(siblings.get(0).getId())) {
|
||||
MsMaplayerB temp = new MsMaplayerB();
|
||||
temp.setId(parent.getId());
|
||||
temp.setHasChildren(0);
|
||||
msMaplayerBMapper.updateById(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否关联菜单,删除关联
|
||||
QueryWrapper<MsMapmoduleB> moduleWrapper = new QueryWrapper<>();
|
||||
moduleWrapper.eq("RES_TYPE", "layer");
|
||||
moduleWrapper.eq("IS_DELETED", 0);
|
||||
moduleWrapper.eq("RES_ID", id);
|
||||
List<MsMapmoduleB> moduleList = msMapmoduleBMapper.selectList(moduleWrapper);
|
||||
if (!moduleList.isEmpty()) {
|
||||
Set<String> moduleIds = moduleList.stream()
|
||||
.map(MsMapmoduleB::getId)
|
||||
.collect(Collectors.toSet());
|
||||
msMapmoduleBMapper.deleteBatchIds(moduleIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户ID
|
||||
*/
|
||||
private String getCurrentUserId() {
|
||||
try {
|
||||
return SecurityUtils.getUserId();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父级编码查询子一级数据
|
||||
*/
|
||||
private List<MsMaplayerB> getSubList(String parentId) {
|
||||
LambdaQueryWrapper<MsMaplayerB> wrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(parentId)) {
|
||||
wrapper.eq(MsMaplayerB::getParentId, parentId);
|
||||
} else {
|
||||
wrapper.eq(MsMaplayerB::getTreeLevel, 1);
|
||||
}
|
||||
wrapper.orderByAsc(MsMaplayerB::getOrderIndex);
|
||||
return msMaplayerBMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最大排序号
|
||||
*/
|
||||
private Integer getMaxOrderIndex(List<MsMaplayerB> list) {
|
||||
if (list.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return list.stream()
|
||||
.sorted(Comparator.comparing(MsMaplayerB::getOrderIndex, Comparator.nullsLast(Comparator.reverseOrder())))
|
||||
.collect(Collectors.toList())
|
||||
.get(0)
|
||||
.getOrderIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断同级下是否有编码一样的数据
|
||||
*/
|
||||
private boolean hasSameCode(MsMaplayerB layer) {
|
||||
LambdaQueryWrapper<MsMaplayerB> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MsMaplayerB::getCode, layer.getCode())
|
||||
.eq(MsMaplayerB::getIsDeleted, 0);
|
||||
List<MsMaplayerB> list = msMaplayerBMapper.selectList(wrapper);
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return !list.get(0).getId().equals(layer.getId());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
package com.yfd.platform.qgc_sys.mapLayer.service.impl;
|
||||
|
||||
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.extension.service.impl.ServiceImpl;
|
||||
import com.yfd.platform.common.exception.BizException;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.domain.MsMaplegendB;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.domain.MsMapmoduleB;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.mapper.MsMaplegendBMapper;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.mapper.MsMapmoduleBMapper;
|
||||
import com.yfd.platform.qgc_sys.mapLayer.service.IMapLegendService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 地图图例基础服务实现
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Service
|
||||
public class MapLegendServiceImpl extends ServiceImpl<MsMaplegendBMapper, MsMaplegendB>
|
||||
implements IMapLegendService {
|
||||
|
||||
@Resource
|
||||
private MsMapmoduleBMapper msMapmoduleBMapper;
|
||||
|
||||
@Override
|
||||
public void delelteByIds(List<String> ids) {
|
||||
if (CollectionUtil.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
for (String id : ids) {
|
||||
// 根据id查询是否有数据或者子级数据
|
||||
MsMaplegendB legend = this.getById(id);
|
||||
if (legend == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<MsMaplegendB> childWrapper = new LambdaQueryWrapper<>();
|
||||
childWrapper.eq(MsMaplegendB::getParentId, id)
|
||||
.eq(MsMaplegendB::getIsDeleted, 0);
|
||||
List<MsMaplegendB> children = this.list(childWrapper);
|
||||
if (!children.isEmpty()) {
|
||||
throw new BizException("有子级图例,无法删除.");
|
||||
}
|
||||
|
||||
// 判断是否内置的数据
|
||||
if (legend.getInternal() != null && legend.getInternal() == 1) {
|
||||
throw new BizException("无法删除系统内置的图例.");
|
||||
}
|
||||
|
||||
// 判断是否启用
|
||||
if (legend.getEnable() != null && legend.getEnable() == 1) {
|
||||
throw new BizException("无法删除已启用的图例.");
|
||||
}
|
||||
|
||||
// 判断图例是否关联了菜单
|
||||
QueryWrapper<MsMapmoduleB> moduleWrapper = new QueryWrapper<>();
|
||||
moduleWrapper.eq("IS_DELETED", 0);
|
||||
moduleWrapper.eq("RES_TYPE", "legend");
|
||||
moduleWrapper.eq("RES_ID", id);
|
||||
List<MsMapmoduleB> moduleList = msMapmoduleBMapper.selectList(moduleWrapper);
|
||||
if (!moduleList.isEmpty()) {
|
||||
throw new BizException("无法删除:图例关联了菜单.");
|
||||
}
|
||||
|
||||
// 判断父级是否存在
|
||||
if (StrUtil.isBlank(legend.getParentId())) {
|
||||
this.removeById(id); // 逻辑删除
|
||||
return;
|
||||
}
|
||||
|
||||
// 删除数据
|
||||
this.removeById(id); // 逻辑删除
|
||||
|
||||
if (StrUtil.isNotBlank(legend.getParentId())) {
|
||||
// 判断父级下是否只有一个子级,如果只有一个子级并且是当前图例,则需要设置父级的hasChildren为0
|
||||
MsMaplegendB parent = this.getById(legend.getParentId());
|
||||
if (parent != null) {
|
||||
LambdaQueryWrapper<MsMaplegendB> siblingWrapper = new LambdaQueryWrapper<>();
|
||||
siblingWrapper.eq(MsMaplegendB::getParentId, parent.getId());
|
||||
List<MsMaplegendB> siblings = this.list(siblingWrapper);
|
||||
if (siblings.size() == 1 && id.equals(siblings.get(0).getId())) {
|
||||
MsMaplegendB updateParent = new MsMaplegendB();
|
||||
updateParent.setId(parent.getId());
|
||||
updateParent.setHasChildren(0);
|
||||
this.updateById(updateParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
package com.yfd.platform.qgc_sys.mapcfg.controller;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yfd.platform.common.DataSourceRequest;
|
||||
import com.yfd.platform.common.DataSourceResult;
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* 地图菜单配置控制层
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mapmodule")
|
||||
@Tag(name = "地图菜单配置")
|
||||
public class MapmoduleBController {
|
||||
|
||||
@Resource
|
||||
private IMapmoduleBService mapmoduleBService;
|
||||
|
||||
/**
|
||||
* 条件过滤数据列表(Kendo UI 数据源)
|
||||
*/
|
||||
@Operation(summary = "条件过滤数据列表")
|
||||
@PostMapping("/GetKendoList")
|
||||
public ResponseResult getKendoList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
// 构建查询条件
|
||||
QueryWrapper<MsMapmoduleB> wrapper = DataSourceRequestUtil.buildQueryWrapper(
|
||||
dataSourceRequest, MsMapmoduleB.class);
|
||||
|
||||
// 执行分页查询
|
||||
Page<MsMapmoduleB> page = DataSourceRequestUtil.getPage(dataSourceRequest);
|
||||
Page<MsMapmoduleB> resultPage;
|
||||
if (page != null) {
|
||||
resultPage = mapmoduleBService.page(page, wrapper);
|
||||
} else {
|
||||
List<MsMapmoduleB> list = mapmoduleBService.list(wrapper);
|
||||
resultPage = new Page<>();
|
||||
resultPage.setRecords(list);
|
||||
resultPage.setTotal(list.size());
|
||||
}
|
||||
|
||||
// 构建 Kendo 数据源结果
|
||||
DataSourceResult<MsMapmoduleB> dataSourceResult = new DataSourceResult<>();
|
||||
List<MsMapmoduleB> dataList = resultPage.getRecords();
|
||||
dataSourceResult.setData(dataList);
|
||||
dataSourceResult.setTotal(resultPage.getTotal());
|
||||
|
||||
// 翻译字典值(菜单名称)
|
||||
if (dataList != null && !dataList.isEmpty()) {
|
||||
mapmoduleBService.translateDict(dataList);
|
||||
}
|
||||
|
||||
return ResponseResult.successData(dataSourceResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图图例关联系统及菜单
|
||||
*/
|
||||
@Operation(summary = "地图图例关联系统及菜单")
|
||||
@PostMapping("/save")
|
||||
public ResponseResult saveOrUpdate(@RequestBody MsMapmoduleB mapmoduleB) {
|
||||
if (mapmoduleB == null) {
|
||||
throw new BizException("对象不能为空.");
|
||||
}
|
||||
if (StrUtil.isBlank(mapmoduleB.getModuleId())) {
|
||||
throw new BizException("关联菜单(moduleId)不能为空.");
|
||||
}
|
||||
if (StrUtil.isBlank(mapmoduleB.getSystemId())) {
|
||||
throw new BizException("关联系统(systemId)不能为空.");
|
||||
}
|
||||
if (StrUtil.isBlank(mapmoduleB.getResType())) {
|
||||
throw new BizException("资源类型(resType: layer=图层,legend=图例,mapbox=地图)不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(mapmoduleB.getResId())) {
|
||||
throw new BizException("资源(resId)不能为空.");
|
||||
}
|
||||
return ResponseResult.successData(mapmoduleBService.saveOrUpdate(mapmoduleB));
|
||||
}
|
||||
|
||||
/**
|
||||
* 图例与系统菜单关联关系删除
|
||||
*/
|
||||
@Operation(summary = "图例与系统菜单关联关系删除")
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult deleteData(@RequestBody List<String> ids) {
|
||||
mapmoduleBService.delelteByIds(ids);
|
||||
return ResponseResult.success("删除成功.");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
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 java.util.List;
|
||||
|
||||
/**
|
||||
* 地图菜单配置服务接口
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
public interface IMapmoduleBService extends IService<MsMapmoduleB> {
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean saveOrUpdate(MsMapmoduleB entity);
|
||||
|
||||
/**
|
||||
* 翻译字典值(菜单名称)
|
||||
*
|
||||
* @param list 数据列表
|
||||
*/
|
||||
void translateDict(List<MsMapmoduleB> list);
|
||||
|
||||
/**
|
||||
* 根据ID列表删除关联关系
|
||||
*
|
||||
* @param ids ID列表
|
||||
*/
|
||||
void delelteByIds(List<String> ids);
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package com.yfd.platform.qgc_sys.mapcfg.service.impl;
|
||||
|
||||
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.mapper.MsMapmoduleBMapper;
|
||||
import com.yfd.platform.qgc_sys.mapcfg.service.IMapmoduleBService;
|
||||
import com.yfd.platform.system.domain.SysMenu;
|
||||
import com.yfd.platform.system.mapper.SysMenuMapper;
|
||||
import com.yfd.platform.utils.SecurityUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 地图菜单配置服务实现类
|
||||
*
|
||||
* @author migration
|
||||
*/
|
||||
@Service
|
||||
public class MapmoduleBServiceImpl extends ServiceImpl<MsMapmoduleBMapper, MsMapmoduleB>
|
||||
implements IMapmoduleBService {
|
||||
|
||||
@Resource
|
||||
private SysMenuMapper sysMenuMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdate(MsMapmoduleB entity) {
|
||||
if (StrUtil.isBlank(entity.getId())) {
|
||||
// 新增
|
||||
entity.setRecordUser(SecurityUtils.getUserId());
|
||||
this.baseMapper.insert(entity);
|
||||
} else {
|
||||
// 修改
|
||||
this.baseMapper.updateById(entity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delelteByIds(List<String> ids) {
|
||||
if (ids != null) {
|
||||
for (String id : ids) {
|
||||
this.baseMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateDict(List<MsMapmoduleB> list) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// 收集所有 moduleId
|
||||
List<String> moduleIds = list.stream()
|
||||
.filter(it -> StrUtil.isNotBlank(it.getModuleId()))
|
||||
.map(MsMapmoduleB::getModuleId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (moduleIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 查询本地菜单表获取名称
|
||||
LambdaQueryWrapper<SysMenu> menuWrapper = new LambdaQueryWrapper<>();
|
||||
menuWrapper.in(SysMenu::getId, moduleIds);
|
||||
List<SysMenu> menus = sysMenuMapper.selectList(menuWrapper);
|
||||
|
||||
Map<String, String> menuMap = new HashMap<>();
|
||||
menuMap.put("common", "通用菜单");
|
||||
for (SysMenu menu : menus) {
|
||||
menuMap.put(menu.getId(), menu.getName());
|
||||
}
|
||||
|
||||
// 设置菜单名称
|
||||
for (MsMapmoduleB item : list) {
|
||||
if (StrUtil.isNotBlank(item.getModuleId())) {
|
||||
String name = menuMap.get(item.getModuleId());
|
||||
if (name != null) {
|
||||
item.setModuleName(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user