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
<?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.JitMonitorMapper">
    <select id="CountServerStatus" resultType="map" parameterType="map">
        SELECT
        COUNT( * ),
        a.RESOURCESTATUS,
        a.RESOURCECLASS
        FROM
        RES_MAININFO a
        WHERE
        1 = 1
        GROUP BY
        ( a.RESOURCESTATUS, a.RESOURCECLASS )
        ORDER BY
        count( * )
    </select>
 
    <select id="CountServerStatusAudited" resultType="map"
        parameterType="map">
        SELECT
        COUNT( * ),
        a.RESOURCESTATUS,
        a.RESOURCECLASS
        FROM
        RES_MAININFO a
        WHERE
        1 = 1 and a.AUDITSTATUS=1
        GROUP BY
        ( a.RESOURCESTATUS, a.RESOURCECLASS )
        ORDER BY
        count( * )
    </select>
 
    <select id="calTop10UserForInvokingResource" resultType="map"
        parameterType="map">
        SELECT tmp.* from (
            SELECT
                row_number() over () as rownumber,
                b.*
            FROM
            (
                SELECT
                    t.USERID,
                    count( * ) AS count
                FROM
                    RES_ACTIONRECORD t LEFT JOIN RES_MAININFO d on t.RESOURCEID=d.RESOURCEID
                WHERE
                    d.RESOURCESTATUS=0 and d.AUDITSTATUS=2
                    <if test="actionType!=null and actionType!=''">
                        and t.ACTIONTYPE = #{actionType}
                    </if>
                    GROUP BY t.USERID ORDER BY count DESC
            ) b
        ) tmp
        WHERE rownumber <![CDATA[<=]]> 10
    </select>
 
 
    <select id="calTop10SysForInvokingResource" resultType="map"
        parameterType="map">
        SELECT tmp.* from (
            SELECT
                row_number() over () as rownumber,
                b.*
            FROM
            (
                SELECT
                    t.APPID,
                    count( * ) as count
                FROM
                    RES_ACTIONRECORD t LEFT JOIN RES_MAININFO d on t.RESOURCEID=d.RESOURCEID
                WHERE
                    d.RESOURCESTATUS=0 and d.AUDITSTATUS=2
                    <if test="actionType!=null and actionType!=''">
                        and t.ACTIONTYPE = #{actionType}
                    </if>
                    GROUP BY t.APPID ORDER BY count DESC
            ) b
        ) tmp
        WHERE rownumber <![CDATA[<=]]> 10
    </select>
 
 
    <select id="getTop10ResourceByActionType" resultType="map" parameterType="map">
        SELECT tmp.* from (
            SELECT
            b.*,
            row_number() over () as rownumber
            FROM
            (
                SELECT
                t.RESOURCEID,
                d.TITLE,
                count( * ) AS count
                FROM
                RES_ACTIONRECORD t LEFT JOIN RES_MAININFO d on t.RESOURCEID=d.RESOURCEID
                WHERE
                d.RESOURCESTATUS=0 and d.AUDITSTATUS=2
                <if test="actionType!=null and actionType!=''">and t.ACTIONTYPE = #{actionType}</if>
                GROUP BY t.RESOURCEID, d.TITLE ORDER BY count DESC
            ) b
        ) tmp
        WHERE rownumber <![CDATA[<=]]> 10
    </select>
 
 
 
    <select id="getGisResNumByResStatus" resultType="map"
        parameterType="map">
        SELECT
        t.RESOURCESTATUS,
        count( * ) AS count
        FROM
        RES_MAININFO t
        WHERE
        t.AUDITSTATUS=2
        GROUP BY
        t.RESOURCESTATUS
        ORDER BY
        count DESC
    </select>
 
    <select id="getActiveResource" resultType="map" parameterType="map">
        SELECT
        a.RESOURCEID,
        t.TITLE,
        count(*) as count
        FROM
        RES_ACTIONRECORD a LEFT JOIN RES_MAININFO t on a.RESOURCEID=t.RESOURCEID
        where 1=1
        <if test="actionType!=null and actionType!=''">and a.ACTIONTYPE = #{actionType}</if>
        <if test="day!=null and day!=''">AND a.ACTIONTIME > CURRENT_DATE-day </if>
        group by a.RESOURCEID,t.TITLE
        order by a.RESOURCEID DESC
    </select>
 
 
    <select id="getResourceAssignTimesCount" resultType="map" parameterType="map">
        SELECT
        t.ACTIONTIME as time,
        count(*) as count
        FROM
        RES_ACTIONRECORD t
        WHERE t.IP IS NOT NULL AND 1 =1
        <if test="actionType!=null and actionType!=''">and t.ACTIONTYPE = #{actionType}</if>
        <if test="userid!=null and userid!='' ">
            AND t.USERID=#{userid}
        </if>
        <if test="appid!=null and appid!='' ">
            AND t.APPID=#{appid}
        </if>
        <if test="resourceid!=null and resourceid!='' ">
            AND t.RESOURCEID=#{resourceid}
        </if>
        <if test="months!=null and months!='' ">
            AND t.ACTIONTIME> now() + interval '${month} month'
        </if>
        <if test="day!=null and day !=''">
            AND t.ACTIONTIME> now() - interval '${day} day'
        </if>
        <if test="startdate!=null and  startdate!='' and enddate!=null and  enddate !=''">
            t.ACTIONTIME BETWEEN to_timestamp( #{startdate}, 'yyyy-MM-DD:HH24:mi:ss' )
            AND to_timestamp( #{enddate}, 'yyyy-MM-DD:HH24:mi:ss' )
        </if>
        group by t.ACTIONTIME
        ORDER BY t.ACTIONTIME asc
    </select>
 
 
    
    <select id="queryResourceLog" resultType="map" parameterType="map">
        select 
          b.RESOURCEID as resourceid,
        b.USERID as userid,
        b.ACTIONTIME as time,
        b.IP as ip,
        b.APPID as appid,
        a.count
        from (
        SELECT
              count(*) as count,
            t.ACTIONTIME,
            t.USERID
        FROM
        RES_ACTIONRECORD t
        WHERE t.IP IS NOT NULL AND 1 =1
        <if test="actionType!=null and actionType!=''">and t.ACTIONTYPE = #{actionType}</if>
        <if test="userid!=null and userid!='' ">
            AND t.USERID= #{userid}
        </if>
        <if test="appid!=null and appid!='' ">
            AND t.APPID=#{appid}
        </if>
        <if test="resourceid!=null and resourceid!='' ">
            AND t.RESOURCEID=#{resourceid}
        </if>
        <if test="months!=null and months!='' ">
            AND t.ACTIONTIME> now() + interval '${month} month'
        </if>
        <if test="day!=null and  day!=''">
            AND t.ACTIONTIME> now() - interval '${day} day'
        </if>
        <if test="startdate!=null and  startdate!='' and enddate!=null and  enddate !=''">
            t.ACTIONTIME BETWEEN to_timestamp( #{startdate}, 'yyyy-MM-DD:HH24:mi:ss' )
            AND to_timestamp( #{enddate}, 'yyyy-MM-DD:HH24:mi:ss' )
        </if>
        GROUP BY t.ACTIONTIME,t.USERID
        ) a
        LEFT JOIN RES_ACTIONRECORD b on a.ACTIONTIME=b.ACTIONTIME
        ORDER BY a.ACTIONTIME desc
    </select>
 
 
    <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="selectResActionRecordByResourceId" resultMap="BaseResultMap" parameterType="map" >
        select e.* from (
            select
                row_number() over() as rownumber,
                <include refid="Base_Column_List" />
            from RES_ACTIONRECORD
            where RESOURCEID = #{resourceid,jdbcType=DECIMAL}
        ) e
        WHERE 1=1
        <if test="page!=null and page!='' and limit!=null and limit!=''">
            <![CDATA[ and rownumber >= #{page}*#{limit} and rownumber < #{page}*#{limit}+#{limit} ]]>
        </if>
    </select>
</mapper>