fix(sj_1.1.1): 批量插入需要使用isOracle/notOracle进行区分

This commit is contained in:
dhb52 2024-07-18 14:52:59 +08:00
parent 158f22f674
commit cfc544e35b
9 changed files with 201 additions and 59 deletions

View File

@ -18,4 +18,11 @@ public class DbUtils {
return DbTypeEnum.modeOf(url);
}
public static boolean isOracle() {
return DbTypeEnum.ORACLE.equals(getDbType());
}
public static boolean notOracle() {
return !DbTypeEnum.ORACLE.equals(getDbType());
}
}

View File

@ -5,7 +5,8 @@
<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)
VALUES
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@notOracle()">
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.namespaceId},
@ -19,6 +20,22 @@
#{item.realTime}
)
</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>
</if>
</insert>
</mapper>

View File

@ -5,23 +5,43 @@
<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)
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>
<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>
</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>
</if>
</insert>
<select id="selectJobTaskList"

View File

@ -5,9 +5,9 @@
<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
)
VALUES
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},
@ -22,6 +22,23 @@
#{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>
</mapper>

View File

@ -5,19 +5,36 @@
<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)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.namespaceId},
#{item.groupName},
#{item.sceneName},
#{item.triggerAt},
#{item.runningNum},
#{item.finishNum},
#{item.maxCountNum},
#{item.suspendNum}
)
</foreach>
<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>
</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>
</if>
</insert>
<select id="selectRetryTaskList"

View File

@ -5,14 +5,25 @@
<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)
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>
<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>
</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>
</if>
</insert>
<!-- 重试统计 -->

View File

@ -5,9 +5,23 @@
<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)
VALUES
<foreach collection="list" item="item" separator=",">
(
<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>
</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},
@ -15,8 +29,9 @@
#{item.message},
#{item.createDt},
#{item.realTime}
)
FROM DUAL
</foreach>
</if>
</insert>
</mapper>

View File

@ -6,6 +6,7 @@
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=",">
(
@ -24,6 +25,26 @@
#{item.createDt}
)
</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>
</if>
</insert>
</mapper>

View File

@ -6,19 +6,36 @@
INSERT INTO sj_server_node (namespace_id, group_name, host_id, host_ip, host_port,
expire_at, node_type, ext_attrs, create_dt)
VALUES
<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}
)
</foreach>
<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}
)
</foreach>
</if>
<if test="@com.aizuda.snailjob.template.datasource.utils.DbUtils@isOracle()">
<foreach collection="records" 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>
</if>
</insert>
<select id="selectActivePodCount"