日志导出忽略分页

This commit is contained in:
XinWei 2024-07-12 14:11:57 +08:00
parent 09e269947d
commit f691164000

View File

@ -3,27 +3,27 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxl.job.admin.dao.XxlJobLogDao">
<resultMap id="XxlJobLog" type="com.xxl.job.admin.core.model.XxlJobLog" >
<result column="id" property="id" />
<resultMap id="XxlJobLog" type="com.xxl.job.admin.core.model.XxlJobLog">
<result column="id" property="id"/>
<result column="job_group" property="jobGroup" />
<result column="job_id" property="jobId" />
<result column="job_group" property="jobGroup"/>
<result column="job_id" property="jobId"/>
<result column="executor_address" property="executorAddress" />
<result column="executor_handler" property="executorHandler" />
<result column="executor_param" property="executorParam" />
<result column="executor_sharding_param" property="executorShardingParam" />
<result column="executor_fail_retry_count" property="executorFailRetryCount" />
<result column="executor_address" property="executorAddress"/>
<result column="executor_handler" property="executorHandler"/>
<result column="executor_param" property="executorParam"/>
<result column="executor_sharding_param" property="executorShardingParam"/>
<result column="executor_fail_retry_count" property="executorFailRetryCount"/>
<result column="trigger_time" property="triggerTime" />
<result column="trigger_code" property="triggerCode" />
<result column="trigger_msg" property="triggerMsg" />
<result column="trigger_time" property="triggerTime"/>
<result column="trigger_code" property="triggerCode"/>
<result column="trigger_msg" property="triggerMsg"/>
<result column="handle_time" property="handleTime" />
<result column="handle_code" property="handleCode" />
<result column="handle_msg" property="handleMsg" />
<result column="handle_time" property="handleTime"/>
<result column="handle_code" property="handleCode"/>
<result column="handle_msg" property="handleMsg"/>
<result column="alarm_status" property="alarmStatus" />
<result column="alarm_status" property="alarmStatus"/>
</resultMap>
<sql id="Base_Column_List">
@ -45,9 +45,10 @@
</sql>
<select id="pageList" resultMap="XxlJobLog">
SELECT <include refid="Base_Column_List" />
SELECT
<include refid="Base_Column_List"/>
FROM xxl_job_log AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<trim prefix="WHERE" prefixOverrides="AND | OR">
<if test="jobId==0 and jobGroup gt 0">
AND t.job_group = #{jobGroup}
</if>
@ -60,16 +61,16 @@
<if test="triggerTimeEnd != null">
AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
</if>
<if test="logStatus == 1" >
<if test="logStatus == 1">
AND t.handle_code = 200
</if>
<if test="logStatus == 2" >
<if test="logStatus == 2">
AND (
t.trigger_code NOT IN (0, 200) OR
t.handle_code NOT IN (0, 200)
)
</if>
<if test="logStatus == 3" >
<if test="logStatus == 3">
AND t.trigger_code = 200
AND t.handle_code = 0
</if>
@ -90,10 +91,11 @@
<result column="status" property="status"/>
</resultMap>
<select id="apiPageList" resultMap="ApiXxlJobLog">
SELECT <include refid="Base_Column_List" />, ROW_NUMBER() OVER (ORDER BY t.trigger_time) AS 'index', (t.handle_time -t.trigger_time) AS 'duration',
SELECT<include refid="Base_Column_List"/>, ROW_NUMBER() OVER (ORDER BY t.trigger_time) AS 'index',
(t.handle_time -t.trigger_time) AS 'duration',
IF(t.handle_code = 200, 1, 2) AS 'status'
FROM xxl_job_log AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<trim prefix="WHERE" prefixOverrides="AND | OR">
<if test="jobId==0 and jobGroup gt 0">
AND t.job_group = #{jobGroup}
</if>
@ -106,16 +108,16 @@
<if test="triggerTimeEnd != null">
AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
</if>
<if test="logStatus == 1" >
<if test="logStatus == 1">
AND t.handle_code = 200
</if>
<if test="logStatus == 2" >
<if test="logStatus == 2">
AND (
t.trigger_code NOT IN (0, 200) OR
t.handle_code NOT IN (0, 200)
)
</if>
<if test="logStatus == 3" >
<if test="logStatus == 3">
AND t.trigger_code = 200
AND t.handle_code = 0
</if>
@ -124,13 +126,15 @@
</if>
</trim>
ORDER BY t.trigger_time DESC
<if test="pagesize > 0">
LIMIT #{offset}, #{pagesize}
</if>
</select>
<select id="pageListCount" resultType="int">
SELECT count(1)
FROM xxl_job_log AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<trim prefix="WHERE" prefixOverrides="AND | OR">
<if test="jobId==0 and jobGroup gt 0">
AND t.job_group = #{jobGroup}
</if>
@ -143,16 +147,16 @@
<if test="triggerTimeEnd != null">
AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
</if>
<if test="logStatus == 1" >
<if test="logStatus == 1">
AND t.handle_code = 200
</if>
<if test="logStatus == 2" >
<if test="logStatus == 2">
AND (
t.trigger_code NOT IN (0, 200) OR
t.handle_code NOT IN (0, 200)
)
</if>
<if test="logStatus == 3" >
<if test="logStatus == 3">
AND t.trigger_code = 200
AND t.handle_code = 0
</if>
@ -161,7 +165,7 @@
<select id="apiPageListCount" resultType="int">
SELECT count(1)
FROM xxl_job_log AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<trim prefix="WHERE" prefixOverrides="AND | OR">
<if test="jobId==0 and jobGroup gt 0">
AND t.job_group = #{jobGroup}
</if>
@ -174,16 +178,16 @@
<if test="triggerTimeEnd != null">
AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
</if>
<if test="logStatus == 1" >
<if test="logStatus == 1">
AND t.handle_code = 200
</if>
<if test="logStatus == 2" >
<if test="logStatus == 2">
AND (
t.trigger_code NOT IN (0, 200) OR
t.handle_code NOT IN (0, 200)
)
</if>
<if test="logStatus == 3" >
<if test="logStatus == 3">
AND t.trigger_code = 200
AND t.handle_code = 0
</if>
@ -194,13 +198,14 @@
</select>
<select id="load" parameterType="java.lang.Long" resultMap="XxlJobLog">
SELECT <include refid="Base_Column_List" />
SELECT
<include refid="Base_Column_List"/>
FROM xxl_job_log AS t
WHERE t.id = #{id}
</select>
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLog" useGeneratedKeys="true" keyProperty="id" >
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLog" useGeneratedKeys="true" keyProperty="id">
INSERT INTO xxl_job_log (
`job_group`,
`job_id`,
@ -219,10 +224,9 @@
</selectKey>-->
</insert>
<update id="updateTriggerInfo" >
<update id="updateTriggerInfo">
UPDATE xxl_job_log
SET
`trigger_time`= #{triggerTime},
SET `trigger_time`= #{triggerTime},
`trigger_code`= #{triggerCode},
`trigger_msg`= #{triggerMsg},
`executor_address`= #{executorAddress},
@ -230,20 +234,20 @@
`executor_param`= #{executorParam},
`executor_sharding_param`= #{executorShardingParam},
`executor_fail_retry_count`= #{executorFailRetryCount}
WHERE `id`= #{id}
WHERE `id` = #{id}
</update>
<update id="updateHandleInfo">
UPDATE xxl_job_log
SET
`handle_time`= #{handleTime},
SET `handle_time`= #{handleTime},
`handle_code`= #{handleCode},
`handle_msg`= #{handleMsg}
WHERE `id`= #{id}
WHERE `id` = #{id}
</update>
<delete id="delete" >
delete from xxl_job_log
<delete id="delete">
delete
from xxl_job_log
WHERE job_id = #{jobId}
</delete>
@ -259,18 +263,17 @@
ORDER BY triggerDay
</select>-->
<select id="findLogReport" resultType="java.util.Map" >
SELECT
COUNT(handle_code) triggerDayCount,
<select id="findLogReport" resultType="java.util.Map">
SELECT COUNT(handle_code) triggerDayCount,
SUM(CASE WHEN (trigger_code in (0, 200) and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning,
SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc
FROM xxl_job_log
WHERE trigger_time BETWEEN #{from} and #{to}
</select>
<select id="findClearLogIds" resultType="long" >
<select id="findClearLogIds" resultType="long">
SELECT id FROM xxl_job_log
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<trim prefix="WHERE" prefixOverrides="AND | OR">
<if test="jobGroup gt 0">
AND job_group = #{jobGroup}
</if>
@ -284,7 +287,7 @@
AND id NOT in(
SELECT id FROM(
SELECT id FROM xxl_job_log AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" >
<trim prefix="WHERE" prefixOverrides="AND | OR">
<if test="jobGroup gt 0">
AND t.job_group = #{jobGroup}
</if>
@ -302,18 +305,21 @@
LIMIT #{pagesize}
</select>
<delete id="clearLog" >
<delete id="clearLog">
delete from xxl_job_log
WHERE id in
<foreach collection="logIds" item="item" open="(" close=")" separator="," >
<foreach collection="logIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</delete>
<select id="findFailJobLogIds" resultType="long" >
SELECT id FROM `xxl_job_log`
<select id="findFailJobLogIds" resultType="long">
SELECT id
FROM `xxl_job_log`
WHERE !(
(trigger_code in (0, 200) and handle_code = 0)
(trigger_code in (0
, 200)
and handle_code = 0)
OR
(handle_code = 200)
)
@ -322,21 +328,18 @@
LIMIT #{pagesize}
</select>
<update id="updateAlarmStatus" >
<update id="updateAlarmStatus">
UPDATE xxl_job_log
SET
`alarm_status` = #{newAlarmStatus}
WHERE `id`= #{logId} AND `alarm_status` = #{oldAlarmStatus}
SET `alarm_status` = #{newAlarmStatus}
WHERE `id` = #{logId}
AND `alarm_status` = #{oldAlarmStatus}
</update>
<select id="findLostJobIds" resultType="long" >
SELECT
t.id
FROM
xxl_job_log t
<select id="findLostJobIds" resultType="long">
SELECT t.id
FROM xxl_job_log t
LEFT JOIN xxl_job_registry t2 ON t.executor_address = t2.registry_value
WHERE
t.trigger_code = 200
WHERE t.trigger_code = 200
AND t.handle_code = 0
AND t.trigger_time <![CDATA[ <= ]]> #{losedTime}
AND t2.id IS NULL;