!62 fix: 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 f0c4518614
commit a36a62a4d0
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唯一', `unique_id` varchar(64) NOT NULL COMMENT '同组下id唯一',
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`message` text NOT NULL COMMENT '异常信息', `message` text NOT NULL COMMENT '异常信息',
`log_num` int(11) NOT NULL DEFAULT 1 COMMENT '日志数量', `log_num` int(11) NOT NULL DEFAULT 1 COMMENT '日志数量',
`real_time` bigint(13) NOT NULL DEFAULT 0 COMMENT '上报时间', `real_time` bigint(13) NOT NULL DEFAULT 0 COMMENT '上报时间',
`client_info` varchar(128) DEFAULT NULL COMMENT '客户端地址 clientId#ip:port', `client_info` varchar(128) DEFAULT NULL COMMENT '客户端地址 clientId#ip:port',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `idx_namespace_id_group_name_scene_name` (`namespace_id`, `group_name`, `unique_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_job_id_task_batch_status` (`job_id`, `task_batch_status`),
KEY `idx_create_dt` (`create_dt`), KEY `idx_create_dt` (`create_dt`),
KEY `idx_namespace_id_group_name` (`namespace_id`, `group_name`), 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 ) ENGINE = InnoDB
AUTO_INCREMENT = 0 AUTO_INCREMENT = 0
DEFAULT CHARSET = utf8mb4 COMMENT ='任务批次'; DEFAULT CHARSET = utf8mb4 COMMENT ='任务批次';
@ -409,20 +409,21 @@ CREATE TABLE `job_notify_config`
CREATE TABLE `job_summary` CREATE TABLE `job_summary`
( (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`namespace_id` VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id', `namespace_id` VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id',
`group_name` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '组名称', `group_name` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '组名称',
`business_id` bigint NOT NULL COMMENT '业务id (job_id或workflow_id)', `business_id` bigint NOT NULL COMMENT '业务id (job_id或workflow_id)',
`trigger_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '统计时间', `system_task_type` tinyint(4) NOT NULL DEFAULT '3' COMMENT '任务类型 3、JOB任务 4、WORKFLOW任务',
`success_num` int NOT NULL DEFAULT '0' COMMENT '执行成功-日志数量', `trigger_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '统计时间',
`fail_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量', `success_num` int NOT NULL DEFAULT '0' COMMENT '执行成功-日志数量',
`fail_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因', `fail_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
`stop_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量', `fail_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因',
`stop_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因', `stop_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
`cancel_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量', `stop_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因',
`cancel_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因', `cancel_num` int NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `cancel_reason` varchar(512) NOT NULL DEFAULT '' COMMENT '失败原因',
`update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 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`), PRIMARY KEY (`id`),
KEY `idx_namespace_id_group_name_business_id` (`namespace_id`, `group_name`, business_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 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.DashboardLineResponseDO;
import com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO; 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.Job;
import com.aizuda.easy.retry.template.datasource.persistence.po.JobNotifyConfig;
import com.aizuda.easy.retry.template.datasource.persistence.po.JobSummary; import com.aizuda.easy.retry.template.datasource.persistence.po.JobSummary;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; 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.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime;
import java.util.List; 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); 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); 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); 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); List<DashboardRetryLineResponseDO.Rank> dashboardRank(@Param("ew") Wrapper<RetrySummary> wrapper);
} }

View File

@ -19,30 +19,30 @@
<!-- 定义批量新增的 SQL 映射 --> <!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List"> <insert id="batchInsert" parameterType="java.util.List">
INSERT INTO job_log_message 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}, namespace_id,
#{item.groupName}, group_name,
#{item.jobId}, job_id,
#{item.taskBatchId}, task_batch_id,
#{item.taskId}, task_id,
#{item.logNum}, log_num,
#{item.message}, message,
#{item.createDt}, create_dt,
#{item.realTime} 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> </insert>
</mapper> </mapper>

View File

@ -27,17 +27,16 @@
</resultMap> </resultMap>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List"> <update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
update job rt, UPDATE job rt,
( (
<foreach collection="list" item="item" index="index" separator=" union all "> <foreach collection="list" item="item" index="index" separator=" UNION ALL ">
select SELECT
#{item.nextTriggerAt} as next_trigger_at, #{item.nextTriggerAt} AS next_trigger_at,
#{item.id} as id #{item.id} AS id
</foreach> </foreach>
) tt ) tt
set SET rt.next_trigger_at = tt.next_trigger_at
rt.next_trigger_at = tt.next_trigger_at WHERE rt.id = tt.id
where rt.id = tt.id
</update> </update>
</mapper> </mapper>

View File

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

View File

@ -15,19 +15,30 @@
<result column="task_type" jdbcType="TINYINT" property="taskType"/> <result column="task_type" jdbcType="TINYINT" property="taskType"/>
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" /> <result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <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 id, unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, create_dt, task_type
</sql> </sql>
<insert id="insertBatch"> <insert id="insertBatch">
insert into retry_dead_letter (namespace_id, unique_id, group_name, scene_name, INSERT INTO retry_dead_letter (namespace_id, unique_id, group_name, scene_name,
idempotent_id, biz_no, executor_name, args_str, idempotent_id, biz_no, executor_name, args_str,
ext_attrs, create_dt ext_attrs, create_dt
) )
values VALUES
<foreach collection="retryDeadLetters" item="retryDeadLetter" separator=","> <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.namespaceId,jdbcType=VARCHAR},
#{retryDeadLetter.extAttrs,jdbcType=VARCHAR}, #{retryDeadLetter.createDt,jdbcType=TIMESTAMP}) #{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> </foreach>
</insert> </insert>

View File

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

View File

@ -17,9 +17,8 @@
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt"/> <result column="create_dt" jdbcType="TIMESTAMP" property="createDt"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id id, unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, retry_status,
, unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, retry_status, create_dt, task_type, namespace_id
create_dt, task_type, namespace_id
</sql> </sql>
<!-- 定义批量新增的 SQL 映射 --> <!-- 定义批量新增的 SQL 映射 -->

View File

@ -16,34 +16,33 @@
<!-- 定义批量新增的 SQL 映射 --> <!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List"> <insert id="batchInsert" parameterType="java.util.List">
INSERT INTO retry_task_log_message (namespace_id, group_name, unique_id, log_num, message, 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 VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
( (
#{item.namespaceId}, #{item.namespaceId},
#{item.groupName}, #{item.groupName},
#{item.uniqueId}, #{item.uniqueId},
#{item.logNum}, #{item.logNum},
#{item.message}, #{item.message},
#{item.createDt}, #{item.createDt},
#{item.realTime}, #{item.realTime},
#{item.clientInfo} #{item.clientInfo}
) )
</foreach> </foreach>
</insert> </insert>
<update id="batchUpdate" parameterType="java.util.List"> <update id="batchUpdate" parameterType="java.util.List">
UPDATE retry_task_log_message jlm, UPDATE retry_task_log_message jlm,
( (
<foreach collection="list" item="item" index="index" separator=" UNION ALL "> <foreach collection="list" item="item" index="index" separator=" UNION ALL ">
SELECT SELECT
#{item.message} AS message, #{item.message} AS message,
#{item.logNum} AS log_num, #{item.logNum} AS log_num,
#{item.id} AS id #{item.id} AS id
</foreach> </foreach>
) tt ) tt
SET SET jlm.message = tt.message, jlm.log_num = tt.log_num
jlm.message = tt.message, jlm.log_num = tt.log_num
WHERE jlm.id = tt.id WHERE jlm.id = tt.id
</update> </update>

View File

@ -32,16 +32,15 @@
</foreach> </foreach>
</insert> </insert>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List"> <update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
update retry_task_${partition} rt, UPDATE retry_task_${partition} rt,
( (
<foreach collection="list" item="item" index="index" separator=" union all "> <foreach collection="list" item="item" index="index" separator=" UNION ALL ">
select SELECT
#{item.nextTriggerAt} as next_trigger_at, #{item.nextTriggerAt} AS next_trigger_at,
#{item.id} as id #{item.id} AS id
</foreach> </foreach>
) tt ) tt
set SET rt.next_trigger_at = tt.next_trigger_at
rt.next_trigger_at = tt.next_trigger_at WHERE rt.id = tt.id
where rt.id = tt.id
</update> </update>
</mapper> </mapper>

View File

@ -15,25 +15,39 @@
<result column="create_dt" jdbcType="TIMESTAMP" property="createDt" /> <result column="create_dt" jdbcType="TIMESTAMP" property="createDt" />
<result column="update_dt" jdbcType="TIMESTAMP" property="updateDt" /> <result column="update_dt" jdbcType="TIMESTAMP" property="updateDt" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <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 id, namespace_id, group_name, context_path, host_id, host_ip, host_port, expire_at, node_type,create_dt,update_dt
</sql> </sql>
<insert id="insertOrUpdate" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id"> <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, INSERT INTO server_node (namespace_id, group_name, host_id, host_ip, host_port,
expire_at, node_type, ext_attrs, context_path, create_dt) expire_at, node_type, ext_attrs, context_path, create_dt)
values VALUES
<foreach collection="records" item="item" index="index" separator=","> <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.namespaceId,jdbcType=VARCHAR},
#{item.extAttrs,jdbcType=VARCHAR}, #{item.contextPath,jdbcType=VARCHAR}, #{item.createDt,jdbcType=TIMESTAMP}) #{item.groupName,jdbcType=VARCHAR},
</foreach> #{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 ON DUPLICATE KEY UPDATE
expire_at = values(`expire_at`) expire_at = VALUES(`expire_at`)
</insert> </insert>
<select id="countActivePod" <select id="countActivePod"
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.ActivePodQuantityResponseDO"> resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.ActivePodQuantityResponseDO">
SELECT node_type as nodeType, count(*) as total SELECT
from server_node node_type AS nodeType,
COUNT(*) AS total
FROM server_node
${ew.customSqlSegment} ${ew.customSqlSegment}
</select> </select>
</mapper> </mapper>

View File

@ -15,19 +15,18 @@
<result column="deleted" property="deleted" /> <result column="deleted" property="deleted" />
<result column="ext_attrs" property="extAttrs" /> <result column="ext_attrs" property="extAttrs" />
</resultMap> </resultMap>
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List"> <update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
update workflow rt, UPDATE workflow rt,
( (
<foreach collection="list" item="item" index="index" separator=" union all "> <foreach collection="list" item="item" index="index" separator=" UNION ALL ">
select SELECT
#{item.nextTriggerAt} as next_trigger_at, #{item.nextTriggerAt} AS next_trigger_at,
#{item.id} as id #{item.id} AS id
</foreach> </foreach>
) tt ) tt
set SET rt.next_trigger_at = tt.next_trigger_at
rt.next_trigger_at = tt.next_trigger_at WHERE rt.id = tt.id
where rt.id = tt.id
</update> </update>
</mapper> </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.common.log.EasyRetryLog;
import com.aizuda.easy.retry.server.common.dto.DistributeInstance; 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.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.SyetemTaskTypeEnum;
import com.aizuda.easy.retry.server.common.enums.SystemModeEnum; import com.aizuda.easy.retry.server.common.enums.SystemModeEnum;
import com.aizuda.easy.retry.server.common.register.ServerRegister; 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); 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>() LambdaQueryWrapper<RetrySummary> wrapper1 = new LambdaQueryWrapper<RetrySummary>()
.in(CollUtil.isNotEmpty(groupNames), RetrySummary::getGroupName, groupNames) .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) .eq(RetrySummary::getNamespaceId, namespaceId)
.between(RetrySummary::getTriggerAt, startDateTime, endDateTime); .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); List<DashboardLineResponseVO> dashboardLineResponseVOList = DispatchQuantityResponseVOConverter.INSTANCE.toDashboardLineResponseVO(dashboardRetryLinkeResponseDOList);
dateTypeEnum.getConsumer().accept(dashboardLineResponseVOList); dateTypeEnum.getConsumer().accept(dashboardLineResponseVOList);
dashboardLineResponseVOList.sort(Comparator.comparing(a -> a.getCreateDt())); dashboardLineResponseVOList.sort(Comparator.comparing(a -> a.getCreateDt()));
@ -221,7 +222,7 @@ public class DashBoardServiceImpl implements DashBoardService {
.eq(JobSummary::getSystemTaskType, systemTaskType) .eq(JobSummary::getSystemTaskType, systemTaskType)
.eq(JobSummary::getNamespaceId, namespaceId) .eq(JobSummary::getNamespaceId, namespaceId)
.between(JobSummary::getTriggerAt, startDateTime, endDateTime); .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); List<DashboardLineResponseVO> dashboardLineResponseVOList = DispatchQuantityResponseVOConverter.INSTANCE.toDashboardLineResponseVO(dashboardLineResponseDOList);
dateTypeEnum.getConsumer().accept(dashboardLineResponseVOList); dateTypeEnum.getConsumer().accept(dashboardLineResponseVOList);
dashboardLineResponseVOList.sort(Comparator.comparing(a -> a.getCreateDt())); dashboardLineResponseVOList.sort(Comparator.comparing(a -> a.getCreateDt()));
@ -235,7 +236,7 @@ public class DashBoardServiceImpl implements DashBoardService {
.eq(JobSummary::getSystemTaskType, systemTaskType) .eq(JobSummary::getSystemTaskType, systemTaskType)
.eq(JobSummary::getNamespaceId, namespaceId) .eq(JobSummary::getNamespaceId, namespaceId)
.groupBy(JobSummary::getNamespaceId, JobSummary::getGroupName, JobSummary::getBusinessId); .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); List<DashboardRetryLineResponseVO.Rank> ranks = SceneQuantityRankResponseVOConverter.INSTANCE.toDashboardRetryLineResponseVORank(rankList);
dashboardRetryLineResponseVO.setRankList(ranks); dashboardRetryLineResponseVO.setRankList(ranks);
return dashboardRetryLineResponseVO; return dashboardRetryLineResponseVO;