| | |
| | | @Component |
| | | public class ShuttleExecuteScheduler { |
| | | |
| | | @Autowired |
| | | private ShuttleAction shuttleAction; |
| | | @Autowired |
| | | private DeviceConfigService deviceConfigService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Scheduled(cron = "0/1 * * * * ? ") |
| | | public void execute() { |
| | | List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Shuttle))); |
| | | for (DeviceConfig deviceConfig : shuttleList) { |
| | | Object object = redisUtil.get(RedisKeyType.SHUTTLE_FLAG.key + deviceConfig.getDeviceNo()); |
| | | if (object == null) { |
| | | continue; |
| | | } |
| | | |
| | | int taskNo = Integer.parseInt(String.valueOf(object)); |
| | | if (taskNo != 0) { |
| | | //存在任务需要执行 |
| | | boolean result = shuttleAction.executeWork(deviceConfig.getDeviceNo(), taskNo); |
| | | } |
| | | } |
| | | } |
| | | // @Autowired |
| | | // private ShuttleAction shuttleAction; |
| | | // @Autowired |
| | | // private DeviceConfigService deviceConfigService; |
| | | // @Autowired |
| | | // private RedisUtil redisUtil; |
| | | // |
| | | // @Scheduled(cron = "0/1 * * * * ? ") |
| | | // public void execute() { |
| | | // List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | // .eq("device_type", String.valueOf(SlaveType.Shuttle))); |
| | | // for (DeviceConfig deviceConfig : shuttleList) { |
| | | // Object object = redisUtil.get(RedisKeyType.SHUTTLE_FLAG.key + deviceConfig.getDeviceNo()); |
| | | // if (object == null) { |
| | | // continue; |
| | | // } |
| | | // |
| | | // int taskNo = Integer.parseInt(String.valueOf(object)); |
| | | // if (taskNo != 0) { |
| | | // //存在任务需要执行 |
| | | // boolean result = shuttleAction.executeWork(deviceConfig.getDeviceNo(), taskNo); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | } |