From 7cb1edced371099f4fa55f0645d9223e7f04e66e Mon Sep 17 00:00:00 2001 From: lius <Lius2225@163.com> Date: 星期六, 05 八月 2023 14:45:50 +0800 Subject: [PATCH] 定时任务功能维护 --- lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/controller/SysQuartzLogController.java | 61 +++++++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/entity/SysQuartzLog.java | 77 +++++++++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/dto/SysQuartzLogDto.java | 35 ++++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/SysQuartzLogServiceImpl.java | 50 ++++++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentShiftStatisticalProcessJob.java | 27 +++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/vo/SysQuartzLogVo.java | 24 +++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/GenerateWeekDaysJob.java | 26 ++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentStatisticalProcessJob.java | 27 +++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/mapper/SysQuartzLogMapper.java | 23 ++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/mapper/xml/SysQuartzLogMapper.xml | 68 ++++++++ lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/service/ISysQuartzLogService.java | 36 ++++ lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentTraceProcessJob.java | 26 ++ 12 files changed, 468 insertions(+), 12 deletions(-) diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/GenerateWeekDaysJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/GenerateWeekDaysJob.java index 6d2114e..bfa06db 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/GenerateWeekDaysJob.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/GenerateWeekDaysJob.java @@ -3,11 +3,16 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.util.DateUtils; import org.jeecg.modules.mdc.service.IMdcVacationManagementService; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import javax.annotation.Resource; +import java.util.List; /** * 鐢熸垚鍙屼紤鏃ュ畾鏃朵换鍔� @@ -21,15 +26,30 @@ @Resource private IMdcVacationManagementService mdcVacationManagementService; + @Resource + private ISysQuartzLogService sysQuartzLogService; + + @Resource + private IQuartzJobService quartzJobService; + @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + SysQuartzLog quartzLog = new SysQuartzLog(); + List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } log.info("瀹氭椂鐢熸垚鍙屼紤鏃ヤ换鍔� GenerateWeekDaysJob start! 鏃堕棿:" + DateUtils.now()); + long startTime = System.currentTimeMillis(); try { mdcVacationManagementService.generateWeekDays(); - log.info("瀹氭椂鐢熸垚鍙屼紤鏃ヤ换鍔� GenerateWeekDaysJob 鎵ц鎴愬姛!"); + quartzLog.setIsSuccess(0); } catch (Exception e) { - log.error("瀹氭椂鐢熸垚鍙屼紤鏃ヤ换鍔� GenerateWeekDaysJob 鎵ц澶辫触!"); - log.error(e.getMessage(), e); + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(e.toString()); } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); } } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentShiftStatisticalProcessJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentShiftStatisticalProcessJob.java index 5443fa9..78b6562 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentShiftStatisticalProcessJob.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentShiftStatisticalProcessJob.java @@ -3,9 +3,14 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.util.DateUtils; import org.jeecg.modules.mdc.service.IMdcEquipmentStatisticalShiftInfoService; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; import org.quartz.*; import javax.annotation.Resource; +import java.util.List; /** * @Description: 瀹氭椂缁熻鍗曟棩鐝鏁版嵁浠诲姟 @@ -29,15 +34,31 @@ @Resource private IMdcEquipmentStatisticalShiftInfoService mdcEquipmentStatisticalShiftInfoService; + @Resource + private ISysQuartzLogService sysQuartzLogService; + + @Resource + private IQuartzJobService quartzJobService; + @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + SysQuartzLog quartzLog = new SysQuartzLog(); + List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } + quartzLog.setParams(this.parameter); log.info(String.format("瀹氭椂缁熻鍗曟棩鐝鏁版嵁浠诲姟 param: %s RunningAllEquipmentShiftStatisticalProcessJob start! 鏃堕棿:" + DateUtils.now(), this.parameter)); + long startTime = System.currentTimeMillis(); try { mdcEquipmentStatisticalShiftInfoService.runningAllEquipmentShiftStatisticalProcess(this.parameter); - log.info("瀹氭椂缁熻鍗曟棩鐝鏁版嵁浠诲姟 RunningAllEquipmentShiftStatisticalProcessJob 鎵ц鎴愬姛!"); + quartzLog.setIsSuccess(0); } catch (Exception e) { - log.error("瀹氭椂缁熻鍗曟棩鐝鏁版嵁浠诲姟 RunningAllEquipmentShiftStatisticalProcessJob 鎵ц澶辫触!"); - log.error(e.getMessage(), e); + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(e.toString()); } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); } } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentStatisticalProcessJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentStatisticalProcessJob.java index 6994ef8..19dc333 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentStatisticalProcessJob.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentStatisticalProcessJob.java @@ -3,9 +3,14 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.util.DateUtils; import org.jeecg.modules.mdc.service.IMdcEquipmentStatisticalInfoService; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; import org.quartz.*; import javax.annotation.Resource; +import java.util.List; /** * @Description: 瀹氭椂缁熻鍗曟棩鏁版嵁浠诲姟 @@ -29,15 +34,31 @@ @Resource private IMdcEquipmentStatisticalInfoService mdcEquipmentStatisticalInfoService; + @Resource + private ISysQuartzLogService sysQuartzLogService; + + @Resource + private IQuartzJobService quartzJobService; + @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + SysQuartzLog quartzLog = new SysQuartzLog(); + List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } + quartzLog.setParams(this.parameter); log.info(String.format("瀹氭椂缁熻鍗曟棩鏁版嵁浠诲姟 param: %s RunningAllEquipmentStatisticalProcessJob start! 鏃堕棿:" + DateUtils.now(), this.parameter)); + long startTime = System.currentTimeMillis(); try { mdcEquipmentStatisticalInfoService.runningAllEquipmentStatisticalProcess(this.parameter); - log.info("瀹氭椂缁熻鍗曟棩鏁版嵁浠诲姟 RunningAllEquipmentStatisticalProcessJob 鎵ц鎴愬姛!"); + quartzLog.setIsSuccess(0); } catch (Exception e) { - log.error("瀹氭椂缁熻鍗曟棩鏁版嵁浠诲姟 RunningAllEquipmentStatisticalProcessJob 鎵ц澶辫触!"); - log.error(e.getMessage(), e); + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(e.toString()); } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); } } diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentTraceProcessJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentTraceProcessJob.java index 2ca3212..1bf9f08 100644 --- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentTraceProcessJob.java +++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentTraceProcessJob.java @@ -3,9 +3,14 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.util.DateUtils; import org.jeecg.modules.mdc.service.IMdcEquipmentRunningSectionService; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; import org.quartz.*; import javax.annotation.Resource; +import java.util.List; /** * @Description: 瀹氭椂璁$畻娈垫椂闂� @@ -20,15 +25,30 @@ @Resource private IMdcEquipmentRunningSectionService mdcEquipmentRunningSectionService; + @Resource + private ISysQuartzLogService sysQuartzLogService; + + @Resource + private IQuartzJobService quartzJobService; + @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + SysQuartzLog quartzLog = new SysQuartzLog(); + List<QuartzJob> byJobClassName = this.quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } log.info("瀹氭椂缁熻娈垫椂闂翠换鍔� RunningAllEquipmentTraceProcessJob start! 鏃堕棿:" + DateUtils.now()); + long startTime = System.currentTimeMillis(); try { mdcEquipmentRunningSectionService.runningAllEquipmentTraceProcess(); - log.info("瀹氭椂缁熻娈垫椂闂翠换鍔� RunningAllEquipmentTraceProcessJob 鎵ц鎴愬姛!"); + quartzLog.setIsSuccess(0); } catch (Exception e) { - log.error("瀹氭椂缁熻娈垫椂闂翠换鍔� RunningAllEquipmentTraceProcessJob 鎵ц澶辫触!"); - log.error(e.getMessage(), e); + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(e.toString()); } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); } } diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/controller/SysQuartzLogController.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/controller/SysQuartzLogController.java new file mode 100644 index 0000000..533f6ea --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/controller/SysQuartzLogController.java @@ -0,0 +1,61 @@ +package org.jeecg.modules.quartz.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.quartz.dto.SysQuartzLogDto; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; +import org.jeecg.modules.quartz.vo.SysQuartzLogVo; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + +/** + * @Description: 瀹氭椂浠诲姟鏃ュ織 + * @author: LiuS + * @create: 2023-08-05 14:01 + */ +@Slf4j +@Api(tags = "瀹氭椂浠诲姟鏃ュ織鎺ュ彛") +@RestController +@RequestMapping("/sys/quartzLog") +public class SysQuartzLogController extends JeecgController<SysQuartzLog, ISysQuartzLogService> { + + @Resource + private ISysQuartzLogService sysQuartzLogService; + + @AutoLog(value = "瀹氭椂浠诲姟鏃ュ織鎺ュ彛-鍒嗛〉鍒楄〃鏌ヨ") + @ApiOperation(value = "瀹氭椂浠诲姟鏃ュ織鎺ュ彛-鍒嗛〉鍒楄〃鏌ヨ", notes = "瀹氭椂浠诲姟鏃ュ織鎺ュ彛-鍒嗛〉鍒楄〃鏌ヨ") + @GetMapping(value = "/list") + public Result<IPage<SysQuartzLogDto>> queryList(SysQuartzLogVo sysQuartzLogVo, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { + if (StringUtils.isBlank(sysQuartzLogVo.getJobId())) { + return Result.error("浠诲姟ID涓嶈兘涓虹┖锛�"); + } + IPage<SysQuartzLogDto> result = sysQuartzLogService.pageList(pageNo, pageSize, sysQuartzLogVo); + return Result.OK(result); + } + + @AutoLog(value = "瀹氭椂浠诲姟鏃ュ織鎺ュ彛-瀵煎嚭") + @ApiOperation(value = "瀹氭椂浠诲姟鏃ュ織鎺ュ彛-瀵煎嚭", notes = "瀹氭椂浠诲姟鏃ュ織鎺ュ彛-瀵煎嚭") + @RequestMapping("/exportXls") + public ModelAndView exportXls(HttpServletRequest request, SysQuartzLogVo sysQuartzLogVo) { + return this.sysQuartzLogService.exportXls(sysQuartzLogVo); + } + + +} diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/dto/SysQuartzLogDto.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/dto/SysQuartzLogDto.java new file mode 100644 index 0000000..2683964 --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/dto/SysQuartzLogDto.java @@ -0,0 +1,35 @@ +package org.jeecg.modules.quartz.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * @author: LiuS + * @create: 2023-08-05 14:05 + */ +@Data +public class SysQuartzLogDto { + + @Excel(name = "浠诲姟绫诲悕", width = 40) + private String jobClassName; + @Excel(name = "cron琛ㄨ揪寮�", width = 30) + private String cronExpression; + @Excel(name = "鍙傛暟", width = 15) + private String parameter; + @Excel(name = "鎻忚堪", width = 40) + private String description; + @Excel(name = "鎶ラ敊淇℃伅", width = 50) + private String exceptionDetail; + @Excel(name = "鎴愬姛鏍囧織 0鎴愬姛 -1澶辫触", width = 15) + private Integer isSuccess; + @Excel(name = "鎵ц鏃堕棿", width = 15) + private Integer executionTime; + @Excel(name = "鍒涘缓鏃堕棿", width = 20, format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; +} diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/entity/SysQuartzLog.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/entity/SysQuartzLog.java new file mode 100644 index 0000000..dbe3a6d --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/entity/SysQuartzLog.java @@ -0,0 +1,77 @@ +package org.jeecg.modules.quartz.entity; + +import java.io.Serializable; +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; +import org.jeecgframework.poi.excel.annotation.Excel; + +/** + * @Description: 瀹氭椂浠诲姟鏃ュ織 + * @Author: Lius + * @Date: 2023-08-05 + * @Version: V1.0 + */ +@Data +@TableName("sys_quartz_log") +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "sys_quartz_log瀵硅薄", description = "瀹氭椂浠诲姟鏃ュ織") +public class SysQuartzLog implements Serializable { + + private static final long serialVersionUID = 1804183004277004124L; + + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "id") + private String id; + /** + * 浠诲姟id + */ + @Excel(name = "浠诲姟id", width = 15) + @ApiModelProperty(value = "浠诲姟id") + private String jobId; + /** + * 鎶ラ敊淇℃伅 + */ + @Excel(name = "鎶ラ敊淇℃伅", width = 15) + @ApiModelProperty(value = "鎶ラ敊淇℃伅") + private String exceptionDetail; + /** + * 鎴愬姛鏍囧織 0鎴愬姛 -1澶辫触 + */ + @Excel(name = "鎴愬姛鏍囧織 0鎴愬姛 -1澶辫触", width = 15) + @ApiModelProperty(value = "鎴愬姛鏍囧織 0鎴愬姛 -1澶辫触") + private Integer isSuccess; + /** + * 鍙傛暟 + */ + @Excel(name = "鍙傛暟", width = 15) + @ApiModelProperty(value = "鍙傛暟") + private String params; + /** + * 鎵ц鏃堕棿 + */ + @Excel(name = "鎵ц鏃堕棿", width = 15) + @ApiModelProperty(value = "鎵ц鏃堕棿") + private Integer executionTime; + /** + * 鍒涘缓鏃堕棿 + */ + @Excel(name = "鍒涘缓鏃堕棿", width = 20, format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "鍒涘缓鏃堕棿") + private Date createTime; +} diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/mapper/SysQuartzLogMapper.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/mapper/SysQuartzLogMapper.java new file mode 100644 index 0000000..ca8a06d --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/mapper/SysQuartzLogMapper.java @@ -0,0 +1,23 @@ +package org.jeecg.modules.quartz.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.quartz.dto.SysQuartzLogDto; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.vo.SysQuartzLogVo; + +import java.util.List; + +/** + * @Description: 瀹氭椂浠诲姟鏃ュ織 + * @Author: Lius + * @Date: 2023-08-05 + * @Version: V1.0 + */ +public interface SysQuartzLogMapper extends BaseMapper<SysQuartzLog> { + + IPage<SysQuartzLogDto> pageList(IPage<SysQuartzLogDto> page, @Param("sysQuartzLogVo") SysQuartzLogVo sysQuartzLogVo); + + List<SysQuartzLogDto> list(@Param("sysQuartzLogVo") SysQuartzLogVo sysQuartzLogVo); +} diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/mapper/xml/SysQuartzLogMapper.xml b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/mapper/xml/SysQuartzLogMapper.xml new file mode 100644 index 0000000..af40faf --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/mapper/xml/SysQuartzLogMapper.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="org.jeecg.modules.quartz.mapper.SysQuartzLogMapper"> + + <!--鍒嗛〉鍒楄〃鏌ヨ--> + <select id="pageList" resultType="org.jeecg.modules.quartz.dto.SysQuartzLogDto"> + SELECT + t2.job_class_name jobClassName, + t2.cron_expression cronExpression, + t1.params params, + t2.description description, + t1.exception_detail exceptionDetail, + t1.is_success isSuccess, + t1.execution_time executionTime, + t1.create_time createTime + FROM + sys_quartz_log t1 + LEFT JOIN sys_quartz_job t2 ON t1.job_id = t2.id + <where> + AND t2.id = #{ sysQuartzLogVo.jobId } + <if test="sysQuartzLogVo.isSuccess != null"> + AND t1.is_success = #{ sysQuartzLogVo.isSuccess } + </if> + <if test="sysQuartzLogVo.startTime != null and sysQuartzLogVo.startTime != '' and sysQuartzLogVo.endTime != null and sysQuartzLogVo.endTime != ''"> + AND t1.create_time BETWEEN #{ sysQuartzLogVo.startTime } AND #{ sysQuartzLogVo.endTime } + </if> + <if test="sysQuartzLogVo.jobClassName != null and sysQuartzLogVo.jobClassName != ''"> + AND t2.job_class_name LIKE CONCAT(CONCAT('%',#{ sysQuartzLogVo.jobClassName }),'%') + </if> + <if test="sysQuartzLogVo.description != null and sysQuartzLogVo.description != ''"> + AND t2.description LIKE CONCAT(CONCAT('%',#{ sysQuartzLogVo.description }),'%') + </if> + </where> + ORDER BY t1.create_time DESC + </select> + + + <select id="list" resultType="org.jeecg.modules.quartz.dto.SysQuartzLogDto"> + SELECT + t2.job_class_name jobClassName, + t2.cron_expression cronExpression, + t1.params params, + t2.description description, + t1.exception_detail exceptionDetail, + t1.is_success isSuccess, + t1.execution_time executionTime, + t1.create_time createTime + FROM + sys_quartz_log t1 + LEFT JOIN sys_quartz_job t2 ON t1.job_id = t2.id + <where> + AND t2.id = #{ sysQuartzLogVo.jobId } + <if test="sysQuartzLogVo.isSuccess != null"> + AND t1.is_success = #{ sysQuartzLogVo.isSuccess } + </if> + <if test="sysQuartzLogVo.startTime != null and sysQuartzLogVo.startTime != '' and sysQuartzLogVo.endTime != null and sysQuartzLogVo.endTime != ''"> + AND t1.create_time BETWEEN #{ sysQuartzLogVo.startTime } AND #{ sysQuartzLogVo.endTime } + </if> + <if test="sysQuartzLogVo.jobClassName != null and sysQuartzLogVo.jobClassName != ''"> + AND t2.job_class_name LIKE CONCAT(CONCAT('%',#{ sysQuartzLogVo.jobClassName }),'%') + </if> + <if test="sysQuartzLogVo.description != null and sysQuartzLogVo.description != ''"> + AND t2.description LIKE CONCAT(CONCAT('%',#{ sysQuartzLogVo.description }),'%') + </if> + </where> + ORDER BY t1.create_time DESC + </select> +</mapper> \ No newline at end of file diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/service/ISysQuartzLogService.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/service/ISysQuartzLogService.java new file mode 100644 index 0000000..8fee224 --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/service/ISysQuartzLogService.java @@ -0,0 +1,36 @@ +package org.jeecg.modules.quartz.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.quartz.dto.SysQuartzLogDto; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.vo.SysQuartzLogVo; +import org.springframework.web.servlet.ModelAndView; + +/** + * @Description: 瀹氭椂浠诲姟鏃ュ織 + * @Author: Lius + * @Date: 2023-08-05 + * @Version: V1.0 + */ +public interface ISysQuartzLogService extends IService<SysQuartzLog> { + + /** + * 鍒嗛〉鍒楄〃 + * + * @param pageNo + * @param pageSize + * @param sysQuartzLogVo + * @return + */ + IPage<SysQuartzLogDto> pageList(Integer pageNo, Integer pageSize, SysQuartzLogVo sysQuartzLogVo); + + /** + * 瀵煎嚭 + * + * @param sysQuartzLogVo + * @return + */ + ModelAndView exportXls(SysQuartzLogVo sysQuartzLogVo); + +} diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/SysQuartzLogServiceImpl.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/SysQuartzLogServiceImpl.java new file mode 100644 index 0000000..83a28c8 --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/service/impl/SysQuartzLogServiceImpl.java @@ -0,0 +1,50 @@ +package org.jeecg.modules.quartz.service.impl; + + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.shiro.SecurityUtils; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.quartz.dto.SysQuartzLogDto; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.mapper.SysQuartzLogMapper; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; +import org.jeecg.modules.quartz.vo.SysQuartzLogVo; +import org.jeecgframework.poi.excel.def.NormalExcelConstants; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; +import org.springframework.stereotype.Service; +import org.springframework.web.servlet.ModelAndView; + +import java.util.List; + +/** + * @Description: 瀹氭椂浠诲姟鏃ュ織 + * @Author: Lius + * @Date: 2023-08-05 + * @Version: V1.0 + */ +@Service +public class SysQuartzLogServiceImpl extends ServiceImpl<SysQuartzLogMapper, SysQuartzLog> implements ISysQuartzLogService { + + @Override + public IPage<SysQuartzLogDto> pageList(Integer pageNo, Integer pageSize, SysQuartzLogVo sysQuartzLogVo) { + IPage<SysQuartzLogDto> page = new Page<>(pageNo, pageSize); + return this.baseMapper.pageList(page, sysQuartzLogVo); + } + + @Override + public ModelAndView exportXls(SysQuartzLogVo sysQuartzLogVo) { + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + List<SysQuartzLogDto> list = this.baseMapper.list(sysQuartzLogVo); + // 瀵煎嚭鏂囦欢鍚嶇О + mv.addObject(NormalExcelConstants.FILE_NAME, "瀹氭椂浠诲姟鏃ュ織鍒楄〃"); + mv.addObject(NormalExcelConstants.CLASS, SysQuartzLogDto.class); + LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("瀹氭椂浠诲姟鏃ュ織鍒楄〃鏁版嵁", "瀵煎嚭浜�:"+user.getRealname(), "瀵煎嚭淇℃伅")); + //update-end---author:wangshuai ---date:20211227 for锛歔JTC-116]瀵煎嚭浜哄啓姝讳簡------------ + mv.addObject(NormalExcelConstants.DATA_LIST, list); + return mv; + } +} diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/vo/SysQuartzLogVo.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/vo/SysQuartzLogVo.java new file mode 100644 index 0000000..4a69249 --- /dev/null +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/quartz/vo/SysQuartzLogVo.java @@ -0,0 +1,24 @@ +package org.jeecg.modules.quartz.vo; + +import lombok.Data; + +/** + * @author: LiuS + * @create: 2023-08-05 14:07 + */ +@Data +public class SysQuartzLogVo { + + private String jobId; + + private Integer isSuccess; + + private String startTime; + + private String endTime; + + private String jobClassName; + + private String description; + +} -- Gitblit v1.9.3