From 546a53d51f4e12ebeee1d060ca8d32be42f152cd Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期六, 10 六月 2023 19:22:16 +0800
Subject: [PATCH] 出入库模式

---
 src/main/java/com/zy/core/thread/LiftThread.java |   85 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 72 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/LiftThread.java b/src/main/java/com/zy/core/thread/LiftThread.java
index a656f4d..0b39f99 100644
--- a/src/main/java/com/zy/core/thread/LiftThread.java
+++ b/src/main/java/com/zy/core/thread/LiftThread.java
@@ -297,22 +297,19 @@
             liftProtocol.setTaskNo(assignCommand.getTaskNo());
             switch (assignCommand.getTaskMode()) {
                 case 1://涓婂崌涓�灞�
-                    command.setRun((short) 1);//鍗囬檷
-                    command.setDistPosition(++lev);
+                    command = getLiftUpDownCommand(++lev);//鑾峰彇鎻愬崌鏈轰笂鍗囦笅闄嶅懡浠�
                     break;
                 case 2://涓嬮檷涓�灞�
-                    command.setRun((short) 1);//涓嬮檷
-                    command.setDistPosition(--lev);
+                    command = getLiftUpDownCommand(--lev);//鑾峰彇鎻愬崌鏈轰笂鍗囦笅闄嶅懡浠�
                     break;
                 case 3://鏈夎揣姝h浆
-                    command.setRun((short) 6);
+                    command = getLiftTurnCommand(1);//鑾峰彇鎻愬崌鏈鸿浆鍔ㄥ懡浠�
                     break;
                 case 4://鏈夎揣鍙嶈浆
-                    command.setRun((short) 3);
+                    command = getLiftTurnCommand(2);//鑾峰彇鎻愬崌鏈鸿浆鍔ㄥ懡浠�
                     break;
                 case 5://澶嶄綅
-                    command.setRun((short) 0);
-                    command.setLiftLock(false);
+                    command = getResetCommand();//鑾峰彇澶嶄綅鍛戒护
                     break;
                 default:
             }
@@ -406,11 +403,8 @@
                 }
 
                 //涓嬪彂涓�鏉℃彁鍗囨満瑙i攣鍛戒护
-                LiftCommand liftCommand = new LiftCommand();
-                liftCommand.setRun((short) 0);
-                liftCommand.setLiftNo(command.getLiftNo());
-                liftCommand.setLiftLock(false);
-                if (write(liftCommand)) {
+                LiftCommand unlockCommand = getUnlockCommand(command.getLiftNo());
+                if (write(unlockCommand)) {
                     News.info("鎻愬崌鏈虹姸鎬佸凡瑙i攣锛屾彁鍗囨満鍙�={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
                 }
 
@@ -421,6 +415,71 @@
     }
 
     /**
+     * 鑾峰彇鎻愬崌鏈鸿В閿佸懡浠�
+     */
+    public LiftCommand getUnlockCommand(Short liftNo) {
+        LiftCommand command = new LiftCommand();
+        command.setRun((short) 0);
+        command.setLiftNo(liftNo);
+        command.setLiftLock(false);
+        return command;
+    }
+
+    /**
+     * 鑾峰彇澶嶄綅鍛戒护
+     */
+    public LiftCommand getResetCommand() {
+        LiftCommand command = new LiftCommand();
+        command.setRun((short) 0);
+        command.setLiftLock(false);
+        return command;
+    }
+
+    /**
+     * 鑾峰彇鎻愬崌鏈轰笂鍗囦笅闄嶅懡浠�
+     */
+    public LiftCommand getLiftUpDownCommand(Short lev) {
+        LiftCommand command = new LiftCommand();
+        command.setRun((short) 1);//鍗囬檷
+        command.setDistPosition(lev);
+        return command;
+    }
+
+    /**
+     * 鑾峰彇鎻愬崌鏈轰笂鍗囦笅闄嶅懡浠�
+     */
+    public LiftCommand getLiftUpDownCommand(Short liftNo, Short taskNo, Short lev) {
+        LiftCommand command = new LiftCommand();
+        command.setRun((short) 1);//鍗囬檷
+        command.setLiftNo(liftNo);//鎻愬崌鏈哄彿
+        command.setTaskNo(taskNo);//浠诲姟鍙�
+        command.setDistPosition(lev);//鐩爣妤煎眰1灞�
+        command.setLiftLock(true);//閿佸畾鎻愬崌鏈�
+        return command;
+    }
+
+    /**
+     * 鑾峰彇鎻愬崌鏈鸿浆鍔ㄥ懡浠わ紝direction锛�1=銆嬫湁璐ф杞紝2=銆嬫湁璐у弽杞�
+     */
+    public LiftCommand getLiftTurnCommand(Integer direction) {
+        LiftCommand command = new LiftCommand();
+        command.setRun(direction == 1 ? (short) 6 : (short) 3);
+        return command;
+    }
+
+    /**
+     * 鑾峰彇鎻愬崌鏈鸿浆鍔ㄥ懡浠わ紝direction锛�1=銆嬫湁璐ф杞紝2=銆嬫湁璐у弽杞�
+     */
+    public LiftCommand getLiftTurnCommand(Short liftNo, Short taskNo, Integer direction) {
+        LiftCommand command = new LiftCommand();
+        command.setRun(direction == 1 ? (short) 6 : (short) 3);
+        command.setLiftNo(liftNo);//鎻愬崌鏈哄彿
+        command.setTaskNo(taskNo);//浠诲姟鍙�
+        command.setLiftLock(true);//閿佸畾鎻愬崌鏈�
+        return command;
+    }
+
+    /**
      * 鍒濆鍖栨彁鍗囨満
      */
     private void initLift() {

--
Gitblit v1.9.1