fix(3.2.0) Dashboard对应mapper函数少参数,用于条件判断

* style: 格式化mysql的SQL文件
* style: 格式化mysql的mapper.xml文件
* fix: Dashboard对应mapper函数少参数,用于条件判断
* fix: `job_summary`表缺`system_task_type`字段
This commit is contained in:
dhb52 2024-03-29 05:37:55 +00:00 committed by byteblogs168
parent 035f468749
commit 8c58aca247
14 changed files with 236 additions and 213 deletions

View File

@ -159,8 +159,8 @@ CREATE TABLE `retry_task_log_message`
`unique_id` varchar(64) NOT NULL COMMENT '同组下id唯一',
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`message` text NOT NULL COMMENT '异常信息',
`log_num` int(11) NOT NULL DEFAULT 1 COMMENT '日志数量',
`real_time` bigint(13) NOT NULL DEFAULT 0 COMMENT '上报时间',
`log_num` int(11) NOT NULL DEFAULT 1 COMMENT '日志数量',
`real_time` bigint(13) NOT NULL DEFAULT 0 COMMENT '上报时间',
`client_info` varchar(128) DEFAULT NULL COMMENT '客户端地址 clientId#ip:port',
PRIMARY KEY (`id`),
KEY `idx_namespace_id_group_name_scene_name` (`namespace_id`, `group_name`, `unique_id`),
@ -380,7 +380,7 @@ CREATE TABLE `job_task_batch`
KEY `idx_job_id_task_batch_status` (`job_id`, `task_batch_status`),
KEY `idx_create_dt` (`create_dt`),
KEY `idx_namespace_id_group_name` (`namespace_id`, `group_name`),
KEY `idx_workflow_task_batch_id_workflow_node_id` (`workflow_task_batch_id`,`workflow_node_id`)
KEY `idx_workflow_task_batch_id_workflow_node_id` (`workflow_task_batch_id`, `workflow_node_id`)
) ENGINE = InnoDB
AUTO_INCREMENT = 0
DEFAULT CHARSET = utf8mb4 COMMENT ='任务批次';
@ -409,20 +409,21 @@ CREATE TABLE `job_notify_config`
CREATE TABLE `job_summary`
(
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`namespace_id` VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id',
`group_name` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '组名称',
`business_id` bigint NOT NULL COMMENT '业务id (job_id或workflow_id)',
`trigger_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '统计时间',
`success_num` int NOT NULL DEFAULT '0' COMMENT '执行成功-日志数量',
`fail_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
`fail_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因',
`stop_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
`stop_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因',
`cancel_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
`cancel_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因',
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`namespace_id` VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id',
`group_name` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '组名称',
`business_id` bigint NOT NULL COMMENT '业务id (job_id或workflow_id)',
`system_task_type` tinyint(4) NOT NULL DEFAULT '3' COMMENT '任务类型 3、JOB任务 4、WORKFLOW任务',
`trigger_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '统计时间',
`success_num` int NOT NULL DEFAULT '0' COMMENT '执行成功-日志数量',
`fail_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
`fail_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因',
`stop_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
`stop_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因',
`cancel_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
`cancel_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因',
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`),
KEY `idx_namespace_id_group_name_business_id` (`namespace_id`, `group_name`, business_id),
UNIQUE KEY `uk_business_id_trigger_at` (`business_id`, `trigger_at`) USING BTREE

View File

@ -4,7 +4,6 @@ import com.aizuda.easy.retry.template.datasource.persistence.dataobject.Dashboar
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.po.Job;
import com.aizuda.easy.retry.template.datasource.persistence.po.JobNotifyConfig;
import com.aizuda.easy.retry.template.datasource.persistence.po.JobSummary;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -13,7 +12,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime;
import java.util.List;
/**
@ -28,9 +26,9 @@ public interface JobSummaryMapper extends BaseMapper<JobSummary> {
IPage<DashboardRetryLineResponseDO.Task> jobTaskList(@Param("ew") Wrapper<Job> wrapper, Page<Object> page);
List<DashboardLineResponseDO> jobLineList(@Param("ew") Wrapper<JobSummary> wrapper);
List<DashboardLineResponseDO> jobLineList(String dateFormat, @Param("ew") Wrapper<JobSummary> wrapper);
List<DashboardRetryLineResponseDO.Rank> dashboardRank(@Param("ew") Wrapper<JobSummary> wrapper);
List<DashboardRetryLineResponseDO.Rank> dashboardRank(Integer systemTaskType, @Param("ew") Wrapper<JobSummary> wrapper);
DashboardCardResponseDO.JobTask toJobTask(@Param("ew") Wrapper<JobSummary> wrapper);
}

View File

@ -32,7 +32,7 @@ public interface RetrySummaryMapper extends BaseMapper<RetrySummary> {
IPage<DashboardRetryLineResponseDO.Task> retryTaskList(@Param("ew") Wrapper<SceneConfig> wrapper, Page<Object> page);
List<DashboardLineResponseDO> retryLineList(@Param("ew") Wrapper<RetrySummary> wrapper);
List<DashboardLineResponseDO> retryLineList(String type, @Param("ew") Wrapper<RetrySummary> wrapper);
List<DashboardRetryLineResponseDO.Rank> dashboardRank(@Param("ew") Wrapper<RetrySummary> wrapper);
}

View File

@ -19,30 +19,30 @@
<!-- 定义批量新增的 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
)
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}
namespace_id,
group_name,
job_id,
task_batch_id,
task_id,
log_num,
message,
create_dt,
real_time
)
</foreach>
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>
</insert>
</mapper>

View File

@ -27,17 +27,16 @@
</resultMap>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
update job 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 job 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

@ -20,45 +20,44 @@
</resultMap>
<insert id="insertOrUpdate" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
INSERT INTO
job_summary (namespace_id, group_name, business_id, trigger_at, system_task_type,
success_num,fail_num,fail_reason,stop_num,stop_reason, cancel_num,cancel_reason)
INSERT INTO job_summary (namespace_id, group_name, business_id, trigger_at, system_task_type,
success_num,fail_num,fail_reason,stop_num,stop_reason, cancel_num,cancel_reason)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.namespaceId},
#{item.groupName},
#{item.businessId},
#{item.triggerAt},
#{item.systemTaskType},
#{item.successNum},
#{item.failNum},
#{item.failReason},
#{item.stopNum},
#{item.stopReason},
#{item.cancelNum},
#{item.cancelReason}
)
</foreach>
<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>
ON DUPLICATE KEY UPDATE
success_num = values(`success_num`),
fail_num = values(`fail_num`),
fail_reason = values(`fail_reason`),
stop_num = values(`stop_num`),
stop_reason = values(`stop_reason`),
cancel_num = values(`cancel_num`),
cancel_reason = values(`cancel_reason`)
success_num = VALUES(`success_num`),
fail_num = VALUES(`fail_num`),
fail_reason = VALUES(`fail_reason`),
stop_num = VALUES(`stop_num`),
stop_reason = VALUES(`stop_reason`),
cancel_num = VALUES(`cancel_num`),
cancel_reason = VALUES(`cancel_reason`)
</insert>
<select id="jobLineList"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
SELECT
DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt,
ifnull(SUM(success_num), 0) AS success,
ifnull(SUM(stop_num), 0) AS stop,
ifnull(SUM(cancel_num), 0) AS cancel,
ifnull(SUM(fail_num), 0) AS fail,
ifnull(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt,
IFNULL(SUM(success_num), 0) AS success,
IFNULL(SUM(stop_num), 0) AS stop,
IFNULL(SUM(cancel_num), 0) AS cancel,
IFNULL(SUM(fail_num), 0) AS fail,
IFNULL(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
FROM job_summary
${ew.customSqlSegment}
GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
@ -67,11 +66,11 @@
<select id="toJobTask"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$JobTask">
SELECT
ifnull(sum(success_num), 0) AS successNum,
ifnull(sum(stop_num), 0) AS stopNum,
ifnull(sum(cancel_num), 0) AS cancelNum,
ifnull(sum(fail_num), 0) AS failNum,
ifnull(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
IFNULL(SUM(success_num), 0) AS successNum,
IFNULL(SUM(stop_num), 0) AS stopNum,
IFNULL(SUM(cancel_num), 0) AS cancelNum,
IFNULL(SUM(fail_num), 0) AS failNum,
IFNULL(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
FROM job_summary
${ew.customSqlSegment}
</select>
@ -83,19 +82,21 @@
CONCAT(group_name, '/', (SELECT job_name FROM job WHERE id = business_id)) name,
</if>
<if test="systemTaskType == 4">
CONCAT(group_name, '/', (SELECT workflow_name FROM workflow WHERE id = business_id)) name,
CONCAT(group_name, '/', (SELECT workflow_name FROM workflow WHERE id = business_id)) name,
</if>
SUM(fail_num) AS total FROM job_summary
SUM(fail_num) AS total
FROM job_summary
${ew.customSqlSegment}
HAVING total > 0
ORDER BY total DESC LIMIT 10
ORDER BY total DESC
LIMIT 10
</select>
<select id="jobTaskList"
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
${ew.customSqlSegment}
GROUP BY namespace_id, group_name

View File

@ -15,19 +15,30 @@
<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, 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
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})
(
#{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>

View File

@ -17,8 +17,8 @@
<insert id="insertOrUpdate" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
INSERT INTO
retry_summary (namespace_id, group_name, scene_name, trigger_at, running_num, finish_num, max_count_num,
suspend_num)
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=",">
(
@ -33,28 +33,30 @@
)
</foreach>
ON DUPLICATE KEY UPDATE
running_num = values(`running_num`),
finish_num = values(`finish_num`),
max_count_num = values(`max_count_num`),
suspend_num = values(`suspend_num`)
running_num = values(`running_num`),
finish_num = values(`finish_num`),
max_count_num = values(`max_count_num`),
suspend_num = values(`suspend_num`)
</insert>
<select id="retryTask"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
SELECT
IFNULL(SUM(running_num), 0) AS runningNum,
IFNULL(SUM(finish_num), 0) AS finishNum,
IFNULL(SUM(max_count_num), 0) AS maxCountNum,
IFNULL(SUM(suspend_num), 0) AS suspendNum,
IFNULL(SUM(running_num + finish_num + max_count_num + suspend_num), 0) AS totalNum
SELECT IFNULL(SUM(running_num), 0) AS runningNum,
IFNULL(SUM(finish_num), 0) AS finishNum,
IFNULL(SUM(max_count_num), 0) AS maxCountNum,
IFNULL(SUM(suspend_num), 0) AS suspendNum,
IFNULL(SUM(running_num + finish_num + max_count_num + suspend_num), 0) AS totalNum
FROM retry_summary
${ew.customSqlSegment}
</select>
<select id="retryTaskBarList"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
SELECT
trigger_at, running_num, finish_num, max_count_num, suspend_num
SELECT trigger_at,
running_num,
finish_num,
max_count_num,
suspend_num
FROM retry_summary
${ew.customSqlSegment}
LIMIT 7
@ -63,29 +65,29 @@
<select id="retryLineList"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
SELECT
<choose>
<when test="type == 'DAY'">
DATE_FORMAT(create_dt,'%H')
</when>
<when test="type == 'WEEK'">
DATE_FORMAT(create_dt,'%Y-%m-%d')
</when>
<when test="type =='MONTH'">
DATE_FORMAT(create_dt,'%Y-%m-%d')
</when>
<when test="type == 'YEAR'">
DATE_FORMAT(create_dt,'%Y-%m')
</when>
<otherwise>
DATE_FORMAT(create_dt,'%Y-%m-%d')
</otherwise>
</choose>
AS createDt,
IFNULL(SUM(finish_num), 0) AS successNum,
IFNULL(SUM(running_num), 0) AS runningNum,
IFNULL(SUM(max_count_num), 0) AS maxCountNum,
IFNULL(SUM(suspend_num), 0) AS suspendNum,
IFNULL(SUM(finish_num + running_num + max_count_num + suspend_num), 0) AS total
<choose>
<when test="type == 'DAY'">
DATE_FORMAT(create_dt,'%H')
</when>
<when test="type == 'WEEK'">
DATE_FORMAT(create_dt,'%Y-%m-%d')
</when>
<when test="type =='MONTH'">
DATE_FORMAT(create_dt,'%Y-%m-%d')
</when>
<when test="type == 'YEAR'">
DATE_FORMAT(create_dt,'%Y-%m')
</when>
<otherwise>
DATE_FORMAT(create_dt,'%Y-%m-%d')
</otherwise>
</choose>
AS createDt,
IFNULL(SUM(finish_num), 0) AS successNum,
IFNULL(SUM(running_num), 0) AS runningNum,
IFNULL(SUM(max_count_num), 0) AS maxCountNum,
IFNULL(SUM(suspend_num), 0) AS suspendNum,
IFNULL(SUM(finish_num + running_num + max_count_num + suspend_num), 0) AS total
FROM retry_summary
${ew.customSqlSegment}
GROUP BY createDt
@ -93,20 +95,20 @@
<select id="dashboardRank"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
SELECT
CONCAT(group_name, '/', scene_name) `name`,
SUM(running_num + finish_num + max_count_num + suspend_num) AS total
SELECT CONCAT(group_name, '/', scene_name) `name`,
SUM(running_num + finish_num + max_count_num + suspend_num) AS total
FROM retry_summary
${ew.customSqlSegment}
HAVING total > 0
ORDER BY total DESC LIMIT 10
ORDER BY total DESC
LIMIT 10
</select>
<select id="retryTaskList"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Task">
SELECT group_name AS groupName,
SUM(CASE WHEN (scene_status = 1) THEN 1 ELSE 0 END) AS run,
COUNT(*) AS total
SELECT group_name AS groupName,
SUM(CASE WHEN (scene_status = 1) THEN 1 ELSE 0 END) AS run,
COUNT(*) AS total
FROM scene_config
${ew.customSqlSegment}
GROUP BY namespace_id, group_name

View File

@ -17,9 +17,8 @@
<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 映射 -->

View File

@ -16,34 +16,33 @@
<!-- 定义批量新增的 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, client_info)
create_dt, real_time, client_info)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.namespaceId},
#{item.groupName},
#{item.uniqueId},
#{item.logNum},
#{item.message},
#{item.createDt},
#{item.realTime},
#{item.clientInfo}
)
</foreach>
<foreach collection="list" item="item" separator=",">
(
#{item.namespaceId},
#{item.groupName},
#{item.uniqueId},
#{item.logNum},
#{item.message},
#{item.createDt},
#{item.realTime},
#{item.clientInfo}
)
</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
(
<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>

View File

@ -32,16 +32,15 @@
</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
</foreach>
) tt
set
rt.next_trigger_at = tt.next_trigger_at
where rt.id = tt.id
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

@ -15,25 +15,39 @@
<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, context_path, host_id, host_ip, host_port, expire_at, node_type,create_dt,update_dt
</sql>
<insert id="insertOrUpdate" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
insert into server_node (namespace_id, group_name, host_id, host_ip, host_port,
expire_at, node_type, ext_attrs, context_path, create_dt)
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})
</foreach>
INSERT INTO server_node (namespace_id, group_name, host_id, host_ip, host_port,
expire_at, node_type, ext_attrs, context_path, create_dt)
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}
)
</foreach>
ON DUPLICATE KEY UPDATE
expire_at = values(`expire_at`)
expire_at = VALUES(`expire_at`)
</insert>
<select id="countActivePod"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.ActivePodQuantityResponseDO">
SELECT node_type as nodeType, count(*) as total
from server_node
SELECT
node_type AS nodeType,
COUNT(*) AS total
FROM server_node
${ew.customSqlSegment}
</select>
</mapper>

View File

@ -15,19 +15,18 @@
<result column="deleted" property="deleted" />
<result column="ext_attrs" property="extAttrs" />
</resultMap>
<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
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
</update>
</mapper>

View File

@ -9,6 +9,7 @@ import com.aizuda.easy.retry.common.core.util.NetUtil;
import com.aizuda.easy.retry.common.log.EasyRetryLog;
import com.aizuda.easy.retry.server.common.dto.DistributeInstance;
import com.aizuda.easy.retry.server.common.dto.ServerNodeExtAttrs;
import com.aizuda.easy.retry.server.common.enums.DashboardLineEnum;
import com.aizuda.easy.retry.server.common.enums.SyetemTaskTypeEnum;
import com.aizuda.easy.retry.server.common.enums.SystemModeEnum;
import com.aizuda.easy.retry.server.common.register.ServerRegister;
@ -164,10 +165,10 @@ public class DashBoardServiceImpl implements DashBoardService {
LocalDateTime endDateTime = dateTypeEnum.getEndTime().apply(StrUtil.isNotBlank(endTime) ? LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null);
LambdaQueryWrapper<RetrySummary> wrapper1 = new LambdaQueryWrapper<RetrySummary>()
.in(CollUtil.isNotEmpty(groupNames), RetrySummary::getGroupName, groupNames)
.eq(StrUtil.isNotBlank(groupName), RetrySummary::getGroupName, groupNames)
.eq(StrUtil.isNotBlank(groupName), RetrySummary::getGroupName, groupName)
.eq(RetrySummary::getNamespaceId, namespaceId)
.between(RetrySummary::getTriggerAt, startDateTime, endDateTime);
List<DashboardLineResponseDO> dashboardRetryLinkeResponseDOList = retrySummaryMapper.retryLineList(wrapper1);
List<DashboardLineResponseDO> dashboardRetryLinkeResponseDOList = retrySummaryMapper.retryLineList(type, wrapper1);
List<DashboardLineResponseVO> dashboardLineResponseVOList = DispatchQuantityResponseVOConverter.INSTANCE.toDashboardLineResponseVO(dashboardRetryLinkeResponseDOList);
dateTypeEnum.getConsumer().accept(dashboardLineResponseVOList);
dashboardLineResponseVOList.sort(Comparator.comparing(a -> a.getCreateDt()));
@ -221,7 +222,7 @@ public class DashBoardServiceImpl implements DashBoardService {
.eq(JobSummary::getSystemTaskType, systemTaskType)
.eq(JobSummary::getNamespaceId, namespaceId)
.between(JobSummary::getTriggerAt, startDateTime, endDateTime);
List<DashboardLineResponseDO> dashboardLineResponseDOList = jobSummaryMapper.jobLineList(queryWrapper);
List<DashboardLineResponseDO> dashboardLineResponseDOList = jobSummaryMapper.jobLineList(DashboardLineEnum.modeOf(type).getDateFormat(), queryWrapper);
List<DashboardLineResponseVO> dashboardLineResponseVOList = DispatchQuantityResponseVOConverter.INSTANCE.toDashboardLineResponseVO(dashboardLineResponseDOList);
dateTypeEnum.getConsumer().accept(dashboardLineResponseVOList);
dashboardLineResponseVOList.sort(Comparator.comparing(a -> a.getCreateDt()));
@ -235,7 +236,7 @@ public class DashBoardServiceImpl implements DashBoardService {
.eq(JobSummary::getSystemTaskType, systemTaskType)
.eq(JobSummary::getNamespaceId, namespaceId)
.groupBy(JobSummary::getNamespaceId, JobSummary::getGroupName, JobSummary::getBusinessId);
List<DashboardRetryLineResponseDO.Rank> rankList = jobSummaryMapper.dashboardRank(wrapper);
List<DashboardRetryLineResponseDO.Rank> rankList = jobSummaryMapper.dashboardRank(systemTaskType, wrapper);
List<DashboardRetryLineResponseVO.Rank> ranks = SceneQuantityRankResponseVOConverter.INSTANCE.toDashboardRetryLineResponseVORank(rankList);
dashboardRetryLineResponseVO.setRankList(ranks);
return dashboardRetryLineResponseVO;