1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
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
<?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.sys.dao.MonitorDao">
    <!-- 可根据自己的需求,是否要使用 -->
    <resultMap type="com.landtool.lanbase.modules.sys.entity.SysSysteminfo" id="systeminfoMap">
        <result property="appid" column="APPID"/>
        <result property="appfullname" column="APPFULLNAME"/>
        <result property="appname" column="APPNAME"/>
        <result property="appcode" column="APPCODE"/>
        <result property="systype" column="SYSTYPE"/>
        <result property="version" column="VERSION"/>
        <result property="sysaddress" column="SYSADDRESS"/>
        <result property="sysimgurl" column="SYSIMGURL"/>
        <result property="sysdescription" column="SYSDESCRIPTION"/>
        <result property="sysstatus" column="SYSSTATUS"/>
        <result property="logintimes" column="LOGINTIMES"/>
        <result property="magunitname" column="MAGUNITNAME"/>
        <result property="maguser" column="MAGUSER"/>
        <result property="magtechuser" column="MAGTECHUSER"/>
        <result property="techusertel" column="TECHUSERTEL"/>
        <result property="rcreateuser" column="RCREATEUSER"/>
        <result property="rcreatedate" column="RCREATEDATE"/>
        <result property="rlasteditdate" column="RLASTEDITDATE"/>
        <result property="remark" column="REMARK"/>
        <result property="iscaslogin" column="ISCASLOGIN"/>
        <result property="isnavigationshow" column="ISNAVIGATIONSHOW"/>
        <result property="orderid" column="ORDERID"/>
        <result property="referenceurl" column="REFERENCEURL"/>
        <result property="browser" column="BROWSER"/>
    </resultMap>
 
    <resultMap type="com.landtool.lanbase.modules.log.entity.LogAction" id="actionMap">
        <result property="actionid" column="ACTIONID"/>
        <result property="userid" column="USERID"/>
        <result property="appid" column="APPID"/>
        <result property="dodate" column="DODATE"/>
        <result property="largemodel" column="LARGEMODEL"/>
        <result property="smallmodel" column="SMALLMODEL"/>
        <result property="requesturl" column="REQUESTURL"/>
        <result property="requestip" column="REQUESTIP"/>
        <result property="remark" column="REMARK"/>
        <result property="actiontype" column="ACTIONTYPE"/>
        <result property="resourceid" column="RESOURCEID"/>
        <result property="title" column="TITLE"/>
    </resultMap>
 
    <select id="queryUsers" resultType="map" parameterType="list">
        select USERID,CHINESENAME,JOBTITLE,JOBLEVEL,LOGINNAME from ORG_USER
        where LOGINNAME in
        <foreach item="item" collection="list" separator="," open="(" close=")" index="">
            #{item}
        </foreach>
    </select>
 
 
    <select id="queryUserops" resultType="map" parameterType="map">
        SELECT C.REMARK, C.ACTIONTYPE,count(*) as count from (
        SELECT
        ROW_NUMBER () OVER ( ORDER BY B.dodate DESC ) AS rownumber,
        B.*
        FROM
        (
        SELECT
        la.*,
        ssi.APPFULLNAME,
        os.CHINESENAME
        FROM
        LOG_ACTION la
        LEFT JOIN SYS_SYSTEMINFO ssi ON la.appid = ssi.appid
        LEFT JOIN ORG_USER os ON os.USERID = la.USERID
        WHERE 1=1
        <if test="userid!=null and userid!=''">
            and la.USERID = #{userid}
        </if>
        <if test="username!=null and username!=''">
            and os.CHINESENAME = #{username}
        </if>
        <if test="months!=null and months!='' ">
            AND la.DODATE> now() + interval '${month} month'
        </if>
        <if test="day!=null and day!=''">
            AND la.DODATE> now() - interval '${day} day'
        </if>
        <if test="startdate!=null and  startdate!='' and enddate!=null and  enddate!=''">
            la.DODATE BETWEEN to_timestamp(#{startdate}, 'yyyy-MM-DD:HH24:mi:ss') AND to_timestamp( #{enddate}, 'yyyy-MM-DD:HH24:mi:ss' )
        </if>
        ) B) C group by (C.REMARK, C.ACTIONTYPE)
    </select>
 
 
    <select id="queryTotal" resultType="map" parameterType="map">
        SELECT C.ACTIONTYPE, count(*) from (
        SELECT
        ROW_NUMBER () OVER ( ORDER BY B.dodate DESC ) AS rownumber,
        B.*
        FROM
        (
        SELECT
        la.*,
        ssi.APPFULLNAME,
        os.CHINESENAME
        FROM
        LOG_ACTION la
        LEFT JOIN SYS_SYSTEMINFO ssi ON la.appid = ssi.appid
        LEFT JOIN ORG_USER os ON os.USERID = la.USERID
        WHERE 1=1
        <if test="userid!=null and userid!='' ">
            and la.USERID = #{userid}
        </if>
        <if test="months !=null and months!='' ">
            AND la.DODATE> now() + interval '${month} month'
        </if>
        <if test="day!=null and   day !=''">
            AND la.DODATE> now() - interval '${day} day'
        </if>
        <if test="startdate!=null and  startdate!='' and enddate!=null and  enddate !=''">
            la.DODATE BETWEEN to_timestamp( #{startdate}, 'yyyy-MM-DD:HH24:mi:ss' ) AND to_timestamp( #{enddate}, 'yyyy-MM-DD:HH24:mi:ss' )
        </if>
        ) B) C GROUP BY C.ACTIONTYPE
    </select>
 
    <select id="queryUserActionLine" resultType="map" parameterType="map">
        SELECT
            t.USERID userid,
            t.REQUESTIP requestip,
            t.ACTIONTYPE actiontype,
            t.REMARK remark,
            t.DODATE time,
            c.CHINESENAME chinesename
        FROM
            LOG_ACTION t  LEFT JOIN ORG_USER c ON t.USERID = c.USERID
        WHERE
            t.USERID = 4
    </select>
 
    <select id="querySysSystemInfo" resultMap="systeminfoMap" parameterType="map">
        SELECT
            *
        FROM
            SYS_SYSTEMINFO
    </select>
 
    <insert id="insertSystemProblem" parameterType="com.landtool.lanbase.modules.sys.entity.SysSystemProblemTrack">
        <selectKey keyProperty="id" resultType="java.lang.Integer" order="BEFORE">
            select NEXTVAL('SYS_SYSTEMPROBLEMTRACK_INS_SEQ') from dual
        </selectKey>
        INSERT INTO SYSSYSTEMPROBLEMTRACK (
        ID,
        APPID,
        STATUS,
        ADDRESS,
        CREATETIME,
        PROBLEMREASON
        )
        VALUES
        (
        #{id,jdbcType=DECIMAL},
        #{appid,jdbcType=DECIMAL},
        #{status,jdbcType=VARCHAR},
        #{address,jdbcType=VARCHAR},
        #{createtime,jdbcType=TIMESTAMP},
        #{problemreason,jdbcType=VARCHAR}
        )
    </insert>
 
    <select id="queryProblemSystem" resultType="map" parameterType="map">
        select e.* from (
        SELECT
        row_number() over() as num,
        c.*,
        b.APPNAME
        FROM
        (
        SELECT
        ROW_NUMBER () OVER ( PARTITION BY APPID ORDER BY CREATETIME DESC ) rn,
        APPID,
        STATUS,
        ADDRESS,
        CREATETIME,
        PROBLEMREASON
        FROM
        SYSSYSTEMPROBLEMTRACK t
        ) c left join SYS_SYSTEMINFO b on c.APPID=b.APPID
        WHERE
        rn = 1 and createtime > now()- interval '0.25 h'
        order by c.APPID
        ) e
        WHERE 1=1
        <if test="page!=null and page!='' and limit!=null and limit!=''">
            <![CDATA[ and  num >=#{page}*#{limit} and num<#{page}*#{limit}+#{limit} ]]>
        </if>
    </select>
 
 
    <select id="queryUserTrace" resultType="com.landtool.lanbase.modules.log.entity.LogAction" parameterType="map">
        select * from (
        SELECT *
        FROM(
        SELECT ROW_NUMBER() OVER(
        ORDER BY B.dodate DESC) AS rownumber,B.*
        FROM (
        SELECT la.*,ssi.APPFULLNAME,os.CHINESENAME FROM LOG_ACTION la
        LEFT JOIN SYS_SYSTEMINFO ssi ON la.appid=ssi.appid
        LEFT JOIN ORG_USER os ON os.USERID=la.USERID
        <where>
            <if test="UserName != null and UserName!=''">
                AND (os.CHINESENAME LIKE ('%' || #{UserName} || '%') or loginname like ('%' || #{UserName} || '%') or
                LOWER(os.spellfirst) like ('%' || LOWER(#{UserName}) || '%'))
            </if>
            <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="beginDate != null and beginDate !=''">
                and DODATE &gt;=
                to_timestamp(#{beginDate,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss')
            </if>
            <if test="endDate != null and endDate !=''">
                <![CDATA[ AND DODATE <=to_timestamp(#{endDate,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss') ]]>
 
            </if>
            <if test="requestip != null and requestip != ''">
                AND la.REQUESTIP LIKE ('%' || #{requestip} || '%')
            </if>
        </where>
        ) B
        ) A
        WHERE <![CDATA[   rownumber >=#{page}*#{limit} and rownumber<#{page}*#{limit}+#{limit} ]]>
        )a order by
        <choose>
            <when test="sidx != null and sidx != ''">
                ${sidx} ${order}
            </when>
            <otherwise>
                dodate DESC
            </otherwise>
        </choose>
    </select>
 
</mapper>