2024-03-25 08:50:57 +08:00
|
|
|
<?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">
|
2024-04-15 18:26:32 +08:00
|
|
|
<mapper namespace="com.aizuda.snail.job.template.datasource.persistence.mapper.RetrySummaryMapper">
|
|
|
|
<resultMap id="BaseResultMap" type="com.aizuda.snail.job.template.datasource.persistence.po.RetrySummary">
|
2024-03-25 08:50:57 +08:00
|
|
|
<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>
|
|
|
|
|
2024-03-31 21:12:29 +08:00
|
|
|
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
2024-04-04 20:16:21 +08:00
|
|
|
INSERT INTO
|
|
|
|
retry_summary (namespace_id, group_name, scene_name, trigger_at, running_num, finish_num, max_count_num,
|
|
|
|
suspend_num)
|
2024-03-31 21:12:29 +08:00
|
|
|
VALUES
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
(
|
|
|
|
#{item.namespaceId},
|
|
|
|
#{item.groupName},
|
2024-04-04 20:16:21 +08:00
|
|
|
#{item.sceneName},
|
2024-03-31 21:12:29 +08:00
|
|
|
#{item.triggerAt},
|
2024-04-04 20:16:21 +08:00
|
|
|
#{item.runningNum},
|
|
|
|
#{item.finishNum},
|
|
|
|
#{item.maxCountNum},
|
|
|
|
#{item.suspendNum}
|
2024-03-31 21:12:29 +08:00
|
|
|
)
|
|
|
|
</foreach>
|
2024-03-25 08:50:57 +08:00
|
|
|
</insert>
|
|
|
|
|
2024-03-31 21:12:29 +08:00
|
|
|
<update id="batchUpdate" parameterType="java.util.List">
|
2024-04-04 20:16:21 +08:00
|
|
|
UPDATE retry_summary
|
|
|
|
SET running_num = src.running_num,
|
|
|
|
finish_num = src.finish_num,
|
|
|
|
max_count_num = src.max_count_num,
|
|
|
|
suspend_num = src.suspend_num
|
|
|
|
FROM retry_summary AS dest
|
|
|
|
JOIN (
|
|
|
|
<foreach collection="list" item="item" index="index" separator="UNION ALL">
|
|
|
|
SELECT
|
|
|
|
#{item.runningNum} AS running_num,
|
|
|
|
#{item.finishNum} AS finish_num,
|
|
|
|
#{item.maxCountNum} AS max_count_num,
|
|
|
|
#{item.suspendNum} AS suspend_num,
|
|
|
|
#{item.triggerAt} AS trigger_at,
|
|
|
|
#{item.sceneName} AS scene_name,
|
|
|
|
#{item.namespaceId} AS namespace_id,
|
|
|
|
#{item.groupName} AS group_name
|
|
|
|
</foreach>
|
|
|
|
) AS src
|
|
|
|
ON (dest.trigger_at = src.trigger_at AND dest.group_name = src.group_name
|
|
|
|
AND dest.scene_name = src.scene_name AND dest.namespace_id = src.namespace_id
|
|
|
|
)
|
2024-03-31 21:12:29 +08:00
|
|
|
</update>
|
|
|
|
|
2024-03-25 08:50:57 +08:00
|
|
|
<select id="retryTask"
|
2024-04-15 18:26:32 +08:00
|
|
|
resultType="com.aizuda.snail.job.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
2024-03-25 08:50:57 +08:00
|
|
|
SELECT
|
|
|
|
ISNULL(SUM(running_num), 0) AS runningNum,
|
|
|
|
ISNULL(SUM(finish_num), 0) AS finishNum,
|
|
|
|
ISNULL(SUM(max_count_num), 0) AS maxCountNum,
|
|
|
|
ISNULL(SUM(suspend_num), 0) AS suspendNum,
|
|
|
|
ISNULL(SUM(running_num + finish_num + max_count_num + suspend_num), 0) AS totalNum
|
|
|
|
FROM retry_summary
|
2024-03-28 13:39:31 +08:00
|
|
|
${ew.customSqlSegment}
|
2024-03-25 08:50:57 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="retryTaskBarList"
|
2024-04-15 18:26:32 +08:00
|
|
|
resultType="com.aizuda.snail.job.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
2024-03-25 08:50:57 +08:00
|
|
|
SELECT TOP 7
|
|
|
|
trigger_at,
|
|
|
|
running_num,
|
|
|
|
finish_num,
|
|
|
|
max_count_num,
|
|
|
|
suspend_num
|
|
|
|
FROM retry_summary
|
2024-03-28 13:39:31 +08:00
|
|
|
${ew.customSqlSegment}
|
2024-03-25 08:50:57 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="retryLineList"
|
2024-04-15 18:26:32 +08:00
|
|
|
resultType="com.aizuda.snail.job.template.datasource.persistence.dataobject.DashboardLineResponseDO">
|
2024-03-25 08:50:57 +08:00
|
|
|
SELECT
|
|
|
|
createDt,
|
|
|
|
ISNULL(SUM(finish_num), 0) AS successNum,
|
|
|
|
ISNULL(SUM(running_num), 0) AS runningNum,
|
|
|
|
ISNULL(SUM(max_count_num), 0) AS maxCountNum,
|
|
|
|
ISNULL(SUM(suspend_num), 0) AS suspendNum,
|
|
|
|
ISNULL(SUM(finish_num + running_num + max_count_num + suspend_num), 0) AS total
|
|
|
|
FROM (
|
|
|
|
SELECT
|
2024-03-31 21:12:29 +08:00
|
|
|
FORMAT(create_dt, #{dateFormat}) AS createDt,
|
2024-03-25 08:50:57 +08:00
|
|
|
finish_num,
|
|
|
|
running_num,
|
|
|
|
max_count_num,
|
|
|
|
suspend_num
|
|
|
|
FROM retry_summary
|
2024-03-28 13:39:31 +08:00
|
|
|
${ew.customSqlSegment}
|
2024-03-25 08:50:57 +08:00
|
|
|
) AS subquery
|
|
|
|
GROUP BY createDt
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="dashboardRank"
|
2024-04-15 18:26:32 +08:00
|
|
|
resultType="com.aizuda.snail.job.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
2024-03-25 08:50:57 +08:00
|
|
|
SELECT TOP 10
|
|
|
|
CONCAT(group_name, '/', scene_name) AS name,
|
|
|
|
SUM(running_num + finish_num + max_count_num + suspend_num) AS total
|
|
|
|
FROM retry_summary
|
2024-03-28 13:39:31 +08:00
|
|
|
${ew.customSqlSegment}
|
2024-03-25 08:50:57 +08:00
|
|
|
HAVING SUM(running_num + finish_num + max_count_num + suspend_num) > 0
|
|
|
|
ORDER BY total DESC
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- SQL Server GROUP BY 的分页必须 ORDER BY xxx -->
|
|
|
|
<select id="retryTaskList"
|
2024-04-15 18:26:32 +08:00
|
|
|
resultType="com.aizuda.snail.job.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Task">
|
2024-03-25 08:50:57 +08:00
|
|
|
SELECT
|
|
|
|
group_name AS groupName,
|
|
|
|
SUM(CASE WHEN (scene_status = 1) THEN 1 ELSE 0 END) AS run,
|
|
|
|
COUNT(*) AS total
|
|
|
|
FROM scene_config
|
2024-03-28 13:39:31 +08:00
|
|
|
${ew.customSqlSegment}
|
2024-03-25 08:50:57 +08:00
|
|
|
GROUP BY namespace_id, group_name
|
|
|
|
ORDER BY group_name
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 用于 retryTaskList 分页的 自定义 COUNT,
|
|
|
|
SQL Server SELECT COUNT(*) FROM (... ORDER BY group_name) 会报错 -->
|
2024-04-04 20:16:21 +08:00
|
|
|
<select id="countRetryTask" resultType="long">
|
2024-03-25 08:50:57 +08:00
|
|
|
SELECT COUNT(DISTINCT group_name)
|
2024-03-28 13:39:31 +08:00
|
|
|
FROM scene_config
|
|
|
|
${ew.customSqlSegment}
|
2024-03-25 08:50:57 +08:00
|
|
|
</select>
|
|
|
|
</mapper>
|