| | |
| | | select count(1) from bd.dlg_agnp a where ST_Intersects(a.geom, |
| | | ST_PolygonFromText('POLYGON ((115.94927385452 32.3754479115071 0,121.989371092554 32.2766788010181 0,121.850621222894 29.6874200067864 0,115.9727267226 29.7835368627922 0,115.94927385452 32.3754479115071 0))', 4326)) |
| | | |
| | | -- |
| | | with geo as (select ST_PolygonFromText('POLYGON ((115.94927385452 32.3754479115071 0,121.989371092554 32.2766788010181 0,121.850621222894 29.6874200067864 0,115.9727267226 29.7835368627922 0,115.94927385452 32.3754479115071 0))', 4326)) |
| | | select count(1) from bd.dlg_25w_aanp a where ST_Intersects(geo, geom); |
| | | |
| | | |
| | | -- 1101:gid >= 50 and name like 县 and objectid < 2000 and pac = 500240 |
| | | select * from bd.dlg_agnp where gid >= 50 and name like '%县%' and objectid < 2000 and pac = '500240' |
| | | |
| | | |
| | | |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.bd.DlgAgnpEntity; |
| | | import com.lf.server.helper.AesHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.mapper.all.GeomBaseMapper; |
| | |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | QueryWrapper<Object> wrapper = new QueryWrapper<>(); |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | baseQueryService.addFilterWrapper(wrapper, filter); |
| | | baseQueryService.addGeomWrapper(baseMapper, wrapper, wkt, srid); |
| | | |
| | |
| | | return fail("查询对象不存在", null); |
| | | } |
| | | |
| | | QueryWrapper<Object> wrapper = new QueryWrapper<>(); |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | baseQueryService.addFilterWrapper(wrapper, filter); |
| | | baseQueryService.addGeomWrapper(baseMapper, wrapper, wkt, srid); |
| | | |
| | |
| | | package com.lf.server.helper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据BaseMapper创建实体类 |
| | | * |
| | | * @param baseMapper 父Mapper |
| | | * @return 实体类 |
| | | */ |
| | | public static Object createInstanceByBaseMapper(BaseMapper baseMapper) { |
| | | String className = baseMapper.getClass().getName().replace(".mapper", ".entity").replace("Mapper", "Entity"); |
| | | |
| | | return createInstance(className); |
| | | } |
| | | |
| | | /** |
| | | * 获取Bean |
| | | * |
| | | * @param className 类名 |
| | |
| | | * @param wrapper |
| | | * @param filter |
| | | */ |
| | | public <T> void addFilterWrapper(QueryWrapper<T> wrapper, String filter) { |
| | | public void addFilterWrapper(QueryWrapper wrapper, String filter) { |
| | | if (StringHelper.isEmpty(filter)) { |
| | | return; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private <T> void addWrapper(QueryWrapper<T> wrapper, String field, String express, String value) { |
| | | private void addWrapper(QueryWrapper wrapper, String field, String express, String value) { |
| | | switch (express) { |
| | | case "like": |
| | | wrapper.like(field, value); |
| | |
| | | * @param srid 空间引用标识符 |
| | | * @throws Exception 异常 |
| | | */ |
| | | public void addGeomWrapper(BaseMapper baseMapper, QueryWrapper<Object> wrapper, String wkt, Integer srid) throws Exception { |
| | | public void addGeomWrapper(BaseMapper baseMapper, QueryWrapper wrapper, String wkt, Integer srid) throws Exception { |
| | | if (baseMapper instanceof GeomBaseMapper && !StringHelper.isEmpty(wkt) && srid != null) { |
| | | wkt = AesHelper.decrypt(wkt); |
| | | wrapper.apply(String.format("ST_Intersects(geom, ST_PolygonFromText('%s', %d))", wkt, srid)); |