自动化立体仓库 - WMS系统
whycq
2024-10-07 792ec31c45fbb4935821d55ab38765febbbb82c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.zy.asrs.task;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.entity.ApiLog;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.ApiLogService;
import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.task.handler.LogClearHandler;
import com.zy.system.entity.OperateLog;
import com.zy.system.service.OperateLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.List;
 
@Component
public class LogClearScheduler {
 
    @Autowired
    private ApiLogService apiLogService;
    @Autowired
    private OperateLogService operateLogService;
    @Autowired
    private LogClearHandler logClearHandler;
//    每天0点开始
//    @Scheduled(cron = "0/1 * * * * ? ")
    @Scheduled(cron = "* * 0 * * ? ")
    private void apiLogExecute(){
        LocalDateTime oneMonthAgo = LocalDateTime.now().minus(1, ChronoUnit.MONTHS);
        List<ApiLog> apiLogs = apiLogService.selectList(new EntityWrapper<ApiLog>().lt("create_time", oneMonthAgo));
        for(ApiLog apiLog : apiLogs){
            ReturnT<String> returnT = logClearHandler.startClearApiLog(apiLog);
        }
    }
 
    @Scheduled(cron = "* * 0 * * ? ")
    private void sysOperateLogExecute(){
        LocalDateTime oneMonthAgo = LocalDateTime.now().minus(2, ChronoUnit.MONTHS);
        List<OperateLog> operateLogs = operateLogService.selectList(new EntityWrapper<OperateLog>().lt("create_time", oneMonthAgo));
        for(OperateLog operateLog : operateLogs){
            ReturnT<String> returnT = logClearHandler.startClearOperateLog(operateLog);
        }
    }
}