170 lines
7.7 KiB
XML
170 lines
7.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.RetrySummaryMapper">
|
|
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.RetrySummary">
|
|
<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="scene_name" jdbcType="TINYINT" property="sceneName"/>
|
|
<result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/>
|
|
<result column="running_num" jdbcType="TINYINT" property="runningNum"/>
|
|
<result column="finish_num" jdbcType="TINYINT" property="finishNum"/>
|
|
<result column="max_count_num" jdbcType="VARCHAR" property="maxCountNum"/>
|
|
<result column="suspend_num" jdbcType="TINYINT" property="suspendNum"/>
|
|
<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
|
|
retry_summary (namespace_id, group_name, scene_name, trigger_at, running_num, finish_num, max_count_num,
|
|
suspend_num)
|
|
VALUES
|
|
<foreach collection="list" item="item" separator=",">
|
|
(
|
|
#{item.namespaceId},
|
|
#{item.groupName},
|
|
#{item.sceneName},
|
|
#{item.triggerAt},
|
|
#{item.runningNum},
|
|
#{item.finishNum},
|
|
#{item.maxCountNum},
|
|
#{item.suspendNum}
|
|
)
|
|
</foreach>
|
|
ON DUPLICATE KEY UPDATE
|
|
running_num = values(`running_num`),
|
|
finish_num = values(`finish_num`),
|
|
max_count_num = values(`max_count_num`),
|
|
suspend_num = values(`suspend_num`)
|
|
</insert>
|
|
|
|
<select id="retryTask"
|
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
|
SELECT ifnull(sum(running_num), 0) AS runningNum,
|
|
ifnull(sum(finish_num), 0) AS finishNum,
|
|
ifnull(sum(max_count_num), 0) AS maxCountNum,
|
|
ifnull(sum(suspend_num), 0) AS suspendNum,
|
|
ifnull(sum(running_num + finish_num + max_count_num + suspend_num), 0) AS totalNum
|
|
FROM retry_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="retryTaskBarList"
|
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTaskBar">
|
|
SELECT tmp.date AS x, ifnull(b.taskTotal, 0) AS taskTotal
|
|
FROM (SELECT curdate() AS date
|
|
UNION ALL
|
|
SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) AS date
|
|
UNION ALL
|
|
SELECT DATE_SUB(CURDATE(), interval 2 day) AS date
|
|
UNION ALL
|
|
SELECT DATE_SUB(CURDATE(), interval 3 day) AS date
|
|
UNION ALL
|
|
SELECT DATE_SUB(CURDATE(), interval 4 day) AS date
|
|
UNION ALL
|
|
SELECT DATE_SUB(CURDATE(), interval 5 day) AS date
|
|
UNION ALL
|
|
SELECT DATE_SUB(CURDATE(), interval 6 day) AS date) tmp
|
|
LEFT JOIN (SELECT DATE (trigger_at) AS triggerAt,
|
|
SUM(running_num + finish_num + max_count_num + suspend_num) AS taskTotal FROM retry_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>
|
|
GROUP BY triggerAt
|
|
) b
|
|
ON tmp.date = b.triggerAt
|
|
</select>
|
|
|
|
<select id="retryLineList"
|
|
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(finish_num), 0) AS successNum,
|
|
ifnull(SUM(running_num), 0) AS runningNum,
|
|
ifnull(SUM(max_count_num), 0) AS maxCountNum,
|
|
ifnull(SUM(suspend_num), 0) AS suspendNum,
|
|
ifnull(SUM(finish_num + running_num + max_count_num + suspend_num), 0) AS total
|
|
FROM retry_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="dashboardRank"
|
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
|
SELECT
|
|
CONCAT(group_name, '/', scene_name) `name`,
|
|
SUM(running_num + finish_num + max_count_num + suspend_num) AS total FROM retry_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 namespace_id = #{namespaceId}
|
|
AND trigger_at >= #{startTime} AND trigger_at <= #{endTime}
|
|
</where>
|
|
GROUP BY namespace_id, group_name, scene_name
|
|
HAVING total > 0
|
|
ORDER BY total DESC LIMIT 10
|
|
</select>
|
|
|
|
<select id="retryTaskList"
|
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Task">
|
|
SELECT group_name AS groupName,
|
|
sum(CASE WHEN (scene_status = 1) THEN 1 ELSE 0 END) AS run,
|
|
count(*) AS total
|
|
FROM scene_config
|
|
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>
|