From 44cf1e2793733f703cfe7ccad5e2727a81a98cad Mon Sep 17 00:00:00 2001
From: mrzhssss <pro6@qq.com>
Date: 星期一, 09 一月 2023 16:19:00 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |   88 +++++++++++++++++++++++++++++++-------------
 1 files changed, 62 insertions(+), 26 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index 0ef82f2..56b1ffe 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -121,7 +121,7 @@
                     log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
                     if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
                         staProtocol.setWorkNo((short) 9998);
-                        staProtocol.setStaNo((short)14);
+                        staProtocol.setStaNo((short) 14);
                         devpThread.setPakMk(staProtocol.getSiteId(), false);
                         MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                         // led 寮傚父鏄剧ず
@@ -207,9 +207,11 @@
                             if (!result) {
                                 throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
                             }
+                            String successMsg = "鍏ュ簱宸ヤ綔妗�--宸ヤ綔鍙�:" + dto.getWorkNo() + " 鐩爣搴撲綅:" + dto.getLocNo();
+                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, successMsg));
                         } else {
                             staProtocol.setWorkNo((short) 9998);
-                            staProtocol.setStaNo((short)14);
+                            staProtocol.setStaNo((short) 14);
                             devpThread.setPakMk(staProtocol.getSiteId(), false);
                             MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                             if (ledThread != null) {
@@ -376,11 +378,11 @@
                 }
                 String barcode = barcodeThread.getBarcode();
 
-                if(!Cools.isEmpty(barcode) && (staProtocol.getWorkNo() != 9998 || staProtocol.getWorkNo() != 9996 )) {
+                if (!Cools.isEmpty(barcode) && (staProtocol.getWorkNo() != 9998 || staProtocol.getWorkNo() != 9996)) {
                     log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode);
-                    if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
                         staProtocol.setWorkNo((short) 9998);
-                        staProtocol.setStaNo((short)14);
+                        staProtocol.setStaNo((short) 14);
                         devpThread.setPakMk(staProtocol.getSiteId(), false);
                         MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                         // led 寮傚父鏄剧ず
@@ -395,9 +397,6 @@
                 }
 
 
-
-
-
 //                // 鍏ュ嚭搴撴ā寮忓垽鏂�
 //                if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; }
 
@@ -405,7 +404,7 @@
                         && staProtocol.isLoading()
                         && staProtocol.isInEnable()
                         && !staProtocol.isEmptyMk()
-                        && ( staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9997 || staProtocol.getWorkNo() == 9995)
+                        && (staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9997 || staProtocol.getWorkNo() == 9995)
                         && staProtocol.isPakMk()) {
 
                     WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
@@ -1094,6 +1093,50 @@
             return;
         }
 
+        // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞�
+        if (Utils.isDeepLoc(slaveProperties, wrkMast.getSourceLocNo())) {
+            String shallowLocNo = Utils.getShallowLoc(slaveProperties, wrkMast.getSourceLocNo());
+            LocMast shallowLoc = locMastService.selectById(shallowLocNo);
+            // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒
+            if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) {
+                WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
+                if (null == waitWrkMast) {
+                    log.error("{}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo);
+                } else {
+                    if (waitWrkMast.getWrkSts() == 11) {
+                        waitWrkMast.setIoPri(15D);
+                        waitWrkMast.setModiTime(new Date());
+                        if (wrkMastMapper.updateById(waitWrkMast) == 0) {
+                            log.error("璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo());
+                        }
+                        return;
+                    } else {
+
+                    }
+                }
+            } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) {
+//                            WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
+                //2022-08-16 modify,涓嶆牴鎹畊pdmk鏍囪绉诲簱浠诲姟(瀹规槗琚彇娑堝鑷村牭濉�)锛屾煡璇㈠伐浣滄。鏄惁瀛樺湪浠诲姟
+                WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo);
+                // 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔�
+//                            if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())
+//                                || Cools.isEmpty(waitWrkMast)) {
+                if (Cools.isEmpty(waitWrkMast)) {
+                    wrkMast.setUpdMk("Y");
+                    wrkMastMapper.updateById(wrkMast);
+                    // 鐢熸垚宸ヤ綔妗�,灏嗘祬搴撲綅绉昏浆鍒版柊鐨勫簱浣嶄腑
+                    moveLocForDeepLoc(slave, shallowLoc);
+                }
+                log.error("{}浠诲姟鍑哄簱澶辫触锛屾祬搴撲綅鍫靛锛佹祬搴撲綅鍙�:{}", wrkMast.getWrkNo(), shallowLocNo);
+                return;
+            } else if (shallowLoc.getLocSts().equals("Q") || shallowLoc.getLocSts().equals("S")) {
+                WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo);
+                if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) {
+                    return;
+                }
+            }
+        }
+
         // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�
         if (wrkMastMapper.selectWorking(slave.getId()) != null) {
             return;
@@ -1480,26 +1523,19 @@
             // 鑾峰彇LED绾跨▼
             LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
             // 鐩稿悓宸ヤ綔鍙烽泦鍚堝垯杩囨护
-            if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) {
-                continue;
-            }
+//            if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) {
+//                continue;
+//            }
             // 鍛戒护涓嬪彂 -------------------------------------------------------------------------------
             if (!commands.isEmpty()) {
-                if (led.getId() == 7) {
-                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) {
-                        log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
-                        continue;
-                    } else {
-                        ledThread.setLedMk(false);
-                    }
+                String errMsg = "";
+                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) {
+                    log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
+                    continue;
                 } else {
-                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
-                        log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
-                        continue;
-                    } else {
-                        ledThread.setLedMk(false);
-                    }
+                    ledThread.setLedMk(false);
                 }
+
 
             }
 
@@ -2046,7 +2082,7 @@
                     JSONObject data = (JSONObject) jsonObject.get("data");
                     log.info((String) data.get("msg"));
                 } else {
-                    log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/auto/emptyOut/v1","", response);
+                    log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/auto/emptyOut/v1", "", response);
                 }
             } catch (Exception e) {
                 e.printStackTrace();

--
Gitblit v1.9.1