150 lines
6.7 KiB
XML
150 lines
6.7 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="insertOrUpdate" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
|
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>
|
|
ON DUPLICATE KEY UPDATE
|
|
success_num = values(`success_num`),
|
|
fail_num = values(`fail_num`),
|
|
fail_reason = values(`fail_reason`),
|
|
stop_num = values(`stop_num`),
|
|
stop_reason = values(`stop_reason`),
|
|
cancel_num = values(`cancel_num`),
|
|
cancel_reason = values(`cancel_reason`)
|
|
</insert>
|
|
|
|
<select id="jobLineList"
|
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
|
|
SELECT
|
|
<choose>
|
|
<when test="type == 'DAY'">
|
|
DATE_FORMAT(create_dt,'%H')
|
|
</when>
|
|
<when test="type == 'WEEK'">
|
|
DATE_FORMAT(create_dt,'%Y-%m-%d')
|
|
</when>
|
|
<when test="type =='MONTH'">
|
|
DATE_FORMAT(create_dt,'%Y-%m-%d')
|
|
</when>
|
|
<when test="type == 'YEAR'">
|
|
DATE_FORMAT(create_dt,'%Y-%m')
|
|
</when>
|
|
<otherwise>
|
|
DATE_FORMAT(create_dt,'%Y-%m-%d')
|
|
</otherwise>
|
|
</choose>
|
|
AS createDt,
|
|
ifnull(SUM(success_num), 0) AS success,
|
|
ifnull(SUM(fail_num), 0) AS failNum,
|
|
ifnull(SUM(stop_num), 0) AS stop,
|
|
ifnull(SUM(cancel_num), 0) AS cancel,
|
|
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>
|
|
<if test="groupNames != null and groupNames.size > 0">
|
|
AND group_name IN
|
|
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
|
#{groupName}
|
|
</foreach>
|
|
</if>
|
|
<if test="groupName != null and groupName != '' ">
|
|
AND group_name = #{groupName}
|
|
</if>
|
|
AND namespace_id = #{namespaceId} AND trigger_at BETWEEN #{from} AND #{to}
|
|
</where>
|
|
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(stop_num), 0) AS stopNum,
|
|
ifnull(sum(cancel_num), 0) AS cancelNum,
|
|
ifnull(sum(fail_num), 0) AS failNum,
|
|
ifnull(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
|
|
FROM job_summary
|
|
WHERE namespace_id = #{namespaceId}
|
|
<if test="groupNames != null and groupNames.size > 0">
|
|
AND group_name IN
|
|
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
|
#{groupName}
|
|
</foreach>
|
|
</if>
|
|
</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(fail_num) AS total FROM job_summary
|
|
<where>
|
|
<if test="groupNames != null and groupNames.size > 0">
|
|
AND group_name IN
|
|
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
|
#{groupName}
|
|
</foreach>
|
|
</if>
|
|
<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
|
|
HAVING total > 0
|
|
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}
|
|
<if test="groupNames != null and groupNames.size > 0">
|
|
AND group_name IN
|
|
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
|
#{groupName}
|
|
</foreach>
|
|
</if>
|
|
GROUP BY namespace_id, group_name
|
|
</select>
|
|
</mapper>
|