133 lines
5.9 KiB
XML
133 lines
5.9 KiB
XML
![]() |
<?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.aizuda.easy.retry.template.datasource.persistence.mapper.JobSummaryMapper">
|
||
|
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.JobSummary">
|
||
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
||
|
<result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/>
|
||
|
<result column="group_name" jdbcType="TINYINT" property="groupName"/>
|
||
|
<result column="job_id" jdbcType="TINYINT" property="jobId"/>
|
||
|
<result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/>
|
||
|
<result column="success_num" jdbcType="TINYINT" property="successNum"/>
|
||
|
<result column="fail_num" jdbcType="TINYINT" property="failNum"/>
|
||
|
<result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
|
||
|
<result column="stop_num" jdbcType="TINYINT" property="stopNum"/>
|
||
|
<result column="stop_reason" jdbcType="VARCHAR" property="stopReason"/>
|
||
|
<result column="cancel_num" jdbcType="TINYINT" property="cancelNum"/>
|
||
|
<result column="cancel_reason" jdbcType="VARCHAR" property="cancelReason"/>
|
||
|
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt"/>
|
||
|
<result column="update_dt" jdbcType="TIMESTAMP" property="updateDt"/>
|
||
|
</resultMap>
|
||
|
|
||
|
<insert id="insertBatchJobSummary">
|
||
|
INSERT INTO
|
||
|
job_summary (namespace_id, group_name, job_id, trigger_at,
|
||
|
success_num,fail_num,fail_reason,stop_num,stop_reason, cancel_num,cancel_reason)
|
||
|
VALUES
|
||
|
<foreach collection="list" item="item" separator=",">
|
||
|
(
|
||
|
#{item.namespaceId},
|
||
|
#{item.groupName},
|
||
|
#{item.jobId},
|
||
|
#{item.triggerAt},
|
||
|
#{item.successNum},
|
||
|
#{item.failNum},
|
||
|
#{item.failReason},
|
||
|
#{item.stopNum},
|
||
|
#{item.stopReason},
|
||
|
#{item.cancelNum},
|
||
|
#{item.cancelReason}
|
||
|
)
|
||
|
</foreach>
|
||
|
</insert>
|
||
|
|
||
|
<update id="updateBatchTriggerAtById" parameterType="java.util.List">
|
||
|
UPDATE job_summary js,
|
||
|
(
|
||
|
<foreach collection="list" item="item" index="index" separator=" union all ">
|
||
|
SELECT
|
||
|
#{item.namespaceId} AS namespace_id,
|
||
|
#{item.groupName} AS group_name,
|
||
|
#{item.jobId} AS job_id,
|
||
|
#{item.triggerAt} AS trigger_at,
|
||
|
#{item.successNum} AS success_num,
|
||
|
#{item.failNum} AS fail_num,
|
||
|
#{item.failReason} AS fail_reason,
|
||
|
#{item.stopNum} AS stop_num,
|
||
|
#{item.stopReason} AS stop_reason,
|
||
|
#{item.cancelNum} AS cancel_num,
|
||
|
#{item.cancelReason} AS cancel_reason
|
||
|
</foreach>
|
||
|
) tt
|
||
|
SET
|
||
|
js.namespace_id = tt.namespace_id,
|
||
|
js.group_name = tt.group_name,
|
||
|
js.job_id = tt.job_id,
|
||
|
js.success_num = tt.success_num,
|
||
|
js.fail_num = tt.fail_num,
|
||
|
js.fail_reason = tt.fail_reason,
|
||
|
js.stop_num = tt.stop_num,
|
||
|
js.stop_reason = tt.stop_reason,
|
||
|
js.cancel_num = tt.cancel_num,
|
||
|
js.cancel_reason = tt.cancel_reason
|
||
|
WHERE js.job_id = tt.job_id AND js.trigger_at = tt.trigger_at
|
||
|
</update>
|
||
|
|
||
|
<select id="jobLineList"
|
||
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DispatchQuantityResponseDO">
|
||
|
SELECT
|
||
|
<choose>
|
||
|
<when test="type == 'YEAR'">
|
||
|
DATE_FORMAT(trigger_at,'%Y-%m')
|
||
|
</when>
|
||
|
<otherwise>
|
||
|
DATE_FORMAT(trigger_at,'%Y-%m-%d')
|
||
|
</otherwise>
|
||
|
</choose>
|
||
|
AS createDt,
|
||
|
ifnull(SUM(success_num), 0) AS successNum,
|
||
|
ifnull(SUM(fail_num), 0) AS failNum,
|
||
|
ifnull(SUM(stop_num), 0) AS stopNum,
|
||
|
ifnull(SUM(cancel_num), 0) AS cancelNum,
|
||
|
ifnull(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
|
||
|
ifnull(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
|
||
|
FROM job_summary
|
||
|
WHERE namespace_id = #{namespaceId} AND trigger_at BETWEEN #{from} AND #{to}
|
||
|
GROUP BY createDt
|
||
|
</select>
|
||
|
|
||
|
<select id="toJobTask"
|
||
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$JobTask">
|
||
|
SELECT ifnull(sum(success_num), 0) AS successNum,
|
||
|
ifnull(sum(fail_num + stop_num + cancel_num), 0) AS failNum,
|
||
|
ifnull(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
|
||
|
FROM job_summary
|
||
|
WHERE namespace_id = #{namespaceId}
|
||
|
</select>
|
||
|
|
||
|
<select id="dashboardRank"
|
||
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
||
|
SELECT
|
||
|
CONCAT(group_name, '/', (SELECT job_name FROM job WHERE id=job_id)) `name`,
|
||
|
SUM(success_num + fail_num + stop_num + cancel_num) AS total FROM job_summary
|
||
|
<where>
|
||
|
<if test="groupName != '' and groupName != null">
|
||
|
AND group_name = #{groupName}
|
||
|
</if>
|
||
|
AND trigger_at >= #{startTime} AND trigger_at <= #{endTime}
|
||
|
</where>
|
||
|
AND namespace_id = #{namespaceId}
|
||
|
GROUP BY namespace_id, group_name, job_id
|
||
|
ORDER BY total DESC LIMIT 10
|
||
|
</select>
|
||
|
|
||
|
<select id="jobTaskList"
|
||
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Task">
|
||
|
SELECT group_name AS groupName,
|
||
|
SUM(CASE WHEN (job_status = 1) THEN 1 ELSE 0 END) AS run,
|
||
|
count(*) AS total
|
||
|
FROM job
|
||
|
WHERE namespace_id = #{namespaceId}
|
||
|
GROUP BY namespace_id, group_name
|
||
|
</select>
|
||
|
</mapper>
|