feat(3.2.0) 【Feat PR】:工作流Dashboard多数据源兼容提交I93NGB

* feat: 3.2.0
This commit is contained in:
wodeyangzipingpingwuqi 2024-03-27 07:29:50 +00:00 committed by byteblogs168
parent 99e2ac5245
commit ffe8b7bac9
15 changed files with 193 additions and 193 deletions

View File

@ -18,6 +18,4 @@ import java.util.List;
public interface JobLogMessageMapper extends BaseMapper<JobLogMessage> { public interface JobLogMessageMapper extends BaseMapper<JobLogMessage> {
int batchInsert(List<JobLogMessage> list); int batchInsert(List<JobLogMessage> list);
int batchUpdate(List<JobLogMessage> list);
} }

View File

@ -40,7 +40,7 @@ public class JobSummary implements Serializable {
/** /**
* '任务信息id' * '任务信息id'
*/ */
private Long jobId; private Long businessId;
/** /**
* '统计时间' * '统计时间'

View File

@ -18,8 +18,18 @@
<!-- 定义批量新增的 SQL 映射 --> <!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List"> <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, INSERT INTO job_log_message
create_dt, real_time) (
namespace_id,
group_name,
job_id,
task_batch_id,
task_id,
log_num,
message,
create_dt,
real_time
)
VALUES VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
( (

View File

@ -5,8 +5,9 @@
<id column="id" jdbcType="BIGINT" property="id"/> <id column="id" jdbcType="BIGINT" property="id"/>
<result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/> <result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/>
<result column="group_name" jdbcType="TINYINT" property="groupName"/> <result column="group_name" jdbcType="TINYINT" property="groupName"/>
<result column="job_id" jdbcType="TINYINT" property="jobId"/> <result column="business_id" jdbcType="TINYINT" property="businessId"/>
<result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/> <result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/>
<result column="system_task_type" jdbcType="TINYINT" property="systemTaskType"/>
<result column="success_num" jdbcType="TINYINT" property="successNum"/> <result column="success_num" jdbcType="TINYINT" property="successNum"/>
<result column="fail_num" jdbcType="TINYINT" property="failNum"/> <result column="fail_num" jdbcType="TINYINT" property="failNum"/>
<result column="fail_reason" jdbcType="VARCHAR" property="failReason"/> <result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
@ -20,15 +21,16 @@
<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, job_id, trigger_at, job_summary (namespace_id, group_name, business_id, trigger_at,
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.jobId}, #{item.businessId},
#{item.triggerAt}, #{item.triggerAt},
#{item.systemTaskType},
#{item.successNum}, #{item.successNum},
#{item.failNum}, #{item.failNum},
#{item.failReason}, #{item.failReason},
@ -51,29 +53,12 @@
<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
<choose> DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt,
<when test="type == 'DAY'"> ifnull(SUM(success_num), 0) AS success,
DATE_FORMAT(create_dt,'%H') ifnull(SUM(fail_num), 0) AS failNum,
</when> ifnull(SUM(stop_num), 0) AS stop,
<when test="type == 'WEEK'"> ifnull(SUM(cancel_num), 0) AS cancel,
DATE_FORMAT(create_dt,'%Y-%m-%d') ifnull(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
</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(success_num), 0) AS success,
ifnull(SUM(fail_num), 0) AS failNum,
ifnull(SUM(stop_num), 0) AS stop,
ifnull(SUM(cancel_num), 0) AS cancel,
ifnull(SUM(fail_num + stop_num + cancel_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
<where> <where>
@ -86,9 +71,9 @@
<if test="groupName != null and groupName != '' "> <if test="groupName != null and groupName != '' ">
AND group_name = #{groupName} AND group_name = #{groupName}
</if> </if>
AND namespace_id = #{namespaceId} AND trigger_at BETWEEN #{from} AND #{to} AND system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId} AND trigger_at BETWEEN #{from} AND #{to}
</where> </where>
GROUP BY createDt GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
</select> </select>
<select id="toJobTask" <select id="toJobTask"
@ -99,7 +84,7 @@
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
WHERE namespace_id = #{namespaceId} WHERE system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId}
<if test="groupNames != null and groupNames.size > 0"> <if test="groupNames != null and groupNames.size > 0">
AND group_name IN AND group_name IN
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")"> <foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
@ -111,7 +96,12 @@
<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, '/', (SELECT job_name FROM job WHERE id=job_id)) `name`, <if test="systemTaskType == 3">
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,
</if>
SUM(fail_num) AS total FROM job_summary SUM(fail_num) AS total FROM job_summary
<where> <where>
<if test="groupNames != null and groupNames.size > 0"> <if test="groupNames != null and groupNames.size > 0">
@ -125,8 +115,9 @@
</if> </if>
AND trigger_at >= #{startTime} AND trigger_at &lt;= #{endTime} AND trigger_at >= #{startTime} AND trigger_at &lt;= #{endTime}
</where> </where>
AND system_task_type = #{systemTaskType}
AND namespace_id = #{namespaceId} AND namespace_id = #{namespaceId}
GROUP BY namespace_id, group_name, job_id GROUP BY namespace_id, group_name, business_id
HAVING total > 0 HAVING total > 0
ORDER BY total DESC LIMIT 10 ORDER BY total DESC LIMIT 10
</select> </select>
@ -135,7 +126,7 @@
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
WHERE namespace_id = #{namespaceId} WHERE namespace_id = #{namespaceId}
<if test="groupNames != null and groupNames.size > 0"> <if test="groupNames != null and groupNames.size > 0">

View File

@ -18,8 +18,18 @@
<!-- 定义批量新增的 SQL 映射 --> <!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List"> <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, INSERT INTO job_log_message
create_dt, real_time) (
namespace_id,
group_name,
job_id,
task_batch_id,
task_id,
log_num,
message,
create_dt,
real_time
)
VALUES VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
( (
@ -35,19 +45,4 @@
) )
</foreach> </foreach>
</insert> </insert>
<update id="batchUpdate" parameterType="java.util.List">
UPDATE job_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
</update>
</mapper> </mapper>

View File

@ -5,8 +5,9 @@
<id column="id" jdbcType="BIGINT" property="id"/> <id column="id" jdbcType="BIGINT" property="id"/>
<result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/> <result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/>
<result column="group_name" jdbcType="TINYINT" property="groupName"/> <result column="group_name" jdbcType="TINYINT" property="groupName"/>
<result column="job_id" jdbcType="TINYINT" property="jobId"/> <result column="business_id" jdbcType="TINYINT" property="businessId"/>
<result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/> <result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/>
<result column="system_task_type" jdbcType="TINYINT" property="systemTaskType"/>
<result column="success_num" jdbcType="TINYINT" property="successNum"/> <result column="success_num" jdbcType="TINYINT" property="successNum"/>
<result column="fail_num" jdbcType="TINYINT" property="failNum"/> <result column="fail_num" jdbcType="TINYINT" property="failNum"/>
<result column="fail_reason" jdbcType="VARCHAR" property="failReason"/> <result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
@ -20,14 +21,14 @@
<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, job_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.jobId}, #{item.businessId},
#{item.triggerAt}, #{item.triggerAt},
#{item.systemTaskType}, #{item.systemTaskType},
#{item.successNum}, #{item.successNum},
@ -96,10 +97,10 @@
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank"> resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
SELECT SELECT
<if test="systemTaskType == 3"> <if test="systemTaskType == 3">
CONCAT(group_name, '/', (SELECT job_name FROM job WHERE id = job_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 = job_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
<where> <where>
@ -116,7 +117,7 @@
</where> </where>
AND system_task_type = #{systemTaskType} AND system_task_type = #{systemTaskType}
AND namespace_id = #{namespaceId} AND namespace_id = #{namespaceId}
GROUP BY namespace_id, group_name, job_id GROUP BY namespace_id, group_name, business_id
HAVING total > 0 HAVING total > 0
ORDER BY total DESC LIMIT 10 ORDER BY total DESC LIMIT 10
</select> </select>

View File

@ -20,8 +20,18 @@
<insert id="batchInsert" parameterType="java.util.List"> <insert id="batchInsert" parameterType="java.util.List">
INSERT ALL INSERT ALL
<foreach collection="list" item="item" separator=""> <foreach collection="list" item="item" separator="">
INTO job_log_message (namespace_id, group_name, job_id, task_batch_id, task_id, log_num, message, INTO job_log_message
create_dt, real_time) (
namespace_id,
group_name,
job_id,
task_batch_id,
task_id,
log_num,
message,
create_dt,
real_time
)
VALUES ( VALUES (
#{item.namespaceId}, #{item.namespaceId},
#{item.groupName}, #{item.groupName},

View File

@ -5,8 +5,9 @@
<id column="id" jdbcType="BIGINT" property="id"/> <id column="id" jdbcType="BIGINT" property="id"/>
<result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/> <result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/>
<result column="group_name" jdbcType="TINYINT" property="groupName"/> <result column="group_name" jdbcType="TINYINT" property="groupName"/>
<result column="job_id" jdbcType="TINYINT" property="jobId"/> <result column="business_id" jdbcType="TINYINT" property="businessId"/>
<result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/> <result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/>
<result column="system_task_type" jdbcType="TINYINT" property="systemTaskType"/>
<result column="success_num" jdbcType="TINYINT" property="successNum"/> <result column="success_num" jdbcType="TINYINT" property="successNum"/>
<result column="fail_num" jdbcType="TINYINT" property="failNum"/> <result column="fail_num" jdbcType="TINYINT" property="failNum"/>
<result column="fail_reason" jdbcType="VARCHAR" property="failReason"/> <result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
@ -23,21 +24,22 @@
USING ( USING (
<foreach collection="list" item="item" separator=" UNION ALL "> <foreach collection="list" item="item" separator=" UNION ALL ">
SELECT SELECT
#{item.namespaceId} AS namespace_id, #{item.namespaceId} AS namespace_id,
#{item.groupName} AS group_name, #{item.groupName} AS group_name,
#{item.jobId} AS job_id, #{item.businessId} AS business_id,
#{item.triggerAt} AS trigger_at, #{item.triggerAt} AS trigger_at,
#{item.successNum} AS success_num, #{item.systemTaskType} AS system_task_type,
#{item.failNum} AS fail_num, #{item.successNum} AS success_num,
#{item.failReason} AS fail_reason, #{item.failNum} AS fail_num,
#{item.stopNum} AS stop_num, #{item.failReason} AS fail_reason,
#{item.stopReason} AS stop_reason, #{item.stopNum} AS stop_num,
#{item.cancelNum} AS cancel_num, #{item.stopReason} AS stop_reason,
#{item.cancelReason} AS cancel_reason #{item.cancelNum} AS cancel_num,
#{item.cancelReason} AS cancel_reason
FROM DUAL FROM DUAL
</foreach> </foreach>
) src ) src
ON (dest.job_id = src.job_id AND dest.trigger_at = src.trigger_at) ON (dest.job_id = src.job_id AND dest.trigger_at = src.trigger_at AND dest.system_task_type = src.system_task_type)
WHEN MATCHED THEN WHEN MATCHED THEN
UPDATE SET UPDATE SET
dest.success_num = src.success_num, dest.success_num = src.success_num,
@ -48,7 +50,7 @@
dest.cancel_num = src.cancel_num, dest.cancel_num = src.cancel_num,
dest.cancel_reason = src.cancel_reason dest.cancel_reason = src.cancel_reason
WHEN NOT MATCHED THEN WHEN NOT MATCHED THEN
INSERT (namespace_id, group_name, job_id, trigger_at, INSERT (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=",">
@ -57,6 +59,7 @@
#{item.groupName}, #{item.groupName},
#{item.jobId}, #{item.jobId},
#{item.triggerAt}, #{item.triggerAt},
#{item.systemTaskType},
#{item.successNum}, #{item.successNum},
#{item.failNum}, #{item.failNum},
#{item.failReason}, #{item.failReason},
@ -72,32 +75,15 @@
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO"> resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
SELECT SELECT
createDt, createDt,
COALESCE(SUM(success_num), 0) AS success, COALESCE(SUM(success_num), 0) AS success,
COALESCE(SUM(fail_num), 0) AS failNum, COALESCE(SUM(fail_num), 0) AS failNum,
COALESCE(SUM(stop_num), 0) AS stop, COALESCE(SUM(stop_num), 0) AS stop,
COALESCE(SUM(cancel_num), 0) AS cancel, COALESCE(SUM(cancel_num), 0) AS cancel,
COALESCE(SUM(fail_num + stop_num + cancel_num), 0) AS fail, COALESCE(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
FROM ( FROM (
SELECT SELECT
<choose> DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt,
<when test="type == 'DAY'">
TO_CHAR(create_dt, 'HH24')
</when>
<when test="type == 'WEEK'">
TO_CHAR(create_dt, 'yyyy-MM-dd')
</when>
<when test="type =='MONTH'">
TO_CHAR(create_dt, 'yyyy-MM-dd')
</when>
<when test="type == 'YEAR'">
TO_CHAR(create_dt, 'yyyy-MM')
</when>
<otherwise>
TO_CHAR(create_dt, 'yyyy-MM-dd')
</otherwise>
</choose>
AS createDt,
success_num, success_num,
fail_num, fail_num,
stop_num, stop_num,
@ -113,10 +99,10 @@
<if test="groupName != null and groupName != '' "> <if test="groupName != null and groupName != '' ">
AND group_name = #{groupName} AND group_name = #{groupName}
</if> </if>
AND namespace_id = #{namespaceId} AND trigger_at BETWEEN #{from} AND #{to} AND system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId} AND trigger_at BETWEEN #{from} AND #{to}
</where> </where>
) )
GROUP BY createDt GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
</select> </select>
<select id="toJobTask" <select id="toJobTask"
@ -127,7 +113,7 @@
COALESCE(sum(fail_num), 0) AS failNum, COALESCE(sum(fail_num), 0) AS failNum,
COALESCE(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum COALESCE(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
FROM job_summary FROM job_summary
WHERE namespace_id = #{namespaceId} WHERE system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId}
<if test="groupNames != null and groupNames.size > 0"> <if test="groupNames != null and groupNames.size > 0">
AND group_name IN AND group_name IN
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")"> <foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
@ -141,7 +127,12 @@
SELECT * FROM SELECT * FROM
( (
SELECT SELECT
group_name || '/' || (SELECT job_name FROM job WHERE id=job_id) AS name, <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 SUM(fail_num) AS total
FROM job_summary FROM job_summary
<where> <where>
@ -156,8 +147,9 @@
</if> </if>
AND trigger_at BETWEEN #{startTime} AND #{endTime} AND trigger_at BETWEEN #{startTime} AND #{endTime}
</where> </where>
AND system_task_type = #{systemTaskType}
AND namespace_id = #{namespaceId} AND namespace_id = #{namespaceId}
GROUP BY namespace_id, group_name, job_id GROUP BY namespace_id, group_name, business_id
HAVING SUM(fail_num) > 0 HAVING SUM(fail_num) > 0
ORDER BY total DESC ORDER BY total DESC
) )

View File

@ -17,8 +17,18 @@
</resultMap> </resultMap>
<!-- 定义批量新增的 SQL 映射 --> <!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List"> <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, INSERT INTO job_log_message
create_dt, real_time) (
namespace_id,
group_name,
job_id,
task_batch_id,
task_id,
log_num,
message,
create_dt,
real_time
)
VALUES VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
( (

View File

@ -5,8 +5,9 @@
<id column="id" jdbcType="BIGINT" property="id"/> <id column="id" jdbcType="BIGINT" property="id"/>
<result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/> <result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/>
<result column="group_name" jdbcType="TINYINT" property="groupName"/> <result column="group_name" jdbcType="TINYINT" property="groupName"/>
<result column="job_id" jdbcType="TINYINT" property="jobId"/> <result column="business_id" jdbcType="TINYINT" property="businessId"/>
<result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/> <result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/>
<result column="system_task_type" jdbcType="TINYINT" property="systemTaskType"/>
<result column="success_num" jdbcType="TINYINT" property="successNum"/> <result column="success_num" jdbcType="TINYINT" property="successNum"/>
<result column="fail_num" jdbcType="TINYINT" property="failNum"/> <result column="fail_num" jdbcType="TINYINT" property="failNum"/>
<result column="fail_reason" jdbcType="VARCHAR" property="failReason"/> <result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
@ -20,15 +21,16 @@
<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, job_id, trigger_at, 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.jobId}, #{item.businessId},
#{item.triggerAt}, #{item.triggerAt},
#{item.systemTaskType},
#{item.successNum}, #{item.successNum},
#{item.failNum}, #{item.failNum},
#{item.failReason}, #{item.failReason},
@ -38,7 +40,7 @@
#{item.cancelReason} #{item.cancelReason}
) )
</foreach> </foreach>
ON CONFLICT (job_id, trigger_at) DO UPDATE ON CONFLICT (business_id, trigger_at, system_task_type) DO UPDATE
SET success_num = EXCLUDED.success_num, SET success_num = EXCLUDED.success_num,
fail_num = EXCLUDED.fail_num, fail_num = EXCLUDED.fail_num,
fail_reason = EXCLUDED.fail_reason, fail_reason = EXCLUDED.fail_reason,
@ -51,29 +53,12 @@
<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
<choose> DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt,
<when test="type == 'DAY'"> COALESCE(SUM(success_num), 0) AS success,
to_char(create_dt,'%H') COALESCE(SUM(fail_num), 0) AS failNum,
</when> COALESCE(SUM(stop_num), 0) AS stop,
<when test="type == 'WEEK'"> COALESCE(SUM(cancel_num), 0) AS cancel,
to_char(create_dt,'%Y-%m-%d') COALESCE(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
</when>
<when test="type =='MONTH'">
to_char(create_dt,'%Y-%m-%d')
</when>
<when test="type == 'YEAR'">
to_char(create_dt,'%Y-%m')
</when>
<otherwise>
to_char(create_dt,'%Y-%m-%d')
</otherwise>
</choose>
AS createDt,
COALESCE(SUM(success_num), 0) AS success,
COALESCE(SUM(fail_num), 0) AS failNum,
COALESCE(SUM(stop_num), 0) AS stop,
COALESCE(SUM(cancel_num), 0) AS cancel,
COALESCE(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
FROM job_summary FROM job_summary
<where> <where>
@ -86,9 +71,9 @@
<if test="groupName != null and groupName != '' "> <if test="groupName != null and groupName != '' ">
AND group_name = #{groupName} AND group_name = #{groupName}
</if> </if>
AND namespace_id = #{namespaceId} AND trigger_at BETWEEN #{from} AND #{to} AND system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId} AND trigger_at BETWEEN #{from} AND #{to}
</where> </where>
GROUP BY createDt GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
</select> </select>
<select id="toJobTask" <select id="toJobTask"
@ -99,7 +84,7 @@
COALESCE(sum(fail_num), 0) AS failNum, COALESCE(sum(fail_num), 0) AS failNum,
COALESCE(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum COALESCE(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
FROM job_summary FROM job_summary
WHERE namespace_id = #{namespaceId} WHERE system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId}
<if test="groupNames != null and groupNames.size > 0"> <if test="groupNames != null and groupNames.size > 0">
AND group_name IN AND group_name IN
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")"> <foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
@ -111,7 +96,12 @@
<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, '/', (SELECT job_name FROM job WHERE id=job_id)) name, <if test="systemTaskType == 3">
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,
</if>
SUM(fail_num) AS total FROM job_summary SUM(fail_num) AS total FROM job_summary
<where> <where>
<if test="groupNames != null and groupNames.size > 0"> <if test="groupNames != null and groupNames.size > 0">
@ -125,8 +115,9 @@
</if> </if>
AND trigger_at >= #{startTime} AND trigger_at &lt;= #{endTime} AND trigger_at >= #{startTime} AND trigger_at &lt;= #{endTime}
</where> </where>
AND system_task_type = #{systemTaskType}
AND namespace_id = #{namespaceId} AND namespace_id = #{namespaceId}
GROUP BY namespace_id, group_name, job_id GROUP BY namespace_id, group_name, business_id
HAVING SUM(fail_num) > 0 HAVING SUM(fail_num) > 0
ORDER BY total DESC LIMIT 10 ORDER BY total DESC LIMIT 10
</select> </select>

View File

@ -18,8 +18,18 @@
<!-- 定义批量新增的 SQL 映射 --> <!-- 定义批量新增的 SQL 映射 -->
<insert id="batchInsert" parameterType="java.util.List"> <insert id="batchInsert" parameterType="java.util.List">
INSERT INTO job_log_message (namespace_id, group_name, job_id, task_batch_id, task_id, INSERT INTO job_log_message
log_num, message, create_dt, real_time) (
namespace_id,
group_name,
job_id,
task_batch_id,
task_id,
log_num,
message,
create_dt,
real_time
)
VALUES VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
( (

View File

@ -5,8 +5,9 @@
<id column="id" jdbcType="BIGINT" property="id"/> <id column="id" jdbcType="BIGINT" property="id"/>
<result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/> <result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/>
<result column="group_name" jdbcType="TINYINT" property="groupName"/> <result column="group_name" jdbcType="TINYINT" property="groupName"/>
<result column="job_id" jdbcType="TINYINT" property="jobId"/> <result column="business_id" jdbcType="TINYINT" property="businessId"/>
<result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/> <result column="trigger_at" jdbcType="TIMESTAMP" property="triggerAt"/>
<result column="system_task_type" jdbcType="TINYINT" property="systemTaskType"/>
<result column="success_num" jdbcType="TINYINT" property="successNum"/> <result column="success_num" jdbcType="TINYINT" property="successNum"/>
<result column="fail_num" jdbcType="TINYINT" property="failNum"/> <result column="fail_num" jdbcType="TINYINT" property="failNum"/>
<result column="fail_reason" jdbcType="VARCHAR" property="failReason"/> <result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
@ -26,8 +27,9 @@
( (
#{item.namespaceId}, #{item.namespaceId},
#{item.groupName}, #{item.groupName},
#{item.jobId}, #{item.businessId},
#{item.triggerAt}, #{item.triggerAt},
#{item.systemTaskType},
#{item.successNum}, #{item.successNum},
#{item.failNum}, #{item.failNum},
#{item.failReason}, #{item.failReason},
@ -37,10 +39,10 @@
#{item.cancelReason} #{item.cancelReason}
) )
</foreach> </foreach>
) AS source (namespace_id, group_name, job_id, trigger_at, ) AS source (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)
ON target.namespace_id = source.namespace_id ON target.namespace_id = source.namespace_id
AND target.job_id = source.job_id AND target.business_id = source.business_id
WHEN MATCHED THEN WHEN MATCHED THEN
UPDATE SET UPDATE SET
target.success_num = source.success_num, target.success_num = source.success_num,
@ -51,9 +53,9 @@
target.cancel_num = source.cancel_num, target.cancel_num = source.cancel_num,
target.cancel_reason = source.cancel_reason target.cancel_reason = source.cancel_reason
WHEN NOT MATCHED THEN WHEN NOT MATCHED THEN
INSERT (namespace_id, group_name, job_id, trigger_at, INSERT (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 (source.namespace_id, source.group_name, source.job_id, source.trigger_at, VALUES (source.namespace_id, source.group_name, source.business_id, source.trigger_at, source.system_task_type,
source.success_num, source.fail_num, source.fail_reason, source.stop_num, source.stop_reason, source.success_num, source.fail_num, source.fail_reason, source.stop_num, source.stop_reason,
source.cancel_num, source.cancel_reason); source.cancel_num, source.cancel_reason);
</insert> </insert>
@ -62,30 +64,14 @@
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO"> resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
SELECT SELECT
createDt, createDt,
ISNULL(SUM(success_num), 0) AS success, ISNULL(SUM(success_num), 0) AS success,
ISNULL(SUM(stop_num), 0) AS stop, ISNULL(SUM(stop_num), 0) AS stop,
ISNULL(SUM(cancel_num), 0) AS cancel, ISNULL(SUM(cancel_num), 0) AS cancel,
ISNULL(SUM(fail_num), 0) AS fail, ISNULL(SUM(fail_num), 0) AS fail,
ISNULL(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total ISNULL(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
FROM ( FROM (
SELECT SELECT
<choose> DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt,
<when test="type == 'DAY'">
FORMAT(create_dt,'HH24')
</when>
<when test="type == 'WEEK'">
FORMAT(create_dt,'yyyy-MM-dd')
</when>
<when test="type =='MONTH'">
FORMAT(create_dt,'yyyy-MM-dd')
</when>
<when test="type == 'YEAR'">
FORMAT(create_dt,'yyyy-MM')
</when>
<otherwise>
FORMAT(create_dt,'yyyy-MM-dd')
</otherwise>
</choose> AS createDt,
success_num, success_num,
stop_num, stop_num,
cancel_num, cancel_num,
@ -101,11 +87,12 @@
<if test="groupName != null and groupName != '' "> <if test="groupName != null and groupName != '' ">
AND group_name = #{groupName} AND group_name = #{groupName}
</if> </if>
AND system_task_type = #{systemTaskType}
AND namespace_id = #{namespaceId} AND namespace_id = #{namespaceId}
AND trigger_at BETWEEN #{from} AND #{to} AND trigger_at BETWEEN #{from} AND #{to}
</where> </where>
) AS subquery ) AS subquery
GROUP BY createDt GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
</select> </select>
<select id="toJobTask" <select id="toJobTask"
@ -117,7 +104,7 @@
ISNULL(sum(fail_num), 0) AS failNum, ISNULL(sum(fail_num), 0) AS failNum,
ISNULL(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum ISNULL(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
FROM job_summary FROM job_summary
WHERE namespace_id = #{namespaceId} WHERE system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId}
<if test="groupNames != null and groupNames.size > 0"> <if test="groupNames != null and groupNames.size > 0">
AND group_name IN AND group_name IN
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")"> <foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
@ -129,7 +116,13 @@
<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 TOP 10 SELECT TOP 10
CONCAT(group_name, '/', (SELECT job_name FROM job WHERE id=job_id)) name,
<if test="systemTaskType == 3">
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,
</if>
SUM(fail_num) AS total SUM(fail_num) AS total
FROM job_summary FROM job_summary
<where> <where>
@ -144,8 +137,9 @@
</if> </if>
AND trigger_at BETWEEN #{startTime} AND #{endTime} AND trigger_at BETWEEN #{startTime} AND #{endTime}
AND namespace_id = #{namespaceId} AND namespace_id = #{namespaceId}
AND system_task_type = #{systemTaskType}
</where> </where>
GROUP BY namespace_id, group_name, job_id GROUP BY namespace_id, group_name, business_id
HAVING SUM(fail_num) > 0 HAVING SUM(fail_num) > 0
ORDER BY name DESC ORDER BY name DESC
</select> </select>

View File

@ -115,7 +115,7 @@ public class JobLogMergeSchedule extends AbstractSchedule implements Lifecycle {
List<JobTaskBatch> jobTaskBatchList = jobTaskBatchMapper.selectPage( List<JobTaskBatch> jobTaskBatchList = jobTaskBatchMapper.selectPage(
new Page<>(0, 1000), new Page<>(0, 1000),
new LambdaUpdateWrapper<JobTaskBatch>().ge(JobTaskBatch::getId, startId) new LambdaUpdateWrapper<JobTaskBatch>().ge(JobTaskBatch::getId, startId)
.eq(JobTaskBatch::getTaskBatchStatus, JobTaskBatchStatusEnum.SUCCESS.getStatus()) .in(JobTaskBatch::getTaskBatchStatus, JobTaskBatchStatusEnum.COMPLETED)
.le(JobTaskBatch::getCreateDt, endTime)).getRecords(); .le(JobTaskBatch::getCreateDt, endTime)).getRecords();
return JobTaskConverter.INSTANCE.toJobTaskBatchPartitionTasks(jobTaskBatchList); return JobTaskConverter.INSTANCE.toJobTaskBatchPartitionTasks(jobTaskBatchList);
} }
@ -144,48 +144,46 @@ public class JobLogMergeSchedule extends AbstractSchedule implements Lifecycle {
} }
List<Map.Entry<Long, List<JobLogMessage>>> jobLogMessageGroupList = jobLogMessageList.stream().collect( List<Map.Entry<Long, List<JobLogMessage>>> jobLogMessageGroupList = jobLogMessageList.stream().collect(
groupingBy(JobLogMessage::getTaskId)).entrySet().stream() groupingBy(JobLogMessage::getTaskId)).entrySet().stream()
.filter(entry -> entry.getValue().size() >= 2).collect(toList()); .filter(entry -> entry.getValue().size() >= 2).collect(toList());
for (Map.Entry<Long/*taskId*/, List<JobLogMessage>> jobLogMessageMap : jobLogMessageGroupList) { for (Map.Entry<Long/*taskId*/, List<JobLogMessage>> jobLogMessageMap : jobLogMessageGroupList) {
List<Long> jobLogMessageDeleteBatchIds = new ArrayList<>(); List<Long> jobLogMessageDeleteBatchIds = new ArrayList<>();
List<JobLogMessage> jobLogMessageUpdateList = new ArrayList<>(); List<JobLogMessage> jobLogMessageInsertBatchIds = new ArrayList<>();
List<String> mergeMessages = jobLogMessageMap.getValue().stream().map(k -> { List<String> mergeMessages = jobLogMessageMap.getValue().stream().map(k -> {
jobLogMessageDeleteBatchIds.add(k.getId()); jobLogMessageDeleteBatchIds.add(k.getId());
return JsonUtil.parseObject(k.getMessage(), List.class); return JsonUtil.parseObject(k.getMessage(), List.class);
}) })
.reduce((a, b) -> { .reduce((a, b) -> {
// 合并日志信息 // 合并日志信息
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
list.addAll(a); list.addAll(a);
list.addAll(b); list.addAll(b);
return list; return list;
}).get(); }).get();
// 500条数据为一个批次 // 500条数据为一个批次
List<List<String>> partitionMessages = Lists.partition(mergeMessages, List<List<String>> partitionMessages = Lists.partition(mergeMessages, systemProperties.getMergeLogNum());
systemProperties.getMergeLogNum());
for (int i = 0; i < partitionMessages.size(); i++) { for (int i = 0; i < partitionMessages.size(); i++) {
// 深拷贝 // 深拷贝
JobLogMessage jobLogMessage = JobTaskConverter.INSTANCE.toJobLogMessage( jobLogMessageMap.getValue().get(0)); JobLogMessage jobLogMessage = JobTaskConverter.INSTANCE.toJobLogMessage(jobLogMessageMap.getValue().get(0));
List<String> messages = partitionMessages.get(i); List<String> messages = partitionMessages.get(i);
jobLogMessage.setLogNum(messages.size()); jobLogMessage.setLogNum(messages.size());
jobLogMessage.setMessage(JsonUtil.toJsonString(messages)); jobLogMessage.setMessage(JsonUtil.toJsonString(messages));
jobLogMessageUpdateList.add(jobLogMessage); jobLogMessageInsertBatchIds.add(jobLogMessage);
} }
// 批量删除更新日志 // 批量删除更新日志
if (CollectionUtil.isNotEmpty(jobLogMessageDeleteBatchIds)) { if (CollectionUtil.isNotEmpty(jobLogMessageDeleteBatchIds)) {
jobLogMessageMapper.deleteBatchIds(jobLogMessageDeleteBatchIds); jobLogMessageMapper.deleteBatchIds(jobLogMessageDeleteBatchIds);
} }
if (CollectionUtil.isNotEmpty(jobLogMessageUpdateList)) { if (CollectionUtil.isNotEmpty(jobLogMessageInsertBatchIds)) {
jobLogMessageMapper.batchUpdate(jobLogMessageUpdateList); jobLogMessageMapper.batchInsert(jobLogMessageInsertBatchIds);
} }
} }
} }
}); });
} }

View File

@ -83,7 +83,7 @@ public class JobSummarySchedule extends AbstractSchedule implements Lifecycle {
Map<Long, List<JobBatchSummaryResponseDO>> jobIdListMap = summaryResponseDOList.parallelStream().collect(Collectors.groupingBy(JobBatchSummaryResponseDO::getJobId)); Map<Long, List<JobBatchSummaryResponseDO>> jobIdListMap = summaryResponseDOList.parallelStream().collect(Collectors.groupingBy(JobBatchSummaryResponseDO::getJobId));
for (Map.Entry<Long, List<JobBatchSummaryResponseDO>> job : jobIdListMap.entrySet()) { for (Map.Entry<Long, List<JobBatchSummaryResponseDO>> job : jobIdListMap.entrySet()) {
JobSummary jobSummary = new JobSummary(); JobSummary jobSummary = new JobSummary();
jobSummary.setJobId(job.getKey()); jobSummary.setBusinessId(job.getKey());
jobSummary.setTriggerAt(triggerAt); jobSummary.setTriggerAt(triggerAt);
jobSummary.setNamespaceId(job.getValue().get(0).getNamespaceId()); jobSummary.setNamespaceId(job.getValue().get(0).getNamespaceId());
jobSummary.setGroupName(job.getValue().get(0).getGroupName()); jobSummary.setGroupName(job.getValue().get(0).getGroupName());

View File

@ -86,7 +86,7 @@ public class WorkflowJobSummarySchedule extends AbstractSchedule implements Life
Map<Long, List<JobBatchSummaryResponseDO>> jobIdListMap = summaryResponseDOList.parallelStream().collect(Collectors.groupingBy(JobBatchSummaryResponseDO::getJobId)); Map<Long, List<JobBatchSummaryResponseDO>> jobIdListMap = summaryResponseDOList.parallelStream().collect(Collectors.groupingBy(JobBatchSummaryResponseDO::getJobId));
for (Map.Entry<Long, List<JobBatchSummaryResponseDO>> job : jobIdListMap.entrySet()) { for (Map.Entry<Long, List<JobBatchSummaryResponseDO>> job : jobIdListMap.entrySet()) {
JobSummary jobSummary = new JobSummary(); JobSummary jobSummary = new JobSummary();
jobSummary.setJobId(job.getKey()); jobSummary.setBusinessId(job.getKey());
jobSummary.setTriggerAt(triggerAt); jobSummary.setTriggerAt(triggerAt);
jobSummary.setNamespaceId(job.getValue().get(0).getNamespaceId()); jobSummary.setNamespaceId(job.getValue().get(0).getNamespaceId());
jobSummary.setGroupName(job.getValue().get(0).getGroupName()); jobSummary.setGroupName(job.getValue().get(0).getGroupName());