月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-09-03 3f39280a9b2b814f883a9b578939f421dd056fef
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<?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.moon.server.mapper.data.MetaMapper">
    <select id="selectCount" resultType="java.lang.Integer">
        select count(*) from lf.sys_meta
        <where>
            ismeta between 0 and 1
            <if test="depcode != null">
                and depcode like #{depcode}
            </if>
            <if test="dircode != null">
                and dircode like #{dircode}
            </if>
            <if test="verid != null">
                and verid = #{verid}
            </if>
            <if test="name != null">
                and upper(name) like #{name}
            </if>
            <if test="sensorType != null">
                and sensortype = #{sensorType}
            </if>
            <if test="mataType != null">
                and mata_type = #{mataType}
            </if>
            <if test="startDate != null">
                and acq_time >= #{startDate}
            </if>
            <if test="endDate != null">
                and acq_time &lt;= #{endDate}
            </if>
            <if test="wkt != null">
                and ${wkt}
            </if>
        </where>
    </select>
 
    <select id="selectByPage" resultType="com.moon.server.entity.data.MetaEntity">
        select st_astext(geom) "geom", a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName, fn_get_fullname(a.depcode, 1) depName, fn_ver(a.verid) verName, fn_get_fullname(a.dircode, 2) dirName
        from lf.sys_meta a
        <where>
            ismeta between 0 and 1
            <if test="depcode != null">
                and depcode like #{depcode}
            </if>
            <if test="dircode != null">
                and dircode like #{dircode}
            </if>
            <if test="verid != null">
                and verid = #{verid}
            </if>
            <if test="name != null">
                and upper(name) like #{name}
            </if>
            <if test="sensorType != null">
                and sensortype = #{sensorType}
            </if>
            <if test="mataType != null">
                and mata_type = #{mataType}
            </if>
            <if test="startDate != null">
                and acq_time >= #{startDate}
            </if>
            <if test="endDate != null">
                and acq_time &lt;= #{endDate}
            </if>
            <if test="wkt != null">
                and ${wkt}
            </if>
        </where>
        order by id desc
        limit #{limit} offset #{offset}
    </select>
 
    <select id="selectGdbByGuid" resultType="com.moon.server.entity.data.MetaEntity">
        select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName, fn_get_fullname(a.depcode, 1) depName, fn_ver(a.verid) verName, fn_get_fullname(a.dircode, 2) dirName
        from lf.sys_meta a
        where type = 'gdb' and guid = #{guid};
    </select>
 
    <select id="selectMetasForCount" resultType="java.lang.Integer">
        select count(*) from lf.sys_meta
        <where>
            1 = 1
            <if test="depcode != null">
                and depcode like #{depcode}
            </if>
            <if test="dirs != null">
                and ${dirs}
            </if>
            <if test="name != null">
                and upper(name) like #{name}
            </if>
        </where>
    </select>
 
    <select id="selectMetasForPage" resultType="com.moon.server.entity.data.MetaEntity">
        select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName, fn_get_fullname(a.depcode, 1) depName, fn_ver(a.verid) verName, fn_get_fullname(a.dircode, 2) dirName,
            (select coalesce(sum(dcount), 0) from lf.sys_download b inner join lf.sys_meta_down c on b.id = c.downid where c.metaid = a.id) "downCount",
            (select fn_uname(download_user) from lf.sys_download b inner join lf.sys_meta_down c on b.id = c.downid where c.metaid = a.id order by download_time desc limit 1) "lastUser",
            (select max(download_time) from lf.sys_download b inner join lf.sys_meta_down c on b.id = c.downid where c.metaid = a.id) "lastTime"
        from lf.sys_meta a
        <where>
            1 = 1
            <if test="depcode != null">
                and depcode like #{depcode}
            </if>
            <if test="dirs != null">
                and ${dirs}
            </if>
            <if test="name != null">
                and upper(name) like #{name}
            </if>
        </where>
        order by id desc
        limit #{limit} offset #{offset}
    </select>
 
    <select id="selectCountForUpload" resultType="java.lang.Integer">
        select count(*) from lf.sys_meta
        <where>
            create_user = #{createUser}
            <if test="types != null">
                and type in (${types})
            </if>
            <if test="name != null">
                and upper(name) like #{name}
            </if>
        </where>
    </select>
 
    <select id="selectByPageForUpload" resultType="com.moon.server.entity.data.MetaEntity">
        select st_astext(geom) "geom", fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName, fn_get_fullname(a.depcode, 1) depName, fn_ver(a.verid) verName, fn_get_fullname(a.dircode, 2) dirName
        from lf.sys_meta a
        <where>
            create_user = #{createUser}
            <if test="types != null">
                and type in (${types})
            </if>
            <if test="name != null">
                and upper(name) like #{name}
            </if>
        </where>
        order by id desc
        limit #{limit} offset #{offset}
    </select>
 
    <select id="selectCountByPid" resultType="java.lang.Integer">
        select count(*) from lf.sys_meta
        <where>
            metaid = #{metaid}
            <if test="name != null">
                and upper(name) like #{name}
            </if>
        </where>
    </select>
 
    <select id="selectPageByPid" resultType="com.moon.server.entity.data.MetaEntity">
        select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName, fn_get_fullname(a.depcode, 1) depName, fn_ver(a.verid) verName, fn_get_fullname(a.dircode, 2) dirName
        from lf.sys_meta a
        <where>
            metaid = #{metaid}
            <if test="name != null">
                and upper(name) like #{name}
            </if>
        </where>
        order by id desc
        limit #{limit} offset #{offset}
    </select>
 
    <select id="selectById" resultType="com.moon.server.entity.data.MetaEntity">
        select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName, fn_get_fullname(a.depcode, 1) depName, fn_ver(a.verid) verName, fn_get_fullname(a.dircode, 2) dirName
        from lf.sys_meta a where id = #{id}
    </select>
 
    <select id="selectByIds" resultType="com.moon.server.entity.data.MetaEntity">
        select *
        from lf.sys_meta
        where id in (${ids})
        order by id desc;
    </select>
 
    <select id="selectByGuid" resultType="com.moon.server.entity.data.MetaEntity">
        select st_astext(geom) "geom", a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName, fn_get_fullname(a.depcode, 1) depName, fn_ver(a.verid) verName, fn_get_fullname(a.dircode, 2) dirName
        from lf.sys_meta a
        where guid = #{guid}
        <if test="dircode != null">
            and dircode like #{dircode}
        </if>
        <if test="tab != null">
            and tab = #{tab}
        </if>
        limit 1
    </select>
 
    <select id="selectByIdsForTab" resultType="com.moon.server.entity.data.MetaEntity">
        select a.*
        from lf.sys_meta a
        where id in (${ids}) and a.tab is not null and a.rows > 0
        order by a.tab;
    </select>
 
    <select id="selectMetaFiles" resultType="com.moon.server.entity.data.MetaEntity">
        select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName, fn_get_fullname(a.depcode, 1) depName, fn_ver(a.verid) verName, fn_get_fullname(a.dircode, 2) dirName
        from lf.sys_meta a
        where id in
        <foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
            #{id}
        </foreach>
        order by a.id desc
    </select>
 
    <select id="selectXlsAnnex" resultType="com.moon.server.entity.data.MetaEntity">
        select * from lf.sys_meta
        where type in ('xls', 'xlsx') and eventid is not null and tab is not null and rows > 0 and id in
        <foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
            #{id}
        </foreach>
        <if test="tabs != null">
            and tab in (${tabs})
        </if>
    </select>
 
    <select id="selectMetasByDirCode" resultType="com.moon.server.entity.data.MetaEntity">
        select a.*, fn_uname(a.create_user) createName, fn_uname(a.update_user) updateName, fn_get_fullname(a.depcode, 1) depName, fn_ver(a.verid) verName, fn_get_fullname(a.dircode, 2) dirName
        from lf.sys_meta a
        where dircode like #{dircode} and
            (type = 'tif' or type = 'tiff' or lower(name) in ('平面图索引文件.xlsx', '穿跨越地形图.dwg', '中线成果表.xlsx', '离散点.xlsx', '控制点.xlsx', '地面线.xlsx'))
        order by id;
    </select>
 
    <select id="selectMetaOverflowDep" resultType="java.lang.String">
         select depcode
         from lf.sys_meta
         where id in (${ids}) and depcode not like #{depcode}
         group by depcode
         order by depcode;
    </select>
 
    <insert id="insert" parameterType="com.moon.server.entity.data.MetaEntity">
        <selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
            select currval('lf.sys_meta_id_seq'::regclass) as id
        </selectKey>
 
        insert into lf.sys_meta
        (eventid,metaid,verid,name,type,guid,path,sizes,tab,rows,create_user,create_time,bak,geom,layer,depcode,dircode,ismeta,sensortype,acq_time,resolution,gridsize,coor_sys,epsg,h_datum,mata_type,bands,band_type,ct)
        values
        (#{eventid},#{metaid},#{verid},#{name},#{type},#{guid},#{path},#{sizes},#{tab},#{rows},#{createUser},now(),#{bak},${geom},#{layer},#{depcode},#{dircode},#{ismeta},#{sensortype},#{acqTime},#{resolution},#{gridsize},#{coorSys},#{epsg},#{hDatum},#{mataType},#{bands},#{bandType},#{ct})
    </insert>
 
    <insert id="inserts">
        insert into lf.sys_meta
        (eventid,metaid,verid,name,type,guid,path,sizes,tab,rows,create_user,create_time,bak,geom,layer,depcode,dircode,ismeta,sensortype,acq_time,resolution,gridsize,coor_sys,epsg,h_datum,mata_type,bands,band_type,ct)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.eventid},#{item.metaid},#{item.verid},#{item.name},#{item.type},#{item.guid},#{item.path},#{item.sizes},#{item.tab},#{item.rows},#{item.createUser},now(),#{item.bak},${item.geom},#{item.layer},#{item.depcode},#{item.dircode},#{item.ismeta},#{item.sensortype},#{item.acqTime},#{item.resolution},#{item.gridsize},#{item.coorSys},#{item.epsg},#{item.hDatum},#{item.mataType},#{item.bands},#{item.bandType},#{item.ct})
        </foreach>
    </insert>
 
    <delete id="deletes">
        delete from lf.sys_meta where id in (${ids});
        <if test="sql != null">
            ${sql};
        </if>
    </delete>
 
    <delete id="deletes_old">
        delete from lf.sys_meta where id in
        <foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
 
    <update id="update">
        update lf.sys_meta
        set eventid=#{eventid},metaid=#{metaid},verid=#{verid},name=#{name},type=#{type},guid=#{guid},path=#{path},sizes=#{sizes},tab=#{tab},rows=#{rows},update_user=#{updateUser},update_time=now(),bak=#{bak},geom=${geom},layer=#{layer},depcode=#{depcode},dircode=#{dircode},ismeta=#{ismeta},sensortype=#{sensortype},acq_time=#{acqTime},resolution=#{resolution},gridsize=#{gridsize},coor_sys=#{coorSys},epsg=#{epsg},h_datum=#{hDatum},mata_type=#{mataType},bands=#{bands},band_type=#{bandType},ct=#{ct}
        where id=#{id}
    </update>
 
    <update id="updates">
        <foreach collection="list" item="item" index="index" separator=";">
            update lf.sys_meta
            set eventid=#{item.eventid},metaid=#{item.metaid},verid=#{item.verid},name=#{item.name},type=#{item.type},guid=#{item.guid},path=#{item.path},sizes=#{item.sizes},tab=#{item.tab},rows=#{item.rows},update_user=#{item.updateUser},update_time=now(),bak=#{item.bak},geom=${item.geom},layer=#{item.layer},depcode=#{item.depcode},dircode=#{item.dircode},ismeta=#{item.ismeta},sensortype=#{item.sensortype},acq_time=#{item.acqTime},resolution=#{item.resolution},gridsize=#{item.gridsize},coor_sys=#{item.coorSys},epsg=#{item.epsg},h_datum=#{item.hDatum},mata_type=#{item.mataType},bands=#{item.bands},band_type=#{item.bandType},ct=#{item.ct}
            where id = #{item.id}
        </foreach>
    </update>
</mapper>