style: 格式化SQL脚本
This commit is contained in:
parent
c70948c34a
commit
be9bdefc4d
@ -15,23 +15,24 @@
|
||||
<result column="create_dt" property="createDt"/>
|
||||
<result column="real_time" property="realTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 定义批量新增的 SQL 映射 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO job_log_message (namespace_id, group_name, job_id, task_batch_id, task_id, log_num, message,
|
||||
create_dt, real_time)
|
||||
create_dt, real_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.jobId},
|
||||
#{item.taskBatchId},
|
||||
#{item.taskId},
|
||||
#{item.logNum},
|
||||
#{item.message},
|
||||
#{item.createDt},
|
||||
#{item.realTime}
|
||||
)
|
||||
</foreach>
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.jobId},
|
||||
#{item.taskBatchId},
|
||||
#{item.taskId},
|
||||
#{item.logNum},
|
||||
#{item.message},
|
||||
#{item.createDt},
|
||||
#{item.realTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
|
@ -31,8 +31,8 @@
|
||||
USING (
|
||||
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
|
||||
SELECT
|
||||
#{item.nextTriggerAt} AS next_trigger_at,
|
||||
#{item.id} AS id
|
||||
#{item.nextTriggerAt} AS next_trigger_at,
|
||||
#{item.id} AS id
|
||||
FROM DUAL
|
||||
</foreach>
|
||||
) src
|
||||
|
@ -25,19 +25,21 @@
|
||||
<select id="selectJobNotifyConfigList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.JobNotifyConfigResponseDO">
|
||||
SELECT a.*, b.job_name
|
||||
FROM job_notify_config a join job b on a.job_id = b.id
|
||||
FROM
|
||||
job_notify_config a
|
||||
JOIN job b ON a.job_id = b.id
|
||||
<where>
|
||||
a.namespace_id = #{queryDO.namespaceId}
|
||||
<if test="queryDO.jobId != null">
|
||||
and a.job_id = #{queryDO.jobId}
|
||||
</if>
|
||||
<if test="queryDO.groupNames != null and queryDO.groupNames.size > 0">
|
||||
and a.group_name IN
|
||||
<foreach collection="queryDO.groupNames" item="groupName" open="(" separator="," close=")">
|
||||
#{groupName}
|
||||
</foreach>
|
||||
</if>
|
||||
order by a.id desc
|
||||
a.namespace_id = #{queryDO.namespaceId}
|
||||
<if test="queryDO.jobId != null">
|
||||
AND a.job_id = #{queryDO.jobId}
|
||||
</if>
|
||||
<if test="queryDO.groupNames != null and queryDO.groupNames.size > 0">
|
||||
AND a.group_name IN
|
||||
<foreach collection="queryDO.groupNames" item="groupName" open="(" separator="," close=")">
|
||||
#{groupName}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.id DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -39,7 +39,8 @@
|
||||
) src
|
||||
ON (dest.job_id = src.job_id AND dest.trigger_at = src.trigger_at)
|
||||
WHEN MATCHED THEN
|
||||
SET dest.success_num = src.success_num,
|
||||
UPDATE SET
|
||||
dest.success_num = src.success_num,
|
||||
dest.fail_num = src.fail_num,
|
||||
dest.fail_reason = src.fail_reason,
|
||||
dest.stop_num = src.stop_num,
|
||||
@ -47,7 +48,7 @@
|
||||
dest.cancel_num = src.cancel_num,
|
||||
dest.cancel_reason = src.cancel_reason
|
||||
WHEN NOT MATCHED THEN
|
||||
INSERT job_summary (namespace_id, group_name, job_id, trigger_at,
|
||||
INSERT (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=",">
|
||||
@ -167,7 +168,7 @@
|
||||
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
|
||||
COUNT(*) AS total
|
||||
FROM job
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
|
@ -13,32 +13,34 @@
|
||||
<result column="update_dt" property="updateDt" />
|
||||
<result column="deleted" property="deleted" />
|
||||
</resultMap>
|
||||
|
||||
<select id="selectJobBatchPageList"
|
||||
parameterType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.JobBatchQueryDO"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.JobBatchResponseDO">
|
||||
SELECT a.*, b.job_name, b.task_type, b.block_strategy, b.trigger_type
|
||||
FROM job_task_batch a join job b on a.job_id = b.id
|
||||
FROM job_task_batch a JOIN job b ON a.job_id = b.id
|
||||
<where>
|
||||
a.namespace_id = #{queryDO.namespaceId}
|
||||
<if test="queryDO.jobId != null">
|
||||
and a.job_id = #{queryDO.jobId}
|
||||
AND a.job_id = #{queryDO.jobId}
|
||||
</if>
|
||||
<if test="queryDO.groupNames != null and queryDO.groupNames.size > 0">
|
||||
and a.group_name IN
|
||||
AND a.group_name IN
|
||||
<foreach collection="queryDO.groupNames" item="groupName" open="(" separator="," close=")">
|
||||
#{groupName}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="queryDO.taskBatchStatus != null">
|
||||
and task_batch_status = #{queryDO.taskBatchStatus}
|
||||
AND task_batch_status = #{queryDO.taskBatchStatus}
|
||||
</if>
|
||||
<if test="queryDO.jobName != null">
|
||||
and job_name like #{queryDO.jobName}
|
||||
AND job_name LIKE #{queryDO.jobName}
|
||||
</if>
|
||||
and a.deleted = 0
|
||||
order by a.id desc
|
||||
AND a.deleted = 0
|
||||
</where>
|
||||
ORDER BY a.id DESC
|
||||
</select>
|
||||
|
||||
<select id="summaryJobBatchList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.JobBatchSummaryResponseDO">
|
||||
SELECT namespace_id AS namespaceId,
|
||||
@ -54,18 +56,27 @@
|
||||
FROM job_task_batch
|
||||
WHERE create_dt BETWEEN #{from} AND #{to}
|
||||
GROUP BY namespace_id, group_name, job_id, task_batch_status, operation_reason
|
||||
|
||||
</select>
|
||||
|
||||
<select id="selectJobBatchListByIds"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.JobBatchResponseDO">
|
||||
SELECT a.*, b.job_name, b.task_type, b.block_strategy, b.trigger_type,b.executor_info,b.args_str
|
||||
FROM job_task_batch a join job b on a.job_id = b.id
|
||||
SELECT
|
||||
a.*,
|
||||
b.job_name,
|
||||
b.task_type,
|
||||
b.block_strategy,
|
||||
b.trigger_type,
|
||||
b.executor_info,
|
||||
b.args_str
|
||||
FROM
|
||||
job_task_batch a
|
||||
JOIN job b ON a.job_id = b.id
|
||||
<where>
|
||||
a.id in
|
||||
a.id IN
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and a.deleted = 0
|
||||
AND a.deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -15,25 +15,31 @@
|
||||
<result column="task_type" jdbcType="TINYINT" property="taskType"/>
|
||||
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, namespace_id, unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, create_dt, task_type
|
||||
</sql>
|
||||
|
||||
<insert id="insertBatch">
|
||||
insert into retry_dead_letter (namespace_id, unique_id, group_name, scene_name,
|
||||
idempotent_id, biz_no, executor_name, args_str,
|
||||
ext_attrs, create_dt
|
||||
)
|
||||
values
|
||||
<foreach collection="retryDeadLetters" item="retryDeadLetter" separator=",">
|
||||
(#{retryDeadLetter.namespaceId,jdbcType=VARCHAR}, #{retryDeadLetter.uniqueId,jdbcType=VARCHAR}, #{retryDeadLetter.groupName,jdbcType=VARCHAR}, #{retryDeadLetter.sceneName,jdbcType=VARCHAR},
|
||||
#{retryDeadLetter.idempotentId,jdbcType=VARCHAR}, #{retryDeadLetter.bizNo,jdbcType=VARCHAR}, #{retryDeadLetter.executorName,jdbcType=VARCHAR}, #{retryDeadLetter.argsStr,jdbcType=VARCHAR},
|
||||
#{retryDeadLetter.extAttrs,jdbcType=VARCHAR}, #{retryDeadLetter.createDt,jdbcType=TIMESTAMP})
|
||||
</foreach>
|
||||
INSERT INTO retry_dead_letter (namespace_id, unique_id, group_name, scene_name,
|
||||
idempotent_id, biz_no, executor_name, args_str,
|
||||
ext_attrs, create_dt)
|
||||
VALUES
|
||||
<foreach collection="retryDeadLetters" item="retryDeadLetter" separator=",">
|
||||
(
|
||||
#{retryDeadLetter.namespaceId,jdbcType=VARCHAR}, #{retryDeadLetter.uniqueId,jdbcType=VARCHAR},
|
||||
#{retryDeadLetter.groupName,jdbcType=VARCHAR}, #{retryDeadLetter.sceneName,jdbcType=VARCHAR},
|
||||
#{retryDeadLetter.idempotentId,jdbcType=VARCHAR}, #{retryDeadLetter.bizNo,jdbcType=VARCHAR},
|
||||
#{retryDeadLetter.executorName,jdbcType=VARCHAR}, #{retryDeadLetter.argsStr,jdbcType=VARCHAR},
|
||||
#{retryDeadLetter.extAttrs,jdbcType=VARCHAR}, #{retryDeadLetter.createDt,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="countRetryDeadLetterByCreateAt" resultType="int">
|
||||
select
|
||||
count(*)
|
||||
from retry_dead_letter_${partition} where create_dt>= #{startTime} and create_dt <=#{endTime}
|
||||
SELECT COUNT(*)
|
||||
FROM retry_dead_letter_${partition}
|
||||
WHERE create_dt BETWEEN #{startTime} AND #{endTime}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@ -36,25 +36,25 @@
|
||||
AND dest.scene_name = src.scene_name
|
||||
AND dest.trigger_at = src.trigger_at)
|
||||
WHEN MATCHED THEN
|
||||
SET dest.running_num = src.running_num,
|
||||
UPDATE SET
|
||||
dest.running_num = src.running_num,
|
||||
dest.finish_num = src.finish_num,
|
||||
dest.max_count_num = src.max_count_num,
|
||||
dest.suspend_num = src.suspend_num
|
||||
WHEN NOT MATCHED THEN
|
||||
INSERT
|
||||
retry_summary (namespace_id, group_name, scene_name, trigger_at,
|
||||
running_num, finish_num, max_count_num, suspend_num)
|
||||
INSERT (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}
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.sceneName},
|
||||
#{item.triggerAt},
|
||||
#{item.runningNum},
|
||||
#{item.finishNum},
|
||||
#{item.maxCountNum},
|
||||
#{item.suspendNum}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
@ -16,20 +16,23 @@
|
||||
<result column="task_type" jdbcType="TINYINT" property="taskType"/>
|
||||
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
, unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, retry_status,
|
||||
create_dt, task_type, namespace_id
|
||||
id, unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, retry_status,
|
||||
create_dt, task_type, namespace_id
|
||||
</sql>
|
||||
|
||||
<!-- 定义批量新增的 SQL 映射 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO retry_task_log (unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name,
|
||||
args_str, ext_attrs, task_type, create_dt, namespace_id)
|
||||
args_str, ext_attrs, task_type, create_dt, namespace_id)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.uniqueId}, #{item.groupName}, #{item.sceneName}, #{item.idempotentId},
|
||||
#{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs},
|
||||
#{item.taskType}, #{item.createDt}, #{item.namespaceId})
|
||||
(
|
||||
#{item.uniqueId}, #{item.groupName}, #{item.sceneName}, #{item.idempotentId},
|
||||
#{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs},
|
||||
#{item.taskType}, #{item.createDt}, #{item.namespaceId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
@ -19,16 +19,23 @@
|
||||
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
|
||||
<result column="update_dt" jdbcType="TIMESTAMP" property="updateDt" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, namespace_id, unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, next_trigger_at, retry_count, retry_status,
|
||||
create_dt, update_dt, task_type
|
||||
</sql>
|
||||
|
||||
<!-- 定义批量新增的 SQL 映射 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO retry_task (namespace_id, unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, next_trigger_at, task_type, retry_status, create_dt)
|
||||
INSERT INTO retry_task (namespace_id, unique_id, group_name, scene_name, idempotent_id, biz_no,
|
||||
executor_name, args_str, ext_attrs, next_trigger_at, task_type, retry_status, create_dt)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.namespaceId}, #{item.uniqueId}, #{item.groupName}, #{item.sceneName}, #{item.idempotentId}, #{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs}, #{item.nextTriggerAt}, #{item.taskType}, #{item.retryStatus}, #{item.createDt})
|
||||
(
|
||||
#{item.namespaceId}, #{item.uniqueId}, #{item.groupName}, #{item.sceneName}, #{item.idempotentId},
|
||||
#{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs}, #{item.nextTriggerAt},
|
||||
#{item.taskType}, #{item.retryStatus}, #{item.createDt}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
|
||||
<result column="update_dt" jdbcType="TIMESTAMP" property="updateDt" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, scene_name, group_name, scene_status, max_retry_count, back_off, trigger_interval, deadline_request, description, create_dt, update_dt
|
||||
</sql>
|
||||
|
@ -13,13 +13,13 @@
|
||||
|
||||
<update id="updateMaxIdByCustomStep">
|
||||
UPDATE sequence_alloc
|
||||
SET max_id = max_id + #{step}, update_dt = now()
|
||||
WHERE group_name = #{groupName} and namespace_id = #{namespaceId}
|
||||
SET max_id = max_id + #{step}, update_dt = CURRENT_TIMESTAMP
|
||||
WHERE group_name = #{groupName} AND namespace_id = #{namespaceId}
|
||||
</update>
|
||||
|
||||
<update id="updateMaxId">
|
||||
UPDATE sequence_alloc
|
||||
SET max_id = max_id + step, update_dt = now()
|
||||
WHERE group_name = #{groupName} and namespace_id = #{namespaceId}
|
||||
SET max_id = max_id + step, update_dt = CURRENT_TIMESTAMP
|
||||
WHERE group_name = #{groupName} AND namespace_id = #{namespaceId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
@ -47,26 +47,29 @@
|
||||
VALUES
|
||||
<foreach collection="records" item="item" index="index" separator=",">
|
||||
(#{item.namespaceId,jdbcType=VARCHAR}, #{item.groupName,jdbcType=VARCHAR}, #{item.hostId,jdbcType=VARCHAR}, #{item.hostIp,jdbcType=VARCHAR},
|
||||
#{item.hostPort,jdbcType=INTEGER}, #{item.expireAt,jdbcType=TIMESTAMP}, #{item.nodeType,jdbcType=TINYINT},
|
||||
#{item.extAttrs,jdbcType=VARCHAR}, #{item.contextPath,jdbcType=VARCHAR}, #{item.createDt,jdbcType=TIMESTAMP})
|
||||
#{item.hostPort,jdbcType=INTEGER}, #{item.expireAt,jdbcType=TIMESTAMP}, #{item.nodeType,jdbcType=TINYINT},
|
||||
#{item.extAttrs,jdbcType=VARCHAR}, #{item.contextPath,jdbcType=VARCHAR}, #{item.createDt,jdbcType=TIMESTAMP})
|
||||
</foreach>
|
||||
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByExpireAt">
|
||||
delete
|
||||
from server_node
|
||||
where expire_at <= #{endTime,jdbcType=TIMESTAMP}
|
||||
DELETE
|
||||
FROM server_node
|
||||
WHERE expire_at <= #{endTime,jdbcType=TIMESTAMP}
|
||||
</delete>
|
||||
|
||||
<select id="countActivePod"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.ActivePodQuantityResponseDO">
|
||||
SELECT node_type as nodeType, count(*) as total
|
||||
from server_node where namespace_id in
|
||||
<foreach collection="namespaceIds" item="namespaceId" separator="," open="(" close=")">
|
||||
#{namespaceId}
|
||||
</foreach>
|
||||
GROUP BY node_type
|
||||
SELECT
|
||||
node_type AS nodeType,
|
||||
COUNT(*) AS total
|
||||
FROM server_node
|
||||
WHERE namespace_id IN
|
||||
<foreach collection="namespaceIds" item="namespaceId" separator="," open="(" close=")">
|
||||
#{namespaceId}
|
||||
</foreach>
|
||||
GROUP BY node_type
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@ -28,8 +28,7 @@
|
||||
) src
|
||||
ON (dest.id = src.id)
|
||||
WHEN MATCHED THEN
|
||||
UPDATE SET dest.next_trigger_at = src.next_trigger_at
|
||||
UPDATE SET
|
||||
dest.next_trigger_at = src.next_trigger_at
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
@ -16,31 +16,33 @@
|
||||
<result column="deleted" property="deleted"/>
|
||||
<result column="ext_attrs" property="extAttrs"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectWorkflowBatchPageList"
|
||||
parameterType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.WorkflowBatchQueryDO"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.WorkflowBatchResponseDO">
|
||||
SELECT a.*, b.workflow_name
|
||||
FROM workflow_task_batch a join workflow b on a.workflow_id = b.id
|
||||
FROM workflow_task_batch a
|
||||
JOIN workflow b ON a.workflow_id = b.id
|
||||
<where>
|
||||
a.namespace_id = #{queryDO.namespaceId}
|
||||
<if test="queryDO.workflowId != null">
|
||||
and a.workflow_id = #{queryDO.workflowId}
|
||||
AND a.workflow_id = #{queryDO.workflowId}
|
||||
</if>
|
||||
<if test="queryDO.groupNames != null and queryDO.groupNames.size > 0">
|
||||
and a.group_name IN
|
||||
AND a.group_name IN
|
||||
<foreach collection="queryDO.groupNames" item="groupName" open="(" separator="," close=")">
|
||||
#{groupName}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="queryDO.taskBatchStatus != null">
|
||||
and task_batch_status = #{queryDO.taskBatchStatus}
|
||||
AND task_batch_status = #{queryDO.taskBatchStatus}
|
||||
</if>
|
||||
<if test="queryDO.workflowName != null">
|
||||
and b.workflow_name like #{queryDO.workflowName}
|
||||
AND b.workflow_name LIKE #{queryDO.workflowName}
|
||||
</if>
|
||||
and a.deleted = 0
|
||||
order by a.id desc
|
||||
AND a.deleted = 0
|
||||
</where>
|
||||
ORDER BY a.id DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user