From 0867a0eb7ccf5b0fc20fd1d16a82f6cf9661ba87 Mon Sep 17 00:00:00 2001
From: dubin <bindu_bean@163.com>
Date: 星期四, 19 三月 2026 16:22:16 +0800
Subject: [PATCH] 修复空板入库提示组托问题

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |  151 ++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 128 insertions(+), 23 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 13af51d..87c7e52 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -96,7 +96,7 @@
      * 缁勬墭
      * 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 2
      */
-    public synchronized void generateStoreWrkFile(Integer mark) {
+    public synchronized void generateStoreWrkFile(Integer mark) throws InterruptedException {
         // 鏍规嵁杈撻�佺嚎plc閬嶅巻
         for (DevpSlave devp : slaveProperties.getDevp()) {
             // 閬嶅巻鍏ュ簱鍙�
@@ -167,16 +167,52 @@
                             continue;
                         }
                     }
-                    if (wrkMast != null) {
-                        News.error("" + mark + " - 4" + " - 宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 3.寮�濮嬫墽琛屽叆搴撲换鍔� 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
+//                    if (wrkMast != null) {
+//                        News.error("" + mark + " - 4" + " - 宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 3.寮�濮嬫墽琛屽叆搴撲换鍔� 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
 
                         // led 寮傚父鏄剧ず
-                        if (ledThread != null) {
-                            String errorMsg = "宸ヤ綔妗e凡瀛樺湪璇ユ潯鐮佸彿===>>" + barcode;
-                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
-                        }
-                        continue;
-                    }
+//                        if (ledThread != null) {
+//                            String errorMsg = "宸ヤ綔妗e凡瀛樺湪璇ユ潯鐮佸彿===>>" + barcode;
+//                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
+//                        }
+//                        LiftProtocol liftProtocol = devpThread.getLiftStatus();
+//
+//                        if (liftProtocol == null) {
+//                            continue;
+//                        }
+//                        if (liftProtocol.getMode() != 1) {
+//                            continue;
+//                        }
+//                        if (liftProtocol.getDeviceStatus() != 0) {
+//                            continue;
+//                        }
+//                        if (liftProtocol.getWorkNo() > 0) {
+//                            continue;
+//                        }
+//
+//                        Integer staNo = Utils.getStaNoByLocNo(wrkMast.getLocNo());
+//
+//                        LiftCommand command = new LiftCommand();
+//                        command.setWorkNo(wrkMast.getWrkNo());
+//                        command.setSourceStaNo(inSta.getStaNo());
+//                        command.setTargetStaNo(staNo);
+//
+//                        barcodeThread.setBarcode("");
+//
+//                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, command));
+//                        if (result) {
+//                            News.info("WCS--->PLC涓嬪彂浠诲姟鎴愬姛:{}",command.toString());
+//                        }
+//                        if (!result) {
+//                            throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+//                        }
+//
+//                        wrkMast.setWrkSts(3L);// 3.璁惧鎵ц涓�
+//                        wrkMast.setCrnStrTime(new Date());
+//                        wrkMastService.updateById(wrkMast);
+//                        Thread.sleep(300);// 寤舵椂3S
+//                        continue;
+//                    }
 
                     LiftProtocol liftProtocol = devpThread.getLiftStatus();
                     if(liftProtocol == null) {
@@ -239,25 +275,51 @@
                             wrkMastService.updateById(currentWrkMast);
                             Thread.sleep(3000); // 寤舵椂3S
                         } else {
-                            News.error("" + mark + " - 5" + " - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+//                            News.error("" + mark + " - 5" + " - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
 
                             // led 寮傚父鏄剧ず
-                            if (ledThread != null) {
-                                String errorMsg = jsonObject.getString("msg");
-                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
-                            }
-
+//                            if (ledThread != null) {
+//                                String errorMsg = jsonObject.getString("msg");
+//                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
+//                            }
                             //鎵樼洏閫�鍥�
 //                            LiftCommand command = new LiftCommand();
 //                            command.setWorkNo(9998);
 //                            command.setSourceStaNo(inSta.getStaNo());
 //                            command.setTargetStaNo(inSta.getBackSta());
-                            Integer back = 999;
+                            if (wrkMast != null){
+                                Integer staNo = Utils.getStaNoByLocNo(wrkMast.getLocNo());
 
-                            barcodeThread.setBarcode("");
-                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, back));
-                            if (!result) {
-                                throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+                                LiftCommand commandEmpty = new LiftCommand();
+                                commandEmpty.setWorkNo(wrkMast.getWrkNo());
+                                commandEmpty.setSourceStaNo(inSta.getStaNo());
+                                commandEmpty.setTargetStaNo(staNo);
+
+                                barcodeThread.setBarcode("");
+
+                                boolean resultEmpty = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, commandEmpty));
+                                if (resultEmpty) {
+                                    News.info("WCS--->PLC涓嬪彂浠诲姟鎴愬姛:{}",commandEmpty.toString());
+                                }
+                                if (!resultEmpty) {
+                                    throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+                                }
+
+                                wrkMast.setWrkSts(3L);// 3.璁惧鎵ц涓�
+                                wrkMast.setCrnStrTime(new Date());
+                                wrkMastService.updateById(wrkMast);
+                                Thread.sleep(3000); // 寤舵椂3S
+                            }else {
+                                Integer back = 999;
+
+                                barcodeThread.setBarcode("");
+                                boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, back));
+                                if (result) {
+                                    log.error("鎵樼洏閫�鍥炰换鍔′笅鍙戞垚鍔�");
+                                }
+                                if (!result) {
+                                    throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+                                }
                             }
                         }
 
@@ -458,6 +520,7 @@
 
         //妫�娴嬪嚭搴撶珯鏄惁鍙嚭
         StaProtocol staProtocol = devpThread.getStation().get(100);
+        StaProtocol staProtocol101 = devpThread.getStation().get(101);
         if (staProtocol == null) {
             return;
         }
@@ -467,6 +530,18 @@
         }
 
         if (staProtocol.isLoading()) {
+            return;
+        }
+
+        if (staProtocol101 == null){
+            return;
+        }
+
+        if (staProtocol101.isLoading()){
+            return;
+        }
+
+        if (!staProtocol101.isAutoing()){
             return;
         }
 
@@ -821,7 +896,7 @@
                                     , wrkDetl.getKpCstmrName()
                                     , wrkDetl.getOrderNo()
                                     , wrkDetl.getBatch()
-//                                , wrkDetl.getCstateid$()
+                                    , locNo
                             ));
                         }
                     } else {
@@ -855,7 +930,7 @@
                                         , wrkDetlLog.getKpCstmrName()
                                         , wrkDetlLog.getOrderNo()
                                         , wrkDetlLog.getBatch()
-//                                    , wrkDetlLog.getCstateid$()
+                                        , locNo
                                 ));
                             }
                         }
@@ -925,6 +1000,16 @@
                 // 鑾峰彇鍙夎溅绔欑偣
                 StaProtocol staProtocol = devpThread.getStation().get(staNo);
                 StaProtocol staProtocol1 = devpThread.getStation().get(122);
+                WrkMast wrkMastOut = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_sts", 12).eq("sta_no",staNo));
+                WrkMast wrkMastIn = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_sts", 3).eq("source_sta_no", staNo));
+                if (!Cools.isEmpty(wrkMastOut)){
+                    reset = false;
+                    continue;
+                }
+                if (!Cools.isEmpty(wrkMastIn)){
+                    reset = false;
+                    continue;
+                }
                 if (staProtocol == null) {
                     continue;
                 }
@@ -1036,7 +1121,8 @@
                             wrkDetl.getSupp(),
                             wrkDetl.getKpCstmrName(),
                             wrkDetl.getOrderNo(),
-                            wrkDetl.getBatch()
+                            wrkDetl.getBatch(),
+                            locNo
                     ));
                 }
             }
@@ -1090,4 +1176,23 @@
             }
         }
     }
+
+    public void deviceRunning(int mark) {
+        for (LedSlave led : slaveProperties.getLed()){
+            // 鍛戒护闆嗗悎
+            List<LedCommand> commands = new ArrayList<>();
+            WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_sts", 12));
+            if (Cools.isEmpty(wrkMast)){
+                return;
+            }
+            // 鑾峰彇LED绾跨▼
+            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
+
+            if (ledThread == null) {
+                News.error("鏈壘鍒癓ED绾跨▼锛歔id锛歿}]", led.getId());
+                continue;
+            }
+            MessageQueue.offer(SlaveType.Led, led.getId(), new Task(5, "璁惧鍑哄簱浠诲姟杩愯涓�"));
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1