月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-06-02 dc0d4a7907f3affdbc116288cac24ad4ba05f319
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.lf.server.mapper.all;
 
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
 
import java.util.List;
 
/**
 * 空间基础Mapper
 * @author WWW
 * @param <T> 泛型
 */
public interface GeomBaseMapper<T> extends BasicMapper<T> {
    /**
     * 根据ID查询WKT
     *
     * @param tab 表名
     * @param gid GID
     * @return WKT
     */
    @Select("select ST_AsText(geom) geom from ${tab} where gid = #{gid} limit 1")
    public String selectWktById(@Param("tab") String tab, @Param("gid") Integer gid);
 
    /**
     * 根据表名查询空间参考
     *
     * @param tab 表名
     * @return SRID
     */
    @Select("select ST_SRID(geom) from ${tab} where geom is not null limit 1")
    public Integer selectSrid(@Param("tab") String tab);
 
    /**
     * 根据表名查询空间类型
     *
     * @param tab 表名
     * @return SRID
     */
    @Select("select ST_GeometryType(geom) from ${tab} where geom is not null limit 1")
    public String selectGeometryType(@Param("tab") String tab);
 
    /**
     * 查询DB中溢出的单位ID
     *
     * @param tab       表名
     * @param depid     单位ID
     * @param geoFilter 空间过滤条件
     * @return 溢出的单位ID
     */
    @Select("<script>" +
            " select depid from ${tab} where depid is not null and depid not like '${depid}%'" +
            " <if test='geoFilter != null'>" +
            "  and ${geoFilter}" +
            " </if>" +
            " group by depid" +
            "</script>")
    public List<Integer> selectDbOverflowDep(@Param("tab") String tab, @Param("depid") String depid, @Param("geoFilter") String geoFilter);
 
    /**
     * 更新空间位置
     *
     * @param tab 表名
     * @param gid GID
     * @param wkt WKT
     * @return 影响行数
     */
    @Update("update ${tab} set geom = ST_GeomFromText('${wkt}') where gid = #{gid} limit 1")
    public Integer updateGeom(@Param("tab") String tab, @Param("gid") Integer gid, @Param("wkt") String wkt);
}