#
Junjie
2024-04-07 08c96e4b797573fd64b42a52a2f9b9805d59d3e3
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java
@@ -1,6 +1,7 @@
package com.zy.asrs.wcs.core.timer;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.wcs.core.action.LiftAction;
import com.zy.asrs.wcs.core.action.ShuttleAction;
import com.zy.asrs.wcs.core.utils.RedisUtil;
import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
@@ -28,6 +29,8 @@
    private DeviceTypeService deviceTypeService;
    @Autowired
    private ShuttleAction shuttleAction;
    @Autowired
    private LiftAction liftAction;
    @Scheduled(cron = "0/1 * * * * ? ")
    public synchronized void executeShuttle() {
@@ -50,14 +53,35 @@
            Integer taskNo = Integer.valueOf(String.valueOf(object));
            if (taskNo != 0) {
                //存在任务需要执行
                shuttleAction.executeWork(device, taskNo);
                boolean result = shuttleAction.executeWork(device, taskNo);
            }
        }
    }
    @Scheduled(cron = "0/1 * * * * ? ")
    public synchronized void executeLift() {
        DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>()
                .eq(DeviceType::getFlag, String.valueOf(SlaveType.Lift))
                .eq(DeviceType::getStatus, 1));
        if (deviceType == null) {
            return;
        }
        List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>()
                .eq(Device::getStatus, 1)
                .eq(Device::getDeviceType, deviceType.getId()));
        for (Device device : list) {
            Object object = redisUtil.get(DeviceRedisConstant.LIFT_FLAG + device.getDeviceNo());
            if (object == null) {
                continue;
            }
            Integer taskNo = Integer.valueOf(String.valueOf(object));
            if (taskNo != 0) {
                //存在任务需要执行
                boolean result = liftAction.executeWork(device, taskNo);
            }
        }
    }
    @Scheduled(cron = "0/1 * * * * ? ")