diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoDelLogTask.java b/mes/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoDelLogTask.java index b059c42c..0827de77 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoDelLogTask.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoDelLogTask.java @@ -1,5 +1,7 @@ package org.nl.modules.quartz.task; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; import lombok.extern.slf4j.Slf4j; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -9,20 +11,16 @@ import org.nl.wql.WQL; import org.nl.wql.core.bean.WQLObject; import org.springframework.stereotype.Component; +import java.util.Date; + @Slf4j @Component public class AutoDelLogTask { - public void run () { + public void run() { WQLObject logTab = WQLObject.getWQLObject("sys_log"); - - String delete_time= SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("LOG_DELETE_TIME").getValue(); - JSONArray jsonArray = WQL.getWO("SYS_LOGS01").addParam("flag", "1").process().getResultJSONArray(0); - for (int i = 0; i < jsonArray.size(); i++) { - JSONObject json = jsonArray.getJSONObject(i); - if (Long.parseLong(delete_time) < json.getLong("create_time")) { - logTab.delete(json); - } - } + String perNum = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("AUTO_DELETE_LOG").getValue(); + logTab.delete("DATE(create_time) <= DATE(DATE_SUB(NOW(),INTERVAL " + Integer.valueOf(perNum) + " day))"); + log.info("自动清理日志执行成功...!"); } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/modules/quartz/utils/ExecutionJob.java b/mes/hd/nladmin-system/src/main/java/org/nl/modules/quartz/utils/ExecutionJob.java index 96b28ea2..d51c7226 100644 --- a/mes/hd/nladmin-system/src/main/java/org/nl/modules/quartz/utils/ExecutionJob.java +++ b/mes/hd/nladmin-system/src/main/java/org/nl/modules/quartz/utils/ExecutionJob.java @@ -118,9 +118,10 @@ public class ExecutionJob extends QuartzJobBean { EmailVo emailVo = taskAlarm(quartzJob, ThrowableUtil.getStackTrace(e)); emailService.send(emailVo, emailService.find()); } - } finally { log.info(logDto.toString()); quartzLogRepository.save(logDto); + } finally { + } } diff --git a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls index b3aa2d52..e930be58 100644 Binary files a/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls and b/mes/hd/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls differ