fix: 实现batchInsert、batchUpdate, 格式化mapper.xml

This commit is contained in:
dhb52 2024-04-03 16:21:58 +08:00
parent 0ebeeda840
commit 27ac845c5e
46 changed files with 513 additions and 455 deletions

View File

@ -1,30 +1,33 @@
<?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.JobNotifyConfigMapper">
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.JobNotifyConfig">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="namespace_id" jdbcType="VARCHAR" property="namespaceId" />
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="job_id" jdbcType="BIGINT" property="jobId" />
<result column="notify_status" jdbcType="TINYINT" property="notifyStatus" />
<result column="notify_type" jdbcType="TINYINT" property="notifyType" />
<result column="notify_attribute" jdbcType="VARCHAR" property="notifyAttribute" />
<result column="notify_threshold" jdbcType="TINYINT" property="notifyThreshold" />
<result column="notify_scene" jdbcType="TINYINT" property="notifyScene" />
<result column="rate_limiter_status" jdbcType="TINYINT" property="rateLimiterStatus" />
<result column="rate_limiter_threshold" jdbcType="TINYINT" property="rateLimiterThreshold" />
<result column="description" jdbcType="VARCHAR" property="description" />
<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, group_name,job_id,notify_status,notify_type, notify_attribute, notify_threshold, notify_scene,rate_limiter_status,rate_limiter_threshold, description,
create_dt, update_dt
</sql>
<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
${ew.customSqlSegment}
</select>
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.JobNotifyConfig">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="namespace_id" jdbcType="VARCHAR" property="namespaceId" />
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="job_id" jdbcType="BIGINT" property="jobId" />
<result column="notify_status" jdbcType="TINYINT" property="notifyStatus" />
<result column="notify_type" jdbcType="TINYINT" property="notifyType" />
<result column="notify_attribute" jdbcType="VARCHAR" property="notifyAttribute" />
<result column="notify_threshold" jdbcType="TINYINT" property="notifyThreshold" />
<result column="notify_scene" jdbcType="TINYINT" property="notifyScene" />
<result column="rate_limiter_status" jdbcType="TINYINT" property="rateLimiterStatus" />
<result column="rate_limiter_threshold" jdbcType="TINYINT" property="rateLimiterThreshold" />
<result column="description" jdbcType="VARCHAR" property="description" />
<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, group_name,job_id,notify_status,notify_type, notify_attribute, notify_threshold,
notify_scene, rate_limiter_status, rate_limiter_threshold, description, create_dt, update_dt
</sql>
<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
${ew.customSqlSegment}
</select>
</mapper>

View File

@ -13,11 +13,17 @@
<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
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
${ew.customSqlSegment}
</select>
@ -55,8 +61,15 @@
<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
${ew.customSqlSegment}
</select>
</mapper>

View File

@ -1,20 +1,21 @@
<?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.NotifyConfigMapper">
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.NotifyConfig">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="notify_type" jdbcType="TINYINT" property="notifyType" />
<result column="notify_attribute" jdbcType="VARCHAR" property="notifyAttribute" />
<result column="notify_threshold" jdbcType="TINYINT" property="notifyThreshold" />
<result column="notify_scene" jdbcType="TINYINT" property="notifyScene" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
<result column="update_dt" jdbcType="TIMESTAMP" property="updateDt" />
</resultMap>
<sql id="Base_Column_List">
id, group_name, notify_type, notify_attribute, notify_threshold, notify_scene, description,
create_dt, update_dt
</sql>
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.NotifyConfig">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="notify_type" jdbcType="TINYINT" property="notifyType" />
<result column="notify_attribute" jdbcType="VARCHAR" property="notifyAttribute" />
<result column="notify_threshold" jdbcType="TINYINT" property="notifyThreshold" />
<result column="notify_scene" jdbcType="TINYINT" property="notifyScene" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
<result column="update_dt" jdbcType="TIMESTAMP" property="updateDt" />
</resultMap>
<sql id="Base_Column_List">
id, group_name, notify_type, notify_attribute, notify_threshold, notify_scene, description,
create_dt, update_dt
</sql>
</mapper>

View File

@ -1,20 +1,22 @@
<?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.SceneConfigMapper">
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.SceneConfig">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="scene_name" jdbcType="VARCHAR" property="sceneName" />
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="scene_status" jdbcType="TINYINT" property="sceneStatus" />
<result column="max_retry_count" jdbcType="TINYINT" property="maxRetryCount" />
<result column="back_off" jdbcType="TINYINT" property="backOff" />
<result column="trigger_interval" jdbcType="TINYINT" property="triggerInterval" />
<result column="deadline_request" jdbcType="BIGINT" property="deadlineRequest" />
<result column="description" jdbcType="VARCHAR" property="description" />
<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>
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.SceneConfig">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="scene_name" jdbcType="VARCHAR" property="sceneName" />
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="scene_status" jdbcType="TINYINT" property="sceneStatus" />
<result column="max_retry_count" jdbcType="TINYINT" property="maxRetryCount" />
<result column="back_off" jdbcType="TINYINT" property="backOff" />
<result column="trigger_interval" jdbcType="TINYINT" property="triggerInterval" />
<result column="deadline_request" jdbcType="BIGINT" property="deadlineRequest" />
<result column="description" jdbcType="VARCHAR" property="description" />
<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>
</mapper>

View File

@ -16,11 +16,14 @@
<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
SELECT a.*,
b.workflow_name
FROM workflow_task_batch a
JOIN workflow b ON a.workflow_id = b.id
${ew.customSqlSegment}
</select>

View File

@ -18,18 +18,8 @@
<!-- 定义批量新增的 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
)
INSERT INTO job_log_message (namespace_id, group_name, job_id, task_batch_id, task_id,
log_num, message, create_dt, real_time)
VALUES
<foreach collection="list" item="item" separator=",">
(

View File

@ -29,7 +29,7 @@
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
UPDATE job rt,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id

View File

@ -44,7 +44,7 @@
<update id="batchUpdate" parameterType="java.util.List">
UPDATE job_summary rt,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.successNum} AS success_num,
#{item.failNum} AS fail_num,

View File

@ -36,19 +36,19 @@
<update id="batchUpdate" parameterType="java.util.List">
UPDATE retry_summary rt,
(
<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>
) tt
(
<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>
) tt
SET rt.running_num = tt.running_num,
rt.finish_num = tt.finish_num,
rt.max_count_num = tt.max_count_num,

View File

@ -12,6 +12,7 @@
<result column="message" property="message"/>
<result column="real_time" property="realTime"/>
</resultMap>
<!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO retry_task_log_message (namespace_id, group_name, unique_id, log_num, message,
@ -32,16 +33,16 @@
<update id="batchUpdate" parameterType="java.util.List">
UPDATE retry_task_log_message jlm,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT
#{item.message} AS message,
#{item.logNum} AS log_num,
#{item.id} AS id
</foreach>
) tt
SET jlm.message = tt.message, jlm.log_num = tt.log_num
WHERE jlm.id = tt.id
(
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.message} AS message,
#{item.logNum} AS log_num,
#{item.id} AS id
</foreach>
) tt
SET jlm.message = tt.message, jlm.log_num = tt.log_num
WHERE jlm.id = tt.id
</update>
</mapper>

View File

@ -1,46 +1,63 @@
<?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.RetryTaskMapper">
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.RetryTask">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="namespace_id" jdbcType="VARCHAR" property="namespaceId"/>
<result column="unique_id" jdbcType="VARCHAR" property="uniqueId"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="scene_name" jdbcType="VARCHAR" property="sceneName" />
<result column="idempotent_id" jdbcType="VARCHAR" property="idempotentId" />
<result column="biz_no" jdbcType="VARCHAR" property="bizNo" />
<result column="executor_name" jdbcType="VARCHAR" property="executorName" />
<result column="args_str" jdbcType="VARCHAR" property="argsStr" />
<result column="ext_attrs" jdbcType="VARCHAR" property="extAttrs" />
<result column="next_trigger_at" jdbcType="TIMESTAMP" property="nextTriggerAt" />
<result column="retry_count" jdbcType="TINYINT" property="retryCount" />
<result column="retry_status" jdbcType="TINYINT" property="retryStatus" />
<result column="task_type" jdbcType="TINYINT" property="taskType"/>
<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)
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})
</foreach>
</insert>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
UPDATE retry_task_${partition} rt,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.RetryTask">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="namespace_id" jdbcType="VARCHAR" property="namespaceId"/>
<result column="unique_id" jdbcType="VARCHAR" property="uniqueId"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="scene_name" jdbcType="VARCHAR" property="sceneName" />
<result column="idempotent_id" jdbcType="VARCHAR" property="idempotentId" />
<result column="biz_no" jdbcType="VARCHAR" property="bizNo" />
<result column="executor_name" jdbcType="VARCHAR" property="executorName" />
<result column="args_str" jdbcType="VARCHAR" property="argsStr" />
<result column="ext_attrs" jdbcType="VARCHAR" property="extAttrs" />
<result column="next_trigger_at" jdbcType="TIMESTAMP" property="nextTriggerAt" />
<result column="retry_count" jdbcType="TINYINT" property="retryCount" />
<result column="retry_status" jdbcType="TINYINT" property="retryStatus" />
<result column="task_type" jdbcType="TINYINT" property="taskType"/>
<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)
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}
)
</foreach>
) tt
SET rt.next_trigger_at = tt.next_trigger_at
WHERE rt.id = tt.id
</update>
</insert>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
UPDATE retry_task_${partition} rt,
(
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id
</foreach>
) tt
SET rt.next_trigger_at = tt.next_trigger_at
WHERE rt.id = tt.id
</update>
</mapper>

View File

@ -44,7 +44,7 @@
<update id="batchUpdateExpireAt" parameterType="java.util.List">
UPDATE server_node rt,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.expireAt} AS expire_at,
#{item.contextPath} AS context_path,

View File

@ -18,15 +18,15 @@
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
UPDATE workflow rt,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id
</foreach>
) tt
SET rt.next_trigger_at = tt.next_trigger_at
WHERE rt.id = tt.id
(
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id
</foreach>
) tt
SET rt.next_trigger_at = tt.next_trigger_at
WHERE rt.id = tt.id
</update>
</mapper>

View File

@ -18,18 +18,8 @@
<!-- 定义批量新增的 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
)
INSERT INTO job_log_message (namespace_id, group_name, job_id, task_batch_id, task_id,
log_num, message, create_dt, real_time)
VALUES
<foreach collection="list" item="item" separator=",">
(

View File

@ -29,7 +29,7 @@
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
UPDATE job rt,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id

View File

@ -44,7 +44,7 @@
<update id="batchUpdate" parameterType="java.util.List">
UPDATE job_summary rt,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.successNum} AS success_num,
#{item.failNum} AS fail_num,

View File

@ -36,19 +36,19 @@
<update id="batchUpdate" parameterType="java.util.List">
UPDATE retry_summary rt,
(
<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>
) tt
(
<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>
) tt
SET rt.running_num = tt.running_num,
rt.finish_num = tt.finish_num,
rt.max_count_num = tt.max_count_num,

View File

@ -12,6 +12,7 @@
<result column="message" property="message"/>
<result column="real_time" property="realTime"/>
</resultMap>
<!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO retry_task_log_message (namespace_id, group_name, unique_id, log_num, message,
@ -32,16 +33,16 @@
<update id="batchUpdate" parameterType="java.util.List">
UPDATE retry_task_log_message jlm,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT
#{item.message} AS message,
#{item.logNum} AS log_num,
#{item.id} AS id
</foreach>
) tt
SET jlm.message = tt.message, jlm.log_num = tt.log_num
WHERE jlm.id = tt.id
(
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.message} AS message,
#{item.logNum} AS log_num,
#{item.id} AS id
</foreach>
) tt
SET jlm.message = tt.message, jlm.log_num = tt.log_num
WHERE jlm.id = tt.id
</update>
</mapper>

View File

@ -1,46 +1,63 @@
<?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.RetryTaskMapper">
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.RetryTask">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="namespace_id" jdbcType="VARCHAR" property="namespaceId"/>
<result column="unique_id" jdbcType="VARCHAR" property="uniqueId"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="scene_name" jdbcType="VARCHAR" property="sceneName" />
<result column="idempotent_id" jdbcType="VARCHAR" property="idempotentId" />
<result column="biz_no" jdbcType="VARCHAR" property="bizNo" />
<result column="executor_name" jdbcType="VARCHAR" property="executorName" />
<result column="args_str" jdbcType="VARCHAR" property="argsStr" />
<result column="ext_attrs" jdbcType="VARCHAR" property="extAttrs" />
<result column="next_trigger_at" jdbcType="TIMESTAMP" property="nextTriggerAt" />
<result column="retry_count" jdbcType="TINYINT" property="retryCount" />
<result column="retry_status" jdbcType="TINYINT" property="retryStatus" />
<result column="task_type" jdbcType="TINYINT" property="taskType"/>
<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)
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})
</foreach>
</insert>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
UPDATE retry_task_${partition} rt,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.RetryTask">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="namespace_id" jdbcType="VARCHAR" property="namespaceId"/>
<result column="unique_id" jdbcType="VARCHAR" property="uniqueId"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="scene_name" jdbcType="VARCHAR" property="sceneName" />
<result column="idempotent_id" jdbcType="VARCHAR" property="idempotentId" />
<result column="biz_no" jdbcType="VARCHAR" property="bizNo" />
<result column="executor_name" jdbcType="VARCHAR" property="executorName" />
<result column="args_str" jdbcType="VARCHAR" property="argsStr" />
<result column="ext_attrs" jdbcType="VARCHAR" property="extAttrs" />
<result column="next_trigger_at" jdbcType="TIMESTAMP" property="nextTriggerAt" />
<result column="retry_count" jdbcType="TINYINT" property="retryCount" />
<result column="retry_status" jdbcType="TINYINT" property="retryStatus" />
<result column="task_type" jdbcType="TINYINT" property="taskType"/>
<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)
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}
)
</foreach>
) tt
SET rt.next_trigger_at = tt.next_trigger_at
WHERE rt.id = tt.id
</update>
</insert>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
UPDATE retry_task_${partition} rt,
(
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id
</foreach>
) tt
SET rt.next_trigger_at = tt.next_trigger_at
WHERE rt.id = tt.id
</update>
</mapper>

View File

@ -44,7 +44,7 @@
<update id="batchUpdateExpireAt" parameterType="java.util.List">
UPDATE server_node rt,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.expireAt} AS expire_at,
#{item.contextPath} AS context_path,

View File

@ -18,15 +18,15 @@
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
UPDATE workflow rt,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id
</foreach>
) tt
SET rt.next_trigger_at = tt.next_trigger_at
WHERE rt.id = tt.id
(
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id
</foreach>
) tt
SET rt.next_trigger_at = tt.next_trigger_at
WHERE rt.id = tt.id
</update>
</mapper>

View File

@ -18,21 +18,10 @@
<!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List">
INSERT ALL
<foreach collection="list" item="item" separator="">
INTO job_log_message
(
namespace_id,
group_name,
job_id,
task_batch_id,
task_id,
log_num,
message,
create_dt,
real_time
)
VALUES (
INSERT INTO job_log_message (namespace_id, group_name, job_id, task_batch_id, task_id,
log_num, message, create_dt, real_time)
<foreach collection="list" item="item" separator="UNION ALL">
SELECT
#{item.namespaceId},
#{item.groupName},
#{item.jobId},
@ -42,8 +31,7 @@
#{item.message},
#{item.createDt},
#{item.realTime}
)
FROM DUAL
</foreach>
SELECT * FROM DUAL
</insert>
</mapper>

View File

@ -27,18 +27,11 @@
</resultMap>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
MERGE INTO job dest
USING (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id
FROM DUAL
</foreach>
) src
ON (dest.id = src.id)
WHEN MATCHED THEN
UPDATE SET dest.next_trigger_at = src.next_trigger_at
<foreach collection="list" item="item" open="BEGIN" separator=";" close=";END;">
UPDATE job
SET next_trigger_at = #{item.nextTriggerAt}
WHERE id = #{item.id}
</foreach>
</update>
</mapper>

View File

@ -22,7 +22,7 @@
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="false" 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)
<foreach collection="list" item="item" separator=" UNION ALL ">
<foreach collection="list" item="item" separator="UNION ALL">
SELECT
#{item.namespaceId},
#{item.groupName},
@ -91,21 +91,19 @@
<select id="dashboardRank"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
SELECT * FROM
(
SELECT
<if test="systemTaskType == 3">
group_name || '/' || (SELECT job_name FROM job WHERE id = business_id) AS name,
</if>
<if test="systemTaskType == 4">
group_name || '/' || (SELECT workflow_name FROM workflow WHERE id = business_id) AS name,
</if>
SUM(fail_num) AS total
FROM job_summary
${ew.customSqlSegment}
HAVING SUM(fail_num) > 0
ORDER BY total DESC
)
SELECT * FROM (
SELECT
<if test="systemTaskType == 3">
group_name || '/' || (SELECT job_name FROM job WHERE id = business_id) AS name,
</if>
<if test="systemTaskType == 4">
group_name || '/' || (SELECT workflow_name FROM workflow WHERE id = business_id) AS name,
</if>
SUM(fail_num) AS total
FROM job_summary
${ew.customSqlSegment}
HAVING SUM(fail_num) > 0
ORDER BY total DESC)
WHERE ROWNUM <![CDATA[ <= ]]> 10
</select>

View File

@ -1,46 +1,45 @@
<?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.RetryDeadLetterMapper">
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.RetryDeadLetter">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="namespace_id" jdbcType="VARCHAR" property="namespaceId"/>
<result column="unique_id" jdbcType="VARCHAR" property="uniqueId"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="scene_name" jdbcType="VARCHAR" property="sceneName" />
<result column="idempotent_id" jdbcType="VARCHAR" property="idempotentId" />
<result column="biz_no" jdbcType="VARCHAR" property="bizNo" />
<result column="executor_name" jdbcType="VARCHAR" property="executorName" />
<result column="args_str" jdbcType="VARCHAR" property="argsStr" />
<result column="ext_attrs" jdbcType="VARCHAR" property="extAttrs" />
<result column="task_type" jdbcType="TINYINT" property="taskType"/>
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
</resultMap>
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.RetryDeadLetter">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="namespace_id" jdbcType="VARCHAR" property="namespaceId"/>
<result column="unique_id" jdbcType="VARCHAR" property="uniqueId"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="scene_name" jdbcType="VARCHAR" property="sceneName" />
<result column="idempotent_id" jdbcType="VARCHAR" property="idempotentId" />
<result column="biz_no" jdbcType="VARCHAR" property="bizNo" />
<result column="executor_name" jdbcType="VARCHAR" property="executorName" />
<result column="args_str" jdbcType="VARCHAR" property="argsStr" />
<result column="ext_attrs" jdbcType="VARCHAR" property="extAttrs" />
<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>
<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 ALL
<foreach collection="retryDeadLetters" item="retryDeadLetter" separator="">
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 (
#{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>
SELECT * FROM DUAL
</insert>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false" keyProperty="id">
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)
<foreach collection="retryDeadLetters" item="retryDeadLetter" separator="UNION ALL">
SELECT
#{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}
FROM DUAL
</foreach>
</insert>
<select id="countRetryDeadLetterByCreateAt" resultType="int">
SELECT COUNT(*)
FROM retry_dead_letter_${partition}
WHERE create_dt BETWEEN #{startTime} AND #{endTime}
</select>
<select id="countRetryDeadLetterByCreateAt" resultType="int">
SELECT COUNT(*)
FROM retry_dead_letter_${partition}
WHERE create_dt BETWEEN #{startTime} AND #{endTime}
</select>
</mapper>

View File

@ -94,16 +94,14 @@
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
SELECT
*
FROM
(
FROM (
SELECT
group_name || '/' || scene_name AS name,
SUM(running_num + finish_num + max_count_num + suspend_num) AS total
FROM retry_summary
${ew.customSqlSegment}
HAVING SUM(running_num + finish_num + max_count_num + suspend_num) > 0
ORDER BY SUM(running_num + finish_num + max_count_num + suspend_num) DESC
)
ORDER BY SUM(running_num + finish_num + max_count_num + suspend_num) DESC)
WHERE ROWNUM <![CDATA[ <= ]]> 10
</select>

View File

@ -23,18 +23,16 @@
</sql>
<!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List">
INSERT ALL
<foreach collection="list" item="item" separator="">
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)
VALUES (
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="false" keyProperty="id">
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)
<foreach collection="list" item="item" separator="UNION ALL">
SELECT
#{item.uniqueId}, #{item.groupName}, #{item.sceneName}, #{item.idempotentId},
#{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs},
#{item.taskType}, #{item.createDt}, #{item.namespaceId}
)
FROM DUAL
</foreach>
SELECT * FROM DUAL
</insert>
<!-- 重试统计 -->

View File

@ -11,4 +11,28 @@
<result column="message" property="message" />
</resultMap>
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO retry_task_log_message (namespace_id, group_name, unique_id, log_num, message,
create_dt, real_time)
<foreach collection="list" item="item" separator="UNION ALL">
SELECT
#{item.namespaceId},
#{item.groupName},
#{item.uniqueId},
#{item.logNum},
#{item.message},
#{item.createDt},
#{item.realTime}
FROM DUAL
</foreach>
</insert>
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="BEGIN" separator=";" close=";END;">
UPDATE retry_task_log_message
SET message = #{item.message}, log_num = #{item.logNum}
WHERE id = #{item.id}
</foreach>
</update>
</mapper>

View File

@ -1,57 +1,48 @@
<?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.RetryTaskMapper">
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.RetryTask">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="namespace_id" jdbcType="VARCHAR" property="namespaceId"/>
<result column="unique_id" jdbcType="VARCHAR" property="uniqueId"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="scene_name" jdbcType="VARCHAR" property="sceneName" />
<result column="idempotent_id" jdbcType="VARCHAR" property="idempotentId" />
<result column="biz_no" jdbcType="VARCHAR" property="bizNo" />
<result column="executor_name" jdbcType="VARCHAR" property="executorName" />
<result column="args_str" jdbcType="VARCHAR" property="argsStr" />
<result column="ext_attrs" jdbcType="VARCHAR" property="extAttrs" />
<result column="next_trigger_at" jdbcType="TIMESTAMP" property="nextTriggerAt" />
<result column="retry_count" jdbcType="TINYINT" property="retryCount" />
<result column="retry_status" jdbcType="TINYINT" property="retryStatus" />
<result column="task_type" jdbcType="TINYINT" property="taskType"/>
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
<result column="update_dt" jdbcType="TIMESTAMP" property="updateDt" />
</resultMap>
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.RetryTask">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="namespace_id" jdbcType="VARCHAR" property="namespaceId"/>
<result column="unique_id" jdbcType="VARCHAR" property="uniqueId"/>
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
<result column="scene_name" jdbcType="VARCHAR" property="sceneName" />
<result column="idempotent_id" jdbcType="VARCHAR" property="idempotentId" />
<result column="biz_no" jdbcType="VARCHAR" property="bizNo" />
<result column="executor_name" jdbcType="VARCHAR" property="executorName" />
<result column="args_str" jdbcType="VARCHAR" property="argsStr" />
<result column="ext_attrs" jdbcType="VARCHAR" property="extAttrs" />
<result column="next_trigger_at" jdbcType="TIMESTAMP" property="nextTriggerAt" />
<result column="retry_count" jdbcType="TINYINT" property="retryCount" />
<result column="retry_status" jdbcType="TINYINT" property="retryStatus" />
<result column="task_type" jdbcType="TINYINT" property="taskType"/>
<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 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 ALL
<foreach collection="list" item="item" separator="">
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 (
#{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>
SELECT * FROM DUAL
</insert>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
MERGE INTO retry_task_${partition} dest
USING (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<!-- 定义批量新增的 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)
<foreach collection="list" item="item" separator="UNION ALL">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id
#{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}
FROM DUAL
</foreach>
) src
ON (dest.id = src.id)
WHEN MATCHED THEN
UPDATE SET dest.next_trigger_at = src.next_trigger_at
</update>
</insert>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="BEGIN" separator=";" close=";END;">
UPDATE retry_task_${partition}
SET next_trigger_at = #{item.nextTriggerAt}
WHERE id = #{item.id}
</foreach>
</update>
</mapper>

View File

@ -23,7 +23,7 @@
<!-- useGeneratedKeys="false" 否则报错ORA-00933: SQL command not properly ended -->
INSERT INTO server_node (namespace_id, group_name, host_id, host_ip, host_port,
expire_at, node_type, ext_attrs, context_path, create_dt)
<foreach collection="records" item="item" index="index" separator=" UNION ">
<foreach collection="records" item="item" index="index" separator="UNION ALL">
SELECT
#{item.namespaceId,jdbcType=VARCHAR},
#{item.groupName,jdbcType=VARCHAR},

View File

@ -17,18 +17,10 @@
</resultMap>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
MERGE INTO workflow dest
USING (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id
FROM DUAL
</foreach>
) src
ON (dest.id = src.id)
WHEN MATCHED THEN
UPDATE SET
dest.next_trigger_at = src.next_trigger_at
<foreach collection="list" item="item" open="BEGIN" separator=";" close=";END;">
UPDATE workflow
SET next_trigger_at = #{item.nextTriggerAt}
WHERE id = #{item.id}
</foreach>
</update>
</mapper>

View File

@ -30,7 +30,7 @@
UPDATE job AS rt
SET next_trigger_at = tt.next_trigger_at
FROM (
<foreach collection="list" item="item" index="index" separator=" union all ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
select
#{item.nextTriggerAt} as next_trigger_at,
#{item.id} as id

View File

@ -51,7 +51,7 @@
cancel_num = tt.cancel_num,
cancel_reason = tt.cancel_reason
FROM (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.successNum} AS success_num,
#{item.failNum} AS fail_num,

View File

@ -40,7 +40,7 @@
max_count_num = tt.max_count_num,
suspend_num = tt.suspend_num
FROM (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.runningNum} AS running_num,
#{item.finishNum} AS finish_num,

View File

@ -13,33 +13,33 @@
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO retry_task_log_message (namespace_id, group_name, unique_id, log_num, message,
create_dt, real_time)
create_dt, real_time)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.namespaceId},
#{item.groupName},
#{item.uniqueId},
#{item.logNum},
#{item.message},
#{item.createDt},
#{item.realTime}
)
</foreach>
<foreach collection="list" item="item" separator=",">
(
#{item.namespaceId},
#{item.groupName},
#{item.uniqueId},
#{item.logNum},
#{item.message},
#{item.createDt},
#{item.realTime}
)
</foreach>
</insert>
<update id="batchUpdate" parameterType="java.util.List">
UPDATE retry_task_log_message jlm,
(
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT
#{item.message} AS message,
#{item.logNum} AS log_num,
#{item.id} AS id
</foreach>
) tt
SET jlm.message = tt.message, jlm.log_num = tt.log_num
WHERE jlm.id = tt.id
(
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.message} AS message,
#{item.logNum} AS log_num,
#{item.id} AS id
</foreach>
) tt
SET jlm.message = tt.message, jlm.log_num = tt.log_num
WHERE jlm.id = tt.id
</update>
</mapper>

View File

@ -35,7 +35,7 @@
UPDATE retry_task_${partition} AS rt
SET next_trigger_at = tt.next_trigger_at
FROM (
<foreach collection="list" item="item" index="index" separator=" union all ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
select
#{item.nextTriggerAt} as next_trigger_at,
#{item.id} as id

View File

@ -43,7 +43,7 @@
SET expire_at = tt.expire_at,
context_path = tt.context_path
FROM (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.expireAt} AS expire_at,
#{item.contextPath} AS context_path,

View File

@ -19,7 +19,7 @@
UPDATE workflow AS rt
SET next_trigger_at = tt.next_trigger_at
FROM (
<foreach collection="list" item="item" index="index" separator=" union all ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
select
#{item.nextTriggerAt} as next_trigger_at,
#{item.id} as id

View File

@ -18,31 +18,21 @@
<!-- 定义批量新增的 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
)
INSERT INTO job_log_message (namespace_id, group_name, job_id, task_batch_id, task_id,
log_num, message, 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>

View File

@ -31,7 +31,7 @@
SET next_trigger_at = src.next_trigger_at
FROM job AS dest
JOIN (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id

View File

@ -52,7 +52,7 @@
cancel_reason = src.cancel_reason
FROM job_summary AS dest
JOIN (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.successNum} AS success_num,
#{item.failNum} AS fail_num,

View File

@ -48,7 +48,7 @@
cancel_reason = src.cancel_reason
FROM job_summary AS dest
JOIN (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.successNum} AS success_num,
#{item.failNum} AS fail_num,

View File

@ -0,0 +1,49 @@
<?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.RetryTaskLogMessageMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.RetryTaskLogMessage">
<id column="id" property="id" />
<result column="group_name" property="groupName" />
<result column="unique_id" property="uniqueId" />
<result column="create_dt" property="createDt" />
<result column="log_num" property="logNum"/>
<result column="message" property="message"/>
<result column="real_time" property="realTime"/>
</resultMap>
<!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO retry_task_log_message (namespace_id, group_name, unique_id, log_num, message,
create_dt, real_time)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.namespaceId},
#{item.groupName},
#{item.uniqueId},
#{item.logNum},
#{item.message},
#{item.createDt},
#{item.realTime}
)
</foreach>
</insert>
<update id="batchUpdate" parameterType="java.util.List">
UPDATE retry_task_log_message
SET message = src.message, log_num = src.log_num
FROM retry_task_log_message AS dest
JOIN (
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.message} AS message,
#{item.logNum} AS log_num,
#{item.id} AS id
</foreach>
) AS src
ON dest.id = src.id
</update>
</mapper>

View File

@ -53,7 +53,7 @@
SET target.next_trigger_at = src.next_trigger_at
FROM retry_task_${partition} as target
JOIN (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id

View File

@ -46,7 +46,7 @@
context_path = src.context_path
FROM server_node AS dest
JOIN (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.expireAt} AS expire_at,
#{item.contextPath} AS context_path,

View File

@ -21,7 +21,7 @@
SET workflow.next_trigger_at = src.next_trigger_at
FROM workflow
JOIN (
<foreach collection="list" item="item" index="index" separator=" UNION ALL ">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{item.nextTriggerAt} AS next_trigger_at,
#{item.id} AS id