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-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningAllEquipmentShiftStatisticalProcessJob.java |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

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);
     }
 }

--
Gitblit v1.9.3