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">
|
|
|
|
<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>
|
|
|
|
|
2024-03-31 21:12:29 +08:00
|
|
|
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
INSERT INTO job_summary (namespace_id, group_name, business_id, trigger_at, system_task_type,
|
|
|
|
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.businessId},
|
|
|
|
#{item.triggerAt},
|
|
|
|
#{item.systemTaskType},
|
|
|
|
#{item.successNum},
|
|
|
|
#{item.failNum},
|
|
|
|
#{item.failReason},
|
|
|
|
#{item.stopNum},
|
|
|
|
#{item.stopReason},
|
|
|
|
#{item.cancelNum},
|
|
|
|
#{item.cancelReason}
|
|
|
|
)
|
|
|
|
</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">
|
|
|
|
UPDATE job_summary
|
|
|
|
SET success_num = src.success_num,
|
|
|
|
fail_num = src.fail_num,
|
|
|
|
fail_reason = src.fail_reason,
|
|
|
|
stop_num = src.stop_num,
|
|
|
|
stop_reason = src.stop_reason,
|
|
|
|
cancel_num = src.cancel_num,
|
|
|
|
cancel_reason = src.cancel_reason
|
|
|
|
FROM job_summary AS dest
|
|
|
|
JOIN (
|
2024-04-03 16:57:43 +08:00
|
|
|
<foreach collection="list" item="item" index="index" separator="UNION ALL">
|
2024-03-31 21:12:29 +08:00
|
|
|
SELECT
|
|
|
|
#{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,
|
|
|
|
#{item.triggerAt} AS trigger_at,
|
|
|
|
#{item.businessId} AS business_id
|
|
|
|
</foreach>
|
|
|
|
) AS src
|
|
|
|
ON (dest.trigger_at = src.trigger_at AND dest.business_id = src.business_id)
|
|
|
|
</update>
|
|
|
|
|
2024-03-25 08:50:57 +08:00
|
|
|
<select id="retryTask"
|
|
|
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
|
|
|
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"
|
|
|
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
|
|
|
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"
|
|
|
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
|
|
|
|
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"
|
|
|
|
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
|
|
|
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"
|
|
|
|
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
|
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) 会报错 -->
|
|
|
|
<select id="sqlServer_jobTaskList_Count" resultType="java.lang.Integer">
|
|
|
|
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>
|