fix(sj_1.1.1): insertBatch提取 insertBatch_Column_List

This commit is contained in:
dhb52 2024-07-18 17:07:17 +08:00
parent dbf031f4cb
commit 71e3595693
9 changed files with 186 additions and 233 deletions

View File

@ -2,38 +2,30 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aizuda.snailjob.template.datasource.persistence.mapper.JobLogMessageMapper">
<sql id="insertBatch_Column_List">
#{item.namespaceId},
#{item.groupName},
#{item.jobId},
#{item.taskBatchId},
#{item.taskId},
#{item.logNum},
#{item.message},
#{item.createDt},
#{item.realTime}
</sql>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false">
INSERT INTO sj_job_log_message (namespace_id, group_name, job_id, task_batch_id, task_id,
log_num, message, create_dt, real_time)
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@notOracle()">
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 collection="list" item="item" open="(" separator="," close=")">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@isOracle()">
<foreach collection="list" item="item" separator="UNION ALL">
SELECT
#{item.namespaceId},
#{item.groupName},
#{item.jobId},
#{item.taskBatchId},
#{item.taskId},
#{item.logNum},
#{item.message},
#{item.createDt},
#{item.realTime}
FROM DUAL
<foreach collection="list" item="item" open="SELECT" separator="UNION ALL" close="FROM DUAL">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
</insert>

View File

@ -2,44 +2,33 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aizuda.snailjob.template.datasource.persistence.mapper.JobSummaryMapper">
<sql id="insertBatch_Column_List">
#{item.namespaceId},
#{item.groupName},
#{item.businessId},
#{item.triggerAt},
#{item.systemTaskType},
#{item.successNum},
#{item.failNum},
#{item.failReason},
#{item.stopNum},
#{item.stopReason},
#{item.cancelNum},
#{item.cancelReason}
</sql>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false">
INSERT INTO sj_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)
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@notOracle()">
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 collection="list" item="item" open="(" separator="," close=")">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@isOracle()">
<foreach collection="list" item="item" separator="UNION ALL">
SELECT
#{item.namespaceId},
#{item.groupName},
#{item.businessId},
#{item.triggerAt},
#{item.systemTaskType},
#{item.successNum},
#{item.failNum},
#{item.failReason},
#{item.stopNum},
#{item.stopReason},
#{item.cancelNum},
#{item.cancelReason}
FROM DUAL
<foreach collection="list" item="item" open="SELECT" separator="UNION ALL" close="FROM DUAL">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
</insert>

View File

@ -2,33 +2,42 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aizuda.snailjob.template.datasource.persistence.mapper.JobTaskMapper">
<!-- 定义批量新增的 SQL 映射 -->
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
<sql id="insertBatch_Column_List" >
#{item.namespaceId},
#{item.groupName},
#{item.jobId},
#{item.taskBatchId},
#{item.parentId},
#{item.taskStatus},
#{item.retryCount},
#{item.mrStage},
#{item.leaf},
#{item.taskName},
#{item.clientInfo},
#{item.wfContext},
#{item.argsStr},
#{item.resultMessage},
#{item.argsType},
#{item.extAttrs},
#{item.createDt},
#{item.updateDt}
</sql>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false">
INSERT INTO sj_job_task (namespace_id, group_name, job_id, task_batch_id, parent_id, task_status,
retry_count, mr_stage, leaf, task_name, client_info, wf_context, args_str, result_message, args_type, ext_attrs,
create_dt, update_dt)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.namespaceId},
#{item.groupName},
#{item.jobId},
#{item.taskBatchId},
#{item.parentId},
#{item.taskStatus},
#{item.retryCount},
#{item.mrStage},
#{item.leaf},
#{item.taskName},
#{item.clientInfo},
#{item.wfContext},
#{item.argsStr},
#{item.resultMessage},
#{item.argsType},
#{item.extAttrs},
#{item.createDt},
#{item.updateDt}
)
</foreach>
retry_count, mr_stage, leaf, task_name, client_info, wf_context, args_str,
result_message, args_type, ext_attrs, create_dt, update_dt)
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@notOracle()">
VALUES
<foreach collection="list" item="item" open="(" separator="," close=")">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@isOracle()">
<foreach collection="list" item="item" open="SELECT" separator="UNION ALL" close="FROM DUAL">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
</insert>
</mapper>

View File

@ -2,43 +2,34 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aizuda.snailjob.template.datasource.persistence.mapper.RetryDeadLetterMapper">
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false">
INSERT INTO sj_retry_dead_letter (namespace_id, unique_id, group_name, scene_name,
idempotent_id, biz_no, executor_name, args_str,
ext_attrs, create_dt)
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@notOracle()">
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.namespaceId,jdbcType=VARCHAR},
#{item.uniqueId,jdbcType=VARCHAR},
#{item.groupName,jdbcType=VARCHAR},
#{item.sceneName,jdbcType=VARCHAR},
#{item.idempotentId,jdbcType=VARCHAR},
#{item.bizNo,jdbcType=VARCHAR},
#{item.executorName,jdbcType=VARCHAR},
#{item.argsStr,jdbcType=VARCHAR},
#{item.extAttrs,jdbcType=VARCHAR},
#{item.createDt,jdbcType=TIMESTAMP}
)
</foreach>
</if>
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@isOracle()">
<foreach collection="retryDeadLetters" item="retryDeadLetter" separator="UNION ALL">
SELECT
#{item.namespaceId,jdbcType=VARCHAR},
#{item.uniqueId,jdbcType=VARCHAR},
#{item.groupName,jdbcType=VARCHAR},
#{item.sceneName,jdbcType=VARCHAR},
#{item.idempotentId,jdbcType=VARCHAR},
#{item.bizNo,jdbcType=VARCHAR},
#{item.executorName,jdbcType=VARCHAR},
#{item.argsStr,jdbcType=VARCHAR},
#{item.extAttrs,jdbcType=VARCHAR},
#{item.createDt,jdbcType=TIMESTAMP}
FROM DUAL
</foreach>
</if>
</insert>
<sql id="insertBatch_Column_List">
#{item.namespaceId,jdbcType=VARCHAR},
#{item.uniqueId,jdbcType=VARCHAR},
#{item.groupName,jdbcType=VARCHAR},
#{item.sceneName,jdbcType=VARCHAR},
#{item.idempotentId,jdbcType=VARCHAR},
#{item.bizNo,jdbcType=VARCHAR},
#{item.executorName,jdbcType=VARCHAR},
#{item.argsStr,jdbcType=VARCHAR},
#{item.extAttrs,jdbcType=VARCHAR},
#{item.createDt,jdbcType=TIMESTAMP}
</sql>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false">
INSERT INTO sj_retry_dead_letter (namespace_id, unique_id, group_name, scene_name,
idempotent_id, biz_no, executor_name, args_str,
ext_attrs, create_dt)
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@notOracle()">
VALUES
<foreach collection="list" item="item" open="(" separator="," close=")">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@isOracle()">
<foreach collection="list" item="item" open="SELECT" separator="UNION ALL" close="FROM DUAL">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
</insert>
</mapper>

View File

@ -2,39 +2,31 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aizuda.snailjob.template.datasource.persistence.mapper.RetrySummaryMapper">
<sql id="insertBatch_Column_List">
#{item.namespaceId},
#{item.groupName},
#{item.sceneName},
#{item.triggerAt},
#{item.runningNum},
#{item.finishNum},
#{item.maxCountNum},
#{item.suspendNum}
</sql>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false">
INSERT INTO sj_retry_summary (namespace_id, group_name, scene_name, trigger_at,
running_num, finish_num, max_count_num, suspend_num)
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@notOracle()">
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.namespaceId},
#{item.groupName},
#{item.sceneName},
#{item.triggerAt},
#{item.runningNum},
#{item.finishNum},
#{item.maxCountNum},
#{item.suspendNum}
)
<foreach collection="list" item="item" open="(" separator="," close=")">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@isOracle()">
<foreach collection="list" item="item" separator="UNION ALL">
SELECT
#{item.namespaceId},
#{item.groupName},
#{item.sceneName},
#{item.triggerAt},
#{item.runningNum},
#{item.finishNum},
#{item.maxCountNum},
#{item.suspendNum}
FROM DUAL
<foreach collection="list" item="item" open="SELECT" separator="UNION ALL" close="FROM DUAL">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
</insert>
<select id="selectRetryTaskList"

View File

@ -2,26 +2,32 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aizuda.snailjob.template.datasource.persistence.mapper.RetryTaskLogMapper">
<sql id="insertBatch_Column_List">
#{item.uniqueId},
#{item.groupName},
#{item.sceneName},
#{item.idempotentId},
#{item.bizNo},
#{item.executorName},
#{item.argsStr},
#{item.extAttrs},
#{item.taskType},
#{item.createDt},
#{item.namespaceId}
</sql>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false">
INSERT INTO sj_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)
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@notOracle()">
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}
)
<foreach collection="list" item="item" open="(" separator="," close=")">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@isOracle()">
<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 collection="list" item="item" open="SELECT" separator="UNION ALL" close="FROM DUAL">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
</insert>

View File

@ -2,34 +2,28 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aizuda.snailjob.template.datasource.persistence.mapper.RetryTaskLogMessageMapper">
<sql id="insertBatch_Column_List">
#{item.namespaceId},
#{item.groupName},
#{item.uniqueId},
#{item.logNum},
#{item.message},
#{item.createDt},
#{item.realTime}
</sql>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false">
INSERT INTO sj_retry_task_log_message (namespace_id, group_name, unique_id, log_num, message,
create_dt, real_time)
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@notOracle()">
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" open="(" separator="," close=")">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@isOracle()">
<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 collection="list" item="item" open="SELECT" separator="UNION ALL" close="FROM DUAL">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
</insert>

View File

@ -2,47 +2,35 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aizuda.snailjob.template.datasource.persistence.mapper.RetryTaskMapper">
<sql id="insertBatch_Column_List">
#{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}
</sql>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false">
INSERT INTO sj_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)
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@notOracle()">
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}
)
VALUES
<foreach collection="list" item="item" open="(" separator="," close=")">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@isOracle()">
<foreach collection="list" item="item" separator="UNION ALL">
SELECT
#{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 collection="list" item="item" open="SELECT" separator="UNION ALL" close="FROM DUAL">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
</insert>

View File

@ -2,38 +2,30 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aizuda.snailjob.template.datasource.persistence.mapper.ServerNodeMapper">
<sql id="insertBatch_Column_List" >
#{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.createDt,jdbcType=TIMESTAMP}
</sql>
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="false">
INSERT INTO sj_server_node (namespace_id, group_name, host_id, host_ip, host_port,
expire_at, node_type, ext_attrs, create_dt)
VALUES
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@notOracle()">
<foreach collection="list" 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.createDt,jdbcType=TIMESTAMP}
)
VALUES
<foreach collection="list" item="item" open="(" separator="," close=")">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@isOracle()">
<foreach collection="list" item="item" index="index" separator="UNION ALL">
SELECT
#{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.createDt,jdbcType=TIMESTAMP}
FROM DUAL
<foreach collection="list" item="item" open="SELECT" separator="UNION ALL" close="FROM DUAL">
<include refid="insertBatch_Column_List" />
</foreach>
</if>
</insert>