From 1aac34165c940202ced671a3b02e16ac8dfc560c Mon Sep 17 00:00:00 2001 From: xuxueli <931591021@qq.com> Date: Wed, 6 Jun 2018 22:09:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=93=E5=8D=B0=E6=9C=89?= =?UTF-8?q?=E5=8F=82=E6=97=A5=E5=BF=97=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/XXL-JOB官方文档.md | 1 + .../core/thread/JobFailMonitorHelper.java | 9 ++++---- .../mybatis-mapper/XxlJobLogMapper.xml | 2 +- .../com/xxl/job/core/log/XxlJobLogger.java | 22 +++++++++++-------- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md index 09992d44..0fededb4 100644 --- a/doc/XXL-JOB官方文档.md +++ b/doc/XXL-JOB官方文档.md @@ -1217,6 +1217,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段 - 12、脚本任务异常Log输出优化; - 13、任务线程停止变量修饰符优化; - 14、脚本任务Log文件流关闭优化; +- 15、任务报表成功、失败和进行中统计问题修复; ### TODO LIST diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java index 66a77346..0d5ab6e3 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/thread/JobFailMonitorHelper.java @@ -56,21 +56,22 @@ public class JobFailMonitorHelper { continue; } if (IJobHandler.SUCCESS.getCode() == log.getTriggerCode() && log.getHandleCode() == 0) { + // job running JobFailMonitorHelper.monitor(jobLogId); logger.info(">>>>>>>>>>> job monitor, job running, JobLogId:{}", jobLogId); } else if (IJobHandler.SUCCESS.getCode() == log.getHandleCode()) { // job success, pass logger.info(">>>>>>>>>>> job monitor, job success, JobLogId:{}", jobLogId); - } else if (IJobHandler.FAIL.getCode() == log.getTriggerCode() + } else /*if (IJobHandler.FAIL.getCode() == log.getTriggerCode() || IJobHandler.FAIL.getCode() == log.getHandleCode() - || IJobHandler.FAIL_RETRY.getCode() == log.getHandleCode() ) { + || IJobHandler.FAIL_RETRY.getCode() == log.getHandleCode() )*/ { // job fail, failAlarm(log); logger.info(">>>>>>>>>>> job monitor, job fail, JobLogId:{}", jobLogId); - } else { + }/* else { JobFailMonitorHelper.monitor(jobLogId); logger.info(">>>>>>>>>>> job monitor, job status unknown, JobLogId:{}", jobLogId); - } + }*/ } } diff --git a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml index 9c512a00..e125ac22 100644 --- a/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml +++ b/xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml @@ -172,7 +172,7 @@ SELECT DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay, COUNT(handle_code) triggerDayCount, - SUM(CASE WHEN handle_code = 0 then 1 else 0 end) as triggerDayCountRunning, + SUM(CASE WHEN (trigger_code = 200 and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning, SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc FROM XXL_JOB_QRTZ_TRIGGER_LOG WHERE trigger_time BETWEEN #{from} and #{to} diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobLogger.java b/xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobLogger.java index 248d9de0..5205027a 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobLogger.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobLogger.java @@ -1,14 +1,15 @@ package com.xxl.job.core.log; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.PrintWriter; import java.io.StringWriter; -import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.Date; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.helpers.FormattingTuple; +import org.slf4j.helpers.MessageFormatter; + /** * Created by xuxueli on 17/4/28. */ @@ -54,12 +55,15 @@ public class XxlJobLogger { */ public static void log(String appendLogPattern, Object ... appendLogArguments) { - String appendLog = appendLogPattern; - if (appendLogArguments!=null && appendLogArguments.length>0) { - appendLog = MessageFormat.format(appendLogPattern, appendLogArguments); - } - + FormattingTuple ft = MessageFormatter.format(appendLogPattern, appendLogArguments); + + String appendLog = ft.getMessage(); StackTraceElement callInfo = new Throwable().getStackTrace()[1]; + +// appendLog = appendLogPattern; +// if (appendLogArguments!=null && appendLogArguments.length>0) { +// appendLog = MessageFormat.format(appendLogPattern, appendLogArguments); +// } logDetail(callInfo, appendLog); }