13693261870
2025-07-02 7c7cb1855b7f18802f55a70fa14ed70cbdb11bab
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?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.terra.system.mapper.all.BaseQueryMapper">
    <select id="selectUserFuzzy" resultType="com.terra.system.entity.ctrl.IdNameEntity">
        select id,uname "name" from lf.sys_user
        <where>
            <if test="name != null">
                upper(uname) like #{name}
            </if>
        </where>
        order by uname limit 10
    </select>
 
    <select id="selectDepFuzzy" resultType="com.terra.system.entity.ctrl.IdNameEntity">
        select id,name from lf.sys_dep
        <where>
            <if test="name != null">
                upper(name) like #{name}
            </if>
        </where>
        order by order_num limit 10
    </select>
 
    <select id="selectTabsForCount" resultType="java.lang.Integer">
        select count(*) from lf.sys_dict
        <where>
            field = #{field} and status = 0
            <if test="tab != null">
                and (upper(tab) like #{tab} or upper(tab_desc) like #{tab})
            </if>
            <if test="typesFilter != null">
                and (${typesFilter})
            </if>
        </where>
    </select>
 
    <select id="selectTabsByPage" resultType="com.terra.system.entity.ctrl.TabEntity">
        select ns, tab, tab_desc, fn_get_entity(tab) entity, tableType, bak, fn_tab_count(a.ns, a.tab, #{filters}) "rows"
        from lf.sys_dict a
        <where>
            field = #{field} and status = 0
            <if test="tab != null">
                and (upper(tab) like #{tab} or upper(tab_desc) like #{tab})
            </if>
            <if test="typesFilter != null">
                and (${typesFilter})
            </if>
        </where>
        order by id
        limit #{limit} offset #{offset};
    </select>
 
    <select id="selectFields" resultType="com.terra.system.entity.data.DictEntity">
      select * from lf.sys_dict where ns = #{ns} and tab = #{tab} order by order_num
    </select>
 
    <select id="selectDomains" resultType="com.terra.system.entity.data.DomainEntity">
      select a.* from lf.sys_domain a inner join lf.sys_dict b on a.dom_name = b.domain_na
      where b.ns = #{ns} and b.tab = #{tab} and b.domain_na is not null
    </select>
 
    <select id="selectRoute" resultType="java.lang.String">
        select ST_astext(ST_Union(geom)) as route from pgr_fromAtoB('lrdl'::text, #{x1}, #{y1}, #{x2}, #{y2});
    </select>
 
    <select id="selectLocation" resultType="com.terra.system.entity.ctrl.KeyValueEntity">
        select '国' "key", cname "value" from bs.th_globe_country where ST_Intersects(ST_PointFromText(#{wkt}, 4490), geom)
        union all
        select '省' "key", cname "value" from bs.th_province_area where ST_Intersects(ST_PointFromText(#{wkt}, 4490), geom)
        union all
        select '市' "key", cname "value" from bs.th_district_area where ST_Intersects(ST_PointFromText(#{wkt}, 4490), geom)
        union all
        select '县' "key", cname "value" from bs.th_county_area where ST_Intersects(ST_PointFromText(#{wkt}, 4490), geom);
    </select>
 
    <select id="selectDirTypes" resultType="com.terra.system.entity.ctrl.KeyValueEntity">
        select (select string_agg(code, ',') from lf.sys_dir where name = a.name) "key", name "value"
        from lf.sys_dir a
        <where>
            name in ('基础测绘', '基础地灾', '基础勘察', '合规数据', '管理数据', '测绘(ESV)', '勘察(EGE)', '地灾(EGD)', '洞库(EGD)')
            <if test="name != null">
                and upper(name) like #{name}
            </if>
        </where>
        group by name
        order by key
    </select>
 
    <select id="selectDirsByTypes" resultType="com.terra.system.entity.ctrl.KeyValueEntity">
        with rs as (
            select name, code
            from lf.sys_dir
            <where>
                name in
                <foreach item="type" collection="types" open="(" separator="," close=")">
                    #{type}
                </foreach>
                <if test="dirs != null">
                    and ${dirs}
                </if>
            </where>
        )
        select name "key", (select string_agg(code, ',') from rs where name = a.name) "value"
        from rs a
        group by name
        order by value;
    </select>
 
    <select id="selectAnnexByTab" resultType="com.terra.system.entity.sys.AttachEntity">
        select a.* from lf.sys_attach a
        <where>
            tab = #{tab}
            <if test="gids != null">
                and tab_guid in (select eventid from ${tab} where gid in (${gids}))
            </if>
        </where>
        order by a.id
    </select>
</mapper>