From b5b7846aad51f2d3f335cb0c110b1300199d02e0 Mon Sep 17 00:00:00 2001 From: zhengweilin Date: Wed, 27 Mar 2024 11:46:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=203.2.0=20=E5=B7=A5=E4=BD=9C=E6=B5=81Dash?= =?UTF-8?q?board=E5=A4=9A=E6=95=B0=E6=8D=AE=E6=BA=90=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=8F=90=E4=BA=A4I93NGB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/JobLogMessageMapper.java | 2 - .../datasource/persistence/po/JobSummary.java | 2 +- .../mariadb/mapper/JobLogMessageMapper.xml | 14 +++- .../mariadb/mapper/JobSummaryMapper.xml | 55 ++++++-------- .../mysql/mapper/JobLogMessageMapper.xml | 29 +++---- .../mysql/mapper/JobSummaryMapper.xml | 13 ++-- .../oracle/mapper/JobLogMessageMapper.xml | 14 +++- .../oracle/mapper/JobSummaryMapper.xml | 76 +++++++++---------- .../postgres/mapper/JobLogMessageMapper.xml | 14 +++- .../postgres/mapper/JobSummaryMapper.xml | 55 ++++++-------- .../sqlserver/mapper/JobLogMessageMapper.xml | 14 +++- .../sqlserver/mapper/JobSummaryMapper.xml | 56 ++++++-------- .../support/schedule/JobLogMergeSchedule.java | 38 +++++----- .../support/schedule/JobSummarySchedule.java | 2 +- .../schedule/WorkflowJobSummarySchedule.java | 2 +- 15 files changed, 193 insertions(+), 193 deletions(-) diff --git a/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/mapper/JobLogMessageMapper.java b/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/mapper/JobLogMessageMapper.java index 497218ef..ba11c5ef 100644 --- a/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/mapper/JobLogMessageMapper.java +++ b/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/mapper/JobLogMessageMapper.java @@ -18,6 +18,4 @@ import java.util.List; public interface JobLogMessageMapper extends BaseMapper { int batchInsert(List list); - - int batchUpdate(List list); } diff --git a/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/po/JobSummary.java b/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/po/JobSummary.java index 71a3cbcf..5b5a46db 100644 --- a/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/po/JobSummary.java +++ b/easy-retry-datasource/easy-retry-datasource-template/src/main/java/com/aizuda/easy/retry/template/datasource/persistence/po/JobSummary.java @@ -40,7 +40,7 @@ public class JobSummary implements Serializable { /** * '任务信息id' */ - private Long jobId; + private Long businessId; /** * '统计时间' diff --git a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobLogMessageMapper.xml b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobLogMessageMapper.xml index 98696452..11f0b99a 100644 --- a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobLogMessageMapper.xml +++ b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobLogMessageMapper.xml @@ -18,8 +18,18 @@ - 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 ( diff --git a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobSummaryMapper.xml b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobSummaryMapper.xml index 4017a30d..6edc1ff8 100644 --- a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobSummaryMapper.xml +++ b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobSummaryMapper.xml @@ -5,8 +5,9 @@ - + + @@ -20,15 +21,16 @@ 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 ( #{item.namespaceId}, #{item.groupName}, - #{item.jobId}, + #{item.businessId}, #{item.triggerAt}, + #{item.systemTaskType}, #{item.successNum}, #{item.failNum}, #{item.failReason}, @@ -51,29 +53,12 @@ SELECT - 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, + + + CONCAT(group_name, '/', (SELECT workflow_name FROM workflow WHERE id = business_id)) name, + SUM(fail_num) AS total FROM job_summary @@ -125,8 +115,9 @@ AND trigger_at >= #{startTime} AND trigger_at <= #{endTime} + 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 @@ -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} diff --git a/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobLogMessageMapper.xml b/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobLogMessageMapper.xml index 923a9401..11f0b99a 100644 --- a/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobLogMessageMapper.xml +++ b/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobLogMessageMapper.xml @@ -18,8 +18,18 @@ - 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 ( @@ -35,19 +45,4 @@ ) - - - UPDATE job_log_message jlm, - ( - - SELECT - #{item.message} AS message, - #{item.logNum} AS log_num, - #{item.id} AS id - - ) tt - SET - jlm.message = tt.message, jlm.log_num = tt.log_num - WHERE jlm.id = tt.id - diff --git a/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobSummaryMapper.xml b/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobSummaryMapper.xml index 68cc65f7..2906f463 100644 --- a/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobSummaryMapper.xml +++ b/easy-retry-datasource/easy-retry-mysql-datasource/src/main/resources/mysql/mapper/JobSummaryMapper.xml @@ -5,8 +5,9 @@ - + + @@ -20,14 +21,14 @@ 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 ( #{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 - 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, - 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, SUM(fail_num) AS total FROM job_summary @@ -116,7 +117,7 @@ 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 diff --git a/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobLogMessageMapper.xml b/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobLogMessageMapper.xml index ac1d0630..91bbeb71 100644 --- a/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobLogMessageMapper.xml +++ b/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobLogMessageMapper.xml @@ -20,8 +20,18 @@ INSERT ALL - 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}, diff --git a/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml b/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml index ac3f2ae9..29097370 100644 --- a/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml +++ b/easy-retry-datasource/easy-retry-oracle-datasource/src/main/resources/oracle/mapper/JobSummaryMapper.xml @@ -5,8 +5,9 @@ - + + @@ -23,21 +24,22 @@ USING ( 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 ) 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 @@ -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 - - - TO_CHAR(create_dt, 'HH24') - - - TO_CHAR(create_dt, 'yyyy-MM-dd') - - - TO_CHAR(create_dt, 'yyyy-MM-dd') - - - TO_CHAR(create_dt, 'yyyy-MM') - - - TO_CHAR(create_dt, 'yyyy-MM-dd') - - - AS createDt, + DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt, success_num, fail_num, stop_num, @@ -113,10 +99,10 @@ AND group_name = #{groupName} - 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} ) - GROUP BY createDt + GROUP BY DATE_FORMAT(trigger_at, #{dateFormat}) SELECT - - - to_char(create_dt,'%H') - - - to_char(create_dt,'%Y-%m-%d') - - - to_char(create_dt,'%Y-%m-%d') - - - to_char(create_dt,'%Y-%m') - - - to_char(create_dt,'%Y-%m-%d') - - - 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 @@ -86,9 +71,9 @@ AND group_name = #{groupName} - 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} - GROUP BY createDt + GROUP BY DATE_FORMAT(trigger_at, #{dateFormat}) SELECT - 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, + + + CONCAT(group_name, '/', (SELECT workflow_name FROM workflow WHERE id = business_id)) name, + SUM(fail_num) AS total FROM job_summary @@ -125,8 +115,9 @@ AND trigger_at >= #{startTime} AND trigger_at <= #{endTime} + 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 diff --git a/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobLogMessageMapper.xml b/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobLogMessageMapper.xml index 5abf6d9d..42d4ddf3 100644 --- a/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobLogMessageMapper.xml +++ b/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobLogMessageMapper.xml @@ -18,8 +18,18 @@ - 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 ( diff --git a/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobSummaryMapper.xml b/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobSummaryMapper.xml index 2a25e335..f1e38ff7 100644 --- a/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobSummaryMapper.xml +++ b/easy-retry-datasource/easy-retry-sqlserver-datasource/src/main/resources/sqlserver/mapper/JobSummaryMapper.xml @@ -5,8 +5,9 @@ - + + @@ -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} ) - ) 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); @@ -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 - - - FORMAT(create_dt,'HH24') - - - FORMAT(create_dt,'yyyy-MM-dd') - - - FORMAT(create_dt,'yyyy-MM-dd') - - - FORMAT(create_dt,'yyyy-MM') - - - FORMAT(create_dt,'yyyy-MM-dd') - - AS createDt, + DATE_FORMAT(trigger_at, #{dateFormat}) AS createDt, success_num, stop_num, cancel_num, @@ -101,11 +87,12 @@ AND group_name = #{groupName} + AND system_task_type = #{systemTaskType} AND namespace_id = #{namespaceId} AND trigger_at BETWEEN #{from} AND #{to} ) AS subquery - GROUP BY createDt + GROUP BY DATE_FORMAT(trigger_at, #{dateFormat}) SELECT TOP 10 - 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, + + + CONCAT(group_name, '/', (SELECT workflow_name FROM workflow WHERE id = business_id)) name, + SUM(fail_num) AS total FROM job_summary @@ -144,8 +137,9 @@ AND trigger_at BETWEEN #{startTime} AND #{endTime} AND namespace_id = #{namespaceId} + AND system_task_type = #{systemTaskType} - 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 diff --git a/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/JobLogMergeSchedule.java b/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/JobLogMergeSchedule.java index 18786e76..ee250c5c 100644 --- a/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/JobLogMergeSchedule.java +++ b/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/JobLogMergeSchedule.java @@ -115,7 +115,7 @@ public class JobLogMergeSchedule extends AbstractSchedule implements Lifecycle { List jobTaskBatchList = jobTaskBatchMapper.selectPage( new Page<>(0, 1000), new LambdaUpdateWrapper().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>> 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> jobLogMessageMap : jobLogMessageGroupList) { List jobLogMessageDeleteBatchIds = new ArrayList<>(); - List jobLogMessageUpdateList = new ArrayList<>(); + List jobLogMessageInsertBatchIds = new ArrayList<>(); List mergeMessages = jobLogMessageMap.getValue().stream().map(k -> { - jobLogMessageDeleteBatchIds.add(k.getId()); - return JsonUtil.parseObject(k.getMessage(), List.class); - }) - .reduce((a, b) -> { - // 合并日志信息 - List 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 list = new ArrayList<>(); + list.addAll(a); + list.addAll(b); + return list; + }).get(); // 500条数据为一个批次 - List> partitionMessages = Lists.partition(mergeMessages, - systemProperties.getMergeLogNum()); + List> 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 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); } } - } }); } diff --git a/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/JobSummarySchedule.java b/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/JobSummarySchedule.java index 84436f90..79126e3f 100644 --- a/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/JobSummarySchedule.java +++ b/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/JobSummarySchedule.java @@ -83,7 +83,7 @@ public class JobSummarySchedule extends AbstractSchedule implements Lifecycle { Map> jobIdListMap = summaryResponseDOList.parallelStream().collect(Collectors.groupingBy(JobBatchSummaryResponseDO::getJobId)); for (Map.Entry> 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()); diff --git a/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/WorkflowJobSummarySchedule.java b/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/WorkflowJobSummarySchedule.java index 8dc6349a..3c02c0e4 100644 --- a/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/WorkflowJobSummarySchedule.java +++ b/easy-retry-server/easy-retry-server-job-task/src/main/java/com/aizuda/easy/retry/server/job/task/support/schedule/WorkflowJobSummarySchedule.java @@ -86,7 +86,7 @@ public class WorkflowJobSummarySchedule extends AbstractSchedule implements Life Map> jobIdListMap = summaryResponseDOList.parallelStream().collect(Collectors.groupingBy(JobBatchSummaryResponseDO::getJobId)); for (Map.Entry> 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()); -- Gitee