| | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.lf.server.entity.all.RedisCacheKey; |
| | | import com.lf.server.entity.ctrl.IdNameEntity; |
| | | import com.lf.server.entity.ctrl.TabEntity; |
| | | import com.lf.server.entity.data.DictEntity; |
| | |
| | | import com.lf.server.mapper.all.BasicMapper; |
| | | import com.lf.server.mapper.all.GeomBaseMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.cache.RedisCache; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 父查询服务类 |
| | |
| | | public class BaseQueryService implements BaseQueryMapper { |
| | | @Autowired |
| | | BaseQueryMapper baseQueryMapper; |
| | | |
| | | @Autowired |
| | | RedisService redisService; |
| | | |
| | | /** |
| | | * 表名Map |
| | |
| | | * @param basicMapper 父Mapper |
| | | * @param wrapper QueryWrapper |
| | | * @param wkt WKT(著名文本) |
| | | * @param srid 空间引用标识符 |
| | | * @throws Exception 异常 |
| | | */ |
| | | public void addGeomWrapper(BasicMapper basicMapper, QueryWrapper wrapper, String wkt, Integer srid) throws Exception { |
| | | if (basicMapper instanceof GeomBaseMapper && !StringHelper.isEmpty(wkt) && srid != null) { |
| | | public void addGeomWrapper(BasicMapper basicMapper, QueryWrapper wrapper, String wkt) throws Exception { |
| | | if (basicMapper instanceof GeomBaseMapper && !StringHelper.isEmpty(wkt)) { |
| | | wkt = AesHelper.decrypt(wkt); |
| | | wrapper.apply(String.format("ST_Intersects(geom, ST_PolygonFromText('%s', %d))", wkt, srid)); |
| | | |
| | | Integer srid = getSrid((GeomBaseMapper) basicMapper); |
| | | wrapper.apply(String.format("ST_Intersects(ST_PolygonFromText('%s', %d), geom)", wkt, srid)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取几何对象的空间参考 |
| | | * |
| | | * @param basicMapper 空间基础Mapper |
| | | * @return SRID |
| | | */ |
| | | private Integer getSrid(GeomBaseMapper basicMapper) { |
| | | String tab = getTabName(basicMapper); |
| | | String key = RedisCacheKey.sridKey(tab); |
| | | |
| | | Object obj = redisService.get(key); |
| | | if (obj instanceof Integer) { |
| | | return (Integer) obj; |
| | | } |
| | | |
| | | Integer srid = basicMapper.selectSrid(tab); |
| | | if (srid != null) { |
| | | redisService.put(key, srid, 5, TimeUnit.MINUTES); |
| | | } |
| | | |
| | | return srid; |
| | | } |
| | | |
| | | /** |
| | | * 根据Mapper获取表名 |
| | | * |
| | | * @param basicMapper Mapper |