| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ReportDataService reportDataService; |
| | | |
| | | @Autowired |
| | | private ReportDataLogService reportDataLogService; |
| | | |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | |
| | | @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; |
| | | } |
| | | Page<ReportData> objectPage = new Page<>(1, 1000); |
| | | Page<ReportData> objectPage = new Page<>(1, 100); |
| | | Page<ReportData> reportData = reportDataService.selectPage(objectPage, new EntityWrapper<ReportData>().orderBy("create_time", false)); |
| | | if (reportData != null && !Cools.isEmpty(reportData.getRecords())) { |
| | | Map<String, Object> mesTokenInfo = getMesTokenInfo(); |
| | |
| | | } |
| | | } |
| | | } |
| | | log.info("定时任务结束执行"); |
| | | } |
| | | |
| | | //获取mes token信息 |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | //@Scheduled(fixedDelay = 1000 * 60 * 30) |
| | | public void executeStock() { |
| | | if (!flag) { |
| | | return; |
| | | } |
| | | Map<String, Object> mesTokenInfo = getMesTokenInfo(); |
| | | reportDataHandler.stock(mesTokenInfo); |
| | | } |
| | | } |