From 0f93f5d2abae72f97857dd8a6ee45ea450e7e718 Mon Sep 17 00:00:00 2001 From: XinWei <2718030729@qq.com> Date: Thu, 11 Jul 2024 13:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E5=BA=A6=E4=B8=AD=E5=BF=83API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xxl/job/admin/api/log/JobLogApi.java | 9 +++- .../xxl/job/admin/api/log/JobLogApiImpl.java | 29 +++++++++---- .../com/xxl/job/admin/dao/XxlJobLogDao.java | 11 ++++- .../mybatis-mapper/XxlJobLogMapper.xml | 42 ++++++++++++++++++- .../admin/joblog/JobLogController.java | 6 +-- .../src/main/resources/application.yaml | 1 - 6 files changed, 83 insertions(+), 15 deletions(-) diff --git a/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/JobLogApi.java b/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/JobLogApi.java index 960f1018f..1d8a55164 100644 --- a/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/JobLogApi.java +++ b/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/JobLogApi.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import javax.validation.Valid; +import java.util.Date; /** * @Description 调度任务日志Api接口 @@ -23,7 +24,13 @@ public interface JobLogApi { String PREFIX = ApiConstants.PREFIX + "/log"; @GetMapping(PREFIX + "/page") @Operation(summary = "获得所有任务列表") - public CommonResult> getPage(@Valid JobLogPageReqDTO jobLogPageReqDTO); + public CommonResult> getPage(@RequestParam(value = "pageNo") Integer pageNo, + @RequestParam(value = "pageSize") Integer pageSize, + @RequestParam(value = "jobId") Integer jobId, + @RequestParam(required = false, value = "handlerName") String handlerName, + @RequestParam(required = false, value = "beginTime") Date beginTime, + @RequestParam(required = false, value = "endTime") Date endTime, + @RequestParam(required = false, value = "status") Integer status); @GetMapping(PREFIX + "/get") @Operation(summary = "获得任务日志详情") diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/api/log/JobLogApiImpl.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/api/log/JobLogApiImpl.java index 2a47c1a27..74d43a19a 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/api/log/JobLogApiImpl.java +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/api/log/JobLogApiImpl.java @@ -16,6 +16,7 @@ import com.xxl.job.core.util.DateUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; @@ -40,13 +41,26 @@ public class JobLogApiImpl implements JobLogApi { public XxlJobLogDao xxlJobLogDao; @Override - public CommonResult> getPage(JobLogPageReqDTO jobLogPageReqDTO) { + public CommonResult> getPage(Integer pageNo, + Integer pageSize, + Integer jobId, + String handlerName, + Date beginTime, + Date endTime, + Integer status) { + JobLogPageReqDTO jobLogPageReqDTO = new JobLogPageReqDTO(); + jobLogPageReqDTO.setPageNo(pageNo); + jobLogPageReqDTO.setPageSize(pageSize); + jobLogPageReqDTO.setJobId(jobId); + jobLogPageReqDTO.setHandlerName(handlerName); + jobLogPageReqDTO.setBeginTime(beginTime); + jobLogPageReqDTO.setEndTime(endTime); + jobLogPageReqDTO.setStatus(status); // 设置默认组为3 int jobGroup = 3; - int status = jobLogPageReqDTO.getStatus() == null ? -1 : jobLogPageReqDTO.getStatus(); // page query - List list = xxlJobLogDao.apiPageList(jobLogPageReqDTO.getPageNo(), jobLogPageReqDTO.getPageSize(), jobGroup, jobLogPageReqDTO.getJobId(), jobLogPageReqDTO.getBeginTime(), jobLogPageReqDTO.getEndTime(), status); - int list_count = xxlJobLogDao.pageListCount(jobLogPageReqDTO.getPageNo(), jobLogPageReqDTO.getPageSize(), jobGroup, jobLogPageReqDTO.getJobId(), jobLogPageReqDTO.getBeginTime(), jobLogPageReqDTO.getEndTime(), status); + List list = xxlJobLogDao.apiPageList(jobLogPageReqDTO.getPageNo(), jobLogPageReqDTO.getPageSize(), jobGroup, jobLogPageReqDTO.getJobId(), jobLogPageReqDTO.getBeginTime(), jobLogPageReqDTO.getEndTime(), status, jobLogPageReqDTO.getHandlerName()); + int list_count = xxlJobLogDao.apiPageListCount(jobLogPageReqDTO.getPageNo(), jobLogPageReqDTO.getPageSize(), jobGroup, jobLogPageReqDTO.getJobId(), jobLogPageReqDTO.getBeginTime(), jobLogPageReqDTO.getEndTime(), status, jobLogPageReqDTO.getHandlerName()); // package result PageResult pageResult = new PageResult<>(); pageResult.setTotal((long) list_count); @@ -60,13 +74,14 @@ public class JobLogApiImpl implements JobLogApi { JobLogRespDTO jobLogRespDTO = new JobLogRespDTO(); jobLogRespDTO.setId(id); jobLogRespDTO.setJobId(load.getJobId()); - jobLogRespDTO.setDuration((int)(load.getHandleTime().getTime() - load.getTriggerTime().getTime())); + if (load.getTriggerCode() == 200) { + jobLogRespDTO.setDuration((int) (load.getHandleTime().getTime() - load.getTriggerTime().getTime())); + } jobLogRespDTO.setBeginTime(load.getTriggerTime()); jobLogRespDTO.setEndTime(load.getHandleTime()); jobLogRespDTO.setHandlerName(load.getExecutorHandler()); jobLogRespDTO.setHandlerParam(load.getExecutorParam()); - jobLogRespDTO.setStatus(load.getAlarmStatus()); - jobLogRespDTO.setExecuteIndex(1); + jobLogRespDTO.setStatus(load.getHandleCode() == 200 ? 1 : 2); return CommonResult.success(jobLogRespDTO); } } diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java index fe73542f8..7a5f288a5 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java @@ -30,7 +30,8 @@ public interface XxlJobLogDao { @Param("jobId") int jobId, @Param("triggerTimeStart") Date triggerTimeStart, @Param("triggerTimeEnd") Date triggerTimeEnd, - @Param("logStatus") Integer logStatus); + @Param("logStatus") Integer logStatus, + @Param("handlerName") String handlerName); public int pageListCount(@Param("offset") int offset, @Param("pagesize") int pagesize, @Param("jobGroup") int jobGroup, @@ -67,4 +68,12 @@ public interface XxlJobLogDao { public List findLostJobIds(@Param("losedTime") Date losedTime); + int apiPageListCount(@Param("offset") int offset, + @Param("pagesize") int pagesize, + @Param("jobGroup") int jobGroup, + @Param("jobId") int jobId, + @Param("triggerTimeStart") Date triggerTimeStart, + @Param("triggerTimeEnd") Date triggerTimeEnd, + @Param("logStatus") Integer logStatus, + @Param("handlerName") String handlerName); } diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml index 8fdbbbe6a..32d118ac3 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml @@ -87,10 +87,11 @@ - + +