feat(3.2.0) 【Feat PR】:工作流Dashboard多数据源兼容提交I93NGB
* feat: 3.2.0
This commit is contained in:
parent
99e2ac5245
commit
ffe8b7bac9
@ -18,6 +18,4 @@ import java.util.List;
|
||||
public interface JobLogMessageMapper extends BaseMapper<JobLogMessage> {
|
||||
|
||||
int batchInsert(List<JobLogMessage> list);
|
||||
|
||||
int batchUpdate(List<JobLogMessage> list);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class JobSummary implements Serializable {
|
||||
/**
|
||||
* '任务信息id'
|
||||
*/
|
||||
private Long jobId;
|
||||
private Long businessId;
|
||||
|
||||
/**
|
||||
* '统计时间'
|
||||
|
@ -18,8 +18,18 @@
|
||||
|
||||
<!-- 定义批量新增的 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)
|
||||
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=",">
|
||||
(
|
||||
|
@ -5,8 +5,9 @@
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/>
|
||||
<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="system_task_type" jdbcType="TINYINT" property="systemTaskType"/>
|
||||
<result column="success_num" jdbcType="TINYINT" property="successNum"/>
|
||||
<result column="fail_num" jdbcType="TINYINT" property="failNum"/>
|
||||
<result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
|
||||
@ -20,15 +21,16 @@
|
||||
|
||||
<insert id="insertOrUpdate" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
||||
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)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.jobId},
|
||||
#{item.businessId},
|
||||
#{item.triggerAt},
|
||||
#{item.systemTaskType},
|
||||
#{item.successNum},
|
||||
#{item.failNum},
|
||||
#{item.failReason},
|
||||
@ -51,29 +53,12 @@
|
||||
<select id="jobLineList"
|
||||
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(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,
|
||||
DATE_FORMAT(trigger_at, #{dateFormat}) 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
|
||||
FROM job_summary
|
||||
<where>
|
||||
@ -86,9 +71,9 @@
|
||||
<if test="groupName != null and groupName != '' ">
|
||||
AND group_name = #{groupName}
|
||||
</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>
|
||||
GROUP BY createDt
|
||||
GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
|
||||
</select>
|
||||
|
||||
<select id="toJobTask"
|
||||
@ -99,7 +84,7 @@
|
||||
ifnull(sum(fail_num), 0) AS failNum,
|
||||
ifnull(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
|
||||
FROM job_summary
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
WHERE system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId}
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
AND group_name IN
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
@ -111,7 +96,12 @@
|
||||
<select id="dashboardRank"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
||||
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
|
||||
<where>
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
@ -125,8 +115,9 @@
|
||||
</if>
|
||||
AND trigger_at >= #{startTime} AND trigger_at <= #{endTime}
|
||||
</where>
|
||||
AND system_task_type = #{systemTaskType}
|
||||
AND namespace_id = #{namespaceId}
|
||||
GROUP BY namespace_id, group_name, job_id
|
||||
GROUP BY namespace_id, group_name, business_id
|
||||
HAVING total > 0
|
||||
ORDER BY total DESC LIMIT 10
|
||||
</select>
|
||||
@ -135,7 +126,7 @@
|
||||
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
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
|
@ -18,8 +18,18 @@
|
||||
|
||||
<!-- 定义批量新增的 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)
|
||||
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=",">
|
||||
(
|
||||
@ -35,19 +45,4 @@
|
||||
)
|
||||
</foreach>
|
||||
</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>
|
||||
|
@ -5,8 +5,9 @@
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/>
|
||||
<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="system_task_type" jdbcType="TINYINT" property="systemTaskType"/>
|
||||
<result column="success_num" jdbcType="TINYINT" property="successNum"/>
|
||||
<result column="fail_num" jdbcType="TINYINT" property="failNum"/>
|
||||
<result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
|
||||
@ -20,14 +21,14 @@
|
||||
|
||||
<insert id="insertOrUpdate" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
||||
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)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.jobId},
|
||||
#{item.businessId},
|
||||
#{item.triggerAt},
|
||||
#{item.systemTaskType},
|
||||
#{item.successNum},
|
||||
@ -96,10 +97,10 @@
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
||||
SELECT
|
||||
<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 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>
|
||||
SUM(fail_num) AS total FROM job_summary
|
||||
<where>
|
||||
@ -116,7 +117,7 @@
|
||||
</where>
|
||||
AND system_task_type = #{systemTaskType}
|
||||
AND namespace_id = #{namespaceId}
|
||||
GROUP BY namespace_id, group_name, job_id
|
||||
GROUP BY namespace_id, group_name, business_id
|
||||
HAVING total > 0
|
||||
ORDER BY total DESC LIMIT 10
|
||||
</select>
|
||||
|
@ -20,8 +20,18 @@
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT ALL
|
||||
<foreach collection="list" item="item" separator="">
|
||||
INTO job_log_message (namespace_id, group_name, job_id, task_batch_id, task_id, log_num, message,
|
||||
create_dt, real_time)
|
||||
INTO job_log_message
|
||||
(
|
||||
namespace_id,
|
||||
group_name,
|
||||
job_id,
|
||||
task_batch_id,
|
||||
task_id,
|
||||
log_num,
|
||||
message,
|
||||
create_dt,
|
||||
real_time
|
||||
)
|
||||
VALUES (
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
|
@ -5,8 +5,9 @@
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/>
|
||||
<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="system_task_type" jdbcType="TINYINT" property="systemTaskType"/>
|
||||
<result column="success_num" jdbcType="TINYINT" property="successNum"/>
|
||||
<result column="fail_num" jdbcType="TINYINT" property="failNum"/>
|
||||
<result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
|
||||
@ -23,21 +24,22 @@
|
||||
USING (
|
||||
<foreach collection="list" item="item" separator=" UNION ALL ">
|
||||
SELECT
|
||||
#{item.namespaceId} AS namespace_id,
|
||||
#{item.groupName} AS group_name,
|
||||
#{item.jobId} AS job_id,
|
||||
#{item.triggerAt} AS trigger_at,
|
||||
#{item.successNum} AS success_num,
|
||||
#{item.failNum} AS fail_num,
|
||||
#{item.failReason} AS fail_reason,
|
||||
#{item.stopNum} AS stop_num,
|
||||
#{item.stopReason} AS stop_reason,
|
||||
#{item.cancelNum} AS cancel_num,
|
||||
#{item.cancelReason} AS cancel_reason
|
||||
#{item.namespaceId} AS namespace_id,
|
||||
#{item.groupName} AS group_name,
|
||||
#{item.businessId} AS business_id,
|
||||
#{item.triggerAt} AS trigger_at,
|
||||
#{item.systemTaskType} AS system_task_type,
|
||||
#{item.successNum} AS success_num,
|
||||
#{item.failNum} AS fail_num,
|
||||
#{item.failReason} AS fail_reason,
|
||||
#{item.stopNum} AS stop_num,
|
||||
#{item.stopReason} AS stop_reason,
|
||||
#{item.cancelNum} AS cancel_num,
|
||||
#{item.cancelReason} AS cancel_reason
|
||||
FROM DUAL
|
||||
</foreach>
|
||||
) 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
|
||||
UPDATE SET
|
||||
dest.success_num = src.success_num,
|
||||
@ -48,7 +50,7 @@
|
||||
dest.cancel_num = src.cancel_num,
|
||||
dest.cancel_reason = src.cancel_reason
|
||||
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)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
@ -57,6 +59,7 @@
|
||||
#{item.groupName},
|
||||
#{item.jobId},
|
||||
#{item.triggerAt},
|
||||
#{item.systemTaskType},
|
||||
#{item.successNum},
|
||||
#{item.failNum},
|
||||
#{item.failReason},
|
||||
@ -72,32 +75,15 @@
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
|
||||
SELECT
|
||||
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), 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
|
||||
FROM (
|
||||
SELECT
|
||||
<choose>
|
||||
<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,
|
||||
DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt,
|
||||
success_num,
|
||||
fail_num,
|
||||
stop_num,
|
||||
@ -113,10 +99,10 @@
|
||||
<if test="groupName != null and groupName != '' ">
|
||||
AND group_name = #{groupName}
|
||||
</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>
|
||||
)
|
||||
GROUP BY createDt
|
||||
GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
|
||||
</select>
|
||||
|
||||
<select id="toJobTask"
|
||||
@ -127,7 +113,7 @@
|
||||
COALESCE(sum(fail_num), 0) AS failNum,
|
||||
COALESCE(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
|
||||
FROM job_summary
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
WHERE system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId}
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
AND group_name IN
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
@ -141,7 +127,12 @@
|
||||
SELECT * FROM
|
||||
(
|
||||
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
|
||||
FROM job_summary
|
||||
<where>
|
||||
@ -156,8 +147,9 @@
|
||||
</if>
|
||||
AND trigger_at BETWEEN #{startTime} AND #{endTime}
|
||||
</where>
|
||||
AND system_task_type = #{systemTaskType}
|
||||
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
|
||||
ORDER BY total DESC
|
||||
)
|
||||
|
@ -17,8 +17,18 @@
|
||||
</resultMap>
|
||||
<!-- 定义批量新增的 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)
|
||||
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=",">
|
||||
(
|
||||
|
@ -5,8 +5,9 @@
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/>
|
||||
<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="system_task_type" jdbcType="TINYINT" property="systemTaskType"/>
|
||||
<result column="success_num" jdbcType="TINYINT" property="successNum"/>
|
||||
<result column="fail_num" jdbcType="TINYINT" property="failNum"/>
|
||||
<result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
|
||||
@ -20,15 +21,16 @@
|
||||
|
||||
<insert id="insertOrUpdate" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
||||
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)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.jobId},
|
||||
#{item.businessId},
|
||||
#{item.triggerAt},
|
||||
#{item.systemTaskType},
|
||||
#{item.successNum},
|
||||
#{item.failNum},
|
||||
#{item.failReason},
|
||||
@ -38,7 +40,7 @@
|
||||
#{item.cancelReason}
|
||||
)
|
||||
</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,
|
||||
fail_num = EXCLUDED.fail_num,
|
||||
fail_reason = EXCLUDED.fail_reason,
|
||||
@ -51,29 +53,12 @@
|
||||
<select id="jobLineList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="type == 'DAY'">
|
||||
to_char(create_dt,'%H')
|
||||
</when>
|
||||
<when test="type == 'WEEK'">
|
||||
to_char(create_dt,'%Y-%m-%d')
|
||||
</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,
|
||||
DATE_FORMAT(trigger_at, #{dateFormat}) 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
|
||||
FROM job_summary
|
||||
<where>
|
||||
@ -86,9 +71,9 @@
|
||||
<if test="groupName != null and groupName != '' ">
|
||||
AND group_name = #{groupName}
|
||||
</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>
|
||||
GROUP BY createDt
|
||||
GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
|
||||
</select>
|
||||
|
||||
<select id="toJobTask"
|
||||
@ -99,7 +84,7 @@
|
||||
COALESCE(sum(fail_num), 0) AS failNum,
|
||||
COALESCE(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
|
||||
FROM job_summary
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
WHERE system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId}
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
AND group_name IN
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
@ -111,7 +96,12 @@
|
||||
<select id="dashboardRank"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
||||
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
|
||||
<where>
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
@ -125,8 +115,9 @@
|
||||
</if>
|
||||
AND trigger_at >= #{startTime} AND trigger_at <= #{endTime}
|
||||
</where>
|
||||
AND system_task_type = #{systemTaskType}
|
||||
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
|
||||
ORDER BY total DESC LIMIT 10
|
||||
</select>
|
||||
|
@ -18,8 +18,18 @@
|
||||
|
||||
<!-- 定义批量新增的 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)
|
||||
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=",">
|
||||
(
|
||||
|
@ -5,8 +5,9 @@
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="namespace_id" jdbcType="TINYINT" property="namespaceId"/>
|
||||
<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="system_task_type" jdbcType="TINYINT" property="systemTaskType"/>
|
||||
<result column="success_num" jdbcType="TINYINT" property="successNum"/>
|
||||
<result column="fail_num" jdbcType="TINYINT" property="failNum"/>
|
||||
<result column="fail_reason" jdbcType="VARCHAR" property="failReason"/>
|
||||
@ -26,8 +27,9 @@
|
||||
(
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.jobId},
|
||||
#{item.businessId},
|
||||
#{item.triggerAt},
|
||||
#{item.systemTaskType},
|
||||
#{item.successNum},
|
||||
#{item.failNum},
|
||||
#{item.failReason},
|
||||
@ -37,10 +39,10 @@
|
||||
#{item.cancelReason}
|
||||
)
|
||||
</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)
|
||||
ON target.namespace_id = source.namespace_id
|
||||
AND target.job_id = source.job_id
|
||||
AND target.business_id = source.business_id
|
||||
WHEN MATCHED THEN
|
||||
UPDATE SET
|
||||
target.success_num = source.success_num,
|
||||
@ -51,9 +53,9 @@
|
||||
target.cancel_num = source.cancel_num,
|
||||
target.cancel_reason = source.cancel_reason
|
||||
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)
|
||||
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.cancel_num, source.cancel_reason);
|
||||
</insert>
|
||||
@ -62,30 +64,14 @@
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardLineResponseDO">
|
||||
SELECT
|
||||
createDt,
|
||||
ISNULL(SUM(success_num), 0) AS success,
|
||||
ISNULL(SUM(stop_num), 0) AS stop,
|
||||
ISNULL(SUM(cancel_num), 0) AS cancel,
|
||||
ISNULL(SUM(fail_num), 0) AS fail,
|
||||
ISNULL(SUM(success_num), 0) AS success,
|
||||
ISNULL(SUM(stop_num), 0) AS stop,
|
||||
ISNULL(SUM(cancel_num), 0) AS cancel,
|
||||
ISNULL(SUM(fail_num), 0) AS fail,
|
||||
ISNULL(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
|
||||
FROM (
|
||||
SELECT
|
||||
<choose>
|
||||
<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,
|
||||
DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt,
|
||||
success_num,
|
||||
stop_num,
|
||||
cancel_num,
|
||||
@ -101,11 +87,12 @@
|
||||
<if test="groupName != null and groupName != '' ">
|
||||
AND group_name = #{groupName}
|
||||
</if>
|
||||
AND system_task_type = #{systemTaskType}
|
||||
AND namespace_id = #{namespaceId}
|
||||
AND trigger_at BETWEEN #{from} AND #{to}
|
||||
</where>
|
||||
) AS subquery
|
||||
GROUP BY createDt
|
||||
GROUP BY DATE_FORMAT(trigger_at, #{dateFormat})
|
||||
</select>
|
||||
|
||||
<select id="toJobTask"
|
||||
@ -117,7 +104,7 @@
|
||||
ISNULL(sum(fail_num), 0) AS failNum,
|
||||
ISNULL(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
|
||||
FROM job_summary
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
WHERE system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId}
|
||||
<if test="groupNames != null and groupNames.size > 0">
|
||||
AND group_name IN
|
||||
<foreach collection="groupNames" item="groupName" open="(" separator="," close=")">
|
||||
@ -129,7 +116,13 @@
|
||||
<select id="dashboardRank"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
||||
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
|
||||
FROM job_summary
|
||||
<where>
|
||||
@ -144,8 +137,9 @@
|
||||
</if>
|
||||
AND trigger_at BETWEEN #{startTime} AND #{endTime}
|
||||
AND namespace_id = #{namespaceId}
|
||||
AND system_task_type = #{systemTaskType}
|
||||
</where>
|
||||
GROUP BY namespace_id, group_name, job_id
|
||||
GROUP BY namespace_id, group_name, business_id
|
||||
HAVING SUM(fail_num) > 0
|
||||
ORDER BY name DESC
|
||||
</select>
|
||||
|
@ -115,7 +115,7 @@ public class JobLogMergeSchedule extends AbstractSchedule implements Lifecycle {
|
||||
List<JobTaskBatch> jobTaskBatchList = jobTaskBatchMapper.selectPage(
|
||||
new Page<>(0, 1000),
|
||||
new LambdaUpdateWrapper<JobTaskBatch>().ge(JobTaskBatch::getId, startId)
|
||||
.eq(JobTaskBatch::getTaskBatchStatus, JobTaskBatchStatusEnum.SUCCESS.getStatus())
|
||||
.in(JobTaskBatch::getTaskBatchStatus, JobTaskBatchStatusEnum.COMPLETED)
|
||||
.le(JobTaskBatch::getCreateDt, endTime)).getRecords();
|
||||
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(
|
||||
groupingBy(JobLogMessage::getTaskId)).entrySet().stream()
|
||||
groupingBy(JobLogMessage::getTaskId)).entrySet().stream()
|
||||
.filter(entry -> entry.getValue().size() >= 2).collect(toList());
|
||||
|
||||
for (Map.Entry<Long/*taskId*/, List<JobLogMessage>> jobLogMessageMap : jobLogMessageGroupList) {
|
||||
List<Long> jobLogMessageDeleteBatchIds = new ArrayList<>();
|
||||
List<JobLogMessage> jobLogMessageUpdateList = new ArrayList<>();
|
||||
List<JobLogMessage> jobLogMessageInsertBatchIds = new ArrayList<>();
|
||||
|
||||
List<String> mergeMessages = jobLogMessageMap.getValue().stream().map(k -> {
|
||||
jobLogMessageDeleteBatchIds.add(k.getId());
|
||||
return JsonUtil.parseObject(k.getMessage(), List.class);
|
||||
})
|
||||
.reduce((a, b) -> {
|
||||
// 合并日志信息
|
||||
List<String> list = new ArrayList<>();
|
||||
list.addAll(a);
|
||||
list.addAll(b);
|
||||
return list;
|
||||
}).get();
|
||||
jobLogMessageDeleteBatchIds.add(k.getId());
|
||||
return JsonUtil.parseObject(k.getMessage(), List.class);
|
||||
})
|
||||
.reduce((a, b) -> {
|
||||
// 合并日志信息
|
||||
List<String> list = new ArrayList<>();
|
||||
list.addAll(a);
|
||||
list.addAll(b);
|
||||
return list;
|
||||
}).get();
|
||||
|
||||
// 500条数据为一个批次
|
||||
List<List<String>> partitionMessages = Lists.partition(mergeMessages,
|
||||
systemProperties.getMergeLogNum());
|
||||
List<List<String>> partitionMessages = Lists.partition(mergeMessages, systemProperties.getMergeLogNum());
|
||||
|
||||
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);
|
||||
|
||||
jobLogMessage.setLogNum(messages.size());
|
||||
jobLogMessage.setMessage(JsonUtil.toJsonString(messages));
|
||||
jobLogMessageUpdateList.add(jobLogMessage);
|
||||
jobLogMessageInsertBatchIds.add(jobLogMessage);
|
||||
}
|
||||
|
||||
// 批量删除、更新日志
|
||||
if (CollectionUtil.isNotEmpty(jobLogMessageDeleteBatchIds)) {
|
||||
jobLogMessageMapper.deleteBatchIds(jobLogMessageDeleteBatchIds);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(jobLogMessageUpdateList)) {
|
||||
jobLogMessageMapper.batchUpdate(jobLogMessageUpdateList);
|
||||
if (CollectionUtil.isNotEmpty(jobLogMessageInsertBatchIds)) {
|
||||
jobLogMessageMapper.batchInsert(jobLogMessageInsertBatchIds);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class JobSummarySchedule extends AbstractSchedule implements Lifecycle {
|
||||
Map<Long, List<JobBatchSummaryResponseDO>> jobIdListMap = summaryResponseDOList.parallelStream().collect(Collectors.groupingBy(JobBatchSummaryResponseDO::getJobId));
|
||||
for (Map.Entry<Long, List<JobBatchSummaryResponseDO>> job : jobIdListMap.entrySet()) {
|
||||
JobSummary jobSummary = new JobSummary();
|
||||
jobSummary.setJobId(job.getKey());
|
||||
jobSummary.setBusinessId(job.getKey());
|
||||
jobSummary.setTriggerAt(triggerAt);
|
||||
jobSummary.setNamespaceId(job.getValue().get(0).getNamespaceId());
|
||||
jobSummary.setGroupName(job.getValue().get(0).getGroupName());
|
||||
|
@ -86,7 +86,7 @@ public class WorkflowJobSummarySchedule extends AbstractSchedule implements Life
|
||||
Map<Long, List<JobBatchSummaryResponseDO>> jobIdListMap = summaryResponseDOList.parallelStream().collect(Collectors.groupingBy(JobBatchSummaryResponseDO::getJobId));
|
||||
for (Map.Entry<Long, List<JobBatchSummaryResponseDO>> job : jobIdListMap.entrySet()) {
|
||||
JobSummary jobSummary = new JobSummary();
|
||||
jobSummary.setJobId(job.getKey());
|
||||
jobSummary.setBusinessId(job.getKey());
|
||||
jobSummary.setTriggerAt(triggerAt);
|
||||
jobSummary.setNamespaceId(job.getValue().get(0).getNamespaceId());
|
||||
jobSummary.setGroupName(job.getValue().get(0).getGroupName());
|
||||
|
Loading…
Reference in New Issue
Block a user