| | |
| | | package org.dromara.eims.job; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.dromara.common.redis.utils.RedisUtils; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | |
| | | |
| | | import java.util.Calendar; |
| | | |
| | | @Slf4j |
| | | @Configuration |
| | | @EnableScheduling |
| | | public class DeviceDataIncrJob { |
| | |
| | | */ |
| | | @Scheduled(cron = "0/5 * 8-17 * * ?") |
| | | public void updateDeviceDataScheduled() { |
| | | System.out.println("执行定时任务,更新设备数据:::"); |
| | | // 检查当前时间是否在早上8点到下午5点之间 |
| | | Calendar now = Calendar.getInstance(); |
| | | int hourOfDay = now.get(Calendar.HOUR_OF_DAY); |
| | |
| | | // 新增一个定时器,第天零点清零 |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | public void resetDeviceDataScheduled() { |
| | | System.out.println("执行定时任务,重置设备数据:::"); |
| | | |
| | | log.info("执行定时任务,重置设备数据:::"); |
| | | RedisUtils.setAtomicValue(DEVICE_DATA_PREFIX + "smtTapeJamCount", 0); // 5/5s |
| | | RedisUtils.setAtomicValue(DEVICE_DATA_PREFIX + "smtMaterialJamCount", 0); // 5/5s |
| | | RedisUtils.setAtomicValue(DEVICE_DATA_PREFIX + "smtPanelCount", 0); // 100/5s |