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
<?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_ActionRecordMapper" >
  <resultMap id="BaseResultMap" type="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" >
    <id column="ACTIONID" property="actionid" jdbcType="DECIMAL" />
    <result column="RESOURCEID" property="resourceid" jdbcType="DECIMAL" />
    <result column="USERID" property="userid" jdbcType="DECIMAL" />
    <result column="APPID" property="appid" jdbcType="DECIMAL" />
    <result column="ACTIONTIME" property="actiontime" jdbcType="TIMESTAMP" />
    <result column="ACTIONTYPE" property="actiontype" jdbcType="OTHER" />
      <result column="IP" property="ip" jdbcType="OTHER"/>
  </resultMap>
  <sql id="Base_Column_List" >
    ACTIONID, RESOURCEID, USERID, APPID, ACTIONTIME, ACTIONTYPE,IP
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from RES_ACTIONRECORD
    where ACTIONID = #{actionid,jdbcType=DECIMAL}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from RES_ACTIONRECORD
    where ACTIONID = #{actionid,jdbcType=DECIMAL}
  </delete>
  <insert id="insert" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" >
    insert into RES_ACTIONRECORD (ACTIONID, RESOURCEID, USERID, APPID, ACTIONTIME, ACTIONTYPE,IP)
    values (#{actionid,jdbcType=DECIMAL}, #{resourceid,jdbcType=DECIMAL}, #{userid,jdbcType=DECIMAL}, 
      #{appid,jdbcType=DECIMAL}, #{actiontime,jdbcType=TIMESTAMP}, #{actiontype,jdbcType=OTHER}, #{ip,jdbcType=OTHER}
    )
  </insert>
  <insert id="insertSelective" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" >
    insert into RES_ACTIONRECORD
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="resourceid != null" >
        RESOURCEID,
      </if>
      <if test="userid != null" >
        USERID,
      </if>
      <if test="appid != null" >
        APPID,
      </if>
      <if test="actiontime != null" >
        ACTIONTIME,
      </if>
      <if test="actiontype != null" >
        ACTIONTYPE,
      </if>
      <if test="ip != null" >
        IP,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="resourceid != null" >
        #{resourceid,jdbcType=DECIMAL},
      </if>
      <if test="userid != null" >
        #{userid,jdbcType=DECIMAL},
      </if>
      <if test="appid != null" >
        #{appid,jdbcType=DECIMAL},
      </if>
      <if test="actiontime != null" >
        #{actiontime,jdbcType=TIMESTAMP},
      </if>
      <if test="actiontype != null" >
        #{actiontype,jdbcType=OTHER},
      </if>
      <if test="ip != null" >
        #{ip,jdbcType=OTHER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" >
    update RES_ACTIONRECORD
    <set >
      <if test="resourceid != null" >
        RESOURCEID = #{resourceid,jdbcType=DECIMAL},
      </if>
      <if test="userid != null" >
        USERID = #{userid,jdbcType=DECIMAL},
      </if>
      <if test="appid != null" >
        APPID = #{appid,jdbcType=DECIMAL},
      </if>
      <if test="actiontime != null" >
        ACTIONTIME = #{actiontime,jdbcType=TIMESTAMP},
      </if>
      <if test="actiontype != null" >
        ACTIONTYPE = #{actiontype,jdbcType=OTHER},
      </if>
      <if test="ip != null" >
        IP = #{ip,jdbcType=OTHER},
      </if>
    </set>
    where ACTIONID = #{actionid,jdbcType=DECIMAL}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" >
    update RES_ACTIONRECORD
    set RESOURCEID = #{resourceid,jdbcType=DECIMAL},
      USERID = #{userid,jdbcType=DECIMAL},
      APPID = #{appid,jdbcType=DECIMAL},
      ACTIONTIME = #{actiontime,jdbcType=TIMESTAMP},
      ACTIONTYPE = #{actiontype,jdbcType=OTHER},
       IP = #{ip,jdbcType=OTHER}
    where ACTIONID = #{actionid,jdbcType=DECIMAL}
  </update>
 
  <select id="selectByActiontype" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord" >
 
      WITH tab as(
        SELECT row_number() over(ORDER BY b.ACTIONTIME DESC) rn, a.RESOURCEID, a.TITLE, a.ABBREVIATION, a.RESOURCECLASS, a.PUBUNITID, a.PUBDATE, b.USERID, b.ACTIONTIME, b.ACTIONTYPE,b.IP from RES_MAININFO a left join RES_ACTIONRECORD b on(a.resourceid=b.resourceid)
    where USERID = #{userid,jdbcType=DECIMAL} and ACTIONTYPE = #{actiontype,jdbcType=VARCHAR} and RESOURCESTATUS=0 and AUDITSTATUS=2
      <if test="isDiTuFuwu != null and isDiTuFuwu != ''">
          and a.RESOURCECLASS in ( ${isDiTuFuwu} )
      </if>
      )
 
      SELECT * from tab WHERE <![CDATA[ rn <= 10 ]]>
  </select>
  <select id="getUserActionRecord" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" resultType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord">
    SELECT
    <include refid="Base_Column_List" />
    FROM RES_ACTIONRECORD
    WHERE USERID = #{userid,jdbcType=DECIMAL} and ACTIONTYPE = #{actiontype,jdbcType=OTHER} and RESOURCEID = #{resourceid,jdbcType=DECIMAL}
  </select>
 
  <select id="selectResourceCount" parameterType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord" resultType="java.lang.Integer">
    SELECT COUNT(*) from RES_ACTIONRECORD where RESOURCEID = #{resourceid,jdbcType=DECIMAL} AND  ACTIONTYPE = #{actiontype,jdbcType=OTHER}
      <if test="appid != null and appid != '' ">
          and appid = #{appid}
      </if>
  </select>
 
  <select id="selectFangWenPaiHang" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
 
      WITH tab as(
      select row_number() over(ORDER BY t desc) rn, v.* from (
      SELECT COUNT(*) AS t, a.TITLE,a.RESOURCEID FROM RES_MAININFO a INNER JOIN RES_ACTIONRECORD b ON a.RESOURCEID = b.RESOURCEID where RESOURCESTATUS=0 and AUDITSTATUS=2 and b.ACTIONTYPE = '浏览'  GROUP BY a.TITLE, a.RESOURCEID
      ) v
      )
 
      SELECT * from tab where <![CDATA[ rn <= 10 ]]>
  </select>
 
  <select id="selectResMainInfoWodeShouCang" parameterType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord"
          resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord">
    select a.RESOURCEID, a.TITLE, a.ABBREVIATION, a.RESOURCECLASS, a.PUBUNITID, a.PUBDATE, b.USERID, b.ACTIONTIME, b.ACTIONTYPE,b.IP
    from RES_MAININFO a inner join RES_ACTIONRECORD b on(a.resourceid=b.resourceid)
    <where>
      and USERID = #{userid,jdbcType=DECIMAL} and ACTIONTYPE = #{actiontype,jdbcType=OTHER} and RESOURCESTATUS=0 and AUDITSTATUS=2
      <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="pubdateBegin!=null and pubdateBegin != '' ">
        and ACTIONTIME >= to_timestamp(#{pubdateBegin} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss')
      </if>
      <if test="pubdatefinish!=null and pubdatefinish != '' ">
        <![CDATA[ and ACTIONTIME <= to_timestamp(#{pubdatefinish} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
      </if>
 
    </where>
    order by b.ACTIONTIME desc
  </select>
 
  <select id="selectResMainInfoZuiXinZiYuan" parameterType="com.landtool.lanbase.modules.res.entity.Res_MainInfo" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
    select a.RESOURCEID, a.TITLE, a.ABBREVIATION, a.RESOURCECLASS, a.PUBUNITID, a.PUBDATE
    from RES_MAININFO a
    <where>
      and 1=1 and RESOURCESTATUS=0 and AUDITSTATUS=2
      <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="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>
 
    </where>
    order by pubdate desc
  </select>
 
    <!--获取 N 条记录-->
    <select id="getTopList" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
        WITH tab as(
        select row_number() over(order by ActionTotal desc) rn, v.* from (
        select m.TITLE, m.RESOURCEID, count(*) as ActionTotal from RES_ACTIONRECORD a
        inner join RES_MAININFO m on a.RESOURCEID = m.RESOURCEID
        where RESOURCESTATUS = 0 and AUDITSTATUS = 2 and a.ACTIONTYPE = #{actionType, jdbcType = OTHER}
        <if test="userId != -1">and userId = #{userId, jdbcType = OTHER}
            and m.RESOURCECLASS in ( ${isDiTuFuwu} )</if>
        <if test="isDiTuFuwu != ''">
            and m.RESOURCECLASS in ( ${isDiTuFuwu} )
        </if>
        group by m.TITLE, m.RESOURCEID
        ) v
        )
        SELECT * from tab WHERE <![CDATA[ rn <= ${num} ]]>
  </select>
 
    <select id="getListFWPH" parameterType="com.landtool.lanbase.modules.res.entity.Res_MainInfo" resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
        select * from(select COUNT(*) AS t,a.title,a.resourceid,a.resourceclass,a.pubdate,a.pubunitid
        from RES_MAININFO a inner join RES_ACTIONRECORD b on(a.resourceid=b.resourceid)
        <where>
            AUDITSTATUS = 2 and RESOURCESTATUS = 0 AND RESOURCECLASS in ( ${isDiTuFuwu} ) and b.ACTIONTYPE = '浏览'
            <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 like #{resourceclass} || '%' )
            </if>
            <if test="createuserid!=null and createuserid != '' ">
                and createuserid = #{createuserid,dbcType=OTHERj}
            </if>
            <if test="catlogid!=null and catlogid != '' ">
                and catlogid = #{catlogid,jdbcType=OTHER}
            </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>
            group by a.title,a.resourceid,a.resourceclass,a.pubdate,a.pubunitid
        </where>)  v order by t desc
    </select>
    <select id="getListWDSC" parameterType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord" resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord">
        select a.RESOURCEID, a.TITLE, a.ABBREVIATION, a.RESOURCECLASS, a.PUBUNITID, a.PUBDATE, b.USERID, b.ACTIONTIME, b.ACTIONTYPE
        from RES_MAININFO a inner join RES_ACTIONRECORD b on(a.resourceid = b.resourceid)
        <where>
            RESOURCESTATUS = 0 and AUDITSTATUS = 2 AND RESOURCECLASS in ( ${isDiTuFuwu} )
            and USERID = #{userid, jdbcType = DECIMAL} and ACTIONTYPE = #{actiontype, jdbcType = OTHER}
            <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 like #{resourceclass} || '%' )
            </if>
            <if test="pubdateBegin!=null and pubdateBegin != '' ">
                and ACTIONTIME >= to_timestamp(#{pubdateBegin} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss')
            </if>
            <if test="pubdatefinish!=null and pubdatefinish != '' ">
                <![CDATA[ and ACTIONTIME <= to_timestamp(#{pubdatefinish} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
            </if>
        </where>
        order by b.ACTIONTIME desc
  </select>
 
    <select id="selectActionRecordJoinMainInfo" parameterType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord"
            resultType="com.landtool.lanbase.modules.res.entity.UserDefined.MainInfoJoinActionRecord">
        select RES_ACTIONRECORD.*,CREATEUSERID,TITLE,ABBREVIATION,KEYWORDS from  RES_ACTIONRECORD left join RES_MAININFO on RES_ACTIONRECORD.RESOURCEID = RES_MAININFO.RESOURCEID
        <where>
            <if test="title!=null and title != '' ">
                and (TITLE like '%'||#{title}||'%' OR replace(KEYWORDS,',','') like '%'||#{title}||'%' OR ABBREVIATION like '%'||#{title}||'%')
            </if>
            <if test="actiontimebegin!=null and actiontimebegin != '' ">
                and actiontime >= to_timestamp(#{actiontimebegin} || ' 00:00:00','yyyy-mm-dd hh24:mi:ss')
            </if>
            <if test="actiontimefinish!=null and actiontimefinish != '' ">
                <![CDATA[ and actiontime <= to_timestamp(#{actiontimefinish} || ' 23:59:59','yyyy-mm-dd hh24:mi:ss') ]]>
            </if>
            <if test="actiontype != null and actiontype != '' ">
                and actiontype = #{actiontype}
            </if>
            <if test="existpermission !=null">
                and CREATEUSERID=#{existpermission}
            </if>
        </where>
        <if test="sort!=null and sort != '' ">
            order by ${sort} ${dir}
        </if>
        <if test="sort==null">
            order by ACTIONTIME DESC
        </if>
    </select>
 
    <select id="selectCountByResourceid" resultType="java.lang.Integer" parameterType="java.lang.Integer" >
        select count(*) from RES_ACTIONRECORD
        where resourceid = #{resourceid,jdbcType=DECIMAL}
    </select>
 
    <delete id="deleteByResourceid" parameterType="java.lang.Integer" >
        delete from RES_ACTIONRECORD
        where resourceid = #{resourceid,jdbcType=DECIMAL}
    </delete>
 
    <select id="selectKeyWordsByUserid" resultType="java.lang.String" parameterType="java.lang.Integer">
        select distinct(KEYWORDS) from RES_MAININFO where RESOURCEID in (select distinct(RESOURCEID) from RES_ACTIONRECORD where
            userid = #{userid}) and KEYWORDS is not null order by KEYWORDS
    </select>
 
    <select id="selectMainInfoRecommends"  resultType="com.landtool.lanbase.modules.res.entity.Res_MainInfo">
        with tab as (
        select KEYWORDS from RES_MAININFO a where exists (
        select RESOURCEID from RES_ACTIONRECORD b where a.resourceid = b.resourceid and userid = #{userid} group by resourceid
        ) and KEYWORDS is not null group by KEYWORDS order by KEYWORDS
        )
        select * from RES_MAININFO a where exists(select KEYWORDS from tab b where a.keywords = b.keywords ) and RESOURCESTATUS=0
        and AUDITSTATUS=2 and not
        exists (select RESOURCEID from RES_ACTIONRECORD r where a.resourceid = r.resourceid and ACTIONTYPE = '收藏' and userid = #{userid})
        <if test="isDiTuFuwu != null">
        and RESOURCECLASS in ( ${isDiTuFuwu} )
        </if>
        order by CREATEDATE desc
    </select>
 
    <select id="queryAppByResourceid" resultType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord">
        SELECT *
        FROM(
        SELECT DISTINCT la.appid,la.resourceid,actiontype FROM RES_ACTIONRECORD la
        <where>
            <if test="appid != null and appid!=''">
                AND la.appid LIKE ('%' || #{appid} || '%')
            </if>
            <if test="actiontype != null and actiontype!=''">
                AND la.actiontype = #{actiontype}
            </if>
            <if test="resourceid != null and resourceid!=''">
                AND la.resourceid = #{resourceid}
            </if>
            <if test="ids != null and ids!=''">
                AND appid in( ${ids} )
            </if>
        </where>
        ) B
    </select>
 
    <select id="queryAppActionCount" resultType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord">
        SELECT COUNT(appid) as actioncount, appid FROM RES_ACTIONRECORD where ACTIONTYPE = '调用' and APPID is not null
        <if test="ids != null and ids!=''">
            AND appid in( ${ids} )
        </if>
        GROUP BY appid
    </select>
 
    <select id="queryResourceByAppid" resultType="com.landtool.lanbase.modules.res.entity.Res_ActionRecord">
        SELECT DISTINCT(a.RESOURCEID),b.title as resourcename,count(a.appid) as actioncount from RES_ACTIONRECORD a LEFT JOIN RES_MAININFO b on a.RESOURCEID = b.RESOURCEID where ACTIONTYPE = '调用' and APPID is not null
        <if test="appid != null and appid!=''">
            AND appid = #{appid}
        </if>
        GROUP BY title,a.RESOURCEID
    </select>
</mapper>