From 941bf6ff9bb24315dce4b9e39fb370b9fa766842 Mon Sep 17 00:00:00 2001 From: zhangc <zc@123> Date: 星期二, 18 二月 2025 12:35:35 +0800 Subject: [PATCH] 兼容四期 --- src/main/java/com/zy/asrs/task/ReportDataScheduler.java | 38 ++++++++++++++++++++++++++++++++++---- 1 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/zy/asrs/task/ReportDataScheduler.java b/src/main/java/com/zy/asrs/task/ReportDataScheduler.java index a788232..73fb731 100644 --- a/src/main/java/com/zy/asrs/task/ReportDataScheduler.java +++ b/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; @@ -15,11 +18,12 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Async; 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; @@ -33,6 +37,9 @@ @Autowired private ReportDataService reportDataService; + + @Autowired + private ReportDataLogService reportDataLogService; @Autowired private ApiLogService apiLogService; @@ -57,10 +64,25 @@ @Value("${mes.getTokenPath}") private String getTokenPath; + @Value("${mes.stock}") + private String stock; - @Scheduled(fixedDelay = 5000) + + /** + * 鍒犻櫎鍛婅鏃ュ織 + */ + @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("create_time", format)); + for (ReportDataLog agvWarn : agvWarnList) { + reportDataLogService.deleteById(agvWarn); + } + } + + + @Scheduled(fixedDelay = 30000) public void execute() { - log.info("瀹氭椂浠诲姟寮�濮嬫墽琛�"); if (!flag) { return; } @@ -76,7 +98,6 @@ } } } - log.info("瀹氭椂浠诲姟缁撴潫鎵ц"); } //鑾峰彇mes token淇℃伅 @@ -118,4 +139,13 @@ } } + + //@Scheduled(fixedDelay = 1000 * 60 * 30) + public void executeStock() { + if (!flag) { + return; + } + Map<String, Object> mesTokenInfo = getMesTokenInfo(); + reportDataHandler.stock(mesTokenInfo); + } } -- Gitblit v1.9.1