From 0d04bc5d8080b82338302fba0a59fccff2eaedfc Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 06 七月 2025 11:28:29 +0800
Subject: [PATCH] #

---
 zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java |   64 ++++++++++++++++++++++++++++---
 1 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
index 49dbbc6..3aa33ba 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/LiftAction.java
@@ -1,14 +1,17 @@
 package com.zy.asrs.wcs.core.action;
 
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.wcs.core.entity.Task;
 import com.zy.asrs.wcs.core.model.command.*;
 import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType;
+import com.zy.asrs.wcs.core.service.TaskService;
 import com.zy.asrs.wcs.core.utils.RedisUtil;
 import com.zy.asrs.wcs.rcs.News;
 import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
 import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
 import com.zy.asrs.wcs.rcs.entity.Device;
-import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
+import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType;
 import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
 import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
 import com.zy.asrs.wcs.rcs.thread.LiftThread;
@@ -22,6 +25,8 @@
 
     @Autowired
     private RedisUtil redisUtil;
+    @Autowired
+    private TaskService taskService;
 
     public synchronized boolean assignWork(Device device, LiftAssignCommand assignCommand) {
         LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue());
@@ -53,6 +58,11 @@
             return false;
         }
 
+        Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, taskNo));
+        if (task == null) {
+            return false;
+        }
+
         LiftRedisCommand redisCommand = JSON.parseObject(obj.toString(), LiftRedisCommand.class);
         if (redisCommand == null) {
             return false;
@@ -69,7 +79,7 @@
         }
 
         //鍒ゆ柇鎻愬崌鏈烘槸鍚︾┖闂�
-        if (!liftThread.isIdle()) {
+        if (!liftThread.isDeviceIdle()) {
             return false;
         }
 
@@ -83,22 +93,57 @@
 
         if (commandStep != 0) {
             LiftCommand command = commands.get(commandStep - 1);
+            if (command.getMode() == LiftCommandModeType.MOVE.id) {
+                //鎻愬崌鏈哄崌闄�
+                if (liftProtocol.getLev() == command.getTargetLev()) {
+                    command.setComplete(true);
+                }
+            } else if (command.getMode() == LiftCommandModeType.MOVE_CAR.id) {
+                //鎻愬崌鏈哄崌闄嶅皬杞�
+                if (liftProtocol.getLev() == command.getTargetLev()) {
+                    command.setComplete(true);
+                }
+            } else if (command.getMode() == LiftCommandModeType.PALLET_INOUT.id) {
+                //鎵樼洏鍑哄叆
+                if (liftProtocol.getLev() == command.getTargetLev()) {
+                    command.setComplete(true);
+                }
 
-            //鐩墠娌℃湁鍒ゆ柇锛岀洿鎺ュ垽瀹氫笂涓�鏉℃寚浠ゅ畬鎴�
-            command.setComplete(true);
+                if (task.getTaskSts() < 100) {//鍏ュ簱鍒ゆ柇鎵樼洏鏄惁杩涘叆鎻愬崌鏈�
+                    if (!liftProtocol.getHasTray()) {
+                        return false;
+                    }
+                } else if (task.getTaskSts() >= 100 && task.getTaskSts() < 200) {//鍑哄簱鍒ゆ柇鎵樼洏鏄惁绂诲紑鎻愬崌鏈�
+                    if (liftProtocol.getHasTray()) {
+                        return false;
+                    }
+                }
+            } else if (command.getMode() == LiftCommandModeType.RESET.id) {
+                //澶嶄綅
+                command.setComplete(true);
+            } else if (command.getMode() == LiftCommandModeType.LOCK.id) {
+                //澶嶄綅
+                command.setComplete(true);
+            } else if (command.getMode() == LiftCommandModeType.UNLOCK.id) {
+                //澶嶄綅
+                command.setComplete(true);
+            }
 
             // 鏇存柊redis鏁版嵁
-            redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand));
+            redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo, JSON.toJSONString(redisCommand));
 
             if (!command.getComplete()) {
                 return false;
             }
 
-
             //鍒ゆ柇鏄惁涓烘渶鍚庝竴鏉″懡浠や笖鍛戒护鎵ц瀹屾垚锛屾姏鍑虹瓑寰呯‘璁ょ姸鎬�
             LiftCommand endCommand = commands.get(commands.size() - 1);
             if (endCommand.getComplete()) {
                 News.info("鎻愬崌鏈轰换鍔℃墽琛屼笅鍙戝畬鎴愮瓑寰呮墽琛岀粨鏉燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", liftProtocol.getLiftNo(), JSON.toJSON(commands));
+
+                //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting
+                liftThread.setProtocolStatus(LiftProtocolStatusType.WAITING);
+                redisUtil.del(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo);
                 return false;//绂佹鍐嶄笅鍙戝懡浠�
             }
         }
@@ -114,7 +159,12 @@
             News.info("鎻愬崌鏈哄懡浠や笅鍙戞垚鍔燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
         }
 
-        redisUtil.del(DeviceRedisConstant.LIFT_WORK_FLAG + command.getTaskNo());
+        liftThread.setProtocolStatus(LiftProtocolStatusType.WORKING);
+        commandStep++;
+        //鏇存柊redis鏁版嵁
+        redisCommand.setCommandStep(commandStep);
+        // 鏇存柊redis鏁版嵁
+        redisUtil.set(DeviceRedisConstant.LIFT_WORK_FLAG + taskNo, JSON.toJSONString(redisCommand));
         return true;
     }
 

--
Gitblit v1.9.1