diff --git a/wms/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCleanUpLogs.java b/wms/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCleanUpLogs.java new file mode 100644 index 0000000..a744db6 --- /dev/null +++ b/wms/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCleanUpLogs.java @@ -0,0 +1,37 @@ +package org.nl.modules.quartz.task; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.wql.core.bean.WQLObject; +import org.springframework.stereotype.Component; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + + +/** + * @author geng by + * 自动清理大于十五天的日志 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class AutoCleanUpLogs { + + private ExecutorService threadPool = Executors.newCachedThreadPool(); + + public void run() throws Exception { + try { + System.out.println("开始清理日志"); + // 0 0/10 0,1 * * ? * 每天0-1点执行间隔10分钟一次 + //sys_log + //delete from sys_log where DATE(create_time) <= DATE(DATE_SUB(NOW(),INTERVAL 30 day)) limit 10; + WQLObject logTab = WQLObject.getWQLObject("sys_log"); + String days = WQLObject.getWQLObject("sys_param").query("code='clean_day'").uniqueResult(0).getString("value"); + logTab.delete("DATE(create_time) <= DATE(DATE_SUB(NOW(),INTERVAL '" + days + "' day)) limit 500"); + log.info("自动清理日志执行成功...!"); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/wms/hd/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls b/wms/hd/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls index 289138f..7339825 100644 Binary files a/wms/hd/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls and b/wms/hd/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls differ