2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
<?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.landtool.lanbase.modules.res.dao.Res_ApplyRecommendMapper">
    <resultMap id="BaseResultMap" type="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend">
        <id column="APPID" property="appid" jdbcType="DECIMAL"/>
        <result column="RESOURCEID" property="resourceid" jdbcType="DECIMAL"/>
        <result column="APPUSERID" property="appuserid" jdbcType="OTHER"/>
        <result column="APPUNITID" property="appunitid" jdbcType="OTHER"/>
        <result column="APPTYPE" property="apptype" jdbcType="DECIMAL"/>
        <result column="APPREASON" property="appreason" jdbcType="OTHER"/>
        <result column="APPDATE" property="appdate" jdbcType="TIMESTAMP"/>
        <result column="AUDITUSERID" property="audituserid" jdbcType="DECIMAL"/>
        <result column="AUDITTIME" property="audittime" jdbcType="TIMESTAMP"/>
        <result column="AUDITOPINION" property="auditopinion" jdbcType="OTHER"/>
        <result column="AUDITRESULT" property="auditresult" jdbcType="DECIMAL"/>
        <result column="RESUSETYPE" property="resusetype" jdbcType="OTHER"/>
        <result column="OFFLINEURL" property="offlineurl" jdbcType="OTHER"/>
        <result column="EFFENDTIME" property="effendtime" jdbcType="TIMESTAMP"/>
        <result column="ISRECOMMEND" property="isrecommend" jdbcType="DECIMAL"/>
        <result column="SYSID" property="sysid" jdbcType="DECIMAL"/>
    </resultMap>
    <sql id="Base_Column_List">
    APPID, ra.RESOURCEID, APPUSERID, APPUNITID, APPTYPE, APPREASON, APPDATE, AUDITUSERID,
    AUDITTIME, AUDITOPINION, AUDITRESULT, RESUSETYPE, OFFLINEURL, EFFENDTIME, ISRECOMMEND, SYSID
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select
        <include refid="Base_Column_List"/>,b.title
        from RES_APPLYRECOMMEND ra
        left join RES_MAININFO b on RES_APPLYRECOMMEND.RESOURCEID = b.RESOURCEID
        where APPID = #{appid,jdbcType=DECIMAL}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from RES_APPLYRECOMMEND
    where APPID = #{appid,jdbcType=DECIMAL}
    </delete>
    <insert id="insert" parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend">
    insert into RES_APPLYRECOMMEND (APPID, RESOURCEID, APPUSERID,
      APPUNITID, APPTYPE, APPREASON, 
      APPDATE, AUDITUSERID, AUDITTIME, 
      AUDITOPINION, AUDITRESULT, RESUSETYPE, 
      OFFLINEURL, EFFENDTIME, ISRECOMMEND, SYSID
      )
    values (#{appid,jdbcType=DECIMAL}, #{resourceid,jdbcType=DECIMAL}, #{appuserid,jdbcType=OTHER}, 
      #{appunitid,jdbcType=OTHER}, #{apptype,jdbcType=DECIMAL}, #{appreason,jdbcType=OTHER}, 
      #{appdate,jdbcType=TIMESTAMP}, #{audituserid,jdbcType=DECIMAL}, #{audittime,jdbcType=TIMESTAMP}, 
      #{auditopinion,jdbcType=OTHER}, #{auditresult,jdbcType=DECIMAL}, #{resusetype,jdbcType=OTHER}, 
      #{offlineurl,jdbcType=OTHER}, #{effendtime,jdbcType=TIMESTAMP}, #{isrecommend,jdbcType=DECIMAL},
      #{sysid,jdbcType=DECIMAL}
      )
    </insert>
    <insert id="insertSelective" parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend">
        insert into RES_APPLYRECOMMEND
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="appid != null">
                APPID,
            </if>
            <if test="resourceid != null">
                RESOURCEID,
            </if>
            <if test="appuserid != null">
                APPUSERID,
            </if>
            <if test="appunitid != null">
                APPUNITID,
            </if>
            <if test="apptype != null">
                APPTYPE,
            </if>
            <if test="appreason != null">
                APPREASON,
            </if>
            <if test="appdate != null">
                APPDATE,
            </if>
            <if test="audituserid != null">
                AUDITUSERID,
            </if>
            <if test="audittime != null">
                AUDITTIME,
            </if>
            <if test="auditopinion != null">
                AUDITOPINION,
            </if>
            <if test="auditresult != null">
                AUDITRESULT,
            </if>
            <if test="resusetype != null">
                RESUSETYPE,
            </if>
            <if test="offlineurl != null">
                OFFLINEURL,
            </if>
            <if test="effendtime != null">
                EFFENDTIME,
            </if>
            <if test="isrecommend != null">
                ISRECOMMEND,
            </if>
            <if test="sysid != null">
                SYSID,
            </if>
            <if test="sysName != null">
                SYS_NAME,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="appid != null">
                #{appid,jdbcType=DECIMAL},
            </if>
            <if test="resourceid != null">
                #{resourceid,jdbcType=DECIMAL},
            </if>
            <if test="appuserid != null">
                #{appuserid,jdbcType=OTHER},
            </if>
            <if test="appunitid != null">
                #{appunitid,jdbcType=OTHER},
            </if>
            <if test="apptype != null">
                #{apptype,jdbcType=DECIMAL},
            </if>
            <if test="appreason != null">
                #{appreason,jdbcType=OTHER},
            </if>
            <if test="appdate != null">
                #{appdate,jdbcType=TIMESTAMP},
            </if>
            <if test="audituserid != null">
                #{audituserid,jdbcType=DECIMAL},
            </if>
            <if test="audittime != null">
                #{audittime,jdbcType=TIMESTAMP},
            </if>
            <if test="auditopinion != null">
                #{auditopinion,jdbcType=OTHER},
            </if>
            <if test="auditresult != null">
                #{auditresult,jdbcType=DECIMAL},
            </if>
            <if test="resusetype != null">
                #{resusetype,jdbcType=OTHER},
            </if>
            <if test="offlineurl != null">
                #{offlineurl,jdbcType=OTHER},
            </if>
            <if test="effendtime != null">
                #{effendtime,jdbcType=TIMESTAMP},
            </if>
            <if test="isrecommend != null">
                #{isrecommend,jdbcType=DECIMAL},
            </if>
            <if test="sysid != null">
                #{sysid,jdbcType=DECIMAL},
            </if>
            <if test="sysName != null">
                #{sysName,jdbcType=OTHER},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend">
        update RES_APPLYRECOMMEND
        <set>
            <if test="resourceid != null">
                RESOURCEID = #{resourceid,jdbcType=DECIMAL},
            </if>
            <if test="appuserid != null">
                APPUSERID = #{appuserid,jdbcType=OTHER},
            </if>
            <if test="appunitid != null">
                APPUNITID = #{appunitid,jdbcType=OTHER},
            </if>
            <if test="apptype != null">
                APPTYPE = #{apptype,jdbcType=DECIMAL},
            </if>
            <if test="appreason != null">
                APPREASON = #{appreason,jdbcType=OTHER},
            </if>
            <if test="appdate != null">
                APPDATE = #{appdate,jdbcType=TIMESTAMP},
            </if>
            <if test="audituserid != null">
                AUDITUSERID = #{audituserid,jdbcType=DECIMAL},
            </if>
            <if test="audittime != null">
                AUDITTIME = #{audittime,jdbcType=TIMESTAMP},
            </if>
            <if test="auditopinion != null">
                AUDITOPINION = #{auditopinion,jdbcType=OTHER},
            </if>
            <if test="auditresult != null">
                AUDITRESULT = #{auditresult,jdbcType=DECIMAL},
            </if>
            <if test="resusetype != null">
                RESUSETYPE = #{resusetype,jdbcType=OTHER},
            </if>
            <if test="offlineurl != null">
                OFFLINEURL = #{offlineurl,jdbcType=OTHER},
            </if>
            <if test="effendtime != null">
                EFFENDTIME = #{effendtime,jdbcType=TIMESTAMP},
            </if>
            <if test="isrecommend != null">
                ISRECOMMEND = #{isrecommend,jdbcType=DECIMAL},
            </if>
            <if test="sysid != null">
                SYSID = #{sysid,jdbcType=DECIMAL},
            </if>
        </set>
        where APPID = #{appid,jdbcType=DECIMAL}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend">
    update RES_APPLYRECOMMEND
    set RESOURCEID = #{resourceid,jdbcType=DECIMAL},
      APPUSERID = #{appuserid,jdbcType=OTHER},
      APPUNITID = #{appunitid,jdbcType=OTHER},
      APPTYPE = #{apptype,jdbcType=DECIMAL},
      APPREASON = #{appreason,jdbcType=OTHER},
      APPDATE = #{appdate,jdbcType=TIMESTAMP},
      AUDITUSERID = #{audituserid,jdbcType=DECIMAL},
      AUDITTIME = #{audittime,jdbcType=TIMESTAMP},
      AUDITOPINION = #{auditopinion,jdbcType=OTHER},
      AUDITRESULT = #{auditresult,jdbcType=DECIMAL},
      RESUSETYPE = #{resusetype,jdbcType=OTHER},
      OFFLINEURL = #{offlineurl,jdbcType=OTHER},
      EFFENDTIME = #{effendtime,jdbcType=TIMESTAMP},
      ISRECOMMEND = #{isrecommend,jdbcType=DECIMAL},
      SYSID = #{sysid,jdbcType=DECIMAL}
    where APPID = #{appid,jdbcType=DECIMAL}
    </update>
    <select id="shenQingZiYuan" parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend"
            resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinApplyRecommend">
 
        WITH tab as(
          SELECT row_number() over(ORDER BY b.APPDATE DESC) rn,  a.RESOURCEID, a.TITLE, a.RESOURCECLASS, b.AUDITOPINION, b.AUDITRESULT, b.AUDITTIME,b.appid from RES_MAININFO a left join RES_APPLYRECOMMEND b on(a.resourceid=b.resourceid)
          where APPUSERID = #{appuserid,jdbcType=INTEGER} and RESOURCESTATUS=0
        <!--我的申请只显示自己申请的个人申请部分 alert ykm 2018/12/25-->
        and apptype = 0 and ISRECOMMEND = 0
        )
 
        SELECT * from tab where <![CDATA[ rn <= 10 ]]>
    </select>
 
    <select id="selectResApplyreCommend" parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend"
            resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinApplyRecommendInfo">
        select * from (
        select
        a.APPID,a.RESOURCEID,d.CREATEUSERID,d.INSTEADAUDIT,d.TITLE,d.KEYWORDS,APPTYPE,APPDATE,APPUSERID,AUDITUSERID,a.AUDITRESULT,applycount,
        case when replycount > 0 then replycount else 0 end as replycount,a.sysId,
        date_part('day',(a.EFFENDTIME - a.APPDATE)) as appDays,
        a.sys_name  from RES_APPLYRECOMMEND a
        left join (select RESOURCEID,COUNT(*) as applycount from RES_APPLYRECOMMEND group by RESOURCEID)b
        on a.RESOURCEID = b.RESOURCEID
        left join (select RESOURCEID,COUNT(*) as replycount from RES_APPLYRECOMMEND where AUDITRESULT=1 group by
        RESOURCEID)c
        on a.RESOURCEID = c.RESOURCEID
        left join RES_MAININFO d on a.RESOURCEID = d.RESOURCEID
        <where>
            RESOURCESTATUS = 0 and ISRECOMMEND = 0
            <if test="title!=null and title != '' ">
                and (d.TITLE like ('%' || #{title} || '%') OR replace(KEYWORDS,',','') like ('%' || #{title} || '%'))
            </if>
            <if test="auditresult !=null and auditresult != 3">
                and AUDITRESULT= #{auditresult}
            </if>
            <if test="auditresult == 3">
                and AUDITRESULT != 0
            </if>
            <if test="isaudit == 0 and ExistPermission ==null">  <!--有权限批复,即当前用户是发布人且为管理员 或者是委托批复-->
                and (CREATEUSERID = #{createuserid} or INSTEADAUDIT = 1)
            </if>
            <if test="isaudit == 1 and ExistPermission ==null"> <!--无权限批复,即当前用户不是发布人且为管理员 且不为委托批复资源-->
                and CREATEUSERID != #{createuserid} and (INSTEADAUDIT != 1 or INSTEADAUDIT is null)
            </if>
            <if test="apptype !=null">
                and APPTYPE=#{apptype}
            </if>
            <if test="ExistPermission !=null">
                and CREATEUSERID=#{ExistPermission}
            </if>
            <if test="appdateBeg != null and appdateBeg != '' ">
                <![CDATA[ and APPDATE >= to_timestamp(#{appdateBeg} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss') ]]>
            </if>
            <if test="appdateEnd != null and appdateEnd != '' ">
                <![CDATA[ and APPDATE <= to_timestamp(#{appdateEnd} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
            </if>
        </where>
        ) tmp order by APPDATE DESC
    </select>
 
    <select id="selectResApplyreCommendCount" parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend"
            resultType="java.lang.Integer">
        select count(*) from RES_APPLYRECOMMEND a
        left join (select RESOURCEID,COUNT(*) as applycount from RES_APPLYRECOMMEND group by RESOURCEID)b on
        a.RESOURCEID = b.RESOURCEID
        left join (select RESOURCEID,COUNT(*) as replycount from RES_APPLYRECOMMEND where AUDITRESULT=1 group by
        RESOURCEID)c on a.RESOURCEID = c.RESOURCEID
        left join RES_MAININFO d on a.RESOURCEID = d.RESOURCEID
        <where>
            RESOURCESTATUS = 0 and ISRECOMMEND = 0
            <if test="title!=null and title != '' ">
                and (d.TITLE like ('%' || #{title} || '%') OR replace(KEYWORDS,',','') like ('%' || #{title} || '%'))
            </if>
            <if test="auditresult !=null and auditresult != 3">
                and AUDITRESULT= #{auditresult}
            </if>
            <if test="auditresult == 3">
                and AUDITRESULT != 0
            </if>
            <if test="apptype !=null">
                and APPTYPE=#{apptype}
            </if>
            <if test="appdateBeg != null and appdateBeg != '' ">
                <![CDATA[ and APPDATE >= to_timestamp(#{appdateBeg} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss') ]]>
            </if>
            <if test="appdateEnd != null and appdateEnd != '' ">
                <![CDATA[ and APPDATE <= to_timestamp(#{appdateEnd} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
            </if>
        </where>
    </select>
    <update id="updateResApplyreCommendResult"
            parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend">
    update RES_APPLYRECOMMEND
    set 
      AUDITUSERID = #{audituserid,jdbcType=DECIMAL},
      AUDITTIME = #{audittime,jdbcType=TIMESTAMP},
      AUDITOPINION = #{auditopinion,jdbcType=OTHER},
      AUDITRESULT = #{auditresult,jdbcType=DECIMAL}
    where APPID = #{appid,jdbcType=DECIMAL}
    </update>
    <select id="selectByResApplyRecommend" resultMap="BaseResultMap"
            parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend">
        select
        <include refid="Base_Column_List"/>
        from RES_APPLYRECOMMEND ra
        <where>
            isRecommend=0
            <if test="appuserid!=null and appuserid!=''">
                and appuserid=#{appuserid,jdbcType=DECIMAL}
            </if>
            <if test="resourceid!=null and resourceid!=''">
                and resourceid=#{resourceid,jdbcType=DECIMAL}
            </if>
            <if test="apptype!=null and apptype!=''">
                and apptype=#{apptype,jdbcType=OTHER}
            </if>
        </where>
    </select>
    <select id="selectResMainInfoShenQingZiYuan"
            parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend"
            resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinApplyRecommend">
        select a.RESOURCEID, a.TITLE, a.ABBREVIATION, a.RESOURCECLASS, a.PUBUNITID, a.PUBDATE,b.APPDATE,b.AUDITOPINION,
        b.AUDITRESULT, b.AUDITTIME, b.APPID
        from RES_MAININFO a inner join RES_APPLYRECOMMEND b on(a.resourceid=b.resourceid)
        <where>
            and APPUSERID = #{appuserid,jdbcType=OTHER} 
            <!--我的申请只显示自己申请的个人申请部分 alert ykm 2018/12/25-->
            and ISRECOMMEND = 0
            <if test="title!=null and title != '' ">
                and (TITLE like '%'||#{title}||'%' OR replace(KEYWORDS,',','') like '%'||#{title}||'%' OR ABBREVIATION like
                '%'||#{title}||'%')
            </if>
            <if test="resourceclass !=null and resourceclass != '' ">
                <!--and resourceclass=#{resourceclass,jdbcType=OTHER}-->
                and (resourceclass like #{resourceclass} || '%' )
            </if>
            <if test="auditresult !=null and (auditresult==0 ? '0' : auditresult) ">
                and auditresult = #{auditresult}
            </if>
            <if test="pubdateBegin!=null and pubdateBegin != '' ">
                and APPDATE >= to_timestamp(#{pubdateBegin} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss')
            </if>
            <if test="pubdatefinish!=null and pubdatefinish != '' ">
                <![CDATA[ and APPDATE <= to_timestamp(#{pubdatefinish} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
            </if>
        </where>
        order by b.appdate desc
    </select>
    <select id="getTopRecommend" parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
        select a.*
        from RES_MAININFO a
        left join RES_APPLYRECOMMEND b on a.RESOURCEID=b.RESOURCEID
        where a.RESOURCESTATUS=0
        and a.AUDITSTATUS=2
        and b.ISRECOMMEND=1
        and (
        (cast(b.APPUSERID as numeric)=#{appuserid} and b.APPTYPE=0)
        <if test="appunitid !=null and (appunitid==0 ? '0' : appunitid)">
        or (cast(b.APPUNITID as numeric)=#{appunitid} and b.APPTYPE=1)
        </if>
        )
        <if test="isDiTuFuwu != '' and isDiTuFuwu != null">
            and a.RESOURCECLASS in ( ${isDiTuFuwu} )
        </if>
        order by b.APPDATE desc
    </select>
    <select id="getAllRecommend" parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
        select a.*
        from RES_MAININFO a
        left join RES_APPLYRECOMMEND b on a.RESOURCEID=b.RESOURCEID
        where a.RESOURCESTATUS=0
        and a.AUDITSTATUS=2
        and b.ISRECOMMEND=1
        and (
        (b.APPUSERID=cast(#{appuserid} as char) and b.APPTYPE=0)
        <if test="appunitid !=null and (appunitid==0 ? '0' : appunitid)">
            or (b.APPUNITID=cast(#{appunitid} as char) and b.APPTYPE=1)
        </if>
        )
        <if test="isDiTuFuwu != '' and isDiTuFuwu != null">
            and a.RESOURCECLASS in ( ${isDiTuFuwu} )
        </if>
        <if test="title!=null and title != '' ">
            and (a.TITLE like '%'||#{title}||'%' OR replace(a.KEYWORDS,',','') like '%'||#{title}||'%' OR a.ABBREVIATION like '%'||#{title}||'%')
        </if>
        <if test="resourceclass !=null and resourceclass != '' ">
            <!--and resourceclass=#{resourceclass,jdbcType=OTHER}-->
            and (a.resourceclass like #{resourceclass} || '%' )
        </if>
        <if test="pubdateBegin!=null and pubdateBegin != '' ">
            and PUBDATE >= to_timestamp(#{pubdateBegin} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss')
        </if>
        <if test="pubdatefinish!=null and pubdatefinish != '' ">
            <![CDATA[ and PUBDATE <= to_timestamp(#{pubdatefinish} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
        </if>
        order by b.APPDATE desc
    </select>
    <select id="getRecommendListByResourceid" parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend" resultType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend">
        select *
        from RES_APPLYRECOMMEND
        where RESOURCEID=#{resourceid}
        and ISRECOMMEND=1
        <if test="apptype != null and (apptype == 0 ? '0' : apptype)">
            and APPTYPE = #{apptype}
        </if>
    </select>
    <!--add: Xxx 新增获取资源申请数量统计-->
    <select id="getApplyCount" parameterType="java.lang.Integer" resultType="java.lang.Integer">
        select COUNT(*) from RES_APPLYRECOMMEND
        where RESOURCEID=#{resourceid} and ISRECOMMEND=0
    </select>
    <select id="checkZiYuanShenQing" resultType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend">
        select * from RES_APPLYRECOMMEND
        where RESOURCEID = #{resourceid} and ISRECOMMEND = 0
        and ((APPTYPE = 0 and APPUSERID = #{userid}) or (APPTYPE = 1 and APPUNITID = #{unitid}))
    </select>
    <select id="selectCountByResourceid" resultType="java.lang.Integer" parameterType="java.lang.Integer">
        select count(*) from RES_APPLYRECOMMEND
        where resourceid = #{resourceid,jdbcType=DECIMAL}
    </select>
    <delete id="deleteByResourceid" parameterType="java.lang.Integer">
        delete from RES_APPLYRECOMMEND
        where resourceid = #{resourceid,jdbcType=DECIMAL}
    </delete>
    <select id="selectByResourceidAndUserid"  parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend" resultType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend">
        select *
        from RES_APPLYRECOMMEND
        where resourceid = #{resourceid,jdbcType=DECIMAL} and APPUSERID = #{appuserid}
    </select>
    <select id="selectResMainInfoBySysid" parameterType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinApplyRecommend" resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinApplyRecommend">
        select b.*,a.auditresult,a.appdate,appuserid from RES_APPLYRECOMMEND a left join RES_MAININFO b on a.RESOURCEID = b.RESOURCEID
        <where>
            a.APPTYPE = 3 and a.SYSID = #{sysid} and RESOURCESTATUS = 0
            <if test="title!=null and title != '' ">
                and (b.TITLE like ('%' || #{title} || '%') OR replace(KEYWORDS,',','') like ('%' || #{title} || '%') OR b.ABBREVIATION like '%'||#{title}||'%')
            </if>
            <if test="auditresult !=null and auditresult != ''">
                and auditresult = #{auditresult}
            </if>
            <if test="resourceclass !=null and resourceclass != '' ">
                and (resourceclass like #{resourceclass} || '%' )
            </if>
            <if test="appdateBeg != null and appdateBeg != '' ">
                <![CDATA[ and APPDATE >= to_timestamp(#{appdateBeg} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss') ]]>
            </if>
            <if test="appdateEnd != null and appdateEnd != '' ">
                <![CDATA[ and APPDATE <= to_timestamp(#{appdateEnd} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
            </if>
        </where>
        order by b.CREATEDATE desc
    </select>
    <select id="checkAppZiYuan" resultType="java.lang.Integer">
        SELECT COUNT(*) FROM RES_APPLYRECOMMEND
        where APPTYPE=3 and RESOURCEID=#{resourceid} and SYSID=#{sysid} and AUDITRESULT=1
    </select>
    
    <select id="selectCatalog" resultType="com.landtool.lanbase.modules.res.entity.Res_Catalog">
        select distinct b.CATLOGID,b.CATLOGCODE,b.PARENTID,b.TITLE,b.PINGYINFIIRST,b.IMGURL,b.ORDERID,b.CREATEUSER,b.CREATEDATE,b.ICON
        from RES_CATALOG b
        left join (
        SELECT CATLOGCODE FROM RES_MAININFO a
        where 1 = 1
        and a.AUDITSTATUS = 2
        and a.RESOURCESTATUS = 0
        and a.sharprotocol != '完全公开'
        and a.RESOURCEID not in
        (select RESOURCEID from RES_APPLYRECOMMEND where APPTYPE = 3 and SYSID = #{sysid} and (EFFENDTIME >= to_timestamp(to_char(now(),'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss') or EFFENDTIME is null)and AUDITRESULT != 2)
        group by CATLOGCODE
        ) c on b.CATLOGCODE = substr(c.CATLOGCODE, 1, LENGTH(b.CATLOGCODE))
        where parentid = #{parentid} and c.CATLOGCODE is not null
        order by ORDERID
    </select>
 
    <select id="selectCatalogZiYuanList" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
        select distinct a.RESOURCEID,a.CATLOGID, a.TITLE,
        a.ABBREVIATION, a.PINGYINFIIRST, a.CATLOGCODE,
        a.KEYWORDS, a.DESURL,
        a.IMGURL, a.RESOURCECLASS,
        a.DATASOURCES, a.PRODUCTIONTIME,
        a.UPDATETIMES, a.PUBDATE, a.PUBUNITID,
        a.CREATEUSERID, a.ADMINISTRATIVEID, a.SECURITYLEV,
        a.SHARPROTOCOL, a.ESPPROXY, a.USERNAME,
        a.PASSWORD, a.RESOURCESTATUS,
        a.AUDITSTATUS, a.DISPLAYBY2D, a.DISPLAYBY3D,
        a.ORDERID from RES_MAININFO a
        where 1 = 1
        and a.AUDITSTATUS = 2
        and a.RESOURCESTATUS = 0
        and a.sharprotocol != '完全公开'
        and a.RESOURCEID not in
        (select RESOURCEID from RES_APPLYRECOMMEND where APPTYPE = 3 and SYSID = #{sysid} and (EFFENDTIME >= to_timestamp(to_char(now(),'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss') or EFFENDTIME is null)and AUDITRESULT != 2)
        <if test="parentid != null and (parentid==0 ? '0' : parentid)">
            and a.CATLOGID = #{parentid,jdbcType=DECIMAL}
        </if>
        order by a.ORDERID
    </select>
 
    <select id="getResourceList" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
        select b.* from RES_APPLYRECOMMEND a LEFT JOIN RES_MAININFO b on a.RESOURCEID = b.RESOURCEID where APPTYPE = 3 and AUDITRESULT = 1  and (EFFENDTIME is null or EFFENDTIME >= to_timestamp(to_char(now(),'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss'))
        and RESOURCESTATUS = 0
        <if test="sysid != null">
            and SYSID = #{sysid}
        </if>
    </select>
 
    <select id="selectResApplyreCommendForSys" parameterType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend"
            resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinApplyRecommendInfo">
 
    </select>
 
    <select id="getApplyDate" resultType="com.landtool.lanbase.modules.res.entity.Res_ApplyRecommend">
        select *
        from (
            select date_part('day',(ra.EFFENDTIME - ra.APPDATE)) as appDays,ra.*
                from RES_APPLYRECOMMEND ra
                where  RESOURCEID = #{resourceid}
                and  APPUSERID = #{userid}
                and AUDITRESULT = 1
                order by APPDATE desc
             ) TEMP limit 1
    </select>
</mapper>