From 71a2c3d3df0c9d430431baaae9d3042882255d44 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 28 三月 2024 09:23:04 +0800
Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java
index 0518fca..04df88d 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/DeviceTimer.java
@@ -1,10 +1,20 @@
 package com.zy.asrs.wcs.core.timer;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.wcs.core.action.ShuttleAction;
 import com.zy.asrs.wcs.core.utils.RedisUtil;
+import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
+import com.zy.asrs.wcs.rcs.entity.Device;
+import com.zy.asrs.wcs.rcs.entity.DeviceType;
+import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
+import com.zy.asrs.wcs.rcs.service.DeviceService;
+import com.zy.asrs.wcs.rcs.service.DeviceTypeService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
+
+import java.util.List;
 
 @Slf4j
 @Component
@@ -12,10 +22,37 @@
 
     @Autowired
     private RedisUtil redisUtil;
+    @Autowired
+    private DeviceService deviceService;
+    @Autowired
+    private DeviceTypeService deviceTypeService;
+    @Autowired
+    private ShuttleAction shuttleAction;
 
     @Scheduled(cron = "0/1 * * * * ? ")
     public synchronized void executeShuttle() {
+        DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>()
+                .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle))
+                .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.SHUTTLE_FLAG + device.getDeviceNo());
+            if (object == null) {
+                continue;
+            }
+
+            Integer taskNo = Integer.valueOf(String.valueOf(object));
+            if (taskNo != 0) {
+                //瀛樺湪浠诲姟闇�瑕佹墽琛�
+                shuttleAction.executeWork(device, taskNo);
+            }
+        }
     }
 
     @Scheduled(cron = "0/1 * * * * ? ")

--
Gitblit v1.9.1