自动化立体仓库 - WMS系统
zhangc
2025-01-16 3349927666da63c6f3a7737f9c6108d3facfef40
添加定时删除报告数据日志功能
1个文件已修改
21 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/task/ReportDataScheduler.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/task/ReportDataScheduler.java
@@ -1,5 +1,6 @@
package com.zy.asrs.task;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
@@ -7,7 +8,9 @@
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.ReportData;
import com.zy.asrs.entity.ReportDataLog;
import com.zy.asrs.service.ApiLogService;
import com.zy.asrs.service.ReportDataLogService;
import com.zy.asrs.service.ReportDataService;
import com.zy.asrs.task.handler.ReportDataHandler;
import com.zy.common.utils.HttpHandler;
@@ -18,7 +21,9 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -32,6 +37,9 @@
    @Autowired
    private ReportDataService reportDataService;
    @Autowired
    private ReportDataLogService reportDataLogService;
    @Autowired
    private ApiLogService apiLogService;
@@ -60,6 +68,19 @@
    private String stock;
    /**
     *  删除告警日志
     */
    @Scheduled(cron = "0 0 2 * * ? ")
    private void delReportDataLog() {
        String format = DateUtil.format(DateUtil.offsetMonth(new Date(), -2), "yyyy-MM-dd HH:mm:ss");
        List<ReportDataLog> agvWarnList = reportDataLogService.selectList(new EntityWrapper<ReportDataLog>().le("modi_time", format));
        for (ReportDataLog agvWarn : agvWarnList) {
            reportDataLogService.deleteById(agvWarn);
        }
    }
    @Scheduled(fixedDelay = 30000)
    public void execute() {
        if (!flag) {