From 0ac76f7d8101903e1d050116f7d3835ce1303dfa Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 06 一月 2025 17:00:37 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java |  247 ++++++++++++++++++------------------------------
 1 files changed, 93 insertions(+), 154 deletions(-)

diff --git a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java b/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java
similarity index 62%
rename from src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java
rename to src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java
index 3cb4367..72f341a 100644
--- a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java
+++ b/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java
@@ -1,32 +1,25 @@
-package com.zy.common.utils;
+package com.zy.core.dispatcher;
 
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
-import com.core.common.SpringUtils;
 import com.core.exception.CoolException;
-import com.zy.asrs.entity.BasShuttle;
-import com.zy.asrs.entity.WrkCharge;
 import com.zy.asrs.entity.WrkMast;
-import com.zy.asrs.mapper.WrkChargeMapper;
-import com.zy.asrs.mapper.WrkMastMapper;
-import com.zy.asrs.service.BasShuttleService;
 import com.zy.asrs.service.WrkMastService;
 import com.zy.asrs.utils.Utils;
 import com.zy.common.model.NavigateNode;
 import com.zy.common.model.enums.NavigationMapType;
 import com.zy.common.service.CommonService;
+import com.zy.common.utils.ForkLiftUtils;
+import com.zy.common.utils.NavigateUtils;
 import com.zy.core.News;
 import com.zy.core.cache.SlaveConnection;
-import com.zy.core.enums.ShuttleChargeType;
 import com.zy.core.enums.SlaveType;
-import com.zy.core.model.LiftSlave;
+import com.zy.core.enums.WrkStsType;
+import com.zy.core.model.ForkLiftSlave;
 import com.zy.core.model.ShuttleSlave;
-import com.zy.core.model.protocol.LiftProtocol;
-import com.zy.core.model.protocol.LiftStaProtocol;
-import com.zy.core.model.protocol.NyShuttleProtocol;
+import com.zy.core.model.protocol.*;
 import com.zy.core.properties.SlaveProperties;
-import com.zy.core.thread.LiftThread;
-import com.zy.core.thread.NyShuttleThread;
+import com.zy.core.thread.ForkLiftThread;
+import com.zy.core.thread.ShuttleThread;
 import com.zy.system.entity.Config;
 import com.zy.system.service.ConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -46,20 +39,16 @@
     @Autowired
     private WrkMastService wrkMastService;
     @Autowired
-    private WrkMastMapper wrkMastMapper;
-    @Autowired
-    private WrkChargeMapper wrkChargeMapper;
-    @Autowired
     private CommonService commonService;
+    @Autowired
+    private NavigateUtils navigateUtils;
+    @Autowired
+    private ConfigService configService;
 
     /**
      * 璋冨害杞﹁締-璋冨害鎸囧畾绌挎杞�
      */
     public boolean dispatchShuttle(Integer wrkNo, String locNo, Integer shuttleNo) {
-        if (!checkCharge(shuttleNo, locNo)) {
-            News.info("{}鍙峰皬杞︼紝瀛樺湪鍏呯數浠诲姟绂佹灏忚溅绉诲姩浠诲姟璋冨害", shuttleNo);
-            return false;//瀛樺湪鍏呯數浠诲姟鏆傚仠璋冨害
-        }
         return shuttleMoveGenerate(wrkNo, locNo, shuttleNo);
     }
 
@@ -68,7 +57,7 @@
      */
     public boolean dispatchShuttle(Integer wrkNo, String locNo) {
         //妫�娴嬬洰鏍囧簱浣嶇粍鏄惁瀛樺湪灏忚溅锛屽瀛樺湪灏忚溅鍒欑洿鎺ユ寚瀹氳杞�
-        WrkMast wrkMast = wrkMastMapper.selectByWorkNo(wrkNo);
+        WrkMast wrkMast = wrkMastService.selectByWorkNo(wrkNo);
         if (wrkMast != null) {
             String targetLocNo = wrkMast.getIoType() < 100 ? wrkMast.getLocNo() : wrkMast.getSourceLocNo();
             List<String> groupLoc = Utils.getGroupLoc(targetLocNo);
@@ -79,13 +68,13 @@
             }
         }
 
-        ArrayList<NyShuttleThread> sameLev = new ArrayList<>();//鐩稿悓妤煎眰鐨勭┛姊溅
-        ArrayList<NyShuttleThread> diffLev = new ArrayList<>();//涓嶅悓妤煎眰鐨勭┛姊溅
+        ArrayList<ShuttleThread> sameLev = new ArrayList<>();//鐩稿悓妤煎眰鐨勭┛姊溅
+        ArrayList<ShuttleThread> diffLev = new ArrayList<>();//涓嶅悓妤煎眰鐨勭┛姊溅
 
         for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
             //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
-            NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
-            NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
+            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
             if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
                 continue;
             }
@@ -94,30 +83,20 @@
                 continue;//瀛樺湪鍏呯數浠诲姟锛岃繃婊ゅ皬杞�
             }
 
-            if (!shuttleProtocol.isIdle()) {
+            if (!shuttleThread.isIdle()) {
                 continue;//灏忚溅蹇欑涓�
             }
 
-            if (shuttleProtocol.getSuspendState() == 1) {
-                //灏忚溅澶勪簬绠″埗涓�
-                continue;
-            }
-
-            if (shuttleProtocol.getWorkingMode() == 0) {
-                //灏忚溅澶勪簬鎵嬪姩妯″紡
-                continue;
-            }
-
-            int currentLev = shuttleProtocol.getPoint().getZ();//灏忚溅褰撳墠灞傞珮
+            int currentLev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//灏忚溅褰撳墠灞傞珮
             String currentLocNo = shuttleProtocol.getCurrentLocNo();//灏忚溅褰撳墠搴撲綅鍙�
 
             if (currentLocNo.equals(locNo)) {
                 //杞﹁締褰撳墠浣嶇疆宸茬粡鏄洰鏍囧簱浣嶏紝璋冨害璇ヨ溅
                 //缁欏伐浣滄。缁戝畾灏忚溅鍙�
-                WrkMast wrkMast1 = wrkMastMapper.selectByWorkNo(wrkNo);
+                WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkNo);
                 if (wrkMast1 != null) {
-                    wrkMast1.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
-                    wrkMastMapper.updateById(wrkMast1);
+                    wrkMast1.setShuttleNo(shuttleProtocol.getShuttleNo());
+                    wrkMastService.updateById(wrkMast1);
                     return true;
                 }
                 break;
@@ -135,24 +114,28 @@
 
         //浼樺厛璋冨害鍚屾ゼ灞傚皬杞︼紝瀵绘壘绂讳换鍔℃渶杩戠殑绌挎杞�
         if (!sameLev.isEmpty()) {
-            Map<Integer, NyShuttleThread> sameShuttles = new TreeMap<>();//鑷劧鎺掑簭灏忚溅Map
-            for (NyShuttleThread shuttleThread : sameLev) {
+            Map<Integer, ShuttleThread> sameShuttles = new TreeMap<>();//鑷劧鎺掑簭灏忚溅Map
+            for (ShuttleThread shuttleThread : sameLev) {
+                ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+                Integer shuttleNo = shuttleProtocol.getShuttleNo();
                 //褰撳墠绌挎杞﹀簱浣嶅彿
-                String currentLocNo = shuttleThread.getShuttleProtocol().getCurrentLocNo();
+                String currentLocNo = shuttleProtocol.getCurrentLocNo();
                 //褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈
-                List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleThread.getSlave().getId(), Utils.getLev(currentLocNo)), null);//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
+                List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
                 if (currentShuttlePath == null) {
                     continue;
                 }
-                Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
+                Integer currentAllDistance = navigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
                 sameShuttles.put(currentAllDistance, shuttleThread);
             }
 
             //灏濊瘯璋冨害鍚屾ゼ灞傚皬杞�
-            for (Map.Entry<Integer, NyShuttleThread> entry : sameShuttles.entrySet()) {
-                NyShuttleThread shuttleThread = entry.getValue();
+            for (Map.Entry<Integer, ShuttleThread> entry : sameShuttles.entrySet()) {
+                ShuttleThread shuttleThread = entry.getValue();
+                ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+                Integer shuttleNo = shuttleProtocol.getShuttleNo();
                 //灏濊瘯璋冨害灏忚溅
-                boolean result = shuttleMoveGenerate(wrkNo, locNo, shuttleThread.getSlave().getId());
+                boolean result = shuttleMoveGenerate(wrkNo, locNo, shuttleNo);
                 if (result) {
                     return true;//璋冨害鎴愬姛
                 }
@@ -162,9 +145,9 @@
         //鎵ц鍒版澶勶紝鍚屾ゼ灞傛棤璋冨害鎴愬姛灏忚溅銆傞渶瑕佽繘琛岃法妤煎眰璋冨害灏忚溅
         //瀵绘壘绂讳换鍔℃ゼ灞傛渶杩戠殑绌挎杞�(涓嶈�冭檻璺ㄦゼ灞傚皬杞︾Щ鍔ㄨ窛绂�)
         if (!diffLev.isEmpty()) {
-            Map<Integer, NyShuttleThread> diffShuttles = new TreeMap<>();//鑷劧鎺掑簭灏忚溅Map
+            Map<Integer, ShuttleThread> diffShuttles = new TreeMap<>();//鑷劧鎺掑簭灏忚溅Map
             //鑾峰彇浠诲姟
-            WrkMast wrkMast1 = wrkMastMapper.selectByWorkNo(wrkNo);
+            WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkNo);
             if (wrkMast1 != null) {
                 String targetLoc = wrkMast1.getIoType() < 100 ? wrkMast1.getLocNo() : wrkMast1.getSourceLocNo();
                 int lev = Utils.getLev(targetLoc);//鐩爣妤煎眰
@@ -176,9 +159,10 @@
                     return false;
                 }
 
-                for (NyShuttleThread shuttleThread : diffLev) {
+                for (ShuttleThread shuttleThread : diffLev) {
+                    ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
                     //褰撳墠绌挎杞﹀簱浣嶅彿
-                    String currentLocNo = shuttleThread.getShuttleProtocol().getCurrentLocNo();
+                    String currentLocNo = shuttleProtocol.getCurrentLocNo();
                     int currentLev = Utils.getLev(currentLocNo);
                     List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//鍒ゆ柇褰撳墠绌挎杞︽ゼ灞傛槸鍚︽湁寰呭垎閰嶈溅杈嗙殑浠诲姟锛屽鏋滄湁鍒欎笉鍒嗛厤杩欒締杞�
                     int shuttleCount = this.getShuttleCountByLev(currentLev);//鑾峰彇绌挎杞︽ゼ灞傝溅杈嗘暟閲�
@@ -193,10 +177,12 @@
                 }
 
                 //灏濊瘯璋冨害璺ㄦゼ灞傚皬杞�
-                for (Map.Entry<Integer, NyShuttleThread> entry : diffShuttles.entrySet()) {
-                    NyShuttleThread shuttleThread = entry.getValue();
+                for (Map.Entry<Integer, ShuttleThread> entry : diffShuttles.entrySet()) {
+                    ShuttleThread shuttleThread = entry.getValue();
+                    ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+                    Integer shuttleNo = shuttleProtocol.getShuttleNo();
                     //灏濊瘯璋冨害灏忚溅
-                    boolean result = shuttleMoveGenerate(wrkNo, locNo, shuttleThread.getSlave().getId());
+                    boolean result = shuttleMoveGenerate(wrkNo, locNo, shuttleNo);
                     if (result) {
                         return true;//璋冨害鎴愬姛
                     }
@@ -215,32 +201,32 @@
     public boolean shuttleMoveGenerate(Integer wrkNo, String locNo, Integer shuttleNo) {
         Date now = new Date();
         //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
-        NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
+        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
         if (shuttleThread == null) {
             News.info("{}鍙峰皬杞︼紝绾跨▼涓嶅瓨鍦�", shuttleNo);
             return false;
         }
-        NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+        ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
         if (shuttleProtocol == null) {
             News.info("{}鍙峰皬杞︼紝绾跨▼涓嶅瓨鍦�", shuttleNo);
             return false;
         }
 
         //灏忚溅澶勪簬绌洪棽鐘舵��
-        if (!shuttleProtocol.isIdleNoCharge()) {
+        if (!shuttleThread.isIdle()) {
             News.info("{}鍙峰皬杞︼紝蹇欑涓�", shuttleNo);
             return false;
         }
 
         //鍒ゆ柇绌挎杞︽槸鍚﹀瓨鍦ㄦ湭瀹屾垚鐨勫皬杞︾Щ搴撲换鍔�
-        WrkMast hasMoveWorking = wrkMastMapper.selectShuttleHasMoveWorking(shuttleNo);
+        WrkMast hasMoveWorking = wrkMastService.selectShuttleHasMoveWorking(shuttleNo);
         if (hasMoveWorking != null) {//灏忚溅瀛樺湪绉诲簱浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔�
             News.info("{}鍙峰皬杞︼紝瀛樺湪绉诲姩浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔�", shuttleNo);
             return false;
         }
 
         //鍒ゆ柇鏄惁鏈夊叾浠栦换鍔℃鍦ㄤ娇鐢ㄧ┛姊溅
-        WrkMast wrkMast2 = wrkMastMapper.selectShuttleWorking(shuttleNo);
+        WrkMast wrkMast2 = wrkMastService.selectShuttleWorking(shuttleNo);
         if (wrkMast2 != null) {//灏忚溅瀛樺湪鍏朵粬宸ヤ綔妗d换鍔★紝绛夊緟鎵ц瀹屾垚鍚庡啀鐢熸垚鏂扮殑浠诲姟
             News.info("{}鍙峰皬杞︼紝瀛樺湪鍏朵粬宸ヤ綔妗d换鍔★紝绛夊緟鎵ц瀹屾垚鍐嶇敓鎴愭柊鐨勪换鍔�", shuttleNo);
             return false;
@@ -248,10 +234,10 @@
 
         Integer sourceStaNo = null;//灏忚溅鎹㈠眰婧愮珯鐐�
         Integer staNo = null;//灏忚溅鎹㈠眰鐩爣绔欑偣
-        if (Utils.getLev(locNo) != shuttleProtocol.getPoint().getZ()) {
+        if (Utils.getLev(locNo) != Utils.getLev(shuttleProtocol.getCurrentLocNo())) {
             //鐩爣搴撲綅鍜屽皬杞﹀簱浣嶅浜庝笉鍚屼竴妤煎眰锛岄渶瑕侀�氳繃鎻愬崌鏈鸿皟搴�
             //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐�
-            LiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo, Utils.getLev(locNo));
+            ForkLiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo, Utils.getLev(locNo));
             if (liftSta == null) {
                 News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夊彲鐢ㄧ┖闂茶緭閫佺珯鐐�", shuttleNo, locNo);
                 return false;//娌℃湁鍙敤涓旂┖闂茬殑杈撻�佺珯鐐�
@@ -267,30 +253,27 @@
         WrkMast wrkMast = new WrkMast();
         wrkMast.setWrkNo(workNo);
         wrkMast.setIoTime(now);
-        wrkMast.setWrkSts(101L); // 宸ヤ綔鐘舵�侊細101.绉诲姩鍒拌繎鐐圭瓑寰呰縼鍑�
-        wrkMast.setIoType(200); // 鍏ュ嚭搴撶姸鎬侊細 200.灏忚溅绉诲簱
+        wrkMast.setWrkSts(WrkStsType.NEW_MOVE.sts); // 宸ヤ綔鐘舵�侊細301.鐢熸垚杩佺Щ浠诲姟
+        wrkMast.setIoType(200); // 鍏ュ嚭搴撶姸鎬侊細 200.灏忚溅杩佺Щ
         wrkMast.setIoPri(20D);
         wrkMast.setShuttleNo(shuttleNo);//绌挎杞﹀彿
         wrkMast.setSourceLocNo(shuttleProtocol.getCurrentLocNo()); // 婧愬簱浣� => 灏忚溅褰撳墠搴撲綅鍙�
         wrkMast.setLocNo(locNo); // 鐩爣搴撲綅
         wrkMast.setSourceStaNo(sourceStaNo);//婧愮珯
         wrkMast.setStaNo(staNo);//鐩爣绔�
-        wrkMast.setPicking("N"); // 鎷f枡
-        wrkMast.setExitMk("N"); // 閫�鍑�
-        wrkMast.setLinkMis("N");
         wrkMast.setAppeTime(now);
         wrkMast.setModiTime(now);
-        int res = wrkMastMapper.insert(wrkMast);
-        if (res == 0) {
+        boolean res = wrkMastService.insert(wrkMast);
+        if (!res) {
             News.error("灏忚溅杩佺Щ --- 淇濆瓨宸ヤ綔妗eけ璐ワ紒 绌挎杞﹀彿锛�" + shuttleNo);
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
         }
 
         //缁欏伐浣滄。缁戝畾灏忚溅鍙�
-        WrkMast wrkMast1 = wrkMastMapper.selectByWorkNo(wrkNo);
+        WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkNo);
         if (wrkMast1 != null) {
             wrkMast1.setShuttleNo(shuttleNo);
-            wrkMastMapper.updateById(wrkMast1);
+            wrkMastService.updateById(wrkMast1);
         }
 
         return true;
@@ -301,8 +284,6 @@
      * true: 灏忎簬鏈�澶ф暟閲�  false: 澶т簬鎴栫瓑浜庢渶澶ф暟閲�
      */
     public boolean checkDispatchMaxNum(Integer lev) {
-        BasShuttleService basShuttleService = SpringUtils.getBean(BasShuttleService.class);
-        ConfigService configService = SpringUtils.getBean(ConfigService.class);
         EntityWrapper<Config> wrapper = new EntityWrapper<>();
         wrapper.eq("code", "dispatchShuttleMaxNum");
         Config config = configService.selectOne(wrapper);
@@ -313,34 +294,28 @@
         int levCount = 0;//鐩爣妤煎眰杞﹁締鏁伴噺
         for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
             //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
-            NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
-            NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
+            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
             if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
                 continue;
             }
 
-            NyShuttleProtocol.NyShuttlePointClass point = null;
-            if (shuttleProtocol.getPoint() == null) {
+            String currentLocNo = shuttleProtocol.getCurrentLocNo();
+            if (currentLocNo == null) {
                 continue;
-            }else {
-                point = shuttleProtocol.getPoint();
             }
+            int currentLev = Utils.getLev(currentLocNo);
 
-            if (point.getZ().equals(lev)) {
-                if (shuttleProtocol.getChargState() == 1) {
-                    continue;//鍏呯數涓�
+            if (lev == currentLev) {
+                if (shuttleThread.isCharging()) {
+                    continue;
                 }
-
-                if (shuttleProtocol.getSuspendState() == 1) {
-                    continue;//绠″埗涓�
-                }
-
                 levCount++;//鐩爣妤煎眰鏈夎溅锛屾暟閲忓鍔�
             }
         }
 
         //鎼滅储鏄惁瀛樺湪鍓嶅線鐩爣妤煎眰鐨勫皬杞︾Щ鍔ㄥ伐浣滄。
-        for (WrkMast wrkMast : wrkMastMapper.selectShuttleMoveWrk()) {
+        for (WrkMast wrkMast : wrkMastService.selectShuttleMoveWrk()) {
             if (wrkMast.getSourceLocNo() == null || wrkMast.getLocNo() == null) {
                 continue;
             }
@@ -364,40 +339,40 @@
     /**
      * 鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐�
      */
-    public LiftStaProtocol getRecentLiftSta(Integer shuttleNo, Integer targetLev) {
+    public ForkLiftStaProtocol getRecentLiftSta(Integer shuttleNo, Integer targetLev) {
         //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
-        NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
+        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
         if (shuttleThread == null) {
             return null;
         }
-        NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+        ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
         if (shuttleProtocol == null) {
             return null;
         }
 
         //鑾峰彇灏忚溅鍚屼竴妤煎眰鐨勭珯鐐�
-        ArrayList<LiftStaProtocol> list = new ArrayList<>();
+        ArrayList<ForkLiftStaProtocol> list = new ArrayList<>();
         int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//灏忚溅妤煎眰
-        for (LiftSlave slave : slaveProperties.getLift()) {
-            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId());
-            if (liftThread == null) {
+        for (ForkLiftSlave slave : slaveProperties.getForkLift()) {
+            ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, slave.getId());
+            if (forkLiftThread == null) {
                 continue;
             }
-            LiftProtocol liftProtocol = liftThread.getLiftProtocol();
-            if (liftProtocol == null) {
+            ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus();
+            if (forkLiftProtocol == null) {
                 continue;
             }
-            if (!liftProtocol.isIdle()) {
+            if (!forkLiftThread.isIdle()) {
                 continue;
             }
 
-            LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(slave.getId(), lev);
-            if (liftStaProtocol == null) {
+            ForkLiftStaProtocol forkLiftStaProtocol = ForkLiftUtils.getLiftStaByLev(slave.getId(), lev);
+            if (forkLiftStaProtocol == null) {
                 continue;
             }
 
             //鍒ゆ柇鐩爣妤煎眰绔欑偣鏄惁鏃犳墭鐩�
-            LiftStaProtocol targetLiftStaProtocol = NyLiftUtils.getLiftStaByLev(slave.getId(), targetLev);
+            ForkLiftStaProtocol targetLiftStaProtocol = ForkLiftUtils.getLiftStaByLev(slave.getId(), targetLev);
             if (targetLiftStaProtocol == null) {
                 continue;
             }
@@ -406,7 +381,7 @@
                 continue;//鏈夋墭鐩樿烦杩�
             }
 
-            list.add(liftStaProtocol);
+            list.add(forkLiftStaProtocol);
         }
 
         if (list.isEmpty()) {
@@ -415,21 +390,21 @@
 
         String currentLocNo = shuttleProtocol.getCurrentLocNo();//灏忚溅浣嶇疆
         Integer recentAllDistance = 9999999;
-        LiftStaProtocol recentSta = null;//鏈�杩戠珯鐐�
+        ForkLiftStaProtocol recentSta = null;//鏈�杩戠珯鐐�
         //鎼滅储璺濈灏忚溅鏈�杩戠殑绔欑偣
-        for (LiftStaProtocol liftStaProtocol : list) {
-            Integer staNo = liftStaProtocol.getStaNo();//绔欑偣鍙�
-            String locNo = liftStaProtocol.getLocNo();//绔欑偣搴撲綅鍙�
+        for (ForkLiftStaProtocol forkLiftStaProtocol : list) {
+            Integer staNo = forkLiftStaProtocol.getStaNo();//绔欑偣鍙�
+            String locNo = forkLiftStaProtocol.getLocNo();//绔欑偣搴撲綅鍙�
 
             //褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈
-            List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//浣跨敤姝e父閫氶亾鍦板浘
+            List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//浣跨敤姝e父閫氶亾鍦板浘
             if (currentShuttlePath == null) {
                 continue;
             }
-            Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
+            Integer currentAllDistance = navigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
             if (currentAllDistance < recentAllDistance) {
                 //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠珯鐐�
-                recentSta = liftStaProtocol;
+                recentSta = forkLiftStaProtocol;
                 recentAllDistance = currentAllDistance;
             }
         }
@@ -442,42 +417,11 @@
      */
     public boolean checkChargeWrk(int shuttleNo) {
         //鍒ゆ柇鏄惁鏈夊厖鐢典换鍔℃鍦ㄤ娇鐢ㄧ┛姊溅
-        WrkCharge wrkCharge = wrkChargeMapper.selectWorking(shuttleNo);
-        if (wrkCharge != null) {
+        WrkMast wrkMast = wrkMastService.selectChargeWorking(shuttleNo);
+        if (wrkMast != null) {
             return true;//鏈夊厖鐢典换鍔�
         }
         return false;//鏃犲厖鐢典换鍔�
-    }
-
-    /**
-     * 妫�娴嬬┛姊溅鏄惁鏈夊厖鐢典换鍔★紝鐩爣鐐规槸鍚︿负鍏呯數妗╀綅缃�
-     * @param shuttleNo 灏忚溅鍙�
-     * @param locNo 鐩爣浣嶇疆
-     */
-    public boolean checkCharge(int shuttleNo, String locNo) {
-        //鍒ゆ柇鏄惁鏈夊厖鐢典换鍔℃鍦ㄤ娇鐢ㄧ┛姊溅
-        WrkCharge wrkCharge = wrkChargeMapper.selectWorking(shuttleNo);
-        if (wrkCharge != null) {//灏忚溅瀛樺湪鍏呯數浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔�
-            //鍒ゆ柇鐩爣鐐规槸鍚︿负鍏呯數妗╋紝濡傛灉鏄幓鍏呯數鍒欐斁琛�
-            boolean toCharge = false;//鍘诲厖鐢电洰鏍�
-            for (ShuttleChargeType chargeType : ShuttleChargeType.values()) {
-                if (chargeType.locNo.equals(locNo)) {
-                    toCharge = true;//鍘诲厖鐢垫々
-                    break;
-                }
-            }
-
-            if (wrkCharge.getWrkSts() == 53) {
-                toCharge = true;//鍏呯數缁撴潫锛屽厑璁哥敓鎴愮Щ搴撲换鍔�
-            }
-
-            if (!toCharge) {
-                //涓嶆槸鍘诲厖鐢垫々涓斿瓨鍦ㄥ厖鐢典换鍔★紝绂佹鐢熸垚鏂扮殑绉诲姩浠诲姟
-                return false;
-            }
-        }
-
-        return true;//鏃犲厖鐢典换鍔℃斁琛� || 鍘诲厖鐢垫々涓斁琛�
     }
 
     /**
@@ -487,12 +431,12 @@
         int count = 0;
         for (ShuttleSlave slave : slaveProperties.getShuttle()) {
             //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
-            NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
+            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
             if (shuttleThread == null) {
                 continue;
             }
 
-            NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
             if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
                 continue;
             }
@@ -501,16 +445,11 @@
                 continue;//瀛樺湪鍏呯數浠诲姟锛岃繃婊ゅ皬杞�
             }
 
-            if (shuttleProtocol.getWorkingMode() == 0) {
-                continue;//鎵嬪姩鐘舵��
-            }
-
-            if (shuttleProtocol.getSuspendState() == 1) {
-                //灏忚溅澶勪簬绠″埗涓�
+            if (!shuttleThread.isIdle()) {
                 continue;
             }
 
-            if (shuttleProtocol.getPoint().getZ() == lev) {
+            if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) == lev) {
                 //鍚屼竴妤煎眰鍙敤灏忚溅
                 count++;
                 continue;

--
Gitblit v1.9.1