18 changed files with 1458 additions and 15 deletions
@ -0,0 +1,124 @@ |
|||
package com.kms.yg.znjg.controller; |
|||
|
|||
import com.kms.yg.znjg.domain.SyDir; |
|||
import com.kms.yg.znjg.service.SyDirLayerService; |
|||
import com.kms.yg.znjg.service.SyDirService; |
|||
import com.kms.yg.znjg.service.SyLayerService; |
|||
import com.kms.yg.znjg.vo.SyDirVo; |
|||
import com.kms.yxgh.base.Response; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 图层目录管理 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/map/layerDir") |
|||
@Api(tags = "图层目录管理") |
|||
public class SyDirLayerController { |
|||
@Autowired |
|||
private SyLayerService syLayerService; |
|||
|
|||
@Autowired |
|||
private SyDirService syDirService; |
|||
|
|||
@Autowired |
|||
private SyDirLayerService syDirLayerService; |
|||
|
|||
/** |
|||
* 查询图层目录树信息 |
|||
* |
|||
* @param parentId 父节点id,可以为空,不是空的时候查询该父节点id的所有子目录,否则展示所有目录 |
|||
* @return |
|||
*/ |
|||
@GetMapping(value = "/getAllTreeDir") |
|||
@ApiOperation("查询图层目录树信息") |
|||
public Response getAllTreeDir(String parentId) { |
|||
Response response = new Response(); |
|||
try { |
|||
List<SyDirVo> list = syDirService.findAllDir(parentId); |
|||
List<SyDirVo> rootList = new ArrayList<>(); |
|||
rootList.add(new SyDirVo() {{ |
|||
setId("root"); |
|||
setName("全部"); |
|||
setParentId(""); |
|||
setXpath("/目录管理"); |
|||
setDirSeq("root"); |
|||
setOrderNm(1); |
|||
setChildren(list); |
|||
response.setCode("200"); |
|||
}}); |
|||
response.setData(rootList); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.setCode("500"); |
|||
response.setMsg(e.getMessage()); |
|||
} |
|||
return response; |
|||
} |
|||
|
|||
/** |
|||
* 保存或更新图层目录信息 |
|||
* |
|||
* @param syDir 目录实体对象 |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
@PostMapping(value = "/saveDir") |
|||
@ApiOperation("保存或更新图层目录信息") |
|||
public Response saveDir(SyDir syDir) throws Exception { |
|||
try { |
|||
return syDirService.saveSyDir(syDir); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return new Response() {{ |
|||
setCode("500"); |
|||
setMsg(e.getMessage()); |
|||
}}; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 根据目录id删除图层目录 |
|||
* |
|||
* @param dirId 目录id,不能为空 |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@DeleteMapping(value = "/deleteDir") |
|||
@ApiOperation("根据目录id删除图层目录") |
|||
public Response removeDirAndSonById(String dirId) throws Exception { |
|||
Response response = new Response(); |
|||
try { |
|||
//删除目录
|
|||
int deleteCount = syDirService.removeDirAndSonById(dirId); |
|||
if (deleteCount == 0) { |
|||
throw new Exception("未找到需要删除的目录"); |
|||
} |
|||
//删除图层数据
|
|||
syLayerService.removeByMap(new HashMap<String, Object>() {{ |
|||
put("dir_id", dirId); |
|||
}}); |
|||
//删除图层和目录关联的数据
|
|||
syDirLayerService.removeByMap(new HashMap<String, Object>() {{ |
|||
put("dir_id", dirId); |
|||
}}); |
|||
response.setCode("200"); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.setCode("500"); |
|||
response.setMsg(e.getMessage()); |
|||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|||
} |
|||
return response; |
|||
} |
|||
} |
@ -0,0 +1,144 @@ |
|||
package com.kms.yg.znjg.controller; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.kms.common.utils.UserUtils; |
|||
import com.kms.yg.df.domain.BsSgcDfJbxx; |
|||
import com.kms.yg.znjg.domain.SyLayer; |
|||
import com.kms.yg.znjg.service.SyLayerService; |
|||
import com.kms.yxgh.base.Response; |
|||
import com.shuili.common.core.domain.SearchParam; |
|||
import com.shuili.common.core.domain.entity.SysUser; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.apache.commons.lang.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 图层管理 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("/map/layer") |
|||
@Api(tags = "图层管理") |
|||
public class SyLayerController { |
|||
@Autowired |
|||
private SyLayerService syLayerService; |
|||
|
|||
/** |
|||
* 获取图层详细信息 |
|||
* |
|||
* @param layerId |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
@RequestMapping(value = "/getDetails/{layerId}", method = RequestMethod.GET) |
|||
@ApiOperation("根据图层id获取图层详细信息") |
|||
public Response getDetails(@PathVariable(value = "layerId") String layerId) throws Exception { |
|||
Response resultForm = new Response(); |
|||
try { |
|||
JSONObject jsonObjectResult = syLayerService.getDetails(layerId); |
|||
resultForm.setCode("200"); |
|||
resultForm.setData(jsonObjectResult); |
|||
} catch (Exception e) { |
|||
resultForm.setCode("500"); |
|||
resultForm.setMsg(e.getMessage()); |
|||
} |
|||
return resultForm; |
|||
} |
|||
|
|||
/** |
|||
* 保存或者更新服务图层 |
|||
* |
|||
* @param syLayer |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
@PostMapping(value = "/saveOrUpdateLayer") |
|||
@ApiOperation("保存或者更新服务图层") |
|||
public Response saveOrUpdateLayer(@RequestBody SyLayer syLayer) throws Exception { |
|||
Response response = new Response(); |
|||
try { |
|||
if (org.apache.commons.lang3.StringUtils.isBlank(syLayer.getDirId())) { |
|||
throw new Exception("所属目录不能为空"); |
|||
} |
|||
SysUser user = UserUtils.getUser(); |
|||
syLayer.setCreateUser(user.getNickName()); |
|||
Boolean insertDataFlag = false; |
|||
if (StringUtils.isBlank(syLayer.getId())) { |
|||
insertDataFlag = true; |
|||
} |
|||
if (insertDataFlag) { |
|||
//同一层下图层名称不同
|
|||
Boolean serviceIsRepeat = syLayerService.checkNameIsRepeat(syLayer.getServiceName(), syLayer.getId()); |
|||
if (serviceIsRepeat) { |
|||
throw new Exception("同一层级名称不能重复,请重新输入名称"); |
|||
} |
|||
syLayer.setId(UUID.randomUUID().toString()); |
|||
syLayer.setPubDate(new Date()); |
|||
syLayerService.saveLayer(syLayer); |
|||
} else { |
|||
syLayerService.updateLayer(syLayer); |
|||
} |
|||
JSONObject result = new JSONObject(); |
|||
result.put("id", syLayer.getId()); |
|||
result.put("syLayer", syLayer); |
|||
response.setCode("200"); |
|||
response.setData(result); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
response.setCode("500"); |
|||
response.setMsg(e.getMessage()); |
|||
} |
|||
return response; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 根据图层id集合删除资源图层 |
|||
* |
|||
* @param ids 资源图层ID拼接的字符串,用“,”连接 |
|||
* @return |
|||
*/ |
|||
@RequestMapping(value = "/deleteLayer/{ids}", method = RequestMethod.DELETE) |
|||
@ApiOperation("根据图层id集合删除资源图层") |
|||
public Response<String> deleteSrs(@PathVariable(value = "ids") String ids) { |
|||
Response<String> responseInfo = new Response<>(); |
|||
try { |
|||
String[] idArray = ids.split(","); |
|||
List<String> idList = Arrays.stream(idArray).collect(Collectors.toList()); |
|||
List<SyLayer> layerByLayers = syLayerService.findLayerByLayerIds(idList); |
|||
for (SyLayer item : layerByLayers) { |
|||
String[] itemArray = new String[]{item.getId()}; |
|||
syLayerService.delete(itemArray); |
|||
} |
|||
responseInfo.setCode("200"); |
|||
} catch (Exception e) { |
|||
responseInfo.setCode("500"); |
|||
responseInfo.setMsg(e.getMessage()); |
|||
} |
|||
return responseInfo; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 分页查询全部资源信息 |
|||
* @param spLayer |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/getLayers") |
|||
@ApiOperation("根据查询条件分页查询全部资源信息") |
|||
public IPage<SyLayer> getLayers(@RequestBody SearchParam<SyLayer> spLayer) { |
|||
SyLayer syLayerInfo = spLayer.getData(); |
|||
Page<SyLayer> page = new Page<>(spLayer.getPageNum(),spLayer.getPageSize()); |
|||
Map<String, Object> params = spLayer.getParams(); |
|||
return syLayerService.selectPage(page,syLayerInfo,params); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,49 @@ |
|||
package com.kms.yg.znjg.domain; |
|||
|
|||
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; |
|||
|
|||
/** |
|||
* @TableName sy_dir |
|||
*/ |
|||
@TableName(value = "sy_dir") |
|||
@Data |
|||
public class SyDir implements Serializable { |
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@TableId |
|||
private String id; |
|||
|
|||
/** |
|||
* 目录名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 父节点ID |
|||
*/ |
|||
private String parentId; |
|||
|
|||
/** |
|||
* 节点路径 |
|||
*/ |
|||
private String xpath; |
|||
|
|||
/** |
|||
* 目录序列 |
|||
*/ |
|||
private String dirSeq; |
|||
|
|||
/** |
|||
* 排序 |
|||
*/ |
|||
private Integer orderNm; |
|||
|
|||
@TableField(exist = false) |
|||
private static final long serialVersionUID = 1L; |
|||
} |
@ -0,0 +1,40 @@ |
|||
package com.kms.yg.znjg.domain; |
|||
|
|||
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; |
|||
|
|||
/** |
|||
* |
|||
* @TableName sy_dir_layer |
|||
*/ |
|||
@TableName(value ="sy_dir_layer") |
|||
@Data |
|||
public class SyDirLayer implements Serializable { |
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@TableId |
|||
private String id; |
|||
|
|||
/** |
|||
* 目录id,和sy_dir的主键进行关联 |
|||
*/ |
|||
private String dirId; |
|||
|
|||
/** |
|||
* 图层id,和sy_layer的主键进行关联 |
|||
*/ |
|||
private String layerId; |
|||
|
|||
/** |
|||
* 排序序号值 |
|||
*/ |
|||
private Integer orderNm; |
|||
|
|||
@TableField(exist = false) |
|||
private static final long serialVersionUID = 1L; |
|||
} |
@ -0,0 +1,162 @@ |
|||
package com.kms.yg.znjg.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import lombok.Data; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @TableName sy_layer |
|||
*/ |
|||
@TableName(value = "sy_layer") |
|||
@Data |
|||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
|||
public class SyLayer implements Serializable { |
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@TableId |
|||
private String id; |
|||
|
|||
/** |
|||
* 图层名称 |
|||
*/ |
|||
private String serviceName; |
|||
|
|||
/** |
|||
* 图层别名 |
|||
*/ |
|||
private String serviceNameAlias; |
|||
|
|||
/** |
|||
* 图层服务URL |
|||
*/ |
|||
private String serviceUrl; |
|||
|
|||
|
|||
/** |
|||
* 图层服务注记URL(底图) |
|||
*/ |
|||
private String annotationUrl; |
|||
|
|||
/** |
|||
* 图层服务token(底图) |
|||
*/ |
|||
private String serviceToken; |
|||
|
|||
/** |
|||
* 图层服务类型 |
|||
*/ |
|||
private String serviceType; |
|||
|
|||
/** |
|||
* 是否为图层组(配置geoserver图层组时需要判断,如果为图层组,则不加载图层组默认的样式) |
|||
*/ |
|||
private Boolean isLayerGroup; |
|||
|
|||
/** |
|||
* 图层索引,对于易智瑞发布的图层,就是0,1,2这些数字,对于geoserver发布的服务,索引值为`工作空间:图层名称` |
|||
*/ |
|||
private String serviceIndex; |
|||
|
|||
/** |
|||
* 注记图层服务索引(底图) |
|||
*/ |
|||
private String annotationServiceIndex; |
|||
|
|||
/** |
|||
* 发布日期 |
|||
*/ |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date pubDate; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createUser; |
|||
|
|||
/** |
|||
* 3d图层类型 白膜/BIM/倾斜摄影/点云/人工建模 |
|||
*/ |
|||
@TableField(value = "layer_3d_type") |
|||
private String layer3dType; |
|||
|
|||
|
|||
/** |
|||
* 瓦片大小,wmts服务需要填写 |
|||
*/ |
|||
private Integer tileSize; |
|||
|
|||
/** |
|||
* 矩阵集,wmts服务需要填写 |
|||
*/ |
|||
private String tileMatrixSet; |
|||
|
|||
/** |
|||
* 所属目录id |
|||
*/ |
|||
private String dirId; |
|||
|
|||
/** |
|||
* 所属目录名称 |
|||
*/ |
|||
private String dirName; |
|||
|
|||
/** |
|||
* 所属目录名称,以逗号分隔 |
|||
*/ |
|||
private String remark; |
|||
|
|||
/** |
|||
* 后缀名,wmts服务需要填写 |
|||
*/ |
|||
private String format; |
|||
|
|||
/** |
|||
* 图层表扩展字段集合的json |
|||
*/ |
|||
private String data; |
|||
|
|||
/** |
|||
* 3D tiles性能调试参数 |
|||
*/ |
|||
@TableField(value = "tileset_option") |
|||
private String tileSetOption; |
|||
|
|||
@TableField(exist = false) |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 关联服务id |
|||
*/ |
|||
private String relationServiceId; |
|||
|
|||
/** |
|||
* 关联服务名称 |
|||
*/ |
|||
private String relationServiceName; |
|||
|
|||
/** |
|||
* 关联图层样式id |
|||
*/ |
|||
private String relationStyleId; |
|||
|
|||
/** |
|||
* 关联图层样式名称 |
|||
*/ |
|||
private String relationStyleName; |
|||
|
|||
/** |
|||
* 关联场景数量 |
|||
*/ |
|||
private Integer relationSceneCount; |
|||
} |
@ -0,0 +1,55 @@ |
|||
package com.kms.yg.znjg.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.kms.yg.znjg.domain.SyDirLayer; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author lenovo |
|||
* @description 针对表【sy_dir_layer】的数据库操作Mapper |
|||
* @createDate 2023-03-09 17:04:18 |
|||
* @Entity com.sy.servicemanager.domain.SyDirLayer |
|||
*/ |
|||
@Mapper |
|||
@Repository |
|||
public interface SyDirLayerMapper extends BaseMapper<SyDirLayer> { |
|||
|
|||
/** |
|||
* 通过图层id 查询 图层目录信息 |
|||
* |
|||
* @param layerId 图层id |
|||
* @return |
|||
*/ |
|||
List<SyDirLayer> findListByLayerId(@Param("layerId") String layerId); |
|||
|
|||
/** |
|||
* 查询图层目录关联信息 最大排序号 |
|||
* |
|||
* @return |
|||
*/ |
|||
String getMaxOrder(); |
|||
|
|||
/** |
|||
* 插入图层目录关联信息 |
|||
* |
|||
* @param dir |
|||
*/ |
|||
void save(SyDirLayer dir); |
|||
|
|||
/** |
|||
* 通过图层目录关联id 删除图层目录关联信息 |
|||
* |
|||
* @param syDirLayers |
|||
*/ |
|||
void deleteBatchByIds(@Param("syDirLayers") List<SyDirLayer> syDirLayers); |
|||
|
|||
void delete(@Param("ids") String[] ids); |
|||
} |
|||
|
|||
|
|||
|
|||
|
@ -0,0 +1,34 @@ |
|||
package com.kms.yg.znjg.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.kms.yg.znjg.domain.SyDir; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.List; |
|||
import java.util.Set; |
|||
|
|||
@Repository |
|||
@Mapper |
|||
public interface SyDirMapper extends BaseMapper<SyDir> { |
|||
List<SyDir> findAll(); |
|||
|
|||
SyDir findById(@Param("id") String id); |
|||
|
|||
void updateOrderNmByParentId(@Param("orderNm") Integer orderNm, @Param("parentId") String parentId); |
|||
|
|||
void insertAll(SyDir syDir); |
|||
|
|||
void updateSelective(SyDir syDir); |
|||
|
|||
List<SyDir> getChildrenByParentId(@Param("parentId") String parentId); |
|||
|
|||
int deleteByDirIdInSeq(@Param("dirId") String dirId); |
|||
|
|||
List<SyDir> findSecond(); |
|||
|
|||
Set<String> selectDirSeq(); |
|||
|
|||
List<SyDir> findByIds(@Param("ids") String[] ids); |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.kms.yg.znjg.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.kms.yg.znjg.domain.SyLayer; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Repository |
|||
@Mapper |
|||
public interface SyLayerMapper extends BaseMapper<SyLayer> { |
|||
|
|||
Long selectByLayerName(@Param("serviceName") String serviceName, @Param("notEqLayerId") String notEqLayerId); |
|||
|
|||
void saveLayer(SyLayer syLayer); |
|||
|
|||
int updateLayer(SyLayer syLayer); |
|||
|
|||
SyLayer findOneById(@Param("id") String id); |
|||
|
|||
|
|||
List<SyLayer> findLayerByLayerIds(List<String> idList); |
|||
|
|||
void delete(@Param("ids") String[] ids); |
|||
|
|||
Page<SyLayer> findSyLayerList(@Param("page") Page<SyLayer> page, @Param("syLayer") SyLayer syLayer, @Param("orderBy") String orderBy, @Param("sortBy") String sortBy); |
|||
} |
|||
|
@ -0,0 +1,9 @@ |
|||
package com.kms.yg.znjg.service; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.kms.yg.znjg.domain.SyDirLayer; |
|||
import com.kms.yg.znjg.mapper.SyDirLayerMapper; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class SyDirLayerService extends ServiceImpl<SyDirLayerMapper, SyDirLayer> { |
|||
} |
@ -0,0 +1,182 @@ |
|||
package com.kms.yg.znjg.service; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.kms.yg.znjg.domain.SyDir; |
|||
import com.kms.yg.znjg.mapper.SyDirMapper; |
|||
import com.kms.yg.znjg.vo.SyDirVo; |
|||
import com.kms.yxgh.base.Response; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.*; |
|||
import java.util.function.Function; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class SyDirService extends ServiceImpl<SyDirMapper, SyDir> { |
|||
@Autowired |
|||
private SyDirMapper syDirMapper; |
|||
|
|||
|
|||
public List<SyDirVo> findAllDir(String parentId) { |
|||
List<SyDir> allDir = syDirMapper.findAll(); |
|||
return getListFormDirs(allDir, parentId); |
|||
} |
|||
|
|||
|
|||
public Response saveSyDir(SyDir syDir) throws Exception { |
|||
String rootStr = "root"; |
|||
boolean insert = false; |
|||
if (StringUtils.isBlank(syDir.getName())) { |
|||
return new Response() {{ |
|||
setCode("500"); |
|||
setMsg("名称不能为空"); |
|||
}}; |
|||
} |
|||
if (StringUtils.isBlank(syDir.getParentId())) { |
|||
syDir.setParentId(rootStr); |
|||
} |
|||
if (checkRepeatName(syDir.getParentId(), syDir.getName(), syDir.getId())) { |
|||
return new Response() {{ |
|||
setCode("500"); |
|||
setMsg("名称不能重复"); |
|||
}}; |
|||
} |
|||
if (StringUtils.isBlank(syDir.getId())) { |
|||
//syDir.setId(UUID.randomUUID().toString());
|
|||
//图层资源目录编号
|
|||
//1、系统自动生成,全局唯一,由16位数字、字母、下划线组成
|
|||
//2、编号规则,图层资源目录首字母+下划线+随机数字、字母组合,如:TCZYML_23Fd34523
|
|||
String prefix = "TCZYML"; |
|||
String layerResourceDirectoryNumber = generateLayerResourceDirectoryNumber(prefix); |
|||
syDir.setId(layerResourceDirectoryNumber); |
|||
insert = true; |
|||
} |
|||
if (rootStr.equals(syDir.getParentId())) { |
|||
syDir.setXpath("/目录管理/" + syDir.getName()); |
|||
syDir.setDirSeq(syDir.getId() + "," + rootStr); |
|||
} else { |
|||
SyDir parent = syDirMapper.findById(syDir.getParentId()); |
|||
syDir.setXpath(parent.getXpath() + "/" + syDir.getName()); |
|||
syDir.setDirSeq(syDir.getId() + "," + parent.getDirSeq()); |
|||
} |
|||
Boolean b = StringUtils.isNotBlank(syDir.getParentId()) && (syDir.getOrderNm() > 0 || syDir.getOrderNm() < 0); |
|||
if (b) { |
|||
SyDir searchSyDir = new SyDir(); |
|||
searchSyDir.setParentId(syDir.getParentId()); |
|||
if (syDir.getOrderNm() > 0) { |
|||
searchSyDir.setOrderNm(syDir.getOrderNm()); |
|||
} |
|||
LambdaQueryWrapper<SyDir> queryWrapper = new LambdaQueryWrapper<>(); |
|||
queryWrapper |
|||
.eq(StringUtils.isNotBlank(searchSyDir.getParentId()), SyDir::getParentId, searchSyDir.getParentId()) |
|||
.eq(ObjectUtil.isNotNull(searchSyDir.getOrderNm()), SyDir::getOrderNm, searchSyDir.getOrderNm()); |
|||
List<SyDir> syDirs = syDirMapper.selectList(queryWrapper); |
|||
int orderNm = syDir.getOrderNm(); |
|||
// 更新目录排序信息
|
|||
for (SyDir vo : syDirs) { |
|||
if (syDir.getOrderNm() > 0 && !vo.getId().equals(syDir.getId())) { |
|||
syDirMapper.updateOrderNmByParentId(syDir.getOrderNm(), syDir.getParentId()); |
|||
break; |
|||
} |
|||
if (syDir.getOrderNm() < 0 && orderNm <= vo.getOrderNm()) { |
|||
orderNm = vo.getOrderNm(); |
|||
} |
|||
} |
|||
if (syDir.getOrderNm() < 0) { |
|||
syDir.setOrderNm(orderNm < 0 ? 1 : orderNm + 1); |
|||
} |
|||
} |
|||
if (insert) { |
|||
syDirMapper.insertAll(syDir); |
|||
} else { |
|||
syDirMapper.updateSelective(syDir); |
|||
} |
|||
updateChildrenDirSeq(syDir); |
|||
return new Response() {{ |
|||
setCode("200"); |
|||
setData(syDirMapper.findById(syDir.getId())); |
|||
}}; |
|||
} |
|||
|
|||
public static String generateLayerResourceDirectoryNumber(String prefix) { |
|||
String ALPHANUMERIC_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
|||
StringBuilder sb = new StringBuilder(); |
|||
|
|||
// 添加前缀
|
|||
if (prefix != null && !prefix.isEmpty()) { |
|||
sb.append(prefix.toUpperCase()).append("_"); |
|||
} |
|||
|
|||
// 生成随机字符
|
|||
Random random = new Random(); |
|||
for (int i = 0; i < (16 - prefix.length() - 1); i++) { |
|||
int index = random.nextInt(ALPHANUMERIC_CHARS.length()); |
|||
sb.append(ALPHANUMERIC_CHARS.charAt(index)); |
|||
} |
|||
|
|||
return sb.toString(); |
|||
} |
|||
|
|||
|
|||
public int removeDirAndSonById(String dirId) { |
|||
try { |
|||
return syDirMapper.deleteByDirIdInSeq(dirId); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
throw e; |
|||
} |
|||
} |
|||
|
|||
public boolean checkRepeatName(String parentId, String Name, String id) throws Exception { |
|||
List<SyDir> children = syDirMapper.getChildrenByParentId(parentId); |
|||
List<SyDir> matchItems = children.stream().filter(o -> o.getName().equals(Name) && !o.getId().equals(id)).collect(Collectors.toList()); |
|||
return matchItems.size() > 0; |
|||
} |
|||
|
|||
private void updateChildrenDirSeq(SyDir parentSyDir) throws Exception { |
|||
List<SyDir> childrenList = syDirMapper.getChildrenByParentId(parentSyDir.getId()); |
|||
if (childrenList == null || childrenList.size() == 0) { |
|||
return; |
|||
} |
|||
for (SyDir children : childrenList) { |
|||
children.setXpath(parentSyDir.getXpath() + "/" + children.getName()); |
|||
children.setDirSeq(children.getId() + "," + parentSyDir.getDirSeq()); |
|||
syDirMapper.updateSelective(children); |
|||
updateChildrenDirSeq(children); |
|||
} |
|||
} |
|||
|
|||
public List<SyDirVo> getListFormDirs(List<SyDir> dirList, String topId) { |
|||
if (StringUtils.isBlank(topId)) { |
|||
topId = "root"; |
|||
} |
|||
List<SyDirVo> list = dirList.stream().map(x -> { |
|||
SyDirVo vo = new SyDirVo(); |
|||
BeanUtils.copyProperties(x, vo); |
|||
return vo; |
|||
}).collect(Collectors.toList()); |
|||
Map<String, SyDirVo> idMap = list.stream().collect(Collectors.toMap(x -> x.getId(), Function.identity())); |
|||
Iterator<SyDirVo> it = list.iterator(); |
|||
while (it.hasNext()) { |
|||
SyDirVo item = it.next(); |
|||
if (item.getParentId() != null && item.getParentId().equals(topId)) { |
|||
//
|
|||
} else { |
|||
SyDirVo parent = idMap.get(item.getParentId()); |
|||
if (parent != null) { |
|||
if (parent.getChildren() == null) { |
|||
parent.setChildren(new ArrayList<>()); |
|||
} |
|||
parent.getChildren().add(item); |
|||
} |
|||
it.remove(); |
|||
} |
|||
} |
|||
return list; |
|||
} |
|||
} |
@ -0,0 +1,148 @@ |
|||
package com.kms.yg.znjg.service; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.kms.yg.df.domain.BsSgcDfJbxx; |
|||
import com.kms.yg.znjg.domain.SyDirLayer; |
|||
import com.kms.yg.znjg.domain.SyLayer; |
|||
import com.kms.yg.znjg.mapper.SyDirLayerMapper; |
|||
import com.kms.yg.znjg.mapper.SyLayerMapper; |
|||
import com.shuili.common.core.domain.SearchParam; |
|||
import org.apache.commons.lang.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class SyLayerService extends ServiceImpl<SyLayerMapper, SyLayer> { |
|||
@Autowired |
|||
private SyLayerMapper syLayerMapper; |
|||
|
|||
@Autowired |
|||
private SyDirLayerMapper syDirLayerMapper; |
|||
|
|||
public Boolean checkNameIsRepeat(String serviceName, String id) { |
|||
Long cnt = syLayerMapper.selectByLayerName(serviceName, id); |
|||
if (cnt > 0) { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
public JSONObject getDetails(String layerId) { |
|||
JSONObject jsonObjectResult = new JSONObject(); |
|||
try { |
|||
SyLayer rcLayer = syLayerMapper.findOneById(layerId); |
|||
//根据layerId查询出相关字段
|
|||
// List<SyLayerField> syLayerFields = syLayerFieldMapper.selectList(new LambdaQueryWrapper<SyLayerField>()
|
|||
// .eq(SyLayerField::getLayerId, rcLayer.getId()));
|
|||
// rcLayer.setFields(syLayerFields);
|
|||
jsonObjectResult.put("layerInfo", rcLayer); |
|||
} catch (Exception e) { |
|||
throw e; |
|||
} |
|||
return jsonObjectResult; |
|||
} |
|||
|
|||
/** |
|||
* 保存图层信息 |
|||
* |
|||
* @param syLayer |
|||
*/ |
|||
public void saveLayer(SyLayer syLayer) { |
|||
//保存图层基本信息
|
|||
syLayerMapper.saveLayer(syLayer); |
|||
//保存图层目录信息
|
|||
saveLayerDir(syLayer); |
|||
//保存图层字段信息
|
|||
//saveLayerField(syLayer.getId(), syLayer.getFields());
|
|||
} |
|||
|
|||
private void saveLayerDir(SyLayer syLayer) { |
|||
if (StringUtils.isEmpty(syLayer.getDirId())) { |
|||
return; |
|||
} |
|||
List<SyDirLayer> dirLayers = syDirLayerMapper.findListByLayerId(syLayer.getId()); |
|||
Map<String, SyDirLayer> dirIdMap = dirLayers.stream().collect(Collectors.toMap(x -> x.getDirId(), x -> x)); |
|||
String[] dirIdList = syLayer.getDirId().split(","); |
|||
String maxOrder = syDirLayerMapper.getMaxOrder(); |
|||
if (StringUtils.isEmpty(maxOrder)) { |
|||
maxOrder = "0"; |
|||
} |
|||
int orderNm = Integer.parseInt(maxOrder); |
|||
for (int i = 0; i < dirIdList.length; i++) { |
|||
String dirId = dirIdList[i]; |
|||
if (dirIdMap.get(dirId) == null) { |
|||
// 新增
|
|||
SyDirLayer dir = new SyDirLayer(); |
|||
dir.setId(UUID.randomUUID().toString()); |
|||
dir.setDirId(dirId); |
|||
dir.setLayerId(syLayer.getId()); |
|||
dir.setOrderNm(++orderNm); |
|||
syDirLayerMapper.save(dir); |
|||
} |
|||
} |
|||
List<SyDirLayer> delList = dirLayers.stream().filter(x -> { |
|||
boolean match = Arrays.asList(dirIdList).stream().anyMatch(y -> y.equals(x.getDirId())); |
|||
return !match; |
|||
}).collect(Collectors.toList()); |
|||
if (CollectionUtils.isNotEmpty(delList)) { |
|||
syDirLayerMapper.deleteBatchByIds(delList); |
|||
} |
|||
} |
|||
|
|||
public void updateLayer(SyLayer syLayer) { |
|||
//更新图层基本信息
|
|||
syLayerMapper.updateLayer(syLayer); |
|||
//保存图层目录信息
|
|||
saveLayerDir(syLayer); |
|||
//保存图层字段信息
|
|||
//saveLayerField(syLayer.getId(), syLayer.getFields());
|
|||
} |
|||
|
|||
public List<SyLayer> findLayerByLayerIds(List<String> idList) { |
|||
if (CollectionUtils.isNotEmpty(idList)) { |
|||
return syLayerMapper.findLayerByLayerIds(idList); |
|||
} else { |
|||
return new ArrayList<>(); |
|||
} |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
//删除sy_layer图层信息
|
|||
syLayerMapper.delete(ids); |
|||
//删除图层目录关联信息
|
|||
syDirLayerMapper.delete(ids); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 分页查询全部资源信息 |
|||
* |
|||
* @param pageQuery |
|||
* @param syLayer |
|||
* @return |
|||
*/ |
|||
public IPage<SyLayer> selectPage(Page<SyLayer> pageQuery, SyLayer syLayer, Map<String, Object> params) { |
|||
String orderBy = ""; |
|||
String sortBy = ""; |
|||
if (params != null) { |
|||
if (params.get("orderBy") != null) { |
|||
orderBy = (String) params.get("orderBy"); |
|||
} |
|||
if (params.get("sortBy") != null) { |
|||
sortBy = (String) params.get("sortBy"); |
|||
} |
|||
} |
|||
syLayerMapper.findSyLayerList(pageQuery, syLayer, orderBy, sortBy); |
|||
return pageQuery; |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
package com.kms.yg.znjg.vo; |
|||
|
|||
import com.kms.yg.znjg.domain.SyDir; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Data |
|||
public class SyDirVo extends SyDir { |
|||
private List<SyDirVo> children; |
|||
} |
@ -0,0 +1,65 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.kms.yg.znjg.mapper.SyDirLayerMapper"> |
|||
<resultMap id="BaseResultMap" type="com.kms.yg.znjg.domain.SyDirLayer"> |
|||
<id property="id" column="id" jdbcType="VARCHAR"/> |
|||
<result property="dirId" column="dir_id" jdbcType="VARCHAR"/> |
|||
<result property="layerId" column="layer_id" jdbcType="VARCHAR"/> |
|||
<result property="orderNm" column="order_nm" jdbcType="DECIMAL"/> |
|||
</resultMap> |
|||
|
|||
<sql id="Base_Column_List"> |
|||
id |
|||
,dir_id,layer_id, |
|||
order_nm |
|||
</sql> |
|||
|
|||
<select id="findListByLayerId" resultType="com.kms.yg.znjg.domain.SyDirLayer"> |
|||
SELECT |
|||
<include refid="Base_Column_List"/> |
|||
FROM |
|||
sy_dir_layer |
|||
WHERE is_valid = 1 |
|||
AND |
|||
layer_id = #{layerId} |
|||
</select> |
|||
|
|||
<select id="getMaxOrder" resultType="java.lang.String"> |
|||
SELECT max(order_nm) |
|||
FROM sy_dir_layer |
|||
WHERE is_valid = 1 |
|||
</select> |
|||
|
|||
<insert id="save"> |
|||
INSERT INTO sy_dir_layer (id, dir_id, layer_id, order_nm, is_valid) |
|||
VALUES (#{id}, #{dirId}, #{layerId}, #{orderNm}, 1) |
|||
</insert> |
|||
|
|||
|
|||
<delete id="deleteBatchByIds"> |
|||
update sy_dir_layer |
|||
<set> |
|||
is_valid=0, |
|||
</set> |
|||
WHERE |
|||
id IN |
|||
<foreach collection="syDirLayers" item="syDirLayer" open="(" separator="," close=")"> |
|||
#{syDirLayer.id} |
|||
</foreach> |
|||
</delete> |
|||
|
|||
|
|||
<delete id="delete"> |
|||
update sy_dir_layer |
|||
<set> |
|||
is_valid=0, |
|||
</set> |
|||
WHERE |
|||
layer_id IN |
|||
<foreach collection="ids" item="item" separator="," open="(" close=")"> |
|||
#{item} |
|||
</foreach> |
|||
</delete> |
|||
</mapper> |
@ -0,0 +1,132 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.kms.yg.znjg.mapper.SyDirMapper"> |
|||
|
|||
<resultMap id="BaseResultMap" type="com.kms.yg.znjg.domain.SyDir"> |
|||
<id property="id" column="id" jdbcType="VARCHAR"/> |
|||
<result property="name" column="name" jdbcType="VARCHAR"/> |
|||
<result property="parentId" column="parent_id" jdbcType="VARCHAR"/> |
|||
<result property="xpath" column="xpath" jdbcType="VARCHAR"/> |
|||
<result property="dirSeq" column="dir_seq" jdbcType="VARCHAR"/> |
|||
<result property="orderNm" column="order_nm" jdbcType="DECIMAL"/> |
|||
</resultMap> |
|||
|
|||
<sql id="Base_Column_List"> |
|||
id |
|||
,name,parent_id, |
|||
xpath,dir_seq,order_nm |
|||
</sql> |
|||
|
|||
<!--获取指定场景指定类型所有的目录--> |
|||
<select id="findAll" resultMap="BaseResultMap"> |
|||
SELECT |
|||
<include refid="Base_Column_List"/> |
|||
FROM sy_dir |
|||
where is_valid = 1 |
|||
ORDER BY order_nm |
|||
</select> |
|||
|
|||
<!-- 根据id获取目录--> |
|||
<select id="findById" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List"/> |
|||
from sy_dir |
|||
where is_valid = 1 |
|||
and |
|||
id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
|
|||
<!--根据父id更新排序号--> |
|||
<update id="updateOrderNmByParentId"> |
|||
update sy_dir |
|||
set order_nm =order_nm + 1 |
|||
where is_valid = 1 |
|||
AND parent_id = #{parentId,jdbcType=VARCHAR} |
|||
AND <![CDATA[ order_nm >= #{orderNm} |
|||
]]> |
|||
</update> |
|||
|
|||
<!--新增实体对象--> |
|||
<insert id="insertAll"> |
|||
insert into sy_dir |
|||
(id, name, parent_id, xpath, dir_seq, order_nm, is_valid) |
|||
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, |
|||
#{xpath,jdbcType=VARCHAR}, #{dirSeq,jdbcType=VARCHAR}, #{orderNm,jdbcType=NUMERIC}, 1) |
|||
</insert> |
|||
|
|||
<!--更新实体对象--> |
|||
<update id="updateSelective"> |
|||
update sy_dir |
|||
<set> |
|||
<if test="name != null">name=#{name,jdbcType=VARCHAR},</if> |
|||
<if test="parentId != null">parent_id=#{parentId,jdbcType=VARCHAR},</if> |
|||
<if test="xpath != null">xpath=#{xpath,jdbcType=VARCHAR},</if> |
|||
<if test="dirSeq != null">dir_seq=#{dirSeq,jdbcType=VARCHAR},</if> |
|||
<if test="orderNm != null">order_nm=#{orderNm,jdbcType=NUMERIC},</if> |
|||
</set> |
|||
where is_valid = 1 |
|||
and |
|||
id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
|
|||
<!--根据父id获取子节点数据--> |
|||
<select id="getChildrenByParentId" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List"/> |
|||
from sy_dir |
|||
where is_valid = 1 |
|||
and |
|||
parent_id = #{parentId,jdbcType=VARCHAR} |
|||
ORDER BY order_nm |
|||
</select> |
|||
|
|||
<!--根据目录id删除目录--> |
|||
<delete id="deleteByDirIdInSeq"> |
|||
update sy_dir |
|||
<set> |
|||
is_valid=0, |
|||
</set> |
|||
where is_valid = 1 and dir_seq LIKE CONCAT('%', CONCAT(#{dirId}, '%')) |
|||
</delete> |
|||
|
|||
<!--查找所有二级目录--> |
|||
<select id="findSecond" resultMap="BaseResultMap"> |
|||
SELECT |
|||
<include refid="Base_Column_List"/> |
|||
FROM |
|||
sy_dir t1 |
|||
WHERE t1.is_valid = 1 |
|||
and |
|||
t1.PARENT_ID |
|||
IN ("root") |
|||
ORDER BY t1.order_nm |
|||
</select> |
|||
|
|||
<select id="selectDirSeq" resultType="java.lang.String"> |
|||
SELECT sy.dir_seq |
|||
FROM sy_dir sy, |
|||
sy_dir_layer s, |
|||
sy_layer l |
|||
WHERE sy.id = s.dir_id |
|||
AND s.layer_id = l.id |
|||
AND sy.is_valid = 1 |
|||
AND l.is_valid = 1 |
|||
AND s.is_valid = 1 |
|||
</select> |
|||
|
|||
|
|||
<!--按id集合查找--> |
|||
<select id="findByIds" resultMap="BaseResultMap"> |
|||
SELECT |
|||
<include refid="Base_Column_List"/> |
|||
FROM sy_dir |
|||
WHERE is_valid = 1 |
|||
AND id IN |
|||
<foreach collection="ids" item="item" separator="," open="(" close=")"> |
|||
#{item} |
|||
</foreach> |
|||
ORDER BY order_nm |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,252 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.kms.yg.znjg.mapper.SyLayerMapper"> |
|||
|
|||
<resultMap id="BaseResultMap" type="com.kms.yg.znjg.domain.SyLayer"> |
|||
<id property="id" column="id" jdbcType="VARCHAR"/> |
|||
<result property="serviceName" column="service_name" jdbcType="VARCHAR"/> |
|||
<result property="serviceNameAlias" column="service_name_alias" jdbcType="VARCHAR"/> |
|||
<result property="serviceUrl" column="service_url" jdbcType="VARCHAR"/> |
|||
<result property="annotationUrl" column="annotation_url" jdbcType="VARCHAR"/> |
|||
<result property="serviceToken" column="service_token" jdbcType="VARCHAR"/> |
|||
<result property="serviceType" column="service_type" jdbcType="VARCHAR"/> |
|||
<result property="serviceIndex" column="service_index" jdbcType="VARCHAR"/> |
|||
<result property="annotationServiceIndex" column="annotation_service_index" jdbcType="VARCHAR"/> |
|||
<result property="pubDate" column="pub_date" jdbcType="TIMESTAMP"/> |
|||
<result property="createUser" column="create_user" jdbcType="VARCHAR"/> |
|||
<result property="layer3dType" column="layer_3d_type" jdbcType="VARCHAR"/> |
|||
<result property="tileSize" column="tile_size" jdbcType="INTEGER"/> |
|||
<result property="tileMatrixSet" column="tile_matrix_set" jdbcType="VARCHAR"/> |
|||
<result property="dirId" column="dir_id" jdbcType="VARCHAR"/> |
|||
<result property="dirName" column="dir_name" jdbcType="VARCHAR"/> |
|||
<result property="remark" column="remark" jdbcType="VARCHAR"/> |
|||
<result property="format" column="format" jdbcType="VARCHAR"/> |
|||
<result property="data" column="data" jdbcType="VARCHAR"/> |
|||
<result property="tileSetOption" column="tileset_option" jdbcType="VARCHAR"/> |
|||
<result property="isLayerGroup" column="is_layer_group" jdbcType="BOOLEAN"/> |
|||
<result property="relationServiceId" column="relation_service_id" jdbcType="VARCHAR"/> |
|||
<result property="relationServiceName" column="relation_service_name" jdbcType="VARCHAR"/> |
|||
<result property="relationStyleId" column="relation_style_id" jdbcType="VARCHAR"/> |
|||
<result property="relationStyleName" column="relation_style_name" jdbcType="VARCHAR"/> |
|||
</resultMap> |
|||
|
|||
<sql id="Base_Column_List"> |
|||
id |
|||
,service_name,service_name_alias, |
|||
service_url,annotation_url,service_token, |
|||
service_type,service_index,annotation_service_index,pub_date, |
|||
create_user,layer_3d_type,tile_size, |
|||
tile_matrix_set,dir_id,dir_name,remark,format,data,tileset_option,is_layer_group, |
|||
relation_service_id,relation_service_name,relation_style_id,relation_style_name |
|||
</sql> |
|||
|
|||
|
|||
<sql id="Base_Column_List_Query"> |
|||
a |
|||
. |
|||
id |
|||
,service_name,service_name_alias, |
|||
service_url,annotation_url,service_token,service_type,service_index,annotation_service_index, |
|||
pub_date, |
|||
create_user,layer_3d_type,tile_size, |
|||
tile_matrix_set,dir_id,dir_name,remark,format,data,tileset_option,is_layer_group, |
|||
relation_service_id,relation_service_name,relation_style_id,relation_style_name |
|||
</sql> |
|||
|
|||
<insert id="saveLayer"> |
|||
insert into sy_layer |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null">id,</if> |
|||
<if test="serviceName != null">service_name,</if> |
|||
<if test="serviceNameAlias != null">service_name_alias,</if> |
|||
<if test="serviceUrl != null">service_url,</if> |
|||
<if test="annotationUrl != null">annotation_url,</if> |
|||
<if test="serviceToken != null">service_token,</if> |
|||
<if test="serviceType != null">service_type,</if> |
|||
<if test="serviceIndex != null">service_index,</if> |
|||
<if test="annotationServiceIndex != null">annotation_service_index,</if> |
|||
<if test="pubDate != null">pub_date,</if> |
|||
<if test="createUser != null">create_user,</if> |
|||
<if test="layer3dType != null">layer_3d_type,</if> |
|||
<if test="tileSize != null">tile_size,</if> |
|||
<if test="tileMatrixSet != null">tile_matrix_set,</if> |
|||
<if test="dirId != null">dir_id,</if> |
|||
<if test="dirName != null">dir_name,</if> |
|||
<if test="remark != null">remark,</if> |
|||
<if test="format != null">format,</if> |
|||
<if test="data != null">data,</if> |
|||
<if test="tileSetOption != null">tileset_option,</if> |
|||
<if test="isLayerGroup != null">is_layer_group,</if> |
|||
<if test="relationServiceId != null">relation_service_id,</if> |
|||
<if test="relationServiceName != null">relation_service_name,</if> |
|||
<if test="relationStyleId != null">relation_style_id,</if> |
|||
<if test="relationStyleName != null">relation_style_name,</if> |
|||
is_valid, |
|||
</trim> |
|||
values |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null">#{id,jdbcType=VARCHAR},</if> |
|||
<if test="serviceName != null">#{serviceName,jdbcType=VARCHAR},</if> |
|||
<if test="serviceNameAlias != null">#{serviceNameAlias,jdbcType=VARCHAR},</if> |
|||
<if test="serviceUrl != null">#{serviceUrl,jdbcType=VARCHAR},</if> |
|||
<if test="annotationUrl != null">#{annotationUrl,jdbcType=VARCHAR},</if> |
|||
<if test="serviceToken != null">#{serviceToken,jdbcType=VARCHAR},</if> |
|||
<if test="serviceType != null">#{serviceType,jdbcType=VARCHAR},</if> |
|||
<if test="serviceIndex != null">#{serviceIndex,jdbcType=VARCHAR},</if> |
|||
<if test="annotationServiceIndex != null">#{annotationServiceIndex,jdbcType=VARCHAR},</if> |
|||
<if test="pubDate != null">#{pubDate},</if> |
|||
<if test="createUser != null">#{createUser,jdbcType=VARCHAR},</if> |
|||
<if test="layer3dType != null">#{layer3dType,jdbcType=VARCHAR},</if> |
|||
<if test="tileSize != null">#{tileSize,jdbcType=INTEGER},</if> |
|||
<if test="tileMatrixSet != null">#{tileMatrixSet,jdbcType=VARCHAR},</if> |
|||
<if test="dirId != null">#{dirId,jdbcType=VARCHAR},</if> |
|||
<if test="dirName != null">#{dirName,jdbcType=VARCHAR},</if> |
|||
<if test="remark != null">#{remark,jdbcType=VARCHAR},</if> |
|||
<if test="format != null">#{format,jdbcType=VARCHAR},</if> |
|||
<if test="data != null">#{data,jdbcType=VARCHAR},</if> |
|||
<if test="tileSetOption != null">#{tileSetOption,jdbcType=VARCHAR},</if> |
|||
<if test="isLayerGroup != null">#{isLayerGroup,jdbcType=BOOLEAN},</if> |
|||
<if test="relationServiceId != null">#{relationServiceId,jdbcType=VARCHAR},</if> |
|||
<if test="relationServiceName != null">#{relationServiceName,jdbcType=VARCHAR},</if> |
|||
<if test="relationStyleId != null">#{relationStyleId,jdbcType=VARCHAR},</if> |
|||
<if test="relationStyleName != null">#{relationStyleName,jdbcType=VARCHAR},</if> |
|||
1, |
|||
</trim> |
|||
</insert> |
|||
|
|||
<update id="updateLayer"> |
|||
update sy_layer |
|||
<set> |
|||
<if test="serviceName != null">service_name=#{serviceName,jdbcType=VARCHAR},</if> |
|||
<if test="serviceNameAlias != null">service_name_alias=#{serviceNameAlias,jdbcType=VARCHAR},</if> |
|||
<if test="serviceUrl != null">service_url=#{serviceUrl,jdbcType=VARCHAR},</if> |
|||
<if test="annotationUrl != null">annotation_url=#{annotationUrl,jdbcType=VARCHAR},</if> |
|||
<if test="serviceToken != null">service_token=#{serviceToken,jdbcType=VARCHAR},</if> |
|||
<if test="serviceType != null">service_type=#{serviceType,jdbcType=VARCHAR},</if> |
|||
<if test="serviceIndex != null">service_index=#{serviceIndex,jdbcType=VARCHAR},</if> |
|||
<if test="annotationServiceIndex != null"> |
|||
annotation_service_index=#{annotationServiceIndex,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="pubDate != null">pub_date=#{pubDate},</if> |
|||
<if test="createUser != null">create_user=#{createUser,jdbcType=VARCHAR},</if> |
|||
<if test="layer3dType != null">layer_3d_type=#{layer3dType,jdbcType=VARCHAR},</if> |
|||
<if test="tileSize != null">tile_size=#{tileSize,jdbcType=NUMERIC},</if> |
|||
<if test="tileMatrixSet != null">tile_matrix_set=#{tileMatrixSet,jdbcType=VARCHAR},</if> |
|||
<if test="dirId != null">dir_id=#{dirId,jdbcType=VARCHAR},</if> |
|||
<if test="dirName != null">dir_name=#{dirName,jdbcType=VARCHAR},</if> |
|||
<if test="remark != null">remark=#{remark,jdbcType=VARCHAR},</if> |
|||
<if test="format != null">format=#{format,jdbcType=VARCHAR},</if> |
|||
<if test="data != null">data=#{data,jdbcType=VARCHAR},</if> |
|||
<if test="tileSetOption != null">tileset_option=#{tileSetOption,jdbcType=VARCHAR},</if> |
|||
<if test="isLayerGroup != null">is_layer_group=#{isLayerGroup,jdbcType=BOOLEAN},</if> |
|||
<if test="relationServiceId != null">relation_service_id=#{relationServiceId,jdbcType=VARCHAR},</if> |
|||
<if test="relationServiceName != null">relation_service_name=#{relationServiceName,jdbcType=VARCHAR},</if> |
|||
<if test="relationStyleId != null">relation_style_id=#{relationStyleId,jdbcType=VARCHAR},</if> |
|||
<if test="relationStyleName != null">relation_style_name=#{relationStyleName,jdbcType=VARCHAR},</if> |
|||
</set> |
|||
where is_valid=1 |
|||
AND |
|||
id = #{id,jdbcType=VARCHAR} |
|||
</update> |
|||
<delete id="delete"> |
|||
update SY_LAYER |
|||
<set> |
|||
is_valid=0, |
|||
</set> |
|||
where is_valid = 1 |
|||
and |
|||
id IN |
|||
<foreach collection="ids" item="item" separator="," open="(" close=")"> |
|||
#{item} |
|||
</foreach> |
|||
</delete> |
|||
|
|||
<select id="selectByLayerName" resultType="java.lang.Long"> |
|||
SELECT COUNT(*) AS CNT FROM SY_LAYER |
|||
WHERE |
|||
is_valid = 1 |
|||
AND SERVICE_NAME=#{serviceName} |
|||
<if test="notEqLayerId != null"> |
|||
AND ID <![CDATA[ != ]]> #{notEqLayerId} |
|||
</if> |
|||
</select> |
|||
|
|||
<select id="findOneById" resultType="com.kms.yg.znjg.domain.SyLayer"> |
|||
select * |
|||
from sy_layer sl |
|||
where is_valid = 1 |
|||
and sl.id = #{id,jdbcType=VARCHAR} |
|||
</select> |
|||
|
|||
<select id="findLayerByLayerIds" resultMap="BaseResultMap"> |
|||
SELECT |
|||
<include refid="Base_Column_List"/> |
|||
FROM SY_LAYER a |
|||
WHERE a.is_valid=1 |
|||
and a.id in |
|||
<foreach collection="list" close=")" separator="," index="index" open="(" item="item"> |
|||
#{item} |
|||
</foreach> |
|||
</select> |
|||
|
|||
|
|||
<select id="findSyLayerList" resultType="com.kms.yg.znjg.domain.SyLayer"> |
|||
SELECT |
|||
<include refid="Base_Column_List_Query"/> |
|||
,IFNULL(orderNmTbl.orderNm,0) orderNm |
|||
FROM SY_LAYER a |
|||
left join ( |
|||
SELECT dl.layer_id, MAX(dl.order_nm) orderNm FROM sy_dir_layer dl |
|||
where 1=1 |
|||
AND dl.is_valid = 1 |
|||
<if test="syLayer.dirId != null and syLayer.dirId != ''"> |
|||
AND dl.dir_id= TRIM(#{syLayer.dirId}) |
|||
</if> |
|||
GROUP BY dl.layer_id |
|||
) orderNmTbl on a.id = orderNmTbl.layer_id |
|||
<if test="syLayer.dirId != null and syLayer.dirId != ''"> |
|||
LEFT JOIN ( |
|||
SELECT |
|||
SYLAYER.LAYER_ID, count(SYLAYER.DIR_ID) num |
|||
FROM |
|||
SY_DIR_LAYER SYLAYER |
|||
join sy_layer al on SYLAYER.layer_id = al.id, |
|||
SY_DIR SYDIR |
|||
WHERE |
|||
SYLAYER.is_valid = 1 |
|||
AND |
|||
SYLAYER.DIR_ID = SYDIR.ID |
|||
AND SYDIR.DIR_SEQ LIKE CONCAT(CONCAT('%', TRIM(#{syLayer.dirId})),'%') |
|||
GROUP BY SYLAYER.LAYER_ID |
|||
) layerDirCountTbl on layerDirCountTbl.LAYER_ID = a.id |
|||
</if> |
|||
WHERE 1=1 |
|||
AND a.is_valid = 1 |
|||
<if test="syLayer.dirId != null and syLayer.dirId != ''"> |
|||
AND layerDirCountTbl.num > 0 |
|||
</if> |
|||
<if test="syLayer.id != null and syLayer.id != ''"> |
|||
AND a.id = #{syLayer.id} |
|||
</if> |
|||
<if test="syLayer.serviceName != null and syLayer.serviceName != ''"> |
|||
AND a.service_name = #{syLayer.serviceName} |
|||
</if> |
|||
<if test="syLayer.serviceType != null and syLayer.serviceType != ''"> |
|||
AND a.SERVICE_TYPE = #{syLayer.serviceType} |
|||
</if> |
|||
order by |
|||
<if test="orderBy !=null and orderBy != '' "> |
|||
<choose> |
|||
<when test="orderBy =='name'"> |
|||
CONVERT(a.service_name USING gb2312) ${sortBy}, |
|||
</when> |
|||
<otherwise> |
|||
${orderBy} ${sortBy}, |
|||
</otherwise> |
|||
</choose> |
|||
</if> |
|||
a.id |
|||
</select> |
|||
</mapper> |
Loading…
Reference in new issue