diff --git a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/appernder/EasyRetryLog4j2Appender.java b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/appernder/EasyRetryLog4j2Appender.java index c59be35d..a024c89a 100644 --- a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/appernder/EasyRetryLog4j2Appender.java +++ b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/appernder/EasyRetryLog4j2Appender.java @@ -34,7 +34,7 @@ public class EasyRetryLog4j2Appender extends AbstractAppender { if (Objects.isNull(ThreadLocalLogUtil.getContext())) { return; } - + LogContentDTO logContentDTO = new LogContentDTO(); logContentDTO.addTimeStamp(event.getTimeMillis()); logContentDTO.addLevelField(event.getLevel().name()); diff --git a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/dto/LogContentDTO.java b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/dto/LogContentDTO.java index f4fe7b77..926e21b9 100644 --- a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/dto/LogContentDTO.java +++ b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/dto/LogContentDTO.java @@ -6,6 +6,8 @@ import lombok.Data; import java.util.ArrayList; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; /** * @author wodeyangzipingpingwuqi @@ -32,6 +34,11 @@ public class LogContentDTO { this.addField(LogFieldConstant.TIME_STAMP, String.valueOf(timeStamp)); } + public Long getTimeStamp() { + return Long.parseLong(fieldList.stream().filter(taskLogFieldDTO -> !Objects.isNull(taskLogFieldDTO.getValue())) + .collect(Collectors.toMap(TaskLogFieldDTO::getName, TaskLogFieldDTO::getValue)).get(LogFieldConstant.TIME_STAMP)); + } + public void addLevelField(String level) { this.addField(LogFieldConstant.LEVEL, level); } diff --git a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/report/AsyncReportLog.java b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/report/AsyncReportLog.java index d37bdc61..736dea83 100644 --- a/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/report/AsyncReportLog.java +++ b/easy-retry-client/easy-retry-client-common/src/main/java/com/aizuda/easy/retry/client/common/report/AsyncReportLog.java @@ -12,8 +12,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.time.LocalDateTime; -import java.time.ZoneOffset; import java.util.Objects; /** @@ -77,12 +75,12 @@ public class AsyncReportLog implements Lifecycle, Report { JobContext context = ThreadLocalLogUtil.getContext(); LogTaskDTO logTaskDTO = new LogTaskDTO(); - logTaskDTO.setRealTime(LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli()); + logTaskDTO.setJobId(context.getJobId()); + logTaskDTO.setTaskId(context.getTaskId()); + logTaskDTO.setTaskBatchId(context.getTaskBatchId()); + logTaskDTO.setRealTime(logContentDTO.getTimeStamp()); logTaskDTO.setNamespaceId(context.getNamespaceId()); logTaskDTO.setGroupName(context.getGroupName()); - logTaskDTO.setJobId(context.getJobId()); - logTaskDTO.setTaskBatchId(context.getTaskBatchId()); - logTaskDTO.setTaskId(context.getTaskId()); logTaskDTO.setFieldList(logContentDTO.getFieldList()); return logTaskDTO; } 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 b43732be..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 @@ -4,6 +4,8 @@ import com.aizuda.easy.retry.template.datasource.persistence.po.JobLogMessage; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** *
* 调度日志 Mapper 接口
@@ -15,4 +17,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface JobLogMessageMapper extends BaseMapper